[Issue 24424] New: dmd executes itself recursively if CC=dmd
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Feb 29 20:47:34 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24424
Issue ID: 24424
Summary: dmd executes itself recursively if CC=dmd
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: sturtivant at gmail.com
```
$ dmd hello.d
$ ./hello
Hello
$ export CC=dmd #reasonable because of ImportC
$ dmd hello.d
Error: -o no longer supported, use -of or -od
Error: unrecognized switch '-Xlinker'
Error: unrecognized switch '--export-dynamic'
Error: unrecognized switch '-Xlinker'
Error: unrecognized switch '-Bstatic'
Error: unrecognized switch '-lphobos2'
Error: unrecognized switch '-Xlinker'
Error: unrecognized switch '-Bdynamic'
Error: unrecognized switch '-lpthread'
Error: unrecognized switch '-lm'
Error: unrecognized switch '-lrt'
Error: unrecognized switch '-ldl'
run `dmd` to print the compiler manual
run `dmd -man` to open browser on manual
Error: linker exited with status 1
$
```
Bug: dmd should ignore the environment variable CC if its value is dmd.
What happened here is dmd tried to use $CC for linking, so it made a command
line something along the lines of
```
$CC -o hello hello.o [...]
```
where [...] is a log list of linker switches and libs to link to.
Then it tried to execute this line supposedly with its paired C compiler, but
because $CC is dmd it ran the command with dmd which naturally complained that
-o is not supported and all those switches aren't either.
It is in fact recursively forwarding command lines to link to itself, as if it
was the compiler used to actually invoke the linker. Fortunately this recursion
stops at the first step because the command line to link is an error for dmd.
--
More information about the Digitalmars-d-bugs
mailing list