Thread overview
Warning about direct access to weak symbols
Jan 11, 2020
Jacob Carlborg
Jan 12, 2020
kinke
Jan 15, 2020
Jacob Carlborg
Jan 15, 2020
kinke
Jan 16, 2020
Jacob Carlborg
January 11, 2020
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_62ZQBvTAxkTkZQDxFNaNbNiNfQskZm' 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
January 12, 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).
January 15, 2020
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
January 15, 2020
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).
January 16, 2020
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__T8DemangleTSQBcQBa15reencodeMangledFNaNbNfAxaZ12PrependHooksZQCi12decodeNumberMFNaNfQBqZm in demangle.o

__D4core8demangle__T8DemangleTSQBcQBa7NoHooksZQBa12decodeNumberMFNaNfAxaZm in demangle.o

__D2rt8lifetime21__setArrayAllocLengthFNaNbKS4core6memory8BlkInfo_mbxC8TypeInfomZb in lifetime.o

__D2rt8lifetime12__arrayAllocFNaNbmxC8TypeInfoxQlZS4core6memory8BlkInfo_ in lifetime.o

__D2rt8lifetime12__arrayAllocFmKS4core6memory8BlkInfo_xC8TypeInfoxQlZQBl in lifetime.o

__D2rt4util9container5array__T5ArrayTS4core2gc11gcinterface4RootZQBj__T10insertBackZQnMFNbNiQCdZv in array.o

__D2rt4util9container5array__T5ArrayTS4core2gc11gcinterface5RangeZQBk__T10insertBackZQnMFNbNiQCeZv in array.o

And a bunch more.

-- 
/Jacob Carlborg