Skip to content

Commit

Permalink
Auto merge of #125473 - weihanglo:respect-existing-config-toml, r=<try>
Browse files Browse the repository at this point in the history
fix(opt-dist): respect existing config.toml

This is another step toward making opt-dist work in sandboxed environments. See also <#125465>.

opt-dist verifies the final built rustc against a subset of rustc test
suite. However it overwrote the pre-existing `config.toml` [^1],
and that results in ./vendor/ directory removed [^2].

Instead of overwriting, this patch use `--set <config-value>` to
override paths to rustc / cargo / llvm-config.

[^1]: https://github.com/rust-lang/rust/blob/606afbb617a2949a4e35c4b0258ff94c980b9451/src/tools/opt-dist/src/tests.rs#L62-L77
[^2]: https://github.com/rust-lang/rust/blob/8679004993f08807289911d9f400f4ac4391d2bc/src/bootstrap/bootstrap.py#L1057
  • Loading branch information
bors committed May 26, 2024
2 parents 0a59f11 + 159ccd4 commit f94950d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/ci/github-actions/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ envs:

try:
<<: *production
DIST_TRY_BUILD: 1
#DIST_TRY_BUILD: 1

auto:
<<: *production
Expand Down
31 changes: 14 additions & 17 deletions src/tools/opt-dist/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,17 @@ pub fn run_tests(env: &Environment) -> anyhow::Result<()> {
.join(format!("llvm-config{}", executable_extension()));
assert!(llvm_config.is_file());

let config_content = format!(
r#"profile = "user"
change-id = 115898
let rustc = format!("build.rustc={}", rustc_path.to_string().replace('\\', "/"));
let cargo = format!("build.cargo={}", cargo_path.to_string().replace('\\', "/"));
let llvm_config =
format!("target.{host_triple}.llvm-config={}", llvm_config.to_string().replace('\\', "/"));

[build]
rustc = "{rustc}"
cargo = "{cargo}"
[target.{host_triple}]
llvm-config = "{llvm_config}"
"#,
rustc = rustc_path.to_string().replace('\\', "/"),
cargo = cargo_path.to_string().replace('\\', "/"),
llvm_config = llvm_config.to_string().replace('\\', "/")
);
log::info!("Using following `config.toml` for running tests:\n{config_content}");
log::info!("Set the following configurations for running tests:");
log::info!("\t{rustc}");
log::info!("\t{cargo}");
log::info!("\t{llvm_config}");

// Simulate a stage 0 compiler with the extracted optimized dist artifacts.
std::fs::write("config.toml", config_content)?;

let x_py = env.checkout_path().join("x.py");
let mut args = vec![
env.python_binary(),
Expand All @@ -97,6 +88,12 @@ llvm-config = "{llvm_config}"
"tests/run-pass-valgrind",
"tests/ui",
"tests/crashes",
"--set",
&rustc,
"--set",
&cargo,
"--set",
&llvm_config,
];
for test_path in env.skipped_tests() {
args.extend(["--skip", test_path]);
Expand Down

0 comments on commit f94950d

Please sign in to comment.