importC with gc-sections not work on linux

Dakota dakota at gmail.com
Mon Feb 26 12:58:51 UTC 2024


On Monday, 26 February 2024 at 12:33:02 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
> On 27/02/2024 1:28 AM, Dakota wrote:
>> When I use importC to build a c library, there is a lot unused 
>> symbol missing.
>> 
>> I try add `-L--gc-sections` to dmd to workaround this issue.
>
> This removes symbols, not keeps them.
>
> You want the linker flag: ``--no-gc-sections``
>
> "Enable garbage collection of unused input sections. It is 
> ignored on targets that do not support this option. The default 
> behaviour (of not performing this garbage collection) can be 
> restored by specifying ‘--no-gc-sections’ on the command line. 
> Note that garbage collection for COFF and PE format targets is 
> supported, but the implementation is currently considered to be 
> experimental."
>
> https://sourceware.org/binutils/docs/ld/Options.html

I need remove symbol, since the problem is some symbol from 
importC reference to undefined symbol(need to be implement in d, 
but they will never used).


after remove the unused symbol,  I don't need to add the 
implement all of them.



More information about the Digitalmars-d-learn mailing list