Skip to content

Commit e15452f

Browse files
committed
bootstrap: do not rely on LIBRARY_PATH env variable
Clang will not respect this value in cross configurations.
1 parent 8cdc67e commit e15452f

File tree

3 files changed

+4
-29
lines changed

3 files changed

+4
-29
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::core::config::TargetSelection;
2323
use crate::core::config::flags::{Subcommand, get_completion};
2424
use crate::utils::exec::{BootstrapCommand, command};
2525
use crate::utils::helpers::{
26-
self, LldThreads, add_link_lib_path, add_rustdoc_cargo_linker_args, dylib_path, dylib_path_var,
26+
self, LldThreads, add_rustdoc_cargo_linker_args, dylib_path, dylib_path_var,
2727
linker_args, linker_flags, t, target_supports_cranelift_backend, up_to_date,
2828
};
2929
use crate::utils::render_tests::{add_flags_and_try_run_tests, try_run_tests};
@@ -2010,7 +2010,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
20102010
if !builder.config.dry_run() && suite.ends_with("fulldeps") {
20112011
let llvm_libdir =
20122012
command(&llvm_config).arg("--libdir").run_capture_stdout(builder).stdout();
2013-
add_link_lib_path(vec![llvm_libdir.trim().into()], &mut cmd);
2013+
cmd.arg(&format!("-Clink-arg=-L{llvm_libdir}"));
20142014
}
20152015

20162016
if !builder.config.dry_run() && matches!(mode, "run-make" | "coverage-run") {

src/bootstrap/src/core/builder/cargo.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::core::build_steps::{compile, test};
88
use crate::core::config::SplitDebuginfo;
99
use crate::core::config::flags::Color;
1010
use crate::utils::helpers::{
11-
self, LldThreads, add_link_lib_path, check_cfg_arg, linker_args, linker_flags,
11+
self, LldThreads, check_cfg_arg, linker_args, linker_flags,
1212
};
1313
use crate::{
1414
BootstrapCommand, CLang, Compiler, DocTests, DryRun, EXTRA_CHECK_CFGS, GitRepo, Mode,
@@ -951,7 +951,7 @@ impl Builder<'_> {
951951
if let Some(llvm_config) = self.llvm_config(target) {
952952
let llvm_libdir =
953953
command(llvm_config).arg("--libdir").run_capture_stdout(self).stdout();
954-
add_link_lib_path(vec![llvm_libdir.trim().into()], &mut cargo);
954+
rustflags.arg(&format!("-Clink-arg=-L{llvm_libdir}"));
955955
}
956956
}
957957

src/bootstrap/src/utils/helpers.rs

-25
Original file line numberDiff line numberDiff line change
@@ -99,31 +99,6 @@ pub fn add_dylib_path(path: Vec<PathBuf>, cmd: &mut BootstrapCommand) {
9999
cmd.env(dylib_path_var(), t!(env::join_paths(list)));
100100
}
101101

102-
/// Adds a list of lookup paths to `cmd`'s link library lookup path.
103-
pub fn add_link_lib_path(path: Vec<PathBuf>, cmd: &mut BootstrapCommand) {
104-
let mut list = link_lib_path();
105-
for path in path {
106-
list.insert(0, path);
107-
}
108-
cmd.env(link_lib_path_var(), t!(env::join_paths(list)));
109-
}
110-
111-
/// Returns the environment variable which the link library lookup path
112-
/// resides in for this platform.
113-
fn link_lib_path_var() -> &'static str {
114-
if cfg!(target_env = "msvc") { "LIB" } else { "LIBRARY_PATH" }
115-
}
116-
117-
/// Parses the `link_lib_path_var()` environment variable, returning a list of
118-
/// paths that are members of this lookup path.
119-
fn link_lib_path() -> Vec<PathBuf> {
120-
let var = match env::var_os(link_lib_path_var()) {
121-
Some(v) => v,
122-
None => return vec![],
123-
};
124-
env::split_paths(&var).collect()
125-
}
126-
127102
pub struct TimeIt(bool, Instant);
128103

129104
/// Returns an RAII structure that prints out how long it took to drop.

0 commit comments

Comments
 (0)