rust-lang / cc-rs

Rust library for build scripts to compile C/C++ code into a Rust library
https://docs.rs/cc
Apache License 2.0
1.83k stars 442 forks source link

Should integrate cc-rs knowledge of linkers with rustc #693

Open joshtriplett opened 2 years ago

joshtriplett commented 2 years ago

rustc currently has limited knowledge of the correct linker to use on various platforms. cc-rs has a much better idea of which linker to use. There's been a long-standing goal that many people have advocated of making the compiler use cc-rs to find the linker; this would fix cross-compilation for many targets.

Filing this issue to track that possibility. There are also corresponding issues on the rustc repo, which this should link to / be linked from.

dot-asm commented 2 years ago

many people have advocated of making the compiler use cc-rs to find the linker

If the suggestion is to introduce dependency on cc-rs, then I for one[!] would advocate against it(*). I reckon that rustc would be better off being self-sufficient and maintaining its own cross-compile prefixing scheme(**) and provide a way for cc-rs to use at its discretion. As opposed the other way around. Just in case, I do recognize the sentiment behind the suggestion to let cc-rs decide over rustc, and even found myself wishing for it to be possible multiple times, yet at the same time I recognize the value of rustc being self-sufficient.

(*) Well, there already is a dependency, on Windows, so I suppose this is an argument against widening the dependency. (**) Yet keep the current way to specify the linker, so that one can override the default for experimental and trouble-shooting purposes.

dot-asm commented 2 years ago

there already is a dependency, on Windows

For reference. The dependency on Windows is of different nature. cc-rs helps rustc to find the toolchain components it's looking for, but doesn't tell which components to use.