Skip to content

Commit 8b65e00

Browse files
authored
Unrolled build for rust-lang#134913
Rollup merge of rust-lang#134913 - rhelmot:master, r=jieyouxu bootstrap: do not rely on LIBRARY_PATH env variable Closes rust-lang#134811 try-job: test-various try-job: armhf-gnu try-job: x86_64-apple-1 try-job: x86_64-apple-2 try-job: aarch64-apple try-job: x86_64-msvc try-job: i686-msvc try-job: x86_64-mingw-1 try-job: x86_64-mingw-2 try-job: i686-mingw
2 parents 93ba568 + 7f743c7 commit 8b65e00

File tree

3 files changed

+17
-34
lines changed

3 files changed

+17
-34
lines changed

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

+10-4
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ use crate::core::config::flags::{Subcommand, get_completion};
2424
use crate::utils::build_stamp::{self, BuildStamp};
2525
use crate::utils::exec::{BootstrapCommand, command};
2626
use crate::utils::helpers::{
27-
self, LldThreads, add_link_lib_path, add_rustdoc_cargo_linker_args, dylib_path, dylib_path_var,
28-
linker_args, linker_flags, t, target_supports_cranelift_backend, up_to_date,
27+
self, LldThreads, add_rustdoc_cargo_linker_args, dylib_path, dylib_path_var, linker_args,
28+
linker_flags, t, target_supports_cranelift_backend, up_to_date,
2929
};
3030
use crate::utils::render_tests::{add_flags_and_try_run_tests, try_run_tests};
3131
use crate::{CLang, DocTests, GitRepo, Mode, PathSet, envify};
@@ -1975,11 +1975,17 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
19751975
// Tests that use compiler libraries may inherit the `-lLLVM` link
19761976
// requirement, but the `-L` library path is not propagated across
19771977
// separate compilations. We can add LLVM's library path to the
1978-
// platform-specific environment variable as a workaround.
1978+
// rustc args as a workaround.
19791979
if !builder.config.dry_run() && suite.ends_with("fulldeps") {
19801980
let llvm_libdir =
19811981
command(&llvm_config).arg("--libdir").run_capture_stdout(builder).stdout();
1982-
add_link_lib_path(vec![llvm_libdir.trim().into()], &mut cmd);
1982+
let mut rustflags = env::var("RUSTFLAGS").unwrap_or_default();
1983+
if target.is_msvc() {
1984+
rustflags.push_str(&format!("-Clink-arg=-LIBPATH:{llvm_libdir}"));
1985+
} else {
1986+
rustflags.push_str(&format!("-Clink-arg=-L{llvm_libdir}"));
1987+
}
1988+
cmd.env("RUSTFLAGS", rustflags);
19831989
}
19841990

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

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

+7-5
Original file line numberDiff line numberDiff line change
@@ -8,9 +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::build_stamp;
11-
use crate::utils::helpers::{
12-
self, LldThreads, add_link_lib_path, check_cfg_arg, linker_args, linker_flags,
13-
};
11+
use crate::utils::helpers::{self, LldThreads, check_cfg_arg, linker_args, linker_flags};
1412
use crate::{
1513
BootstrapCommand, CLang, Compiler, DocTests, DryRun, EXTRA_CHECK_CFGS, GitRepo, Mode,
1614
TargetSelection, command, prepare_behaviour_dump_dir, t,
@@ -947,12 +945,16 @@ impl Builder<'_> {
947945
// Tools that use compiler libraries may inherit the `-lLLVM` link
948946
// requirement, but the `-L` library path is not propagated across
949947
// separate Cargo projects. We can add LLVM's library path to the
950-
// platform-specific environment variable as a workaround.
948+
// rustc args as a workaround.
951949
if mode == Mode::ToolRustc || mode == Mode::Codegen {
952950
if let Some(llvm_config) = self.llvm_config(target) {
953951
let llvm_libdir =
954952
command(llvm_config).arg("--libdir").run_capture_stdout(self).stdout();
955-
add_link_lib_path(vec![llvm_libdir.trim().into()], &mut cargo);
953+
if target.is_msvc() {
954+
rustflags.arg(&format!("-Clink-arg=-LIBPATH:{llvm_libdir}"));
955+
} else {
956+
rustflags.arg(&format!("-Clink-arg=-L{llvm_libdir}"));
957+
}
956958
}
957959
}
958960

src/bootstrap/src/utils/helpers.rs

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

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

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

0 commit comments

Comments
 (0)