importC with gc-sections not work on linux

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Mon Feb 26 12:33:02 UTC 2024


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


More information about the Digitalmars-d-learn mailing list