Skip to content

Commit acdeaeb

Browse files
Rollup merge of rust-lang#113373 - jyn514:download-rustc-fixes, r=albertlarsan68
various download-rustc fixes separated out from rust-lang#112143 because it keeps getting stuck in limbo. best reviewed commit-by-commit
2 parents 993deaa + 67b5990 commit acdeaeb

14 files changed

+72
-43
lines changed

src/bootstrap/compile.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,8 @@ fn cp_rustc_component_to_ci_sysroot(
688688
contents: Vec<String>,
689689
) {
690690
let sysroot = builder.ensure(Sysroot { compiler, force_recompile: false });
691+
let ci_rustc_dir = builder.config.ci_rustc_dir();
691692

692-
let ci_rustc_dir = builder.out.join(&*builder.build.build.triple).join("ci-rustc");
693693
for file in contents {
694694
let src = ci_rustc_dir.join(&file);
695695
let dst = sysroot.join(file);
@@ -1424,7 +1424,7 @@ impl Step for Sysroot {
14241424
// FIXME: this is wrong when compiler.host != build, but we don't support that today
14251425
OsStr::new(std::env::consts::DLL_EXTENSION),
14261426
];
1427-
let ci_rustc_dir = builder.ci_rustc_dir(builder.config.build);
1427+
let ci_rustc_dir = builder.config.ci_rustc_dir();
14281428
builder.cp_filtered(&ci_rustc_dir, &sysroot, &|path| {
14291429
if path.extension().map_or(true, |ext| !filtered_extensions.contains(&ext)) {
14301430
return true;

src/bootstrap/config.rs

+33-5
Original file line numberDiff line numberDiff line change
@@ -1375,6 +1375,25 @@ impl Config {
13751375
let mut omit_git_hash = None;
13761376

13771377
if let Some(rust) = toml.rust {
1378+
set(&mut config.channel, rust.channel);
1379+
1380+
config.download_rustc_commit = config.download_ci_rustc_commit(rust.download_rustc);
1381+
// This list is incomplete, please help by expanding it!
1382+
if config.download_rustc_commit.is_some() {
1383+
// We need the channel used by the downloaded compiler to match the one we set for rustdoc;
1384+
// otherwise rustdoc-ui tests break.
1385+
let ci_channel = t!(fs::read_to_string(config.src.join("src/ci/channel")));
1386+
let ci_channel = ci_channel.trim_end();
1387+
if config.channel != ci_channel
1388+
&& !(config.channel == "dev" && ci_channel == "nightly")
1389+
{
1390+
panic!(
1391+
"setting rust.channel={} is incompatible with download-rustc",
1392+
config.channel
1393+
);
1394+
}
1395+
}
1396+
13781397
debug = rust.debug;
13791398
debug_assertions = rust.debug_assertions;
13801399
debug_assertions_std = rust.debug_assertions_std;
@@ -1386,6 +1405,7 @@ impl Config {
13861405
debuginfo_level_std = rust.debuginfo_level_std;
13871406
debuginfo_level_tools = rust.debuginfo_level_tools;
13881407
debuginfo_level_tests = rust.debuginfo_level_tests;
1408+
13891409
config.rust_split_debuginfo = rust
13901410
.split_debuginfo
13911411
.as_deref()
@@ -1401,7 +1421,6 @@ impl Config {
14011421
set(&mut config.jemalloc, rust.jemalloc);
14021422
set(&mut config.test_compare_mode, rust.test_compare_mode);
14031423
set(&mut config.backtrace, rust.backtrace);
1404-
set(&mut config.channel, rust.channel);
14051424
config.description = rust.description;
14061425
set(&mut config.rust_dist_src, rust.dist_src);
14071426
set(&mut config.verbose_tests, rust.verbose_tests);
@@ -1442,8 +1461,6 @@ impl Config {
14421461
config.rust_codegen_units_std = rust.codegen_units_std.map(threads_from_config);
14431462
config.rust_profile_use = flags.rust_profile_use.or(rust.profile_use);
14441463
config.rust_profile_generate = flags.rust_profile_generate.or(rust.profile_generate);
1445-
config.download_rustc_commit = config.download_ci_rustc_commit(rust.download_rustc);
1446-
14471464
config.rust_lto = rust
14481465
.lto
14491466
.as_deref()
@@ -1555,6 +1572,11 @@ impl Config {
15551572
let mut target = Target::from_triple(&triple);
15561573

15571574
if let Some(ref s) = cfg.llvm_config {
1575+
if config.download_rustc_commit.is_some() && triple == &*config.build.triple {
1576+
panic!(
1577+
"setting llvm_config for the host is incompatible with download-rustc"
1578+
);
1579+
}
15581580
target.llvm_config = Some(config.src.join(s));
15591581
}
15601582
target.llvm_has_rust_patches = cfg.llvm_has_rust_patches;
@@ -1825,6 +1847,12 @@ impl Config {
18251847
self.out.join(&*self.build.triple).join("ci-llvm")
18261848
}
18271849

1850+
/// Directory where the extracted `rustc-dev` component is stored.
1851+
pub(crate) fn ci_rustc_dir(&self) -> PathBuf {
1852+
assert!(self.download_rustc());
1853+
self.out.join(self.build.triple).join("ci-rustc")
1854+
}
1855+
18281856
/// Determine whether llvm should be linked dynamically.
18291857
///
18301858
/// If `false`, llvm should be linked statically.
@@ -1860,11 +1888,11 @@ impl Config {
18601888
self.download_rustc_commit().is_some()
18611889
}
18621890

1863-
pub(crate) fn download_rustc_commit(&self) -> Option<&'static str> {
1891+
pub(crate) fn download_rustc_commit(&self) -> Option<&str> {
18641892
static DOWNLOAD_RUSTC: OnceCell<Option<String>> = OnceCell::new();
18651893
if self.dry_run() && DOWNLOAD_RUSTC.get().is_none() {
18661894
// avoid trying to actually download the commit
1867-
return None;
1895+
return self.download_rustc_commit.as_deref();
18681896
}
18691897

18701898
DOWNLOAD_RUSTC

src/bootstrap/download.rs

+27-9
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,11 @@ impl Config {
402402

403403
fn ci_component_contents(&self, stamp_file: &str) -> Vec<String> {
404404
assert!(self.download_rustc());
405-
let ci_rustc_dir = self.out.join(&*self.build.triple).join("ci-rustc");
405+
if self.dry_run() {
406+
return vec![];
407+
}
408+
409+
let ci_rustc_dir = self.ci_rustc_dir();
406410
let stamp_file = ci_rustc_dir.join(stamp_file);
407411
let contents_file = t!(File::open(&stamp_file), stamp_file.display().to_string());
408412
t!(BufReader::new(contents_file).lines().collect())
@@ -419,7 +423,7 @@ impl Config {
419423
self.download_toolchain(
420424
&version,
421425
"ci-rustc",
422-
commit,
426+
&format!("{commit}-{}", self.llvm_assertions),
423427
&extra_components,
424428
Self::download_ci_component,
425429
);
@@ -495,8 +499,15 @@ impl Config {
495499

496500
/// Download a single component of a CI-built toolchain (not necessarily a published nightly).
497501
// NOTE: intentionally takes an owned string to avoid downloading multiple times by accident
498-
fn download_ci_component(&self, filename: String, prefix: &str, commit: &str) {
499-
Self::download_component(self, DownloadSource::CI, filename, prefix, commit, "ci-rustc")
502+
fn download_ci_component(&self, filename: String, prefix: &str, commit_with_assertions: &str) {
503+
Self::download_component(
504+
self,
505+
DownloadSource::CI,
506+
filename,
507+
prefix,
508+
commit_with_assertions,
509+
"ci-rustc",
510+
)
500511
}
501512

502513
fn download_component(
@@ -516,11 +527,18 @@ impl Config {
516527
let bin_root = self.out.join(self.build.triple).join(destination);
517528
let tarball = cache_dir.join(&filename);
518529
let (base_url, url, should_verify) = match mode {
519-
DownloadSource::CI => (
520-
self.stage0_metadata.config.artifacts_server.clone(),
521-
format!("{key}/{filename}"),
522-
false,
523-
),
530+
DownloadSource::CI => {
531+
let dist_server = if self.llvm_assertions {
532+
self.stage0_metadata.config.artifacts_with_llvm_assertions_server.clone()
533+
} else {
534+
self.stage0_metadata.config.artifacts_server.clone()
535+
};
536+
let url = format!(
537+
"{}/{filename}",
538+
key.strip_suffix(&format!("-{}", self.llvm_assertions)).unwrap()
539+
);
540+
(dist_server, url, false)
541+
}
524542
DownloadSource::Dist => {
525543
let dist_server = env::var("RUSTUP_DIST_SERVER")
526544
.unwrap_or(self.stage0_metadata.config.dist_server.to_string());

src/bootstrap/lib.rs

-5
Original file line numberDiff line numberDiff line change
@@ -822,11 +822,6 @@ impl Build {
822822
self.stage_out(compiler, mode).join(&*target.triple).join(self.cargo_dir())
823823
}
824824

825-
/// Directory where the extracted `rustc-dev` component is stored.
826-
fn ci_rustc_dir(&self, target: TargetSelection) -> PathBuf {
827-
self.out.join(&*target.triple).join("ci-rustc")
828-
}
829-
830825
/// Root output directory for LLVM compiled for `target`
831826
///
832827
/// Note that if LLVM is configured externally then the directory returned

src/bootstrap/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2348,7 +2348,7 @@ impl Step for Crate {
23482348
// `std_cargo` actually does the wrong thing: it passes `--sysroot build/host/stage2`,
23492349
// but we want to use the force-recompile std we just built in `build/host/stage2-test-sysroot`.
23502350
// Override it.
2351-
if builder.download_rustc() {
2351+
if builder.download_rustc() && compiler.stage > 0 {
23522352
let sysroot = builder
23532353
.out
23542354
.join(compiler.host.triple)

src/tools/lint-docs/src/groups.rs

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ impl<'a> LintExtractor<'a> {
3939
fn collect_groups(&self) -> Result<LintGroups, Box<dyn Error>> {
4040
let mut result = BTreeMap::new();
4141
let mut cmd = Command::new(self.rustc_path);
42-
cmd.env_remove("LD_LIBRARY_PATH");
4342
cmd.arg("-Whelp");
4443
let output = cmd.output().map_err(|e| format!("failed to run command {:?}\n{}", cmd, e))?;
4544
if !output.status.success() {

src/tools/lint-docs/src/lib.rs

-6
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,6 @@ impl<'a> LintExtractor<'a> {
403403
fs::write(&tempfile, source)
404404
.map_err(|e| format!("failed to write {}: {}", tempfile.display(), e))?;
405405
let mut cmd = Command::new(self.rustc_path);
406-
// NOTE: bootstrap sets `LD_LIBRARY_PATH` for building lint-docs itself.
407-
// Unfortunately, lint-docs is a bootstrap tool while rustc is built from source,
408-
// and sometimes the paths conflict. In particular, when using `download-rustc`,
409-
// the LLVM versions can differ between `ci-llvm` and `ci-rustc-sysroot`.
410-
// Unset LD_LIBRARY_PATH here so it doesn't interfere with running the compiler.
411-
cmd.env_remove("LD_LIBRARY_PATH");
412406
if options.contains(&"edition2015") {
413407
cmd.arg("--edition=2015");
414408
} else {

tests/ui-fulldeps/missing-rustc-driver-error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Test that we get the following hint when trying to use a compiler crate without rustc_driver.
22
// error-pattern: try adding `extern crate rustc_driver;` at the top level of this crate
33
// compile-flags: --emit link
4-
// The exactly list of required crates depends on the target. as such only test Unix targets.
5-
// only-unix
4+
// normalize-stderr-test ".*crate .* required.*\n\n" -> ""
5+
// normalize-stderr-test: "aborting due to [0-9]+" -> "aborting due to NUMBER"
66

77
#![feature(rustc_private)]
88

tests/ui-fulldeps/missing-rustc-driver-error.stderr

+1-11
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,5 @@ error: crate `rustc_serialize` required to be available in rlib format, but was
22
|
33
= help: try adding `extern crate rustc_driver;` at the top level of this crate
44

5-
error: crate `smallvec` required to be available in rlib format, but was not found in this form
6-
7-
error: crate `thin_vec` required to be available in rlib format, but was not found in this form
8-
9-
error: crate `indexmap` required to be available in rlib format, but was not found in this form
10-
11-
error: crate `hashbrown` required to be available in rlib format, but was not found in this form
12-
13-
error: crate `equivalent` required to be available in rlib format, but was not found in this form
14-
15-
error: aborting due to 6 previous errors
5+
error: aborting due to NUMBER previous errors
166

tests/ui/sanitize/address.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
// needs-sanitizer-support
22
// needs-sanitizer-address
3+
// ignore-cross-compile
34
//
45
// compile-flags: -Z sanitizer=address -O -g
56
//
67
// run-fail
78
// error-pattern: AddressSanitizer: stack-buffer-overflow
8-
// error-pattern: 'xs' (line 13) <== Memory access at offset
9+
// error-pattern: 'xs' (line 14) <== Memory access at offset
910

1011
use std::hint::black_box;
1112

tests/ui/sanitize/badfree.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// needs-sanitizer-support
22
// needs-sanitizer-address
3+
// ignore-cross-compile
34
//
45
// compile-flags: -Z sanitizer=address -O
56
//

tests/ui/sanitize/issue-72154-lifetime-markers.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//
66
// needs-sanitizer-support
77
// needs-sanitizer-address
8+
// ignore-cross-compile
89
//
910
// compile-flags: -Copt-level=0 -Zsanitizer=address
1011
// run-pass

tests/ui/sanitize/new-llvm-pass-manager-thin-lto.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//
55
// needs-sanitizer-support
66
// needs-sanitizer-address
7+
// ignore-cross-compile
78
//
89
// no-prefer-dynamic
910
// revisions: opt0 opt1

tests/ui/sanitize/use-after-scope.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// needs-sanitizer-support
22
// needs-sanitizer-address
3+
// ignore-cross-compile
34
//
45
// compile-flags: -Zsanitizer=address
56
// run-fail

0 commit comments

Comments
 (0)