www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - Warning about direct access to weak symbols

reply Jacob Carlborg <doob me.com> writes:
When compiling the runtime for iOS using `ldc-build-runtime` I get a lot 
of warnings looking like this:

ld: warning: direct access in function 'ltmp2' from file 
'objects-unittest-debug/std/algorithm/comparison.o' to global weak 
symbol 
'__D3std3uni__T23switchUniformLowerBoundSQBl10functional__T9binaryFunVAyaa6_61203c3d2062VQta1_61VQBba1_62ZQBvTAxkT
ZQDxFNaNbNiNfQskZm' 
from file 'objects-unittest-debug/std/algorithm/comparison.o' means the 
weak symbol cannot be overridden at runtime. This was likely caused by 
different translation units being compiled with different visibility 
settings.

-- 
/Jacob Carlborg
Jan 11 2020
parent reply kinke <noone nowhere.com> writes:
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).
Jan 12 2020
parent reply Jacob Carlborg <doob me.com> writes:
On 2020-01-12 13:16, kinke wrote:
 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).
Not sure I understand. Are these warnings to be expected? -- /Jacob Carlborg
Jan 15 2020
parent reply kinke <noone nowhere.com> writes:
On Wednesday, 15 January 2020 at 19:57:51 UTC, Jacob Carlborg 
wrote:
 Not sure I understand. Are these warnings to be expected?
Nope, they are definitely unexpected, although most likely not really relevant at the moment either. You could try and see if recompiling either with `-linkonce-templates` or `-fvisibility=hidden` gets rid of them (for the latter, exclude the shared libs by setting the CMake var BUILD_SHARED_LIBS=OFF).
Jan 15 2020
parent Jacob Carlborg <doob me.com> writes:
On 2020-01-15 22:22, kinke wrote:

 Nope, they are definitely unexpected, although most likely not really 
 relevant at the moment either. You could try and see if recompiling 
 either with `-linkonce-templates` or `-fvisibility=hidden` gets rid of 
 them (for the latter, exclude the shared libs by setting the CMake var 
 BUILD_SHARED_LIBS=OFF).
`-linkonce-templates` gave a bunch of linker errors (missing symbols, see below). `-fvisibility=hidden` worked, thanks. __D4core10checkedint__T4adduZQgFNaNbNiNfmmKbZm", referenced from: __D4core8demangle__T8DemangleTSQBcQBa15reencodeMangledFNaNbNfAxaZ12PrependHooksZQCi12dec deNumberMFNaNfQBqZm in demangle.o __D4core8demangle__T8DemangleTSQBcQBa7NoHooksZQBa12decodeNumberMFNaNfAxaZm in demangle.o __D2rt8lifetime21__setArrayAllocLengthFNaNbKS4core6memory8BlkI fo_mbxC8TypeInfomZb in lifetime.o __D2rt8lifetime12__arrayAllocFNaNbmxC8TypeInfoxQlZS4core6memory8BlkInfo_ in lifetime.o __D2rt8lifetime12__arrayAllocFmKS4core6memory8BlkInfo_xC8TypeInfoxQlZQBl in lifetime.o __D2rt4util9container5array__T5ArrayTS4core2gc11gcinterface4RootZQBj__T10inse tBackZQnMFNbNiQCdZv in array.o __D2rt4util9container5array__T5ArrayTS4core2gc11gcinterface5RangeZQBk__T10inse tBackZQnMFNbNiQCeZv in array.o And a bunch more. -- /Jacob Carlborg
Jan 16 2020