Skip to content

Commit

Permalink
Add llvm.build-config option
Browse files Browse the repository at this point in the history
  • Loading branch information
tmandry authored and catap committed Jul 17, 2022
1 parent 59461f5 commit 1942ef4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ changelog-seen = 2
# Whether to include the Polly optimizer.
#polly = false

# Custom CMake defines to set when building LLVM.
#build-config = {}

# =============================================================================
# General build configuration options
# =============================================================================
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ pub struct Config {
pub llvm_allow_old_toolchain: bool,
pub llvm_polly: bool,
pub llvm_from_ci: bool,
pub llvm_build_config: HashMap<String, String>,

pub use_lld: bool,
pub lld_enabled: bool,
Expand Down Expand Up @@ -432,6 +433,7 @@ struct Llvm {
allow_old_toolchain: Option<bool>,
polly: Option<bool>,
download_ci_llvm: Option<StringOrBool>,
build_config: Option<HashMap<String, String>>,
}

#[derive(Deserialize, Default, Clone, Merge)]
Expand Down Expand Up @@ -743,6 +745,7 @@ impl Config {
config.llvm_use_linker = llvm.use_linker.clone();
config.llvm_allow_old_toolchain = llvm.allow_old_toolchain.unwrap_or(false);
config.llvm_polly = llvm.polly.unwrap_or(false);
config.llvm_build_config = llvm.build_config.clone().unwrap_or(Default::default());
config.llvm_from_ci = match llvm.download_ci_llvm {
Some(StringOrBool::String(s)) => {
assert!(s == "if-available", "unknown option `{}` for download-ci-llvm", s);
Expand Down Expand Up @@ -789,6 +792,7 @@ impl Config {
check_ci_llvm!(llvm.use_linker);
check_ci_llvm!(llvm.allow_old_toolchain);
check_ci_llvm!(llvm.polly);
check_ci_llvm!(llvm.build_config);

// CI-built LLVM can be either dynamic or static.
let ci_llvm = config.out.join(&*config.build.triple).join("ci-llvm");
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ impl Step for Llvm {

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

for (key, val) in &builder.config.llvm_build_config {
cfg.define(key, val);
}

// FIXME: we don't actually need to build all LLVM tools and all LLVM
// libraries here, e.g., we just want a few components and a few
// tools. Figure out how to filter them down and only build the right
Expand Down

0 comments on commit 1942ef4

Please sign in to comment.