September 28, 2021

Hello, I want to ask this question. Does the D language compiler LDC or DMD need the C compiler and libraries in its environment? Will the D applications I write have a C dependency?

September 28, 2021

On Tuesday, 28 September 2021 at 11:32:30 UTC, curious wrote:

>

Hello, I want to ask this question. Does the D language compiler LDC or DMD need the C compiler and libraries in its environment? Will the D applications I write have a C dependency?

You need a C compiler for its linker (run any D compiler with a verbose flag), and non-static binaries will link in libc and therefore have version requirements (they won't even start on a Linux box with a decade-old libc without some workarounds), libm, etc. D's standard library relies on libc as well.

If you want to not depend on any C toolchain for some ideological reason, you'd have to start writing your own stdlib over OS syscalls for an application to work on Posix systems (not sure about windows), and the D compiler itself would still need C around.

If you're concerned about a specific target, like WASM or OS development, those actually work:

https://wiki.dlang.org/Generating_WebAssembly_with_LDC
https://wiki.osdev.org/D_Bare_Bones

If you're concerned about libc compatibility, you can produce fully static binaries, most easily with an Alpine docker image.