Thread overview | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
March 11, 2021 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 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 |
March 11, 2021 Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos) | ||||
---|---|---|---|---|
| ||||
Posted in reply to David | 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 |
March 11, 2021 Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Imperatorn | 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. |
March 12, 2021 Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos) | ||||
---|---|---|---|---|
| ||||
Posted in reply to David | Pipe it to grep should work | grep -v "__D2" |
March 11, 2021 Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos) | ||||
---|---|---|---|---|
| ||||
Posted in reply to David | 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?
|
March 11, 2021 Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos) | ||||
---|---|---|---|---|
| ||||
Posted in reply to rikki cattermole | 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.
|
March 11, 2021 Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Imperatorn | 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.
|
March 11, 2021 Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos) | ||||
---|---|---|---|---|
| ||||
Posted in reply to David | 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? |
March 11, 2021 Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Imperatorn | 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.
|
March 12, 2021 Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos) | ||||
---|---|---|---|---|
| ||||
Posted in reply to David | 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" ],
|
Copyright © 1999-2021 by the D Language Foundation