iphone + LDC, a new ARM adventure

David Nadlinger code at klickverbot.at
Fri Jan 10 08:45:24 PST 2014

On Fri, Jan 10, 2014 at 5:14 PM, Dan Olson <zans.is.for.cans at yahoo.com> wrote:
> Now I am on to the next assertion that fails.  I know the state of TLS
> is not good, but I'll toss this out for comment before I dig in again
> tonight.
> Assertion failed: (Subtarget->isTargetELF() && "TLS not implemented for non-ELF targets"), function LowerGlobalTLSAddress, file /Users/dan/projects/ldc/llvm-3.4/lib/Target/ARM/ARMISelLowering.cpp, line 2475.

D (also the runtime) relies fairly heavily on thread-local storage
support. LLVM provides an easy way of creating TLS variables via the
thread_local attribute, but support for that is not available on all
target platforms – and it seems that Darwin/ARM is one of them (they
work on Linux resp. glibc).

I'm not sure what the best way of going forward with this would be.
One option might be to just hack LDC to emit all TLS globals as normal
globals. This would obviously break threading support, but might be
interesting for getting first Hello-World-style programs to run.

The other option, and what we might end up with in the long run, would
be to implement a TLS emulation scheme in either LDC or, better, LLVM
itself. pthread_{get,set}specific seem to be supported on iOS, which
would make an implementation similar to DMD already does on OS X
possible (see src/rt/sections_osx.d in the upstream druntime
repository). It might be possible to transfer this approach to LDC
without touching LLVM, even though implementing it on the LLVM side
would certainly be cleaner. Let us know if you want to pursue this
direction so we can discuss possible designs.


More information about the digitalmars-d-ldc mailing list