digitalmars.D.learn - Is it possible to suppress standard lib and dlang symbols in dylib
- David (38/38) Mar 11 2021 I thought it would be fun to convert some old C++/C quant utils
- Imperatorn (5/9) Mar 11 2021 *trigger warning*
- David (3/14) Mar 11 2021 Of course - but unless I've missed something I don't believe it
- Imperatorn (2/20) Mar 11 2021 Hmm, I'm not sure. Have you tried?
- David (4/25) Mar 11 2021 Nope the documentation implies it only works on windows so I've
- Imperatorn (7/33) Mar 11 2021 I see, there might be something similar to .def?
- David (5/26) Mar 11 2021 I was wondering if there was something similar to def - my next
- David Skluzacek (9/11) Mar 13 2021 With the caveats that the linked post is almost 14 years old, I
- David (2/13) Mar 14 2021 It looks straight forward that way - thx
- rikki cattermole (2/2) Mar 11 2021 Pipe it to grep should work
- David (6/8) Mar 11 2021 Thanks - though I'm trying to suppress the symbols being
- Guillaume Piolat (7/21) Mar 11 2021 Create a exports.lst file with:
- David (21/27) Mar 13 2021 Thx that's really helpful.
- Adam D. Ruppe (11/13) Mar 13 2021 You *might* be able to compile with
- David (5/18) Mar 14 2021 I think figuring out how to add phobos to the sandbox is probably
- Guillaume Piolat (3/4) Mar 17 2021 Sorry for delay.
- Jacob Carlborg (5/10) Mar 17 2021 macOS doesn't support static linking.
- Jacob Carlborg (9/10) Mar 17 2021 The proper way to solve this is to bundle the dynamic libraries
- David (5/17) Mar 17 2021 Ah that's really useful to know, thanks - this is my first bit of
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 0000000000003f10 S __D7xlutils12__ModuleInfoZ 0000000000003e44 T _addDD_D 0000000000003ebc T _addrC 0000000000003e84 T _freeP 0000000000003e9c T _strcpyCC 0000000000003e6c T _strlenC_L If I import `to` and `toStringz` I get more symbols than will fit in my shell output. E.g. 00000000000318bc T __D2rt5minfo11ModuleGroup9sortCtorsMFAyaZ8findDepsMFmPmZ9__lambda5MFNbNiQBjZv 0000000000031534 T __D2rt5minfo11ModuleGroup9sortCtorsMFAyaZ8findDepsMFmPmZb 0000000000030dcc T __D2rt5minfo11ModuleGroup9sortCtorsMFAyaZv 0000000000031db4 T __D2rt5minfo11ModuleGroup9sortCtorsMFZv 0000000000048ef0 S __D2rt5minfo12__ModuleInfoZ 00000000000327e4 T __D2rt5minfo16rt_moduleTlsCtorUZ14__foreachbody1MFKSQBx19sections_osx_x86_6412SectionGroupZi ... 00000000000183ac T _thread_resumeAll 0000000000018660 T _thread_scanAll 0000000000018480 T _thread_scanAllType 0000000000019658 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
Mar 11 2021
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
Mar 11 2021
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-dOf course - but unless I've missed something I don't believe it works on macos.Btw, have you looked at excel-d?
Mar 11 2021
On Thursday, 11 March 2021 at 10:29:55 UTC, David wrote:On Thursday, 11 March 2021 at 08:40:58 UTC, Imperatorn wrote:Hmm, I'm not sure. Have you tried?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-dOf course - but unless I've missed something I don't believe it works on macos.Btw, have you looked at excel-d?
Mar 11 2021
On Thursday, 11 March 2021 at 14:49:32 UTC, Imperatorn wrote:On Thursday, 11 March 2021 at 10:29:55 UTC, David wrote: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.On Thursday, 11 March 2021 at 08:40:58 UTC, Imperatorn wrote:Hmm, I'm not sure. Have you tried?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-dOf course - but unless I've missed something I don't believe it works on macos.Btw, have you looked at excel-d?
Mar 11 2021
On Thursday, 11 March 2021 at 17:00:06 UTC, David wrote:On Thursday, 11 March 2021 at 14:49:32 UTC, Imperatorn wrote: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?On Thursday, 11 March 2021 at 10:29:55 UTC, David wrote: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.On Thursday, 11 March 2021 at 08:40:58 UTC, Imperatorn wrote:Hmm, I'm not sure. Have you tried?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-dOf course - but unless I've missed something I don't believe it works on macos.Btw, have you looked at excel-d?
Mar 11 2021
On Thursday, 11 March 2021 at 18:35:37 UTC, Imperatorn wrote:On Thursday, 11 March 2021 at 17:00:06 UTC, David wrote: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.On Thursday, 11 March 2021 at 14:49:32 UTC, Imperatorn wrote: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?On Thursday, 11 March 2021 at 10:29:55 UTC, David wrote: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.On Thursday, 11 March 2021 at 08:40:58 UTC, Imperatorn wrote:Hmm, I'm not sure. Have you tried?[...]Of course - but unless I've missed something I don't believe it works on macos.[...]
Mar 11 2021
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
Mar 13 2021
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:It looks straight forward that way - thxI 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
Mar 14 2021
Pipe it to grep should work | grep -v "__D2"
Mar 11 2021
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.
Mar 11 2021
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 DavidCreate a exports.lst file with: _addDD_D as the only line there. Build with: "lflags-osx-ldc": [ "-exported_symbols_list", "exports.lst", "-dead_strip" ],
Mar 11 2021
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
Mar 13 2021
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.lyYou *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.
Mar 13 2021
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: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.So Excel complains that it can't load my library - presumably because libphobos2 and libdruntime are not in the sandbox.lyYou *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.
Mar 14 2021
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"],
Mar 17 2021
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:macOS doesn't support static linking. -- /Jacob CarlborgAnyone else done this? Pointers welcome.Sorry for delay. Just add "dflags-osx-ldc": ["-static"],
Mar 17 2021
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/wsvlwdgzswxprtfjzqik forum.dlang.org -- /Jacob Carlborg
Mar 17 2021
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: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.On Sunday, 14 March 2021 at 11:33:00 UTC, David wrote:macOS doesn't support static linking. -- /Jacob CarlborgAnyone else done this? Pointers welcome.Sorry for delay. Just add "dflags-osx-ldc": ["-static"],
Mar 17 2021