Bug 24424 – dmd executes itself recursively if CC=dmd

Status
NEW
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2024-02-29T20:47:34Z
Last change time
2024-12-13T19:33:42Z
Assigned to
No Owner
Creator
Carl Sturtivant
Moved to GitHub: dmd#20413 →

Attachments

IDFilenameSummaryContent-TypeSize
1906libx.nmOutput of nm with some MSVC-mangled namestext/plain691

Comments

Comment #0 by sturtivant — 2024-02-29T20:47:34Z
``` $ 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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20413 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB