Open madsmtm opened 1 week ago
Actually, I think my biggest issue is the ad-hoc parsing of the target triple; ideally, that would be done first thing inside Build::try_compile
as a completely separate step, and the rest of the code would never touch the unparsed target triple.
Would you accept a PR changing the target parsing to be up-front? And would you accept a private dependency on target-lexicon
(also used by the Cranelift and GCC rustc backends)? Or would it need to be vendored (possibly with a script) ~to maintain the illusion of low compile times just because you don't have any dependencies~?
Would you accept a PR changing the target parsing to be up-front?
Yeah I think having a new method calls from_cargo_build_script_env
makes sense
And would you accept a private dependency on target-lexicon (also used by the Cranelift and GCC rustc backends)?
I think target-lexicon is small enough, as long as the serde feature is not enabled it should be ok to include it.
Hmm, I realized that target-lexicon
has a build script to determine the host architecture, which would probably be a bit too expensive :/ (mostly in terms of "sequential" delay, Cargo would need to compile and link target-lexicon
's build script, then compile target-lexicon
, then compile cc
, then compile and link the user's build script).
I have opened https://github.com/bytecodealliance/target-lexicon/issues/112 to track that, not sure whether I will start on this in cc
before or after that has been resolved.
cc
's code is littered with brittle checks centered onrustc
target triple. A lot of this is unnecessary though, since Cargo setscfg
values for the target as environment variables, see the docs for more examples.cc
can't actually use those in most cases though, since it doesn't know whether it's being run inside a Cargo build script, or outside of it.A prominent example is that
CARGO_CFG_TARGET_ABI
would be very useful for detecting Apple's simulator targets (doing it based on the target name is misery, and I think we're currently doing it wrong some places).So I got to thinking, would it make sense to "split"
cc
's entry point into two, and deprecatedcc::Build::new
? Something like: