Skip to content

Commit deb4ceb

Browse files
Rollup merge of #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 b8c8287 + f42fb43 commit deb4ceb

File tree

6 files changed

+41
-30
lines changed

6 files changed

+41
-30
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

+25-16
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl Step for Std {
220220
.join("bin");
221221
if src_sysroot_bin.exists() {
222222
let target_sysroot_bin =
223-
builder.sysroot_libdir(compiler, target).parent().unwrap().join("bin");
223+
builder.sysroot_target_libdir(compiler, target).parent().unwrap().join("bin");
224224
t!(fs::create_dir_all(&target_sysroot_bin));
225225
builder.cp_link_r(&src_sysroot_bin, &target_sysroot_bin);
226226
}
@@ -334,7 +334,7 @@ fn copy_third_party_objects(
334334
&& (target.contains("linux") || target.contains("fuchsia"))
335335
{
336336
let libunwind_path =
337-
copy_llvm_libunwind(builder, target, &builder.sysroot_libdir(*compiler, target));
337+
copy_llvm_libunwind(builder, target, &builder.sysroot_target_libdir(*compiler, target));
338338
target_deps.push((libunwind_path, DependencyType::Target));
339339
}
340340

@@ -347,7 +347,8 @@ fn copy_self_contained_objects(
347347
compiler: &Compiler,
348348
target: TargetSelection,
349349
) -> Vec<(PathBuf, DependencyType)> {
350-
let libdir_self_contained = builder.sysroot_libdir(*compiler, target).join("self-contained");
350+
let libdir_self_contained =
351+
builder.sysroot_target_libdir(*compiler, target).join("self-contained");
351352
t!(fs::create_dir_all(&libdir_self_contained));
352353
let mut target_deps = vec![];
353354

@@ -655,8 +656,8 @@ impl Step for StdLink {
655656
let hostdir = sysroot.join(lib).join("rustlib").join(compiler.host).join("lib");
656657
(libdir, hostdir)
657658
} else {
658-
let libdir = builder.sysroot_libdir(target_compiler, target);
659-
let hostdir = builder.sysroot_libdir(target_compiler, compiler.host);
659+
let libdir = builder.sysroot_target_libdir(target_compiler, target);
660+
let hostdir = builder.sysroot_target_libdir(target_compiler, compiler.host);
660661
(libdir, hostdir)
661662
};
662663

@@ -723,7 +724,7 @@ fn copy_sanitizers(
723724
}
724725

725726
let mut target_deps = Vec::new();
726-
let libdir = builder.sysroot_libdir(*compiler, target);
727+
let libdir = builder.sysroot_target_libdir(*compiler, target);
727728

728729
for runtime in &runtimes {
729730
let dst = libdir.join(&runtime.name);
@@ -801,7 +802,7 @@ impl Step for StartupObjects {
801802

802803
let src_dir = &builder.src.join("library").join("rtstartup");
803804
let dst_dir = &builder.native_dir(target).join("rtstartup");
804-
let sysroot_dir = &builder.sysroot_libdir(for_compiler, target);
805+
let sysroot_dir = &builder.sysroot_target_libdir(for_compiler, target);
805806
t!(fs::create_dir_all(dst_dir));
806807

807808
for file in &["rsbegin", "rsend"] {
@@ -1287,10 +1288,17 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect
12871288
}
12881289
}
12891290

1291+
/// `RustcLink` copies all of the rlibs from the rustc build into the previous stage's sysroot.
1292+
/// This is necessary for tools using `rustc_private`, where the previous compiler will build
1293+
/// a tool against the next compiler.
1294+
/// To build a tool against a compiler, the rlibs of that compiler that it links against
1295+
/// must be in the sysroot of the compiler that's doing the compiling.
12901296
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
12911297
struct RustcLink {
1298+
/// The compiler whose rlibs we are copying around.
12921299
pub compiler: Compiler,
1293-
pub target_compiler: Compiler,
1300+
/// This is the compiler into whose sysroot we want to copy the rlibs into.
1301+
pub previous_stage_compiler: Compiler,
12941302
pub target: TargetSelection,
12951303
/// Not actually used; only present to make sure the cache invalidation is correct.
12961304
crates: Vec<String>,
@@ -1300,7 +1308,7 @@ impl RustcLink {
13001308
fn from_rustc(rustc: Rustc, host_compiler: Compiler) -> Self {
13011309
Self {
13021310
compiler: host_compiler,
1303-
target_compiler: rustc.compiler,
1311+
previous_stage_compiler: rustc.compiler,
13041312
target: rustc.target,
13051313
crates: rustc.crates,
13061314
}
@@ -1317,12 +1325,12 @@ impl Step for RustcLink {
13171325
/// Same as `std_link`, only for librustc
13181326
fn run(self, builder: &Builder<'_>) {
13191327
let compiler = self.compiler;
1320-
let target_compiler = self.target_compiler;
1328+
let previous_stage_compiler = self.previous_stage_compiler;
13211329
let target = self.target;
13221330
add_to_sysroot(
13231331
builder,
1324-
&builder.sysroot_libdir(target_compiler, target),
1325-
&builder.sysroot_libdir(target_compiler, compiler.host),
1332+
&builder.sysroot_target_libdir(previous_stage_compiler, target),
1333+
&builder.sysroot_target_libdir(previous_stage_compiler, compiler.host),
13261334
&librustc_stamp(builder, compiler, target),
13271335
);
13281336
}
@@ -1770,7 +1778,7 @@ impl Step for Assemble {
17701778

17711779
// We prepend this bin directory to the user PATH when linking Rust binaries. To
17721780
// avoid shadowing the system LLD we rename the LLD we provide to `rust-lld`.
1773-
let libdir = builder.sysroot_libdir(target_compiler, target_compiler.host);
1781+
let libdir = builder.sysroot_target_libdir(target_compiler, target_compiler.host);
17741782
let libdir_bin = libdir.parent().unwrap().join("bin");
17751783
t!(fs::create_dir_all(&libdir_bin));
17761784

@@ -1854,8 +1862,9 @@ impl Step for Assemble {
18541862
if let Some(enzyme_install) = enzyme_install {
18551863
let lib_ext = std::env::consts::DLL_EXTENSION;
18561864
let src_lib = enzyme_install.join("build/Enzyme/libEnzyme-19").with_extension(lib_ext);
1857-
let libdir = builder.sysroot_libdir(build_compiler, build_compiler.host);
1858-
let target_libdir = builder.sysroot_libdir(target_compiler, target_compiler.host);
1865+
let libdir = builder.sysroot_target_libdir(build_compiler, build_compiler.host);
1866+
let target_libdir =
1867+
builder.sysroot_target_libdir(target_compiler, target_compiler.host);
18591868
let dst_lib = libdir.join("libEnzyme-19").with_extension(lib_ext);
18601869
let target_dst_lib = target_libdir.join("libEnzyme-19").with_extension(lib_ext);
18611870
builder.copy_link(&src_lib, &dst_lib);
@@ -1923,7 +1932,7 @@ impl Step for Assemble {
19231932
let sysroot = builder.sysroot(target_compiler);
19241933
let rustc_libdir = builder.rustc_libdir(target_compiler);
19251934
t!(fs::create_dir_all(&rustc_libdir));
1926-
let src_libdir = builder.sysroot_libdir(build_compiler, host);
1935+
let src_libdir = builder.sysroot_target_libdir(build_compiler, host);
19271936
for f in builder.read_dir(&src_libdir) {
19281937
let filename = f.file_name().into_string().unwrap();
19291938

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

+4-2
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");
@@ -474,7 +475,8 @@ impl Step for Rustc {
474475
}
475476
}
476477
if builder.tool_enabled("wasm-component-ld") {
477-
let src_dir = builder.sysroot_libdir(compiler, host).parent().unwrap().join("bin");
478+
let src_dir =
479+
builder.sysroot_target_libdir(compiler, host).parent().unwrap().join("bin");
478480
let ld = exe("wasm-component-ld", compiler.host);
479481
builder.copy_link(&src_dir.join(&ld), &dst_dir.join(&ld));
480482
}

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");
@@ -1722,7 +1722,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
17221722
// of them!
17231723

17241724
cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(compiler));
1725-
cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target));
1725+
cmd.arg("--run-lib-path").arg(builder.sysroot_target_libdir(compiler, target));
17261726
cmd.arg("--rustc-path").arg(builder.rustc(compiler));
17271727

17281728
// Minicore auxiliary lib for `no_core` tests that need `core` stubs in cross-compilation
@@ -2583,7 +2583,7 @@ fn prepare_cargo_test(
25832583
// by `Cargo::new` and that actually makes things go wrong.
25842584
if builder.kind != Kind::Miri {
25852585
let mut dylib_path = dylib_path();
2586-
dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target)));
2586+
dylib_path.insert(0, PathBuf::from(&*builder.sysroot_target_libdir(compiler, target)));
25872587
cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
25882588
}
25892589

@@ -2818,7 +2818,7 @@ impl Step for CrateRustdoc {
28182818
let libdir = if builder.download_rustc() {
28192819
builder.rustc_libdir(compiler)
28202820
} else {
2821-
builder.sysroot_libdir(compiler, target).to_path_buf()
2821+
builder.sysroot_target_libdir(compiler, target).to_path_buf()
28222822
};
28232823
let mut dylib_path = dylib_path();
28242824
dylib_path.insert(0, PathBuf::from(&*libdir));
@@ -2943,7 +2943,7 @@ impl Step for RemoteCopyLibs {
29432943
cmd.run(builder);
29442944

29452945
// Push all our dylibs to the emulator
2946-
for f in t!(builder.sysroot_libdir(compiler, target).read_dir()) {
2946+
for f in t!(builder.sysroot_target_libdir(compiler, target).read_dir()) {
29472947
let f = t!(f);
29482948
let name = f.file_name().into_string().unwrap();
29492949
if helpers::is_dylib(&name) {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ impl ErrorIndex {
466466
let compiler = builder.compiler_for(builder.top_stage, host, host);
467467
let mut cmd = command(builder.ensure(ErrorIndex { compiler }));
468468
let mut dylib_paths = builder.rustc_lib_paths(compiler);
469-
dylib_paths.push(PathBuf::from(&builder.sysroot_libdir(compiler, compiler.host)));
469+
dylib_paths.push(PathBuf::from(&builder.sysroot_target_libdir(compiler, compiler.host)));
470470
add_dylib_path(dylib_paths, &mut cmd);
471471
cmd
472472
}

src/bootstrap/src/core/builder/mod.rs

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

11641164
/// Returns the libdir where the standard library and other artifacts are
11651165
/// found for a compiler's sysroot.
1166-
pub fn sysroot_libdir(&self, compiler: Compiler, target: TargetSelection) -> PathBuf {
1166+
pub fn sysroot_target_libdir(&self, compiler: Compiler, target: TargetSelection) -> PathBuf {
11671167
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
11681168
struct Libdir {
11691169
compiler: Compiler,
@@ -1211,7 +1211,7 @@ impl<'a> Builder<'a> {
12111211
}
12121212

12131213
pub fn sysroot_codegen_backends(&self, compiler: Compiler) -> PathBuf {
1214-
self.sysroot_libdir(compiler, compiler.host).with_file_name("codegen-backends")
1214+
self.sysroot_target_libdir(compiler, compiler.host).with_file_name("codegen-backends")
12151215
}
12161216

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

0 commit comments

Comments
 (0)