I've had some issues (seg faults) with statics on FreeBSD 14 recently in code that works on Linux and wrote this little test program to try to isolate them:
import std.stdio;
int main(string[] args)
{
static int foo;
foo = 1;
writefln("%d", foo);
return 0;
}
Compiling with dmd produces some interesting complaints from the linker, whereas compiling with ldc (1.35) does not:
(dmd-2.107.1)dca@giovanni:/tmp$ dmd testit.d
ld: error: testit.o:(function D main: .text._Dmain+0xe): R_X86_64_GOTTPOFF must be used in MOVQ or ADDQ instructions only
ld: error: testit.o:(function D main: .text._Dmain+0x26): R_X86_64_GOTTPOFF must be used in MOVQ or ADDQ instructions only
cc: error: linker command failed with exit code 1 (use -v to see invocation)
Error: linker exited with status 1
(dmd-2.107.1)dca@giovanni:/tmp$ ls -l testit
ls: testit: No such file or directory
(dmd-2.107.1)dca@giovanni:/tmp$ ldc2 testit.d
(dmd-2.107.1)dca@giovanni:/tmp$ testit
1
(dmd-2.107.1)dca@giovanni:/tmp$
I will file a bug report, but thought I'd post this here as well, to see if any of you had some useful observations about this.