Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e2865db

Browse files
committedMay 7, 2024
Auto merge of #122504 - jfgoog:update-cc-crate-version-2, r=onur-ozkan
Update cc crate for bootstrap to v1.0.97 Reason: In order to build the Windows version of the Rust toolchain for the Android platform, the following patch to the cc is crate is required to avoid incorrectly determining that we are building with the Android NDK: rust-lang/cc-rs@57853c4 This patch is present in version 1.0.80 and newer versions of the cc crate. The rustc source distribution currently has 3 different versions of cc in the vendor directory, only one of which has the necessary fix. We (the Android Rust toolchain) are currently maintaining local patches to upgrade the cc crate dependency versions, which we would like to upstream. Furthermore, beyond the specific reason, the cc crate in bootstrap is currently pinned at an old version due to problems in the past when trying to update it. It is worthwhile to figure out and resolve these problems so we can keep the dependency up-to-date. Other fixes: As of cc v1.0.78, object files are prefixed with a 16-character hash. Update src/bootstrap/src/core/build_steps/llvm.rs to account for this to avoid failures when building libunwind and libcrt. Note that while the hash prefix was introduced in v1.0.78, in order to determine the names of the object files without scanning the directory, we rely on the compile_intermediates method, which was introduced in cc v1.0.86 As of cc v1.0.86, compilation on MacOS uses the -mmacosx-version-min flag. A long-standing bug in the CMake rules for compiler-rt causes compilation to fail when this flag is specified. So we add a workaround to suppress this flag. Updating to cc v1.0.91 and newer requires fixes to bootstrap unit tests. The unit tests use targets named "A", "B", etc., which fail a validation check introduced in 1.0.91 of the cc crate. As of cc v1.0.74, the SDKROOT environment variable is used on Darwin if present, regardless of whether it is for the correct platform or not. This is fixed in cc v1.0.97.
2 parents d71b3f4 + 615b485 commit e2865db

File tree

7 files changed

+116
-72
lines changed

7 files changed

+116
-72
lines changed
 

‎src/bootstrap/Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ dependencies = [
9898

9999
[[package]]
100100
name = "cc"
101-
version = "1.0.73"
101+
version = "1.0.97"
102102
source = "registry+https://github.com/rust-lang/crates.io-index"
103-
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
103+
checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4"
104104

105105
[[package]]
106106
name = "cfg-if"

‎src/bootstrap/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test = false
3636
# Most of the time updating these dependencies requires modifications to the
3737
# bootstrap codebase(e.g., https://github.com/rust-lang/rust/issues/124565);
3838
# otherwise, some targets will fail. That's why these dependencies are explicitly pinned.
39-
cc = "=1.0.73"
39+
cc = "=1.0.97"
4040
cmake = "=0.1.48"
4141

4242
build_helper = { path = "../tools/build_helper" }

‎src/bootstrap/src/core/build_steps/llvm.rs

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ use std::sync::OnceLock;
2020
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
2121
use crate::core::config::{Config, TargetSelection};
2222
use crate::utils::channel;
23-
use crate::utils::helpers::{self, exe, get_clang_cl_resource_dir, output, t, up_to_date};
23+
use crate::utils::helpers::{
24+
self, exe, get_clang_cl_resource_dir, output, t, unhashed_basename, up_to_date,
25+
};
2426
use crate::{generate_smart_stamp_hash, CLang, GitRepo, Kind};
2527

2628
use build_helper::ci::CiEnv;
@@ -506,7 +508,7 @@ impl Step for Llvm {
506508
cfg.define("LLVM_VERSION_SUFFIX", suffix);
507509
}
508510

509-
configure_cmake(builder, target, &mut cfg, true, ldflags, &[]);
511+
configure_cmake(builder, target, &mut cfg, true, ldflags, &[], &[]);
510512
configure_llvm(builder, target, &mut cfg);
511513

512514
for (key, val) in &builder.config.llvm_build_config {
@@ -596,6 +598,7 @@ fn configure_cmake(
596598
use_compiler_launcher: bool,
597599
mut ldflags: LdFlags,
598600
extra_compiler_flags: &[&str],
601+
suppressed_compiler_flag_prefixes: &[&str],
599602
) {
600603
// Do not print installation messages for up-to-date files.
601604
// LLVM and LLD builds can produce a lot of those and hit CI limits on log size.
@@ -729,7 +732,17 @@ fn configure_cmake(
729732
}
730733

731734
cfg.build_arg("-j").build_arg(builder.jobs().to_string());
732-
let mut cflags: OsString = builder.cflags(target, GitRepo::Llvm, CLang::C).join(" ").into();
735+
let mut cflags: OsString = builder
736+
.cflags(target, GitRepo::Llvm, CLang::C)
737+
.into_iter()
738+
.filter(|flag| {
739+
!suppressed_compiler_flag_prefixes
740+
.iter()
741+
.any(|suppressed_prefix| flag.starts_with(suppressed_prefix))
742+
})
743+
.collect::<Vec<String>>()
744+
.join(" ")
745+
.into();
733746
if let Some(ref s) = builder.config.llvm_cflags {
734747
cflags.push(" ");
735748
cflags.push(s);
@@ -742,7 +755,17 @@ fn configure_cmake(
742755
cflags.push(&format!(" {flag}"));
743756
}
744757
cfg.define("CMAKE_C_FLAGS", cflags);
745-
let mut cxxflags: OsString = builder.cflags(target, GitRepo::Llvm, CLang::Cxx).join(" ").into();
758+
let mut cxxflags: OsString = builder
759+
.cflags(target, GitRepo::Llvm, CLang::Cxx)
760+
.into_iter()
761+
.filter(|flag| {
762+
!suppressed_compiler_flag_prefixes
763+
.iter()
764+
.any(|suppressed_prefix| flag.starts_with(suppressed_prefix))
765+
})
766+
.collect::<Vec<String>>()
767+
.join(" ")
768+
.into();
746769
if let Some(ref s) = builder.config.llvm_cxxflags {
747770
cxxflags.push(" ");
748771
cxxflags.push(s);
@@ -921,7 +944,7 @@ impl Step for Lld {
921944
ldflags.push_all("-Wl,-rpath,'$ORIGIN/../../../'");
922945
}
923946

924-
configure_cmake(builder, target, &mut cfg, true, ldflags, &[]);
947+
configure_cmake(builder, target, &mut cfg, true, ldflags, &[], &[]);
925948
configure_llvm(builder, target, &mut cfg);
926949

927950
// Re-use the same flags as llvm to control the level of debug information
@@ -1022,13 +1045,20 @@ impl Step for Sanitizers {
10221045
let use_compiler_launcher = !self.target.contains("apple-darwin");
10231046
let extra_compiler_flags: &[&str] =
10241047
if self.target.contains("apple") { &["-fembed-bitcode=off"] } else { &[] };
1048+
// Since v1.0.86, the cc crate adds -mmacosx-version-min to the default
1049+
// flags on MacOS. A long-standing bug in the CMake rules for compiler-rt
1050+
// causes architecture detection to be skipped when this flag is present,
1051+
// and compilation fails. https://github.com/llvm/llvm-project/issues/88780
1052+
let suppressed_compiler_flag_prefixes: &[&str] =
1053+
if self.target.contains("apple-darwin") { &["-mmacosx-version-min="] } else { &[] };
10251054
configure_cmake(
10261055
builder,
10271056
self.target,
10281057
&mut cfg,
10291058
use_compiler_launcher,
10301059
LdFlags::default(),
10311060
extra_compiler_flags,
1061+
suppressed_compiler_flag_prefixes,
10321062
);
10331063

10341064
t!(fs::create_dir_all(&out_dir));
@@ -1190,7 +1220,7 @@ impl Step for CrtBeginEnd {
11901220

11911221
let crtbegin_src = builder.src.join("src/llvm-project/compiler-rt/lib/builtins/crtbegin.c");
11921222
let crtend_src = builder.src.join("src/llvm-project/compiler-rt/lib/builtins/crtend.c");
1193-
if up_to_date(&crtbegin_src, &out_dir.join("crtbegin.o"))
1223+
if up_to_date(&crtbegin_src, &out_dir.join("crtbeginS.o"))
11941224
&& up_to_date(&crtend_src, &out_dir.join("crtendS.o"))
11951225
{
11961226
return out_dir;
@@ -1222,10 +1252,15 @@ impl Step for CrtBeginEnd {
12221252
.define("CRT_HAS_INITFINI_ARRAY", None)
12231253
.define("EH_USE_FRAME_REGISTRY", None);
12241254

1225-
cfg.compile("crt");
1255+
let objs = cfg.compile_intermediates();
1256+
assert_eq!(objs.len(), 2);
1257+
for obj in objs {
1258+
let base_name = unhashed_basename(&obj);
1259+
assert!(base_name == "crtbegin" || base_name == "crtend");
1260+
t!(fs::copy(&obj, out_dir.join(format!("{}S.o", base_name))));
1261+
t!(fs::rename(&obj, out_dir.join(format!("{}.o", base_name))));
1262+
}
12261263

1227-
t!(fs::copy(out_dir.join("crtbegin.o"), out_dir.join("crtbeginS.o")));
1228-
t!(fs::copy(out_dir.join("crtend.o"), out_dir.join("crtendS.o")));
12291264
out_dir
12301265
}
12311266
}
@@ -1372,9 +1407,9 @@ impl Step for Libunwind {
13721407
for entry in fs::read_dir(&out_dir).unwrap() {
13731408
let file = entry.unwrap().path().canonicalize().unwrap();
13741409
if file.is_file() && file.extension() == Some(OsStr::new("o")) {
1375-
// file name starts with "Unwind-EHABI", "Unwind-seh" or "libunwind"
1376-
let file_name = file.file_name().unwrap().to_str().expect("UTF-8 file name");
1377-
if cpp_sources.iter().any(|f| file_name.starts_with(&f[..f.len() - 4])) {
1410+
// Object file name without the hash prefix is "Unwind-EHABI", "Unwind-seh" or "libunwind".
1411+
let base_name = unhashed_basename(&file);
1412+
if cpp_sources.iter().any(|f| *base_name == f[..f.len() - 4]) {
13781413
cc_cfg.object(&file);
13791414
count += 1;
13801415
}

‎src/bootstrap/src/core/builder/tests.rs

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fn configure_with_args(cmd: &[String], host: &[&str], target: &[&str]) -> Config
3232
.join(&thread::current().name().unwrap_or("unknown").replace(":", "-"));
3333
t!(fs::create_dir_all(&dir));
3434
config.out = dir;
35-
config.build = TargetSelection::from_user("A");
35+
config.build = TargetSelection::from_user("A-A");
3636
config.hosts = host.iter().map(|s| TargetSelection::from_user(s)).collect();
3737
config.targets = target.iter().map(|s| TargetSelection::from_user(s)).collect();
3838
config
@@ -53,27 +53,27 @@ fn run_build(paths: &[PathBuf], config: Config) -> Cache {
5353
fn check_cli<const N: usize>(paths: [&str; N]) {
5454
run_build(
5555
&paths.map(PathBuf::from),
56-
configure_with_args(&paths.map(String::from), &["A"], &["A"]),
56+
configure_with_args(&paths.map(String::from), &["A-A"], &["A-A"]),
5757
);
5858
}
5959

6060
macro_rules! std {
6161
($host:ident => $target:ident, stage = $stage:literal) => {
6262
compile::Std::new(
63-
Compiler { host: TargetSelection::from_user(stringify!($host)), stage: $stage },
64-
TargetSelection::from_user(stringify!($target)),
63+
Compiler { host: TargetSelection::from_user(concat!(stringify!($host), "-", stringify!($host))), stage: $stage },
64+
TargetSelection::from_user(concat!(stringify!($target), "-", stringify!($target))),
6565
)
6666
};
6767
}
6868

6969
macro_rules! doc_std {
7070
($host:ident => $target:ident, stage = $stage:literal) => {{
71-
let config = configure("doc", &["A"], &["A"]);
71+
let config = configure("doc", &["A-A"], &["A-A"]);
7272
let build = Build::new(config);
7373
let builder = Builder::new(&build);
7474
doc::Std::new(
7575
$stage,
76-
TargetSelection::from_user(stringify!($target)),
76+
TargetSelection::from_user(concat!(stringify!($target), "-", stringify!($target))),
7777
&builder,
7878
DocumentationFormat::Html,
7979
)
@@ -83,8 +83,8 @@ macro_rules! doc_std {
8383
macro_rules! rustc {
8484
($host:ident => $target:ident, stage = $stage:literal) => {
8585
compile::Rustc::new(
86-
Compiler { host: TargetSelection::from_user(stringify!($host)), stage: $stage },
87-
TargetSelection::from_user(stringify!($target)),
86+
Compiler { host: TargetSelection::from_user(concat!(stringify!($host), "-", stringify!($host))), stage: $stage },
87+
TargetSelection::from_user(concat!(stringify!($target), "-", stringify!($target))),
8888
)
8989
};
9090
}
@@ -117,7 +117,7 @@ fn test_intersection() {
117117

118118
#[test]
119119
fn validate_path_remap() {
120-
let build = Build::new(configure("test", &["A"], &["A"]));
120+
let build = Build::new(configure("test", &["A-A"], &["A-A"]));
121121

122122
PATH_REMAP
123123
.iter()
@@ -130,7 +130,7 @@ fn validate_path_remap() {
130130

131131
#[test]
132132
fn test_exclude() {
133-
let mut config = configure("test", &["A"], &["A"]);
133+
let mut config = configure("test", &["A-A"], &["A-A"]);
134134
config.skip = vec!["src/tools/tidy".into()];
135135
let cache = run_build(&[], config);
136136

@@ -145,7 +145,7 @@ fn test_exclude() {
145145
fn test_exclude_kind() {
146146
let path = PathBuf::from("compiler/rustc_data_structures");
147147

148-
let mut config = configure("test", &["A"], &["A"]);
148+
let mut config = configure("test", &["A-A"], &["A-A"]);
149149
// Ensure our test is valid, and `test::Rustc` would be run without the exclude.
150150
assert!(run_build(&[], config.clone()).contains::<test::CrateLibrustc>());
151151
// Ensure tests for rustc are not skipped.
@@ -159,13 +159,13 @@ fn test_exclude_kind() {
159159
#[test]
160160
fn alias_and_path_for_library() {
161161
let mut cache =
162-
run_build(&["library".into(), "core".into()], configure("build", &["A"], &["A"]));
162+
run_build(&["library".into(), "core".into()], configure("build", &["A-A"], &["A-A"]));
163163
assert_eq!(
164164
first(cache.all::<compile::Std>()),
165165
&[std!(A => A, stage = 0), std!(A => A, stage = 1)]
166166
);
167167

168-
let mut cache = run_build(&["library".into(), "core".into()], configure("doc", &["A"], &["A"]));
168+
let mut cache = run_build(&["library".into(), "core".into()], configure("doc", &["A-A"], &["A-A"]));
169169
assert_eq!(first(cache.all::<doc::Std>()), &[doc_std!(A => A, stage = 0)]);
170170
}
171171

@@ -177,9 +177,9 @@ mod defaults {
177177

178178
#[test]
179179
fn build_default() {
180-
let mut cache = run_build(&[], configure("build", &["A"], &["A"]));
180+
let mut cache = run_build(&[], configure("build", &["A-A"], &["A-A"]));
181181

182-
let a = TargetSelection::from_user("A");
182+
let a = TargetSelection::from_user("A-A");
183183
assert_eq!(
184184
first(cache.all::<compile::Std>()),
185185
&[std!(A => A, stage = 0), std!(A => A, stage = 1),]
@@ -197,10 +197,10 @@ mod defaults {
197197

198198
#[test]
199199
fn build_stage_0() {
200-
let config = Config { stage: 0, ..configure("build", &["A"], &["A"]) };
200+
let config = Config { stage: 0, ..configure("build", &["A-A"], &["A-A"]) };
201201
let mut cache = run_build(&[], config);
202202

203-
let a = TargetSelection::from_user("A");
203+
let a = TargetSelection::from_user("A-A");
204204
assert_eq!(first(cache.all::<compile::Std>()), &[std!(A => A, stage = 0)]);
205205
assert!(!cache.all::<compile::Assemble>().is_empty());
206206
assert_eq!(
@@ -214,11 +214,11 @@ mod defaults {
214214

215215
#[test]
216216
fn build_cross_compile() {
217-
let config = Config { stage: 1, ..configure("build", &["A", "B"], &["A", "B"]) };
217+
let config = Config { stage: 1, ..configure("build", &["A-A", "B-B"], &["A-A", "B-B"]) };
218218
let mut cache = run_build(&[], config);
219219

220-
let a = TargetSelection::from_user("A");
221-
let b = TargetSelection::from_user("B");
220+
let a = TargetSelection::from_user("A-A");
221+
let b = TargetSelection::from_user("B-B");
222222

223223
// Ideally, this build wouldn't actually have `target: a`
224224
// rustdoc/rustcc/std here (the user only requested a host=B build, so
@@ -257,11 +257,11 @@ mod defaults {
257257

258258
#[test]
259259
fn doc_default() {
260-
let mut config = configure("doc", &["A"], &["A"]);
260+
let mut config = configure("doc", &["A-A"], &["A-A"]);
261261
config.compiler_docs = true;
262262
config.cmd = Subcommand::Doc { open: false, json: false };
263263
let mut cache = run_build(&[], config);
264-
let a = TargetSelection::from_user("A");
264+
let a = TargetSelection::from_user("A-A");
265265

266266
// error_index_generator uses stage 0 to share rustdoc artifacts with the
267267
// rustdoc tool.
@@ -291,9 +291,9 @@ mod dist {
291291

292292
#[test]
293293
fn dist_baseline() {
294-
let mut cache = run_build(&[], configure(&["A"], &["A"]));
294+
let mut cache = run_build(&[], configure(&["A-A"], &["A-A"]));
295295

296-
let a = TargetSelection::from_user("A");
296+
let a = TargetSelection::from_user("A-A");
297297

298298
assert_eq!(first(cache.all::<dist::Docs>()), &[dist::Docs { host: a },]);
299299
assert_eq!(first(cache.all::<dist::Mingw>()), &[dist::Mingw { host: a },]);
@@ -315,10 +315,10 @@ mod dist {
315315

316316
#[test]
317317
fn dist_with_targets() {
318-
let mut cache = run_build(&[], configure(&["A"], &["A", "B"]));
318+
let mut cache = run_build(&[], configure(&["A-A"], &["A-A", "B-B"]));
319319

320-
let a = TargetSelection::from_user("A");
321-
let b = TargetSelection::from_user("B");
320+
let a = TargetSelection::from_user("A-A");
321+
let b = TargetSelection::from_user("B-B");
322322

323323
assert_eq!(
324324
first(cache.all::<dist::Docs>()),
@@ -344,10 +344,10 @@ mod dist {
344344

345345
#[test]
346346
fn dist_with_hosts() {
347-
let mut cache = run_build(&[], configure(&["A", "B"], &["A", "B"]));
347+
let mut cache = run_build(&[], configure(&["A-A", "B-B"], &["A-A", "B-B"]));
348348

349-
let a = TargetSelection::from_user("A");
350-
let b = TargetSelection::from_user("B");
349+
let a = TargetSelection::from_user("A-A");
350+
let b = TargetSelection::from_user("B-B");
351351

352352
assert_eq!(
353353
first(cache.all::<dist::Docs>()),
@@ -386,8 +386,8 @@ mod dist {
386386

387387
#[test]
388388
fn dist_only_cross_host() {
389-
let b = TargetSelection::from_user("B");
390-
let mut config = configure(&["A", "B"], &["A", "B"]);
389+
let b = TargetSelection::from_user("B-B");
390+
let mut config = configure(&["A-A", "B-B"], &["A-A", "B-B"]);
391391
config.docs = false;
392392
config.extended = true;
393393
config.hosts = vec![b];
@@ -405,11 +405,11 @@ mod dist {
405405

406406
#[test]
407407
fn dist_with_targets_and_hosts() {
408-
let mut cache = run_build(&[], configure(&["A", "B"], &["A", "B", "C"]));
408+
let mut cache = run_build(&[], configure(&["A-A", "B-B"], &["A-A", "B-B", "C-C"]));
409409

410-
let a = TargetSelection::from_user("A");
411-
let b = TargetSelection::from_user("B");
412-
let c = TargetSelection::from_user("C");
410+
let a = TargetSelection::from_user("A-A");
411+
let b = TargetSelection::from_user("B-B");
412+
let c = TargetSelection::from_user("C-C");
413413

414414
assert_eq!(
415415
first(cache.all::<dist::Docs>()),
@@ -439,11 +439,11 @@ mod dist {
439439

440440
#[test]
441441
fn dist_with_empty_host() {
442-
let config = configure(&[], &["C"]);
442+
let config = configure(&[], &["C-C"]);
443443
let mut cache = run_build(&[], config);
444444

445-
let a = TargetSelection::from_user("A");
446-
let c = TargetSelection::from_user("C");
445+
let a = TargetSelection::from_user("A-A");
446+
let c = TargetSelection::from_user("C-C");
447447

448448
assert_eq!(first(cache.all::<dist::Docs>()), &[dist::Docs { host: c },]);
449449
assert_eq!(first(cache.all::<dist::Mingw>()), &[dist::Mingw { host: c },]);
@@ -455,10 +455,10 @@ mod dist {
455455

456456
#[test]
457457
fn dist_with_same_targets_and_hosts() {
458-
let mut cache = run_build(&[], configure(&["A", "B"], &["A", "B"]));
458+
let mut cache = run_build(&[], configure(&["A-A", "B-B"], &["A-A", "B-B"]));
459459

460-
let a = TargetSelection::from_user("A");
461-
let b = TargetSelection::from_user("B");
460+
let a = TargetSelection::from_user("A-A");
461+
let b = TargetSelection::from_user("B-B");
462462

463463
assert_eq!(
464464
first(cache.all::<dist::Docs>()),
@@ -506,7 +506,7 @@ mod dist {
506506

507507
#[test]
508508
fn build_all() {
509-
let build = Build::new(configure(&["A", "B"], &["A", "B", "C"]));
509+
let build = Build::new(configure(&["A-A", "B-B"], &["A-A", "B-B", "C-C"]));
510510
let mut builder = Builder::new(&build);
511511
builder.run_step_descriptions(
512512
&Builder::get_step_descriptions(Kind::Build),
@@ -539,29 +539,29 @@ mod dist {
539539

540540
#[test]
541541
fn llvm_out_behaviour() {
542-
let mut config = configure(&["A"], &["B"]);
542+
let mut config = configure(&["A-A"], &["B-B"]);
543543
config.llvm_from_ci = true;
544544
let build = Build::new(config.clone());
545545

546-
let target = TargetSelection::from_user("A");
546+
let target = TargetSelection::from_user("A-A");
547547
assert!(build.llvm_out(target).ends_with("ci-llvm"));
548-
let target = TargetSelection::from_user("B");
548+
let target = TargetSelection::from_user("B-B");
549549
assert!(build.llvm_out(target).ends_with("llvm"));
550550

551551
config.llvm_from_ci = false;
552552
let build = Build::new(config.clone());
553-
let target = TargetSelection::from_user("A");
553+
let target = TargetSelection::from_user("A-A");
554554
assert!(build.llvm_out(target).ends_with("llvm"));
555555
}
556556

557557
#[test]
558558
fn build_with_empty_host() {
559-
let config = configure(&[], &["C"]);
559+
let config = configure(&[], &["C-C"]);
560560
let build = Build::new(config);
561561
let mut builder = Builder::new(&build);
562562
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Build), &[]);
563563

564-
let a = TargetSelection::from_user("A");
564+
let a = TargetSelection::from_user("A-A");
565565

566566
assert_eq!(
567567
first(builder.cache.all::<compile::Std>()),
@@ -583,7 +583,7 @@ mod dist {
583583

584584
#[test]
585585
fn test_with_no_doc_stage0() {
586-
let mut config = configure(&["A"], &["A"]);
586+
let mut config = configure(&["A-A"], &["A-A"]);
587587
config.stage = 0;
588588
config.paths = vec!["library/std".into()];
589589
config.cmd = Subcommand::Test {
@@ -605,7 +605,7 @@ mod dist {
605605
let build = Build::new(config);
606606
let mut builder = Builder::new(&build);
607607

608-
let host = TargetSelection::from_user("A");
608+
let host = TargetSelection::from_user("A-A");
609609

610610
builder.run_step_descriptions(
611611
&[StepDescription::from::<test::Crate>(Kind::Test)],
@@ -627,13 +627,13 @@ mod dist {
627627

628628
#[test]
629629
fn doc_ci() {
630-
let mut config = configure(&["A"], &["A"]);
630+
let mut config = configure(&["A-A"], &["A-A"]);
631631
config.compiler_docs = true;
632632
config.cmd = Subcommand::Doc { open: false, json: false };
633633
let build = Build::new(config);
634634
let mut builder = Builder::new(&build);
635635
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Doc), &[]);
636-
let a = TargetSelection::from_user("A");
636+
let a = TargetSelection::from_user("A-A");
637637

638638
// error_index_generator uses stage 1 to share rustdoc artifacts with the
639639
// rustdoc tool.
@@ -656,7 +656,7 @@ mod dist {
656656
#[test]
657657
fn test_docs() {
658658
// Behavior of `x.py test` doing various documentation tests.
659-
let mut config = configure(&["A"], &["A"]);
659+
let mut config = configure(&["A-A"], &["A-A"]);
660660
config.cmd = Subcommand::Test {
661661
test_args: vec![],
662662
rustc_args: vec![],
@@ -678,7 +678,7 @@ mod dist {
678678
let mut builder = Builder::new(&build);
679679

680680
builder.run_step_descriptions(&Builder::get_step_descriptions(Kind::Test), &[]);
681-
let a = TargetSelection::from_user("A");
681+
let a = TargetSelection::from_user("A-A");
682682

683683
// error_index_generator uses stage 1 to share rustdoc artifacts with the
684684
// rustdoc tool.

‎src/bootstrap/src/core/sanity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ than building it.
192192
let target_str = target.to_string();
193193

194194
// Ignore fake targets that are only used for unit tests in bootstrap.
195-
if !["A", "B", "C"].contains(&target_str.as_str()) {
195+
if !["A-A", "B-B", "C-C"].contains(&target_str.as_str()) {
196196
let mut has_target = false;
197197

198198
let supported_target_list =

‎src/bootstrap/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,7 @@ impl Build {
17231723
return;
17241724
}
17251725
let _ = fs::remove_file(dst);
1726-
let metadata = t!(src.symlink_metadata());
1726+
let metadata = t!(src.symlink_metadata(), format!("src = {}", src.display()));
17271727
let mut src = src.to_path_buf();
17281728
if metadata.file_type().is_symlink() {
17291729
if dereference_symlinks {

‎src/bootstrap/src/utils/helpers.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,15 @@ pub fn up_to_date(src: &Path, dst: &Path) -> bool {
296296
}
297297
}
298298

299+
/// Returns the filename without the hash prefix added by the cc crate.
300+
///
301+
/// Since v1.0.78 of the cc crate, object files are prefixed with a 16-character hash
302+
/// to avoid filename collisions.
303+
pub fn unhashed_basename(obj: &Path) -> &str {
304+
let basename = obj.file_stem().unwrap().to_str().expect("UTF-8 file name");
305+
basename.split_once('-').unwrap().1
306+
}
307+
299308
fn dir_up_to_date(src: &Path, threshold: SystemTime) -> bool {
300309
t!(fs::read_dir(src)).map(|e| t!(e)).all(|e| {
301310
let meta = t!(e.metadata());

0 commit comments

Comments
 (0)
Please sign in to comment.