Skip to content

Commit 7627a54

Browse files
committed
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`.
1 parent 98dcbae commit 7627a54

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
@@ -93,8 +93,8 @@ impl Step for Std {
9393
// We skip populating the sysroot in non-zero stage because that'll lead
9494
// to rlib/rmeta conflicts if std gets built during this session.
9595
if compiler.stage == 0 {
96-
let libdir = builder.sysroot_libdir(compiler, target);
97-
let hostdir = builder.sysroot_libdir(compiler, compiler.host);
96+
let libdir = builder.sysroot_target_libdir(compiler, target);
97+
let hostdir = builder.sysroot_target_libdir(compiler, compiler.host);
9898
add_to_sysroot(builder, &libdir, &hostdir, &libstd_stamp(builder, compiler, target));
9999
}
100100
drop(_guard);
@@ -244,8 +244,8 @@ impl Step for Rustc {
244244
false,
245245
);
246246

247-
let libdir = builder.sysroot_libdir(compiler, target);
248-
let hostdir = builder.sysroot_libdir(compiler, compiler.host);
247+
let libdir = builder.sysroot_target_libdir(compiler, target);
248+
let hostdir = builder.sysroot_target_libdir(compiler, compiler.host);
249249
add_to_sysroot(builder, &libdir, &hostdir, &librustc_stamp(builder, compiler, target));
250250
}
251251
}

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

+22-14
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ impl Step for Std {
231231
.join("bin");
232232
if src_sysroot_bin.exists() {
233233
let target_sysroot_bin =
234-
builder.sysroot_libdir(compiler, target).parent().unwrap().join("bin");
234+
builder.sysroot_target_libdir(compiler, target).parent().unwrap().join("bin");
235235
t!(fs::create_dir_all(&target_sysroot_bin));
236236
builder.cp_link_r(&src_sysroot_bin, &target_sysroot_bin);
237237
}
@@ -345,7 +345,7 @@ fn copy_third_party_objects(
345345
&& (target.contains("linux") || target.contains("fuchsia"))
346346
{
347347
let libunwind_path =
348-
copy_llvm_libunwind(builder, target, &builder.sysroot_libdir(*compiler, target));
348+
copy_llvm_libunwind(builder, target, &builder.sysroot_target_libdir(*compiler, target));
349349
target_deps.push((libunwind_path, DependencyType::Target));
350350
}
351351

@@ -358,7 +358,8 @@ fn copy_self_contained_objects(
358358
compiler: &Compiler,
359359
target: TargetSelection,
360360
) -> Vec<(PathBuf, DependencyType)> {
361-
let libdir_self_contained = builder.sysroot_libdir(*compiler, target).join("self-contained");
361+
let libdir_self_contained =
362+
builder.sysroot_target_libdir(*compiler, target).join("self-contained");
362363
t!(fs::create_dir_all(&libdir_self_contained));
363364
let mut target_deps = vec![];
364365

@@ -612,8 +613,8 @@ impl Step for StdLink {
612613
let hostdir = sysroot.join(lib).join("rustlib").join(compiler.host.triple).join("lib");
613614
(libdir, hostdir)
614615
} else {
615-
let libdir = builder.sysroot_libdir(target_compiler, target);
616-
let hostdir = builder.sysroot_libdir(target_compiler, compiler.host);
616+
let libdir = builder.sysroot_target_libdir(target_compiler, target);
617+
let hostdir = builder.sysroot_target_libdir(target_compiler, compiler.host);
617618
(libdir, hostdir)
618619
};
619620

@@ -680,7 +681,7 @@ fn copy_sanitizers(
680681
}
681682

682683
let mut target_deps = Vec::new();
683-
let libdir = builder.sysroot_libdir(*compiler, target);
684+
let libdir = builder.sysroot_target_libdir(*compiler, target);
684685

685686
for runtime in &runtimes {
686687
let dst = libdir.join(&runtime.name);
@@ -766,7 +767,7 @@ impl Step for StartupObjects {
766767

767768
let src_dir = &builder.src.join("library").join("rtstartup");
768769
let dst_dir = &builder.native_dir(target).join("rtstartup");
769-
let sysroot_dir = &builder.sysroot_libdir(for_compiler, target);
770+
let sysroot_dir = &builder.sysroot_target_libdir(for_compiler, target);
770771
t!(fs::create_dir_all(dst_dir));
771772

772773
for file in &["rsbegin", "rsend"] {
@@ -1218,10 +1219,17 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect
12181219
}
12191220
}
12201221

1222+
/// `RustcLink` copies all of the rlibs from the rustc build into the previous stage's sysroot.
1223+
/// This is necessary for tools using `rustc_private`, where the previous compiler will build
1224+
/// a tool against the next compiler.
1225+
/// To build a tool against a compiler, the rlibs of that compiler that it links against
1226+
/// must be in the sysroot of the compiler that's doing the compiling.
12211227
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
12221228
struct RustcLink {
1229+
/// The compiler whose rlibs we are copying around.
12231230
pub compiler: Compiler,
1224-
pub target_compiler: Compiler,
1231+
/// This is the compiler into whose sysroot we want to copy the rlibs into.
1232+
pub previous_stage_compiler: Compiler,
12251233
pub target: TargetSelection,
12261234
/// Not actually used; only present to make sure the cache invalidation is correct.
12271235
crates: Vec<String>,
@@ -1231,7 +1239,7 @@ impl RustcLink {
12311239
fn from_rustc(rustc: Rustc, host_compiler: Compiler) -> Self {
12321240
Self {
12331241
compiler: host_compiler,
1234-
target_compiler: rustc.compiler,
1242+
previous_stage_compiler: rustc.compiler,
12351243
target: rustc.target,
12361244
crates: rustc.crates,
12371245
}
@@ -1248,12 +1256,12 @@ impl Step for RustcLink {
12481256
/// Same as `std_link`, only for librustc
12491257
fn run(self, builder: &Builder<'_>) {
12501258
let compiler = self.compiler;
1251-
let target_compiler = self.target_compiler;
1259+
let previous_stage_compiler = self.previous_stage_compiler;
12521260
let target = self.target;
12531261
add_to_sysroot(
12541262
builder,
1255-
&builder.sysroot_libdir(target_compiler, target),
1256-
&builder.sysroot_libdir(target_compiler, compiler.host),
1263+
&builder.sysroot_target_libdir(previous_stage_compiler, target),
1264+
&builder.sysroot_target_libdir(previous_stage_compiler, compiler.host),
12571265
&librustc_stamp(builder, compiler, target),
12581266
);
12591267
}
@@ -1797,7 +1805,7 @@ impl Step for Assemble {
17971805
let sysroot = builder.sysroot(target_compiler);
17981806
let rustc_libdir = builder.rustc_libdir(target_compiler);
17991807
t!(fs::create_dir_all(&rustc_libdir));
1800-
let src_libdir = builder.sysroot_libdir(build_compiler, host);
1808+
let src_libdir = builder.sysroot_target_libdir(build_compiler, host);
18011809
for f in builder.read_dir(&src_libdir) {
18021810
let filename = f.file_name().into_string().unwrap();
18031811
if (is_dylib(&filename) || is_debug_info(&filename)) && !proc_macros.contains(&filename)
@@ -1810,7 +1818,7 @@ impl Step for Assemble {
18101818

18111819
// We prepend this bin directory to the user PATH when linking Rust binaries. To
18121820
// avoid shadowing the system LLD we rename the LLD we provide to `rust-lld`.
1813-
let libdir = builder.sysroot_libdir(target_compiler, target_compiler.host);
1821+
let libdir = builder.sysroot_target_libdir(target_compiler, target_compiler.host);
18141822
let libdir_bin = libdir.parent().unwrap().join("bin");
18151823
t!(fs::create_dir_all(&libdir_bin));
18161824
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
@@ -458,7 +458,8 @@ impl Step for Rustc {
458458

459459
// Copy over lld if it's there
460460
if builder.config.lld_enabled {
461-
let src_dir = builder.sysroot_libdir(compiler, host).parent().unwrap().join("bin");
461+
let src_dir =
462+
builder.sysroot_target_libdir(compiler, host).parent().unwrap().join("bin");
462463
let rust_lld = exe("rust-lld", compiler.host);
463464
builder.copy_link(&src_dir.join(&rust_lld), &dst_dir.join(&rust_lld));
464465
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
@@ -802,7 +802,7 @@ impl Step for RustdocTheme {
802802
.arg(builder.src.join("src/librustdoc/html/static/css/rustdoc.css").to_str().unwrap())
803803
.env("RUSTC_STAGE", self.compiler.stage.to_string())
804804
.env("RUSTC_SYSROOT", builder.sysroot(self.compiler))
805-
.env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host))
805+
.env("RUSTDOC_LIBDIR", builder.sysroot_target_libdir(self.compiler, self.compiler.host))
806806
.env("CFG_RELEASE_CHANNEL", &builder.config.channel)
807807
.env("RUSTDOC_REAL", builder.rustdoc(self.compiler))
808808
.env("RUSTC_BOOTSTRAP", "1");
@@ -1686,7 +1686,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
16861686
// of them!
16871687

16881688
cmd.arg("--compile-lib-path").arg(builder.rustc_libdir(compiler));
1689-
cmd.arg("--run-lib-path").arg(builder.sysroot_libdir(compiler, target));
1689+
cmd.arg("--run-lib-path").arg(builder.sysroot_target_libdir(compiler, target));
16901690
cmd.arg("--rustc-path").arg(builder.rustc(compiler));
16911691

16921692
let is_rustdoc = suite.ends_with("rustdoc-ui") || suite.ends_with("rustdoc-js");
@@ -2512,7 +2512,7 @@ fn prepare_cargo_test(
25122512
// by `Cargo::new` and that actually makes things go wrong.
25132513
if builder.kind != Kind::Miri {
25142514
let mut dylib_path = dylib_path();
2515-
dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target)));
2515+
dylib_path.insert(0, PathBuf::from(&*builder.sysroot_target_libdir(compiler, target)));
25162516
cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
25172517
}
25182518

@@ -2754,7 +2754,7 @@ impl Step for CrateRustdoc {
27542754
let libdir = if builder.download_rustc() {
27552755
builder.rustc_libdir(compiler)
27562756
} else {
2757-
builder.sysroot_libdir(compiler, target).to_path_buf()
2757+
builder.sysroot_target_libdir(compiler, target).to_path_buf()
27582758
};
27592759
let mut dylib_path = dylib_path();
27602760
dylib_path.insert(0, PathBuf::from(&*libdir));
@@ -2879,7 +2879,7 @@ impl Step for RemoteCopyLibs {
28792879
cmd.run(builder);
28802880

28812881
// Push all our dylibs to the emulator
2882-
for f in t!(builder.sysroot_libdir(compiler, target).read_dir()) {
2882+
for f in t!(builder.sysroot_target_libdir(compiler, target).read_dir()) {
28832883
let f = t!(f);
28842884
let name = f.file_name().into_string().unwrap();
28852885
if helpers::is_dylib(&name) {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ impl ErrorIndex {
440440
let compiler = builder.compiler_for(builder.top_stage, host, host);
441441
let mut cmd = command(builder.ensure(ErrorIndex { compiler }));
442442
let mut dylib_paths = builder.rustc_lib_paths(compiler);
443-
dylib_paths.push(PathBuf::from(&builder.sysroot_libdir(compiler, compiler.host)));
443+
dylib_paths.push(PathBuf::from(&builder.sysroot_target_libdir(compiler, compiler.host)));
444444
add_dylib_path(dylib_paths, &mut cmd);
445445
cmd
446446
}

src/bootstrap/src/core/builder.rs

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

11071107
/// Returns the libdir where the standard library and other artifacts are
11081108
/// found for a compiler's sysroot.
1109-
pub fn sysroot_libdir(&self, compiler: Compiler, target: TargetSelection) -> PathBuf {
1109+
pub fn sysroot_target_libdir(&self, compiler: Compiler, target: TargetSelection) -> PathBuf {
11101110
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
11111111
struct Libdir {
11121112
compiler: Compiler,
@@ -1154,7 +1154,7 @@ impl<'a> Builder<'a> {
11541154
}
11551155

11561156
pub fn sysroot_codegen_backends(&self, compiler: Compiler) -> PathBuf {
1157-
self.sysroot_libdir(compiler, compiler.host).with_file_name("codegen-backends")
1157+
self.sysroot_target_libdir(compiler, compiler.host).with_file_name("codegen-backends")
11581158
}
11591159

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

0 commit comments

Comments
 (0)