Skip to content

Commit 5a4a250

Browse files
Kobzolcuviper
authored andcommitted
Rename llvm_config to host_llvm_config to avoid confusion
(cherry picked from commit 7785efd)
1 parent 40c7fe3 commit 5a4a250

File tree

6 files changed

+39
-36
lines changed

6 files changed

+39
-36
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,8 +1416,8 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect
14161416
if builder.config.llvm_enzyme {
14171417
cargo.env("LLVM_ENZYME", "1");
14181418
}
1419-
let llvm::LlvmResult { llvm_config, .. } = builder.ensure(llvm::Llvm { target });
1420-
cargo.env("LLVM_CONFIG", &llvm_config);
1419+
let llvm::LlvmResult { host_llvm_config, .. } = builder.ensure(llvm::Llvm { target });
1420+
cargo.env("LLVM_CONFIG", &host_llvm_config);
14211421

14221422
// Some LLVM linker flags (-L and -l) may be needed to link `rustc_llvm`. Its build script
14231423
// expects these to be passed via the `LLVM_LINKER_FLAGS` env variable, separated by
@@ -2012,13 +2012,13 @@ impl Step for Assemble {
20122012
if builder.config.llvm_enabled(target_compiler.host) {
20132013
trace!("target_compiler.host" = ?target_compiler.host, "LLVM enabled");
20142014

2015-
let llvm::LlvmResult { llvm_config, .. } =
2015+
let llvm::LlvmResult { host_llvm_config, .. } =
20162016
builder.ensure(llvm::Llvm { target: target_compiler.host });
20172017
if !builder.config.dry_run() && builder.config.llvm_tools_enabled {
20182018
trace!("LLVM tools enabled");
20192019

20202020
let llvm_bin_dir =
2021-
command(llvm_config).arg("--bindir").run_capture_stdout(builder).stdout();
2021+
command(host_llvm_config).arg("--bindir").run_capture_stdout(builder).stdout();
20222022
let llvm_bin_dir = Path::new(llvm_bin_dir.trim());
20232023

20242024
// Since we've already built the LLVM tools, install them to the sysroot.

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2176,11 +2176,12 @@ fn maybe_install_llvm(
21762176
builder.install(&llvm_dylib_path, dst_libdir, FileType::NativeLibrary);
21772177
}
21782178
!builder.config.dry_run()
2179-
} else if let llvm::LlvmBuildStatus::AlreadyBuilt(llvm::LlvmResult { llvm_config, .. }) =
2180-
llvm::prebuilt_llvm_config(builder, target, true)
2179+
} else if let llvm::LlvmBuildStatus::AlreadyBuilt(llvm::LlvmResult {
2180+
host_llvm_config, ..
2181+
}) = llvm::prebuilt_llvm_config(builder, target, true)
21812182
{
21822183
trace!("LLVM already built, installing LLVM files");
2183-
let mut cmd = command(llvm_config);
2184+
let mut cmd = command(host_llvm_config);
21842185
cmd.arg("--libfiles");
21852186
builder.verbose(|| println!("running {cmd:?}"));
21862187
let files = cmd.run_capture_stdout(builder).stdout();

src/bootstrap/src/core/build_steps/llvm.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::{CLang, GitRepo, Kind, trace};
3131
pub struct LlvmResult {
3232
/// Path to llvm-config binary.
3333
/// NB: This is always the host llvm-config!
34-
pub llvm_config: PathBuf,
34+
pub host_llvm_config: PathBuf,
3535
/// Path to LLVM cmake directory for the target.
3636
pub llvm_cmake_dir: PathBuf,
3737
}
@@ -111,14 +111,14 @@ pub fn prebuilt_llvm_config(
111111
&& let Some(ref s) = config.llvm_config
112112
{
113113
check_llvm_version(builder, s);
114-
let llvm_config = s.to_path_buf();
115-
let mut llvm_cmake_dir = llvm_config.clone();
114+
let host_llvm_config = s.to_path_buf();
115+
let mut llvm_cmake_dir = host_llvm_config.clone();
116116
llvm_cmake_dir.pop();
117117
llvm_cmake_dir.pop();
118118
llvm_cmake_dir.push("lib");
119119
llvm_cmake_dir.push("cmake");
120120
llvm_cmake_dir.push("llvm");
121-
return LlvmBuildStatus::AlreadyBuilt(LlvmResult { llvm_config, llvm_cmake_dir });
121+
return LlvmBuildStatus::AlreadyBuilt(LlvmResult { host_llvm_config, llvm_cmake_dir });
122122
}
123123

124124
if handle_submodule_when_needed {
@@ -143,7 +143,7 @@ pub fn prebuilt_llvm_config(
143143
};
144144

145145
let llvm_cmake_dir = out_dir.join("lib/cmake/llvm");
146-
let res = LlvmResult { llvm_config: build_llvm_config, llvm_cmake_dir };
146+
let res = LlvmResult { host_llvm_config: build_llvm_config, llvm_cmake_dir };
147147

148148
static STAMP_HASH_MEMO: OnceLock<String> = OnceLock::new();
149149
let smart_stamp_hash = STAMP_HASH_MEMO.get_or_init(|| {
@@ -488,11 +488,11 @@ impl Step for Llvm {
488488

489489
// https://llvm.org/docs/HowToCrossCompileLLVM.html
490490
if !builder.config.is_host_target(target) {
491-
let LlvmResult { llvm_config, .. } =
491+
let LlvmResult { host_llvm_config, .. } =
492492
builder.ensure(Llvm { target: builder.config.host_target });
493493
if !builder.config.dry_run() {
494494
let llvm_bindir =
495-
command(&llvm_config).arg("--bindir").run_capture_stdout(builder).stdout();
495+
command(&host_llvm_config).arg("--bindir").run_capture_stdout(builder).stdout();
496496
let host_bin = Path::new(llvm_bindir.trim());
497497
cfg.define(
498498
"LLVM_TABLEGEN",
@@ -501,7 +501,7 @@ impl Step for Llvm {
501501
// LLVM_NM is required for cross compiling using MSVC
502502
cfg.define("LLVM_NM", host_bin.join("llvm-nm").with_extension(EXE_EXTENSION));
503503
}
504-
cfg.define("LLVM_CONFIG_PATH", llvm_config);
504+
cfg.define("LLVM_CONFIG_PATH", host_llvm_config);
505505
if builder.config.llvm_clang {
506506
let build_bin =
507507
builder.llvm_out(builder.config.host_target).join("build").join("bin");
@@ -543,7 +543,7 @@ impl Step for Llvm {
543543

544544
// Helper to find the name of LLVM's shared library on darwin and linux.
545545
let find_llvm_lib_name = |extension| {
546-
let major = get_llvm_version_major(builder, &res.llvm_config);
546+
let major = get_llvm_version_major(builder, &res.host_llvm_config);
547547
match &llvm_version_suffix {
548548
Some(version_suffix) => format!("libLLVM-{major}{version_suffix}.{extension}"),
549549
None => format!("libLLVM-{major}.{extension}"),
@@ -929,7 +929,7 @@ impl Step for Enzyme {
929929
}
930930
let target = self.target;
931931

932-
let LlvmResult { llvm_config, .. } = builder.ensure(Llvm { target: self.target });
932+
let LlvmResult { host_llvm_config, .. } = builder.ensure(Llvm { target: self.target });
933933

934934
static STAMP_HASH_MEMO: OnceLock<String> = OnceLock::new();
935935
let smart_stamp_hash = STAMP_HASH_MEMO.get_or_init(|| {
@@ -983,7 +983,7 @@ impl Step for Enzyme {
983983

984984
cfg.out_dir(&out_dir)
985985
.profile(profile)
986-
.env("LLVM_CONFIG_REAL", &llvm_config)
986+
.env("LLVM_CONFIG_REAL", &host_llvm_config)
987987
.define("LLVM_ENABLE_ASSERTIONS", "ON")
988988
.define("ENZYME_EXTERNAL_SHARED_LIB", "ON")
989989
.define("LLVM_DIR", builder.llvm_out(target));
@@ -1019,13 +1019,13 @@ impl Step for Lld {
10191019
}
10201020
let target = self.target;
10211021

1022-
let LlvmResult { llvm_config, llvm_cmake_dir } = builder.ensure(Llvm { target });
1022+
let LlvmResult { host_llvm_config, llvm_cmake_dir } = builder.ensure(Llvm { target });
10231023

10241024
// The `dist` step packages LLD next to LLVM's binaries for download-ci-llvm. The root path
10251025
// we usually expect here is `./build/$triple/ci-llvm/`, with the binaries in its `bin`
10261026
// subfolder. We check if that's the case, and if LLD's binary already exists there next to
10271027
// `llvm-config`: if so, we can use it instead of building LLVM/LLD from source.
1028-
let ci_llvm_bin = llvm_config.parent().unwrap();
1028+
let ci_llvm_bin = host_llvm_config.parent().unwrap();
10291029
if ci_llvm_bin.is_dir() && ci_llvm_bin.file_name().unwrap() == "bin" {
10301030
let lld_path = ci_llvm_bin.join(exe("lld", target));
10311031
if lld_path.exists() {
@@ -1108,7 +1108,7 @@ impl Step for Lld {
11081108
// Use the host llvm-tblgen binary.
11091109
cfg.define(
11101110
"LLVM_TABLEGEN_EXE",
1111-
llvm_config.with_file_name("llvm-tblgen").with_extension(EXE_EXTENSION),
1111+
host_llvm_config.with_file_name("llvm-tblgen").with_extension(EXE_EXTENSION),
11121112
);
11131113
}
11141114

@@ -1149,7 +1149,7 @@ impl Step for Sanitizers {
11491149
return runtimes;
11501150
}
11511151

1152-
let LlvmResult { llvm_config, .. } =
1152+
let LlvmResult { host_llvm_config, .. } =
11531153
builder.ensure(Llvm { target: builder.config.host_target });
11541154

11551155
static STAMP_HASH_MEMO: OnceLock<String> = OnceLock::new();
@@ -1189,7 +1189,7 @@ impl Step for Sanitizers {
11891189
cfg.define("COMPILER_RT_BUILD_XRAY", "OFF");
11901190
cfg.define("COMPILER_RT_DEFAULT_TARGET_ONLY", "ON");
11911191
cfg.define("COMPILER_RT_USE_LIBCXX", "OFF");
1192-
cfg.define("LLVM_CONFIG_PATH", &llvm_config);
1192+
cfg.define("LLVM_CONFIG_PATH", &host_llvm_config);
11931193

11941194
if self.target.contains("ohos") {
11951195
cfg.define("COMPILER_RT_USE_BUILTINS_LIBRARY", "ON");

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,12 +1976,14 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
19761976
let mut llvm_components_passed = false;
19771977
let mut copts_passed = false;
19781978
if builder.config.llvm_enabled(compiler.host) {
1979-
let llvm::LlvmResult { llvm_config, .. } =
1979+
let llvm::LlvmResult { host_llvm_config, .. } =
19801980
builder.ensure(llvm::Llvm { target: builder.config.host_target });
19811981
if !builder.config.dry_run() {
1982-
let llvm_version = get_llvm_version(builder, &llvm_config);
1983-
let llvm_components =
1984-
command(&llvm_config).arg("--components").run_capture_stdout(builder).stdout();
1982+
let llvm_version = get_llvm_version(builder, &host_llvm_config);
1983+
let llvm_components = command(&host_llvm_config)
1984+
.arg("--components")
1985+
.run_capture_stdout(builder)
1986+
.stdout();
19851987
// Remove trailing newline from llvm-config output.
19861988
cmd.arg("--llvm-version")
19871989
.arg(llvm_version.trim())
@@ -1999,7 +2001,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
19992001
// rustc args as a workaround.
20002002
if !builder.config.dry_run() && suite.ends_with("fulldeps") {
20012003
let llvm_libdir =
2002-
command(&llvm_config).arg("--libdir").run_capture_stdout(builder).stdout();
2004+
command(&host_llvm_config).arg("--libdir").run_capture_stdout(builder).stdout();
20032005
let link_llvm = if target.is_msvc() {
20042006
format!("-Clink-arg=-LIBPATH:{llvm_libdir}")
20052007
} else {
@@ -2013,7 +2015,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
20132015
// tools. Pass the path to run-make tests so they can use them.
20142016
// (The coverage-run tests also need these tools to process
20152017
// coverage reports.)
2016-
let llvm_bin_path = llvm_config
2018+
let llvm_bin_path = host_llvm_config
20172019
.parent()
20182020
.expect("Expected llvm-config to be contained in directory");
20192021
assert!(llvm_bin_path.is_dir());

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,9 +1615,9 @@ You have to build a stage1 compiler for `{}` first, and then use it to build a s
16151615
/// check build or dry-run, where there's no need to build all of LLVM.
16161616
pub fn llvm_config(&self, target: TargetSelection) -> Option<PathBuf> {
16171617
if self.config.llvm_enabled(target) && self.kind != Kind::Check && !self.config.dry_run() {
1618-
let llvm::LlvmResult { llvm_config, .. } = self.ensure(llvm::Llvm { target });
1619-
if llvm_config.is_file() {
1620-
return Some(llvm_config);
1618+
let llvm::LlvmResult { host_llvm_config, .. } = self.ensure(llvm::Llvm { target });
1619+
if host_llvm_config.is_file() {
1620+
return Some(host_llvm_config);
16211621
}
16221622
}
16231623
None

src/bootstrap/src/core/builder/tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,14 +494,14 @@ fn test_prebuilt_llvm_config_path_resolution() {
494494
false,
495495
)
496496
.llvm_result()
497-
.llvm_config
497+
.host_llvm_config
498498
.clone();
499499
let actual = drop_win_disk_prefix_if_present(actual);
500500
assert_eq!(expected, actual);
501501

502502
let actual = prebuilt_llvm_config(&builder, builder.config.host_target, false)
503503
.llvm_result()
504-
.llvm_config
504+
.host_llvm_config
505505
.clone();
506506
let actual = drop_win_disk_prefix_if_present(actual);
507507
assert_eq!(expected, actual);
@@ -519,7 +519,7 @@ fn test_prebuilt_llvm_config_path_resolution() {
519519

520520
let actual = prebuilt_llvm_config(&builder, builder.config.host_target, false)
521521
.llvm_result()
522-
.llvm_config
522+
.host_llvm_config
523523
.clone();
524524
let expected = builder
525525
.out
@@ -542,7 +542,7 @@ fn test_prebuilt_llvm_config_path_resolution() {
542542

543543
let actual = prebuilt_llvm_config(&builder, builder.config.host_target, false)
544544
.llvm_result()
545-
.llvm_config
545+
.host_llvm_config
546546
.clone();
547547
let expected = builder
548548
.out

0 commit comments

Comments
 (0)