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.
Comment #1 by bugzilla — 2023-09-05T04:39:21Z
The thing to do to make this reproducible is to create a .c file and compile it with both gcc and ImportC, and look to see if the relocations for sir_te is different between them.
Comment #2 by trnsz — 2023-09-05T21:30:52Z
(In reply to Walter Bright from comment #1)
> The thing to do to make this reproducible is to create a .c file and compile
> it with both gcc and ImportC, and look to see if the relocations for sir_te
> is different between them.
gcc.txt:0000000000000182 R_X86_64_TPOFF32 sir_te
gcc.txt:000000000000018f R_X86_64_TPOFF32 sir_te+0x0000000000000108
gcc.txt:000000000000019c R_X86_64_TPOFF32 sir_te+0x0000000000000110
gcc.txt:00000000000001a7 R_X86_64_TPOFF32 sir_te+0x0000000000000118
gcc.txt:00000000000001d4 R_X86_64_TPOFF32 sir_te+0x0000000000000004
gcc.txt:00000000000001e3 R_X86_64_TPOFF32 sir_te
gcc.txt:0000000000000218 R_X86_64_TPOFF32 sir_te
gcc.txt:00000000000004b3 R_X86_64_TPOFF32 sir_te
gcc.txt:000000000000051d R_X86_64_TPOFF32 sir_te
gcc.txt:0000000000000541 R_X86_64_TPOFF32 sir_te
gcc.txt:0000000000000554 R_X86_64_TPOFF32 sir_te+0x0000000000000004
gcc.txt:00000000000005e1 R_X86_64_TPOFF32 sir_te+0x0000000000000118
gcc.txt:00000000000005ea R_X86_64_TPOFF32 sir_te+0x0000000000000110
gcc.txt:00000000000005f3 R_X86_64_TPOFF32 sir_te+0x0000000000000108
gcc.txt:0000000000000667 R_X86_64_TPOFF32 sir_te
dmd.txt:0000000000000027 R_X86_64_TLSGD sir_te-0x0000000000000004
dmd.txt:000000000000003c R_X86_64_TLSGD sir_te-0x0000000000000004
dmd.txt:0000000000000059 R_X86_64_TLSGD sir_te-0x0000000000000004
dmd.txt:0000000000000076 R_X86_64_TLSGD sir_te-0x0000000000000004
dmd.txt:000000000000001f R_X86_64_TLSGD sir_te-0x0000000000000004
dmd.txt:0000000000000038 R_X86_64_TLSGD sir_te-0x0000000000000004
dmd.txt:0000000000000083 R_X86_64_TLSGD sir_te-0x0000000000000004
dmd.txt:0000000000000061 R_X86_64_TLSGD sir_te-0x0000000000000004
dmd.txt:00000000000000d5 R_X86_64_TLSGD sir_te-0x0000000000000004
dmd.txt:00000000000000f6 R_X86_64_TLSGD sir_te-0x0000000000000004
dmd.txt:0000000000000117 R_X86_64_TLSGD sir_te-0x0000000000000004
dmd.txt:00000000000001a7 R_X86_64_TLSGD sir_te-0x0000000000000004
dmd.txt:00000000000001c2 R_X86_64_TLSGD sir_te-0x0000000000000004
dmd.txt:00000000000001e5 R_X86_64_TLSGD sir_te-0x0000000000000004
dmd.txt:0000000000000267 R_X86_64_TLSGD sir_te-0x0000000000000004
Comment #3 by trnsz — 2023-09-05T21:33:35Z
I hope this is helpful, if not, let me know.
Comment #4 by bugzilla — 2023-09-09T04:08:47Z
If you can create, say, a 3 line C file, that exhibits the difference, that would be most helpful.
Comment #5 by robert.schadek — 2024-12-13T19:30:43Z