Bug 24486 – Compiling programs with statics produces complaints from the linker and no executable
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
FreeBSD
Creation time
2024-04-07T14:31:42Z
Last change time
2024-04-07T16:51:07Z
Assigned to
No Owner
Creator
Don Allen
Comments
Comment #0 by donaldcallen1942 — 2024-04-07T14:31:42Z
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$
Comment #1 by donaldcallen1942 — 2024-04-07T14:32:41Z
Jonathan Davis suggested a fix which I submitted as a pull request that has been approved.
Comment #2 by nick — 2024-04-07T16:35:56Z
@Don do you have the link to the pull? Also has it been merged?