Skip to content

Commit cd2ce8d

Browse files
authored
Rollup merge of rust-lang#126136 - Noratrieb:bootstrap-naming, r=onur-ozkan
Call the target libdir target libdir Because it's the target libdir. `--print` uses the same terminology, and it's a simple way to make it obviously different from `$sysroot/lib`.
2 parents 009e738 + 7627a54 commit cd2ce8d

File tree

6 files changed

+36
-27
lines changed

6 files changed

+36
-27
lines changed

src/bootstrap/src/core/build_steps/check.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ impl Step for Std {
9191
// We skip populating the sysroot in non-zero stage because that'll lead
9292
// to rlib/rmeta conflicts if std gets built during this session.
9393
if compiler.stage == 0 {
94-
let libdir = builder.sysroot_libdir(compiler, target);
95-
let hostdir = builder.sysroot_libdir(compiler, compiler.host);
94+
let libdir = builder.sysroot_target_libdir(compiler, target);
95+
let hostdir = builder.sysroot_target_libdir(compiler, compiler.host);
9696
add_to_sysroot(builder, &libdir, &hostdir, &libstd_stamp(builder, compiler, target));
9797
}
9898
drop(_guard);
@@ -257,8 +257,8 @@ impl Step for Rustc {
257257
false,
258258
);
259259

260-
let libdir = builder.sysroot_libdir(compiler, target);
261-
let hostdir = builder.sysroot_libdir(compiler, compiler.host);
260+
let libdir = builder.sysroot_target_libdir(compiler, target);
261+
let hostdir = builder.sysroot_target_libdir(compiler, compiler.host);
262262
add_to_sysroot(builder, &libdir, &hostdir, &librustc_stamp(builder, compiler, target));
263263
}
264264
}

src/bootstrap/src/core/build_steps/compile.rs

+22-14
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl Step for Std {
240240
.join("bin");
241241
if src_sysroot_bin.exists() {
242242
let target_sysroot_bin =
243-
builder.sysroot_libdir(compiler, target).parent().unwrap().join("bin");
243+
builder.sysroot_target_libdir(compiler, target).parent().unwrap().join("bin");
244244
t!(fs::create_dir_all(&target_sysroot_bin));
245245
builder.cp_link_r(&src_sysroot_bin, &target_sysroot_bin);
246246
}
@@ -354,7 +354,7 @@ fn copy_third_party_objects(
354354
&& (target.contains("linux") || target.contains("fuchsia"))
355355
{
356356
let libunwind_path =
357-
copy_llvm_libunwind(builder, target, &builder.sysroot_libdir(*compiler, target));
357+
copy_llvm_libunwind(builder, target, &builder.sysroot_target_libdir(*compiler, target));
358358
target_deps.push((libunwind_path, DependencyType::Target));
359359
}
360360

@@ -367,7 +367,8 @@ fn copy_self_contained_objects(
367367
compiler: &Compiler,
368368
target: TargetSelection,
369369
) -> Vec<(PathBuf, DependencyType)> {
370-
let libdir_self_contained = builder.sysroot_libdir(*compiler, target).join("self-contained");
370+
let libdir_self_contained =
371+
builder.sysroot_target_libdir(*compiler, target).join("self-contained");
371372
t!(fs::create_dir_all(&libdir_self_contained));
372373
let mut target_deps = vec![];
373374

@@ -675,8 +676,8 @@ impl Step for StdLink {
675676
let hostdir = sysroot.join(lib).join("rustlib").join(compiler.host).join("lib");
676677
(libdir, hostdir)
677678
} else {
678-
let libdir = builder.sysroot_libdir(target_compiler, target);
679-
let hostdir = builder.sysroot_libdir(target_compiler, compiler.host);
679+
let libdir = builder.sysroot_target_libdir(target_compiler, target);
680+
let hostdir = builder.sysroot_target_libdir(target_compiler, compiler.host);
680681
(libdir, hostdir)
681682
};
682683

@@ -743,7 +744,7 @@ fn copy_sanitizers(
743744
}
744745

745746
let mut target_deps = Vec::new();
746-
let libdir = builder.sysroot_libdir(*compiler, target);
747+
let libdir = builder.sysroot_target_libdir(*compiler, target);
747748

748749
for runtime in &runtimes {
749750
let dst = libdir.join(&runtime.name);
@@ -821,7 +822,7 @@ impl Step for StartupObjects {
821822

822823
let src_dir = &builder.src.join("library").join("rtstartup");
823824
let dst_dir = &builder.native_dir(target).join("rtstartup");
824-
let sysroot_dir = &builder.sysroot_libdir(for_compiler, target);
825+
let sysroot_dir = &builder.sysroot_target_libdir(for_compiler, target);
825826
t!(fs::create_dir_all(dst_dir));
826827

827828
for file in &["rsbegin", "rsend"] {
@@ -1273,10 +1274,17 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect
12731274
}
12741275
}
12751276

1277+
/// `RustcLink` copies all of the rlibs from the rustc build into the previous stage's sysroot.
1278+
/// This is necessary for tools using `rustc_private`, where the previous compiler will build
1279+
/// a tool against the next compiler.
1280+
/// To build a tool against a compiler, the rlibs of that compiler that it links against
1281+
/// must be in the sysroot of the compiler that's doing the compiling.
12761282
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
12771283
struct RustcLink {
1284+
/// The compiler whose rlibs we are copying around.
12781285
pub compiler: Compiler,
1279-
pub target_compiler: Compiler,
1286+
/// This is the compiler into whose sysroot we want to copy the rlibs into.
1287+
pub previous_stage_compiler: Compiler,
12801288
pub target: TargetSelection,
12811289
/// Not actually used; only present to make sure the cache invalidation is correct.
12821290
crates: Vec<String>,
@@ -1286,7 +1294,7 @@ impl RustcLink {
12861294
fn from_rustc(rustc: Rustc, host_compiler: Compiler) -> Self {
12871295
Self {
12881296
compiler: host_compiler,
1289-
target_compiler: rustc.compiler,
1297+
previous_stage_compiler: rustc.compiler,
12901298
target: rustc.target,
12911299
crates: rustc.crates,
12921300
}
@@ -1303,12 +1311,12 @@ impl Step for RustcLink {
13031311
/// Same as `std_link`, only for librustc
13041312
fn run(self, builder: &Builder<'_>) {
13051313
let compiler = self.compiler;
1306-
let target_compiler = self.target_compiler;
1314+
let previous_stage_compiler = self.previous_stage_compiler;
13071315
let target = self.target;
13081316
add_to_sysroot(
13091317
builder,
1310-
&builder.sysroot_libdir(target_compiler, target),
1311-
&builder.sysroot_libdir(target_compiler, compiler.host),
1318+
&builder.sysroot_target_libdir(previous_stage_compiler, target),
1319+
&builder.sysroot_target_libdir(previous_stage_compiler, compiler.host),
13121320
&librustc_stamp(builder, compiler, target),
13131321
);
13141322
}
@@ -1845,7 +1853,7 @@ impl Step for Assemble {
18451853
let sysroot = builder.sysroot(target_compiler);
18461854
let rustc_libdir = builder.rustc_libdir(target_compiler);
18471855
t!(fs::create_dir_all(&rustc_libdir));
1848-
let src_libdir = builder.sysroot_libdir(build_compiler, host);
1856+
let src_libdir = builder.sysroot_target_libdir(build_compiler, host);
18491857
for f in builder.read_dir(&src_libdir) {
18501858
let filename = f.file_name().into_string().unwrap();
18511859
if (is_dylib(&filename) || is_debug_info(&filename)) && !proc_macros.contains(&filename)
@@ -1858,7 +1866,7 @@ impl Step for Assemble {
18581866

18591867
// We prepend this bin directory to the user PATH when linking Rust binaries. To
18601868
// avoid shadowing the system LLD we rename the LLD we provide to `rust-lld`.
1861-
let libdir = builder.sysroot_libdir(target_compiler, target_compiler.host);
1869+
let libdir = builder.sysroot_target_libdir(target_compiler, target_compiler.host);
18621870
let libdir_bin = libdir.parent().unwrap().join("bin");
18631871
t!(fs::create_dir_all(&libdir_bin));
18641872
if let Some(lld_install) = lld_install {

src/bootstrap/src/core/build_steps/dist.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,8 @@ impl Step for Rustc {
459459

460460
// Copy over lld if it's there
461461
if builder.config.lld_enabled {
462-
let src_dir = builder.sysroot_libdir(compiler, host).parent().unwrap().join("bin");
462+
let src_dir =
463+
builder.sysroot_target_libdir(compiler, host).parent().unwrap().join("bin");
463464
let rust_lld = exe("rust-lld", compiler.host);
464465
builder.copy_link(&src_dir.join(&rust_lld), &dst_dir.join(&rust_lld));
465466
let self_contained_lld_src_dir = src_dir.join("gcc-ld");

src/bootstrap/src/core/build_steps/test.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ impl Step for RustdocTheme {
800800
.arg(builder.src.join("src/librustdoc/html/static/css/rustdoc.css").to_str().unwrap())
801801
.env("RUSTC_STAGE", self.compiler.stage.to_string())
802802
.env("RUSTC_SYSROOT", builder.sysroot(self.compiler))
803-
.env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host))
803+
.env("RUSTDOC_LIBDIR", builder.sysroot_target_libdir(self.compiler, self.compiler.host))
804804
.env("CFG_RELEASE_CHANNEL", &builder.config.channel)
805805
.env("RUSTDOC_REAL", builder.rustdoc(self.compiler))
806806
.env("RUSTC_BOOTSTRAP", "1");
@@ -1728,7 +1728,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
17281728
// of them!
17291729

17301730
cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(compiler));
1731-
cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target));
1731+
cmd.arg("--run-lib-path").arg(builder.sysroot_target_libdir(compiler, target));
17321732
cmd.arg("--rustc-path").arg(builder.rustc(compiler));
17331733

17341734
let is_rustdoc = suite.ends_with("rustdoc-ui") || suite.ends_with("rustdoc-js");
@@ -2553,7 +2553,7 @@ fn prepare_cargo_test(
25532553
// by `Cargo::new` and that actually makes things go wrong.
25542554
if builder.kind != Kind::Miri {
25552555
let mut dylib_path = dylib_path();
2556-
dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target)));
2556+
dylib_path.insert(0, PathBuf::from(&*builder.sysroot_target_libdir(compiler, target)));
25572557
cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
25582558
}
25592559

@@ -2788,7 +2788,7 @@ impl Step for CrateRustdoc {
27882788
let libdir = if builder.download_rustc() {
27892789
builder.rustc_libdir(compiler)
27902790
} else {
2791-
builder.sysroot_libdir(compiler, target).to_path_buf()
2791+
builder.sysroot_target_libdir(compiler, target).to_path_buf()
27922792
};
27932793
let mut dylib_path = dylib_path();
27942794
dylib_path.insert(0, PathBuf::from(&*libdir));
@@ -2913,7 +2913,7 @@ impl Step for RemoteCopyLibs {
29132913
cmd.run(builder);
29142914

29152915
// Push all our dylibs to the emulator
2916-
for f in t!(builder.sysroot_libdir(compiler, target).read_dir()) {
2916+
for f in t!(builder.sysroot_target_libdir(compiler, target).read_dir()) {
29172917
let f = t!(f);
29182918
let name = f.file_name().into_string().unwrap();
29192919
if helpers::is_dylib(&name) {

src/bootstrap/src/core/build_steps/tool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ impl ErrorIndex {
448448
let compiler = builder.compiler_for(builder.top_stage, host, host);
449449
let mut cmd = command(builder.ensure(ErrorIndex { compiler }));
450450
let mut dylib_paths = builder.rustc_lib_paths(compiler);
451-
dylib_paths.push(PathBuf::from(&builder.sysroot_libdir(compiler, compiler.host)));
451+
dylib_paths.push(PathBuf::from(&builder.sysroot_target_libdir(compiler, compiler.host)));
452452
add_dylib_path(dylib_paths, &mut cmd);
453453
cmd
454454
}

src/bootstrap/src/core/builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ impl<'a> Builder<'a> {
11521152

11531153
/// Returns the libdir where the standard library and other artifacts are
11541154
/// found for a compiler's sysroot.
1155-
pub fn sysroot_libdir(&self, compiler: Compiler, target: TargetSelection) -> PathBuf {
1155+
pub fn sysroot_target_libdir(&self, compiler: Compiler, target: TargetSelection) -> PathBuf {
11561156
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
11571157
struct Libdir {
11581158
compiler: Compiler,
@@ -1200,7 +1200,7 @@ impl<'a> Builder<'a> {
12001200
}
12011201

12021202
pub fn sysroot_codegen_backends(&self, compiler: Compiler) -> PathBuf {
1203-
self.sysroot_libdir(compiler, compiler.host).with_file_name("codegen-backends")
1203+
self.sysroot_target_libdir(compiler, compiler.host).with_file_name("codegen-backends")
12041204
}
12051205

12061206
/// Returns the compiler's libdir where it stores the dynamic libraries that

0 commit comments

Comments
 (0)