rust-lang / wg-cargo-std-aware

Repo for working on "std aware cargo"
137 stars 8 forks source link

Figure out how to handle target-specific settings. #30

Open ehuss opened 5 years ago

ehuss commented 5 years ago

Some targets are not supported because they have special logic in bootstrap for flags/features needed. musl, wasi, windows-gnu, etc. Will need to figure out how to handle these. It would be ideal not to hard-code them in cargo, but is there some way to specify what's needed via config files?

Here are some examples:

alexcrichton commented 5 years ago

To give some background on these examples and why they exist in rustbuild:

I think that roughly everything fits in this bucket of "weird toolchain muck", and I can't really think of a better solution other than the following. We could update the source code in rust-lang/rust to know when it's being built by Cargo, and in that case it tweaks how linkage works. The base assumption is that you, the builder, have a full development toolchain for the target locally that rustc can use. The linker itself would pull in the right object files from itself (rustc wouldn't tell the linker to stop injecting object files) and crates like liblibc when linked by libstd would unconditionally say -lc to pull in the system C library.

All-in-all I think that for stabilization we probably want to be conservative and either have a whitelist or a blacklist of targets. This problem generally affects anything requiring a C library (since it's loaded from the system), and only targets that have zero non-Rust dependencies (wasm32-unknown-unknown, custom target specs, etc) are guaranteed to work.

Ericson2314 commented 5 years ago

Distros and extern build systems using Cargo would want to handle these special cases themselves anyways. It's just easier for them if Cargo doesn't special case those platforms.