Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)
On Wednesday, 17 March 2021 at 15:16:36 UTC, Jacob Carlborg wrote: On Wednesday, 17 March 2021 at 13:52:48 UTC, Guillaume Piolat wrote: On Sunday, 14 March 2021 at 11:33:00 UTC, David wrote: Anyone else done this? Pointers welcome. Sorry for delay. Just add "dflags-osx-ldc": ["-static"], macOS doesn't support static linking. -- /Jacob Carlborg Ah that's really useful to know, thanks - this is my first bit of macOS dev (other than high level stuff like R, Python, kdb etc) and I'm having to learn more about internals than I really care to - ho hum.
Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)
On Wednesday, 17 March 2021 at 15:16:36 UTC, Jacob Carlborg wrote: macOS doesn't support static linking. The proper way to solve this is to bundle the dynamic libraries with the application. If it's a GUI application it can be located in the application bundle. It seems like David already figured this out [1]. [1] https://forum.dlang.org/post/wsvlwdgzswxprtfjz...@forum.dlang.org -- /Jacob Carlborg
Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)
On Wednesday, 17 March 2021 at 13:52:48 UTC, Guillaume Piolat wrote: On Sunday, 14 March 2021 at 11:33:00 UTC, David wrote: Anyone else done this? Pointers welcome. Sorry for delay. Just add "dflags-osx-ldc": ["-static"], macOS doesn't support static linking. -- /Jacob Carlborg
Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)
On Sunday, 14 March 2021 at 11:33:00 UTC, David wrote: Anyone else done this? Pointers welcome. Sorry for delay. Just add "dflags-osx-ldc": ["-static"],
Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)
On Sunday, 14 March 2021 at 01:38:23 UTC, David Skluzacek wrote: On Thursday, 11 March 2021 at 22:10:04 UTC, David wrote: I wasn't aware that object files could be manipulated like the strip manual page - thx for the heads up. With the caveats that the linked post is almost 14 years old, I can't try this command myself, and the ldc solution is probably preferable if you can get it to work - if you want to compile with dmd and use the strip command, this might help you (the OP answered his own question at the bottom): https://forum.juce.com/t/how-to-build-dylib-exporting-only-wanted-symbols/2180 He suggests doing: strip -u -r -s FILE_CONTAINING_EXPORTS_LIST MY_DYLIB.dylib It looks straight forward that way - thx
Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)
On Sunday, 14 March 2021 at 00:00:59 UTC, Adam D. Ruppe wrote: On Saturday, 13 March 2021 at 23:41:28 UTC, David wrote: So Excel complains that it can't load my library - presumably because libphobos2 and libdruntime are not in the sandbox.ly You *might* be able to compile with --link-defaultlib-shared=false to use the static phobos+druntime... but with shared libs it prefers shared and might not allow this. Probably worth a try. Otherwise I'd try to just add the phobos so to your sandbox somehow. or the rpath set to current directory and putting them in your correct directory may also work. I don't know how that works on Mac but on Linux it is passing... `-L-rpath -L.` or something like that when compiling... I can't find my notes on this but something like that. I think figuring out how to add phobos to the sandbox is probably the best option as I'm sure it won't be the last dylib I need to load. Anyone else done this? Pointers welcome.
Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)
On Thursday, 11 March 2021 at 22:10:04 UTC, David wrote: I wasn't aware that object files could be manipulated like the strip manual page - thx for the heads up. With the caveats that the linked post is almost 14 years old, I can't try this command myself, and the ldc solution is probably preferable if you can get it to work - if you want to compile with dmd and use the strip command, this might help you (the OP answered his own question at the bottom): https://forum.juce.com/t/how-to-build-dylib-exporting-only-wanted-symbols/2180 He suggests doing: strip -u -r -s FILE_CONTAINING_EXPORTS_LIST MY_DYLIB.dylib
Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)
On Saturday, 13 March 2021 at 23:41:28 UTC, David wrote: So Excel complains that it can't load my library - presumably because libphobos2 and libdruntime are not in the sandbox.ly You *might* be able to compile with --link-defaultlib-shared=false to use the static phobos+druntime... but with shared libs it prefers shared and might not allow this. Probably worth a try. Otherwise I'd try to just add the phobos so to your sandbox somehow. or the rpath set to current directory and putting them in your correct directory may also work. I don't know how that works on Mac but on Linux it is passing... `-L-rpath -L.` or something like that when compiling... I can't find my notes on this but something like that.
Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)
On Friday, 12 March 2021 at 00:12:37 UTC, Guillaume Piolat wrote: Create a exports.lst file with: _addDD_D as the only line there. Build with: "lflags-osx-ldc": [ "-exported_symbols_list", "exports.lst", "-dead_strip" ], Thx that's really helpful. I've hit a snag with LDC. After serveral hours of searching and reading I think it's coming down to sandboxing and needing to deploy libraries in a place that excel can find them. The library DMD creates just references /usr/lib/libSystem.B.dylib and Excel can load my dylib. LDC on the other hand additionally references: @rpath/libphobos2-ldc-shared.95.dylib (compatibility version 95.0.0, current version 2.0.95) @rpath/libdruntime-ldc-shared.95.dylib (compatibility version 95.0.0, current version 2.0.95) So Excel complains that it can't load my library - presumably because libphobos2 and libdruntime are not in the sandbox.ly Can anyone (either tell me how to fix this) or give me pointers pls? (I'm current reading up on DYLD_LIBRARY_PATH (shouldn't use that), sandboxing on Mac, and rpaths) I suppose a solution that allows the additional libraries to be put in a subdirectory of my library would be idea as then I can deploy that within the sandbox. Thx for the help
Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)
On Thursday, 11 March 2021 at 08:34:48 UTC, David wrote: I thought it would be fun to convert some old C++/C quant utils to D. I'm starting with a simple library that I call from vba in Excel on macos: module xlutils; import core.stdc.string : strlen, strcpy; //import std.conv : to; //import std.string : toStringz; import core.stdc.stdlib : malloc, free; extern (C) double addDD_D(double a, double b) {return a + b;} ... Is there a way of not exposing the symbols that aren't mine? - I only need a simple C interface. Thx David Create a exports.lst file with: _addDD_D as the only line there. Build with: "lflags-osx-ldc": [ "-exported_symbols_list", "exports.lst", "-dead_strip" ],
Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)
On Thursday, 11 March 2021 at 18:35:37 UTC, Imperatorn wrote: On Thursday, 11 March 2021 at 17:00:06 UTC, David wrote: On Thursday, 11 March 2021 at 14:49:32 UTC, Imperatorn wrote: On Thursday, 11 March 2021 at 10:29:55 UTC, David wrote: On Thursday, 11 March 2021 at 08:40:58 UTC, Imperatorn wrote: [...] [...] Of course - but unless I've missed something I don't believe it works on macos. Hmm, I'm not sure. Have you tried? Nope the documentation implies it only works on windows so I've ruled it out. But the thing I'm trying to solve is suppression of symbols in the library. I see, there might be something similar to .def? https://docs.microsoft.com/en-us/cpp/build/reference/module-definition-dot-def-files?redirectedfrom=MSDN&view=msvc-160 Or I guess you could strip it? https://www.linux.org/docs/man1/strip.html But I guess you already thought of that and want to not even generate them in the first place? I was wondering if there was something similar to def - my next attempt will be a combination of ldc and export. I wasn't aware that object files could be manipulated like the strip manual page - thx for the heads up.
Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)
On Thursday, 11 March 2021 at 17:00:06 UTC, David wrote: On Thursday, 11 March 2021 at 14:49:32 UTC, Imperatorn wrote: On Thursday, 11 March 2021 at 10:29:55 UTC, David wrote: On Thursday, 11 March 2021 at 08:40:58 UTC, Imperatorn wrote: On Thursday, 11 March 2021 at 08:34:48 UTC, David wrote: I thought it would be fun to convert some old C++/C quant utils to D. I'm starting with a simple library that I call from vba in Excel on macos: [...] *trigger warning* "vba in Excel on macos" ⚠️ Btw, have you looked at excel-d? https://code.dlang.org/packages/excel-d Btw, have you looked at excel-d? Of course - but unless I've missed something I don't believe it works on macos. Hmm, I'm not sure. Have you tried? Nope the documentation implies it only works on windows so I've ruled it out. But the thing I'm trying to solve is suppression of symbols in the library. I see, there might be something similar to .def? https://docs.microsoft.com/en-us/cpp/build/reference/module-definition-dot-def-files?redirectedfrom=MSDN&view=msvc-160 Or I guess you could strip it? https://www.linux.org/docs/man1/strip.html But I guess you already thought of that and want to not even generate them in the first place?
Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)
On Thursday, 11 March 2021 at 14:49:32 UTC, Imperatorn wrote: On Thursday, 11 March 2021 at 10:29:55 UTC, David wrote: On Thursday, 11 March 2021 at 08:40:58 UTC, Imperatorn wrote: On Thursday, 11 March 2021 at 08:34:48 UTC, David wrote: I thought it would be fun to convert some old C++/C quant utils to D. I'm starting with a simple library that I call from vba in Excel on macos: [...] *trigger warning* "vba in Excel on macos" ⚠️ Btw, have you looked at excel-d? https://code.dlang.org/packages/excel-d Btw, have you looked at excel-d? Of course - but unless I've missed something I don't believe it works on macos. Hmm, I'm not sure. Have you tried? Nope the documentation implies it only works on windows so I've ruled it out. But the thing I'm trying to solve is suppression of symbols in the library.
Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)
On Thursday, 11 March 2021 at 14:35:45 UTC, rikki cattermole wrote: Pipe it to grep should work | grep -v "__D2" Thanks - though I'm trying to suppress the symbols being generated in the library. A colleague says it can be done in ldc but not dmd. I'll think I'll try that out.
Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)
On Thursday, 11 March 2021 at 10:29:55 UTC, David wrote: On Thursday, 11 March 2021 at 08:40:58 UTC, Imperatorn wrote: On Thursday, 11 March 2021 at 08:34:48 UTC, David wrote: I thought it would be fun to convert some old C++/C quant utils to D. I'm starting with a simple library that I call from vba in Excel on macos: [...] *trigger warning* "vba in Excel on macos" ⚠️ Btw, have you looked at excel-d? https://code.dlang.org/packages/excel-d Btw, have you looked at excel-d? Of course - but unless I've missed something I don't believe it works on macos. Hmm, I'm not sure. Have you tried?
Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)
Pipe it to grep should work | grep -v "__D2"
Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)
On Thursday, 11 March 2021 at 08:40:58 UTC, Imperatorn wrote: On Thursday, 11 March 2021 at 08:34:48 UTC, David wrote: I thought it would be fun to convert some old C++/C quant utils to D. I'm starting with a simple library that I call from vba in Excel on macos: [...] *trigger warning* "vba in Excel on macos" ⚠️ Btw, have you looked at excel-d? https://code.dlang.org/packages/excel-d Btw, have you looked at excel-d? Of course - but unless I've missed something I don't believe it works on macos.
Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)
On Thursday, 11 March 2021 at 08:34:48 UTC, David wrote: I thought it would be fun to convert some old C++/C quant utils to D. I'm starting with a simple library that I call from vba in Excel on macos: [...] *trigger warning* "vba in Excel on macos" ⚠️ Btw, have you looked at excel-d? https://code.dlang.org/packages/excel-d
Is it possible to suppress standard lib and dlang symbols in dylib (macos)
I thought it would be fun to convert some old C++/C quant utils to D. I'm starting with a simple library that I call from vba in Excel on macos: module xlutils; import core.stdc.string : strlen, strcpy; //import std.conv : to; //import std.string : toStringz; import core.stdc.stdlib : malloc, free; extern (C) double addDD_D(double a, double b) {return a + b;} ... which results in: nm -gU libxlutils.dylib 3f10 S __D7xlutils12__ModuleInfoZ 3e44 T _addDD_D 3ebc T _addrC 3e84 T _freeP 3e9c T _strcpyCC 3e6c T _strlenC_L If I import `to` and `toStringz` I get more symbols than will fit in my shell output. E.g. 000318bc T __D2rt5minfo11ModuleGroup9sortCtorsMFAyaZ8findDepsMFmPmZ9__lambda5MFNbNiQBjZv 00031534 T __D2rt5minfo11ModuleGroup9sortCtorsMFAyaZ8findDepsMFmPmZb 00030dcc T __D2rt5minfo11ModuleGroup9sortCtorsMFAyaZv 00031db4 T __D2rt5minfo11ModuleGroup9sortCtorsMFZv 00048ef0 S __D2rt5minfo12__ModuleInfoZ 000327e4 T __D2rt5minfo16rt_moduleTlsCtorUZ14__foreachbody1MFKSQBx19sections_osx_x86_6412SectionGroupZi ... 000183ac T _thread_resumeAll 00018660 T _thread_scanAll 00018480 T _thread_scanAllType 00019658 T _thread_suspendAll Is there a way of not exposing the symbols that aren't mine? - I only need a simple C interface. Thx David