Skip to content

Commit 1f32908

Browse files
committed
refactor: remove unused sysroot_host_libdir
Copy from <#10469 (comment)>: > I've never been entirely clear why it does this. #4006 didn't really > explain why it added the corresponding host_dylib_path. I can't envision > a scenario where it matters. I think compiler plugins and proc-macros > should load just fine, since libstd.so should already be loaded by the > compiler. Also, rustc uses rpath these days, and on Windows libstd.so is > placed in the bin directory which will be searched first anyways. > > On balance, I think it should be safe to just remove sysroot_host_libdir. > I can't come up with a scenario where it matters, at least on > windows/macos/linux. One issue is that this is most likely to affect > plugins, but those are deprecated and I think only Servo was the real > holdout. A concern is that nobody is going to test this use case before > it hits stable. Also, * compiler plugins were removed rust-lang/rust#116412 * servo has moved off from plugins: servo/servo#30508 So should generally be fine.
1 parent 762c7d8 commit 1f32908

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

Diff for: src/cargo/core/compiler/build_context/target_info.rs

+10-16
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ pub struct TargetInfo {
4848
support_split_debuginfo: Vec<String>,
4949
/// Path to the sysroot.
5050
pub sysroot: PathBuf,
51-
/// Path to the "lib" or "bin" directory that rustc uses for its dynamic
52-
/// libraries.
53-
pub sysroot_host_libdir: PathBuf,
5451
/// Path to the "lib" directory in the sysroot which rustc uses for linking
5552
/// target libraries.
5653
pub sysroot_target_libdir: PathBuf,
@@ -224,19 +221,17 @@ impl TargetInfo {
224221
return error_missing_print_output("sysroot", &process, &output, &error);
225222
};
226223
let sysroot = PathBuf::from(line);
227-
let sysroot_host_libdir = if cfg!(windows) {
228-
sysroot.join("bin")
229-
} else {
230-
sysroot.join("lib")
224+
let sysroot_target_libdir = {
225+
let mut libdir = sysroot.clone();
226+
libdir.push("lib");
227+
libdir.push("rustlib");
228+
libdir.push(match &kind {
229+
CompileKind::Host => rustc.host.as_str(),
230+
CompileKind::Target(target) => target.short_name(),
231+
});
232+
libdir.push("lib");
233+
libdir
231234
};
232-
let mut sysroot_target_libdir = sysroot.clone();
233-
sysroot_target_libdir.push("lib");
234-
sysroot_target_libdir.push("rustlib");
235-
sysroot_target_libdir.push(match &kind {
236-
CompileKind::Host => rustc.host.as_str(),
237-
CompileKind::Target(target) => target.short_name(),
238-
});
239-
sysroot_target_libdir.push("lib");
240235

241236
let support_split_debuginfo = {
242237
// HACK: abuse `--print=crate-name` to use `___` as a delimiter.
@@ -303,7 +298,6 @@ impl TargetInfo {
303298
crate_type_process,
304299
crate_types: RefCell::new(map),
305300
sysroot,
306-
sysroot_host_libdir,
307301
sysroot_target_libdir,
308302
rustflags,
309303
rustdocflags: extra_args(

Diff for: src/cargo/core/compiler/compilation.rs

-9
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ pub struct Compilation<'gctx> {
7474
/// May be for the host or for a specific target.
7575
pub deps_output: HashMap<CompileKind, PathBuf>,
7676

77-
/// The path to the host libdir for the compiler used
78-
sysroot_host_libdir: PathBuf,
79-
8077
/// The path to libstd for each target
8178
sysroot_target_libdir: HashMap<CompileKind, PathBuf>,
8279

@@ -128,11 +125,6 @@ impl<'gctx> Compilation<'gctx> {
128125
native_dirs: BTreeSet::new(),
129126
root_output: HashMap::new(),
130127
deps_output: HashMap::new(),
131-
sysroot_host_libdir: bcx
132-
.target_data
133-
.info(CompileKind::Host)
134-
.sysroot_host_libdir
135-
.clone(),
136128
sysroot_target_libdir: get_sysroot_target_libdir(bcx)?,
137129
tests: Vec::new(),
138130
binaries: Vec::new(),
@@ -282,7 +274,6 @@ impl<'gctx> Compilation<'gctx> {
282274
let mut search_path = Vec::new();
283275
if is_rustc_tool {
284276
search_path.push(self.deps_output[&CompileKind::Host].clone());
285-
search_path.push(self.sysroot_host_libdir.clone());
286277
} else {
287278
search_path.extend(super::filter_dynamic_search_path(
288279
self.native_dirs.iter(),

0 commit comments

Comments
 (0)