September 02, 2023
https://issues.dlang.org/show_bug.cgi?id=24131

          Issue ID: 24131
           Summary: ImportC, Linux: TLS transition from R_X86_64_TLSGD to
                    R_X86_64_TPOFF32 failed with -inline
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: trnsz@pobox.com

GNU ld version 2.39-12.fc38 (Fedora 38) with DMD64 D Compiler v2.105.0

No small reproducer yet, but I can point to our project at https://github.com/aremmell/libsir

3ae1eb8135a887314214672ce327826b97553808 is successful with ImportC with -inline:

$ git checkout 3ae1eb8135a887314214672ce327826b97553808
$ mkdir d && cd d && ln -s ../src/* ../include/sir/* ../include/sir.h . && ln
-s . sir && ln -s ../tests/* .
$ dmd -inline -m64 -fPIC -fPIE -O -release -check=off -boundscheck=off
-P=-DSIR_NO_PLUGINS=1 *.c -of=test
$ ls -la sir
.rwxr-xr-x jhj jhj 1.1 MB Sat Sep  2 01:01:08 2023 test*
$ cd .. && git clean -fdx && gmake clean

The commit 3d7c72cd4e05d25c5518745f756e596c63d94b9b fails:

$ git checkout 3d7c72cd4e05d25c5518745f756e596c63d94b9b
$ mkdir d && cd d && ln -s ../src/* ../include/sir/* ../include/sir.h . && ln
-s . sir && ln -s ../tests/* .
$ dmd -inline -m64 -fPIC -fPIE -O -release -check=off -boundscheck=off
-P=-DSIR_NO_PLUGINS=1 *.c -of=test
/usr/bin/ld: sir.o: TLS transition from R_X86_64_TLSGD to R_X86_64_TPOFF32
against `sir_te' at 0x110d in section `.text' failed

The biggest difference here is the sir_te struct moved to thread local storage, which is relevant, I *think*.  It still works fine without -inline.

I hope this is enough to maybe get an idea but if not, I'll try to make a smaller minimal reproducer.

--