```
$ 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.
Comment #1 by sturtivant — 2024-03-01T05:08:38Z
Created attachment 1906
Output of nm with some MSVC-mangled names
Comment #2 by robert.schadek — 2024-12-13T19:33:42Z