-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discussion: Reconsider target parsing #1317
Comments
Maybe we can require environment variables to be set for customs? We could use |
As one of the affected parties, I think what surprised me most is that this came in a minor version and broke existing builds (#1297). I think the change itself makes a lot of sense, but it would have been a lot easier if this was in a new major version so that the transition can be controlled. Just my two cents. Absolutely love the crate and how responsive you all are as maintainers. |
Yes, please reconsider target parsing! Context: Motor OS is a custom Rust target at the moment (not an official Tier-3 target), so it is not part of the pre-generated list of "targets known to rustc". The switch to pre-generated targets keeps us on an older Rust version, which is somewhat unfortunate. Maybe do target parsing for targets not found in the static/pregenerated list? Related issue: moturus/motor-os#18 |
I think that'd be reasonable, but shouldn't cargo already pass environment variables that we could use https://docs.rs/cc/latest/src/cc/target/parser.rs.html cc @lasiotus |
At the moment rustc/stdlib bootstrap calls get_compiler() which kills the process if the target is not recognized. Essentially we have here a circular dependency: Rust's target bootstrap depends on cc recognizing the target, which does so only for "targets recognized by rustc", if I understand the logic here correctly. So unofficial targets are now a bit more painful to maintain/work on. |
Aha so it's not a build-script issue... Maybe you could set |
It seems this should work - I'll try a bit later; thanks for the suggestion! |
Doesn't work: rustc bootstrap code sets Build::target string triple prior to calling get_compiler(); but get_compiler() -> get_target() parses cargo env vars only if the target string is not set. The latest cc-rs version even explicitly advises forking itself for unrecognized targets. So now new targets need to fork both rust and cc-rs. Again, seems like a circular dependency... Probably the bootstrap code can be hacked to not set the target string triple before calling get_compiler(), but this is becoming increasingly fragile... |
As long as value set by |
That worked, thanks! As it works only at head, and not at 1.2.0 to which Rust bootstrap is pinned, I created a PR to bump the pin to 1.2.4. |
I'm beginning to regret the decision we took in #1225 (comment) to pre-generate a static list of target information from the current nightly, instead of trying to guess it from the target name.
The gist of the issue is that static data doesn't help us much when using a custom target - but when using custom targets, we usually still need to default to some value (example: the LLVM target). Also, I don't like that you can sometimes use
cc
in a build script, but not outside.And yeah,
rustc
target names are a mess, and they're impossible to parse correctly in general, but we can do a fairly good job at it (that's what I implemented in that PR initially) - especially if we have CI that verifies the parsing code against the latestrustc
specs. Of course, manual parsing code is more tedious to update, i.e. the automated GitHub PRs would've instead been turned into a CI failure that we'd have to fix.Idk., still don't know how I feel about it, but I do know that I was unhappy with #1315, as I felt I kinda had to get the default relocation model guessing correct, and once it was correct, there wasn't any point in the pre-generated data.
Related issues:
The text was updated successfully, but these errors were encountered: