Building a dmd that works on old systems: TLS problems with libc

Joakim via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Oct 11 13:57:18 PDT 2014


On Friday, 3 October 2014 at 14:21:02 UTC, Atila Neves wrote:
> Then I tried only using dmd to compile and linking it myself. 
> That worked, but the resulting binary crashed. After loading it 
> up in gdb, it crashed in __tls_get_addr....

My guess would be that your system doesn't have __tls_get_addr, 
which is unique in that it is provided by the runtime linker from 
glibc.  You may want to try out my Android patch for dmd, which 
doesn't use native TLS and doesn't rely on that function either:

http://164.138.25.188/dmd/packed_tls_for_elf.patch

You'll want to get rid of that last change to mars.c, substitute 
rt/sections_android.d for rt/sections_linux.d in druntime (don't 
forget to change the "version (Android):" inside that file to 
"version (linux):" also), and make sure you're using the default 
ld.bfd linker and not the gold linker.  That might work for you.

On Thursday, 9 October 2014 at 17:30:04 UTC, Kevin Lamonte wrote:
> I am experiencing a similar problem trying to build a static 
> executable, exactly as described in 
> https://issues.dlang.org/show_bug.cgi?id=12268 .  I don't know 
> if the root cause is a gcc issue or a phobos issue.

Probably neither, probably a druntime issue, specifically the 
rt.sections_linux module's use of the __tls_get_addr function, 
which is called from the dynamic linker at runtime.


More information about the Digitalmars-d-learn mailing list