Rust needs external linkers (e.g. GCC) to generate final output. Why doesn't it provide a bundled one? Are there any languages that does the similar?


Rust requires a linker to generate final output. It's only "external" insofar as it is a separate program from the compiler that generates object files.

The same is true for most C and C++ compilers, and probably a bunch of other compiled languages, like Swift, Ada and Fortran.

Using the system linker instead of bundling your own is useful to ensure compatibility. Sure, Rust could bundle LLD, but what would be the advantage over using the system linker on Linux, or bundling MinGW (which is needed anyway) on Windows and using the LD inside? (Or if you go for the MSVC ABI, you will want a Visual Studio installed anyway, so link.exe is available.)

Also, relying on an external compiler driver for the linker invocation simplifies the rustc compiler, since linker invocations tend to be complicated and full of platform-specific black magic. Reimplementing this logic would be a waste of time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.