Skip to content

Commit

Permalink
Fix bootstrap test failures
Browse files Browse the repository at this point in the history
There are a number of fixes here:
 * if-unchanged is supposed to be the default for channel=dev, but
   actually used different logic. Make sure it is the same.
 * If no llvm section was specified at all, different logic was
   also used. Go through the standard helper.
 * Some more assertions should depend on if_unchanged.
  • Loading branch information
nikic committed Dec 14, 2023
1 parent bb7c483 commit 5a8d6e7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
36 changes: 18 additions & 18 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1791,8 +1791,7 @@ impl Config {
config.llvm_link_shared.set(Some(true));
}
} else {
config.llvm_from_ci = config.channel == "dev"
&& crate::core::build_steps::llvm::is_ci_llvm_available(&config, false);
config.llvm_from_ci = config.parse_download_ci_llvm(None, false);
}

if let Some(t) = toml.target {
Expand Down Expand Up @@ -2337,29 +2336,30 @@ impl Config {
download_ci_llvm: Option<StringOrBool>,
asserts: bool,
) -> bool {
let if_unchanged = || {
// Git is needed to track modifications here, but tarball source is not available.
// If not modified here or built through tarball source, we maintain consistency
// with '"if available"'.
if !self.rust_info.is_from_tarball()
&& self
.last_modified_commit(&["src/llvm-project"], "download-ci-llvm", true)
.is_none()
{
// there are some untracked changes in the the given paths.
false
} else {
llvm::is_ci_llvm_available(&self, asserts)
}
};
match download_ci_llvm {
None => self.channel == "dev" && llvm::is_ci_llvm_available(&self, asserts),
None => self.channel == "dev" && if_unchanged(),
Some(StringOrBool::Bool(b)) => b,
// FIXME: "if-available" is deprecated. Remove this block later (around mid 2024)
// to not break builds between the recent-to-old checkouts.
Some(StringOrBool::String(s)) if s == "if-available" => {
llvm::is_ci_llvm_available(&self, asserts)
}
Some(StringOrBool::String(s)) if s == "if-unchanged" => {
// Git is needed to track modifications here, but tarball source is not available.
// If not modified here or built through tarball source, we maintain consistency
// with '"if available"'.
if !self.rust_info.is_from_tarball()
&& self
.last_modified_commit(&["src/llvm-project"], "download-ci-llvm", true)
.is_none()
{
// there are some untracked changes in the the given paths.
false
} else {
llvm::is_ci_llvm_available(&self, asserts)
}
}
Some(StringOrBool::String(s)) if s == "if-unchanged" => if_unchanged(),
Some(StringOrBool::String(other)) => {
panic!("unrecognized option for download-ci-llvm: {:?}", other)
}
Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap/src/tests/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ fn download_ci_llvm() {
assert_eq!(parse_llvm(""), if_unchanged);
assert_eq!(parse_llvm("rust.channel = \"dev\""), if_unchanged);
assert!(!parse_llvm("rust.channel = \"stable\""));
assert!(parse_llvm("build.build = \"x86_64-unknown-linux-gnu\""));
assert!(parse_llvm(
assert_eq!(parse_llvm("build.build = \"x86_64-unknown-linux-gnu\""), if_unchanged);
assert_eq!(parse_llvm(
"llvm.assertions = true \r\n build.build = \"x86_64-unknown-linux-gnu\" \r\n llvm.download-ci-llvm = \"if-unchanged\""
));
), if_unchanged);
assert!(!parse_llvm(
"llvm.assertions = true \r\n build.build = \"aarch64-apple-darwin\" \r\n llvm.download-ci-llvm = \"if-unchanged\""
));
Expand Down

0 comments on commit 5a8d6e7

Please sign in to comment.