Warning about direct access to weak symbols

kinke noone at nowhere.com
Sun Jan 12 12:16:09 UTC 2020


On Saturday, 11 January 2020 at 11:06:08 UTC, Jacob Carlborg 
wrote:
> ld: warning: direct access in function 'ltmp2' from file 
> 'objects-unittest-debug/std/algorithm/comparison.o' to global 
> weak symbol [...]

Templated function instantiations aren't supposed to be weak and 
overridable at runtime (!); they are emitted with `weak_odr` LLVM 
linkage, meaning that only a single definition is kept when 
linking (and that it cannot be stripped even if unreferenced). 
LDC has a `-linkonce-templates` option to switch to 
`linkonce_odr` linkage which might be interesting for testing 
(only difference to weak_odr: unreferenced symbols can be 
stripped).


More information about the digitalmars-d-ldc mailing list