Skip to content
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

Bootstrap: Check validity of --target and --host triples before starting a build #123546

Merged
merged 1 commit into from
Apr 28, 2024

Conversation

Rajveer100
Copy link
Contributor

Resolves #122128

As described in the issue, validating the target and host triples would save a lot of time before actually starting a build. This would also check for custom targets by looking for a valid JSON spec if the specified target does not exist in the supported list of targets.

@rustbot
Copy link
Collaborator

rustbot commented Apr 6, 2024

r? @onur-ozkan

rustbot has assigned @onur-ozkan.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Apr 6, 2024
@rust-log-analyzer

This comment has been minimized.

@Rajveer100
Copy link
Contributor Author

Rajveer100 commented Apr 6, 2024

For custom targets, which property do we check for the file specified by passing --target argument?
If I understand correctly, we use this same flag for an existing target too, but instead of a name, we specify the file path?

Also, the build currently fails, since I assumed for my local that the current working directory is the right path, I believe there must exist an environment variable for this rather than using env::current_dir?

Copy link
Member

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For custom targets, which property do we check for the file specified by passing --target argument?
If I understand correctly, we use this same flag for an existing target too, but instead of a name, we specify the file path?

RUST_TARGET_PATH environment variable is reserved to be used for the custom targets.

src/bootstrap/src/core/sanity.rs Outdated Show resolved Hide resolved
src/bootstrap/src/core/sanity.rs Outdated Show resolved Hide resolved
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 6, 2024
@rustbot
Copy link
Collaborator

rustbot commented Apr 6, 2024

These commits modify compiler targets.
(See the Target Tier Policy.)

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@onur-ozkan
Copy link
Member

FWIW the current approach is entirely different from what Mark suggested here.

@Rajveer100
Copy link
Contributor Author

What are your thoughts on this:

That does have the limitation that we're only going to see stage0 targets

@rust-log-analyzer

This comment has been minimized.

@onur-ozkan
Copy link
Member

We can add them (those not included from the stage0 yet) to a hard-coded list on bootstrap.

@Rajveer100
Copy link
Contributor Author

Why do few of the tests have target set to A (the tests fail because of this)?

@onur-ozkan
Copy link
Member

Why do few of the tests have target set to A (the tests fail because of this)?

Those are just an alias for simulating targets to be used for some of the bootstrap tests.

@Rajveer100
Copy link
Contributor Author

What would be the right approach to fix this, give the actual path rather than the alias?

@onur-ozkan
Copy link
Member

What would be the right approach to fix this, give the actual path rather than the alias?

Those tests should remain the same; instead, we should find a way to skip the target name sanity check if it was given from the bootstrap tests. We don't need to check target names while testing bootstrap.

@Rajveer100
Copy link
Contributor Author

In the Build struct, I see few fields like build_stage which I believe would help us?

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 13, 2024
@onur-ozkan
Copy link
Member

FWIW the current approach is entirely different from what Mark suggested here.

Unfortunately, that is still the case.

@rustbot author

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 25, 2024
@rust-log-analyzer

This comment has been minimized.

@onur-ozkan onur-ozkan added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 27, 2024
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 27, 2024
Copy link
Member

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some parts missing in this PR, but this looks good enough for now and I will do the rest in a follow-up PR later as they are not necessarily needed right now.

Thank you for the fixes and patience!

@onur-ozkan
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Apr 27, 2024

📌 Commit 09c0768 has been approved by onur-ozkan

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 27, 2024
@bors
Copy link
Contributor

bors commented Apr 28, 2024

⌛ Testing commit 09c0768 with merge 6c90ac8...

@Rajveer100
Copy link
Contributor Author

Thanks for the approval! 🦀

@bors
Copy link
Contributor

bors commented Apr 28, 2024

☀️ Test successful - checks-actions
Approved by: onur-ozkan
Pushing 6c90ac8 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 28, 2024
@bors bors merged commit 6c90ac8 into rust-lang:master Apr 28, 2024
11 checks passed
@rustbot rustbot added this to the 1.80.0 milestone Apr 28, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (6c90ac8): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.5% [-1.5%, -1.5%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.5% [-1.5%, -1.5%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 672.137s -> 674.338s (0.33%)
Artifact size: 315.98 MiB -> 315.97 MiB (-0.01%)

let target_str = target.to_string();

let supported_target_list =
output(Command::new(&build.config.initial_rustc).args(["--print", "target-list"]));
Copy link
Member

@bjorn3 bjorn3 Apr 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said on the associated issue, asking the bootstrap compiler is not correct when bootstrap doesn't know about a target yet, but the in-tree rustc does. You have to check if the target is listed in compiler/rustc_target/src/spec/mod.rs.

Edit: Missed that this was already discussed in #123546 (comment).

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request May 3, 2024
…roalbini

handle the targets that are missing in stage0

During sanity checks, we search for target names to determine if they exist in the compiler's built-in target list (`rustc --print target-list`). While a target name may be present in the stage2 compiler, it might not yet be included in stage0. This PR handles that difference.

Follow-up of rust-lang#123546
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 3, 2024
Rollup merge of rust-lang#124461 - onur-ozkan:followup-123546, r=pietroalbini

handle the targets that are missing in stage0

During sanity checks, we search for target names to determine if they exist in the compiler's built-in target list (`rustc --print target-list`). While a target name may be present in the stage2 compiler, it might not yet be included in stage0. This PR handles that difference.

Follow-up of rust-lang#123546
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bootstrap: verify that --target and --host triples are valid before starting a build
9 participants