Why D needs a C compiler?

Paul Backus snarwin at gmail.com
Tue Aug 3 13:54:25 UTC 2021


On Tuesday, 3 August 2021 at 12:59:49 UTC, rempas wrote:
> To me big surprise, I tried to compile my program after 
> changing the "/bin/cc" link from "gcc" to "tcc" and I got an 
> error saying: `tcc: error: unsupported linker option 
> '--gc-sections'`.
>
> I haven't noticed that D needs a C compiler before. Why is that 
> and why the TinyC compiler (tcc) cannot be used and more 
> importantly, can we fix that?

By default, the D compiler uses `cc` to invoke the linker. You 
can override this by setting the environment variable `CC` (on 
Posix) [1] or `LINKCMD64` (on Windows) [2].

Alternatively, you can compiler your D modules separately with 
`dmd -c` and then invoke the linker directly to build the final 
executable (or have your build system do this).

[1] https://dlang.org/dmd-linux.html#environment
[2] https://dlang.org/dmd-windows.html#environment


More information about the Digitalmars-d mailing list