-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Description
I ran ./x dist --target mips64-openwrt-linux-musl --host x86_64-unknown-linux-gnu
twice with slight different typos in the --host
argument. Unfortunately, this takes about half an hour to detect (stage2, LLVM builds) and changing the host seems to invalidate some of the build.
Bootstrap can't actually query rustc
for the target list, but it would be great if it could verify the triple string exists somewhere in compiler/rustc_target/src/spec/mod.rs
as a sanity check before kicking off a multistage build.
@rustbot label +T-bootstrap +E-easy -needs-triage
Metadata
Metadata
Assignees
Labels
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Activity
tgross35 commentedon Mar 7, 2024
@rustbot label -needs-triage
bjorn3 commentedon Mar 8, 2024
The target may only exist in the compiler that will be built, so bootstrap would need to parse
rust/compiler/rustc_target/src/spec/mod.rs
Lines 1401 to 1689 in 4282576
Rajveer100 commentedon Apr 3, 2024
@bjorn3
What would be the right place to detect this, i.e, to disallow initiating the build at the beginning itself if the
--target
or--host
triple is invalid?bjorn3 commentedon Apr 3, 2024
Other sanity checks are done in https://github.com/rust-lang/rust/blob/master/src/bootstrap/src/core/sanity.rs
Rajveer100 commentedon Apr 3, 2024
I believe the checks are being done here:
rust/src/bootstrap/src/core/sanity.rs
Line 162 in 703dc9c
rust/src/bootstrap/src/core/sanity.rs
Line 188 in 703dc9c
Although, I am not quite sure about
!build.config.dry_run()
?Since there are limited number of targets, do we just create some constant structure to store this and just map if it does not have any typos?
tgross35 commentedon Apr 3, 2024
I think you found the correct locations for such a check.
./x
takes a--dry-run
flag that doesn't build anything. These checks should run even on dry run, so don't worry about that.You could probably just use regex to extract a target list from the file linked in #122128 (comment), then add a check that the specified hosts and targets all exist in that list.
onur-ozkan commentedon Apr 3, 2024
This approach is too straightforward; custom targets will fail from this logic.
tgross35 commentedon Apr 3, 2024
Do we have custom target info available early? If not, even a warning that something isn't in the list would be helpful here
onur-ozkan commentedon Apr 3, 2024
We do. #71009 can be a good ref to this.
Also, I don't think reading list from the compiler source file will be a good idea. Why not using someting likeEDIT: I just saw #122128 (comment), ignore my suggestion here.rustc --print target-list
? That can give the built-in target list for the stage 0 compiler.Rajveer100 commentedon Apr 4, 2024
@onur-ozkan
I see this function:
rust/src/librustc_back/target/mod.rs
Line 293 in 61aeab4
Do we just use this for the search part?
bjorn3 commentedon Apr 4, 2024
That is a 10 year old commit...
4 remaining items
onur-ozkan commentedon Apr 5, 2024
The logic for validating the target name can be as follows:
If none of the above returns true, then either the user forgot to provide the target specification JSON file for the custom target or made a typo in the target name.
Bootstrap: Check validity of `--target` and `--host` triples before s…
--target
and--host
triples before starting a build #123546Bootstrap: Check validity of `--target` and `--host` triples before s…
Bootstrap: Check validity of `--target` and `--host` triples before s…
Bootstrap: Check validity of `--target` and `--host` triples before s…
Bootstrap: Check validity of `--target` and `--host` triples before s…
Bootstrap: Check validity of `--target` and `--host` triples before s…
Bootstrap: Check validity of `--target` and `--host` triples before s…
Bootstrap: Check validity of `--target` and `--host` triples before s…
Bootstrap: Check validity of `--target` and `--host` triples before s…
Bootstrap: Check validity of `--target` and `--host` triples before s…
Bootstrap: Check validity of `--target` and `--host` triples before s…
Auto merge of rust-lang#123546 - Rajveer100:branch-for-issue-122128, …