Skip to content

Commit 584948d

Browse files
authored
Rollup merge of #93756 - tmandry:llvm-build-config, r=Mark-Simulacrum
Support custom options for LLVM build The LLVM build has a lot of options that rustbuild doesn't need to know about. We should allow the user to customize the LLVM build directly. Here are some [example customizations][recipe] we'd like to do. [recipe]: https://fuchsia.googlesource.com/infra/recipes/+/90105e5e4e37b0441c8dde538df54a55f79b3d22/recipes/contrib/clang_toolchain.py#579
2 parents 03332b0 + 69cd826 commit 584948d

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

config.toml.example

+3
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ changelog-seen = 2
157157
# Whether to build the clang compiler.
158158
#clang = false
159159

160+
# Custom CMake defines to set when building LLVM.
161+
#build-config = {}
162+
160163
# =============================================================================
161164
# General build configuration options
162165
# =============================================================================

src/bootstrap/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ pub struct Config {
108108
pub llvm_polly: bool,
109109
pub llvm_clang: bool,
110110
pub llvm_from_ci: bool,
111+
pub llvm_build_config: HashMap<String, String>,
111112

112113
pub use_lld: bool,
113114
pub lld_enabled: bool,
@@ -477,6 +478,7 @@ derive_merge! {
477478
polly: Option<bool>,
478479
clang: Option<bool>,
479480
download_ci_llvm: Option<StringOrBool>,
481+
build_config: Option<HashMap<String, String>>,
480482
}
481483
}
482484

@@ -807,6 +809,7 @@ impl Config {
807809
config.llvm_allow_old_toolchain = llvm.allow_old_toolchain.unwrap_or(false);
808810
config.llvm_polly = llvm.polly.unwrap_or(false);
809811
config.llvm_clang = llvm.clang.unwrap_or(false);
812+
config.llvm_build_config = llvm.build_config.clone().unwrap_or(Default::default());
810813
config.llvm_from_ci = match llvm.download_ci_llvm {
811814
Some(StringOrBool::String(s)) => {
812815
assert!(s == "if-available", "unknown option `{}` for download-ci-llvm", s);
@@ -876,6 +879,7 @@ impl Config {
876879
check_ci_llvm!(llvm.allow_old_toolchain);
877880
check_ci_llvm!(llvm.polly);
878881
check_ci_llvm!(llvm.clang);
882+
check_ci_llvm!(llvm.build_config);
879883
check_ci_llvm!(llvm.plugins);
880884

881885
// CI-built LLVM can be either dynamic or static.

src/bootstrap/native.rs

+4
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,10 @@ impl Step for Llvm {
353353

354354
configure_cmake(builder, target, &mut cfg, true);
355355

356+
for (key, val) in &builder.config.llvm_build_config {
357+
cfg.define(key, val);
358+
}
359+
356360
// FIXME: we don't actually need to build all LLVM tools and all LLVM
357361
// libraries here, e.g., we just want a few components and a few
358362
// tools. Figure out how to filter them down and only build the right

0 commit comments

Comments
 (0)