Skip to content

add two new build flags to build clang and enable llvm plugins #87297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ changelog-seen = 2
# Indicates whether the LLVM assertions are enabled or not
#assertions = false

# Indicates whether the LLVM plugin is enabled or not
#plugins = false

# Indicates whether ccache is used when building LLVM
#ccache = false
# or alternatively ...
Expand Down Expand Up @@ -145,6 +148,9 @@ changelog-seen = 2
# Whether to include the Polly optimizer.
#polly = false

# Whether to build the clang compiler.
#clang = false

# =============================================================================
# General build configuration options
# =============================================================================
Expand Down
10 changes: 10 additions & 0 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ pub struct Config {
// llvm codegen options
pub llvm_skip_rebuild: bool,
pub llvm_assertions: bool,
pub llvm_plugins: bool,
pub llvm_optimize: bool,
pub llvm_thin_lto: bool,
pub llvm_release_debuginfo: bool,
Expand All @@ -104,6 +105,7 @@ pub struct Config {
pub llvm_use_linker: Option<String>,
pub llvm_allow_old_toolchain: bool,
pub llvm_polly: bool,
pub llvm_clang: bool,
pub llvm_from_ci: bool,

pub use_lld: bool,
Expand Down Expand Up @@ -415,6 +417,7 @@ struct Llvm {
thin_lto: Option<bool>,
release_debuginfo: Option<bool>,
assertions: Option<bool>,
plugins: Option<bool>,
ccache: Option<StringOrBool>,
version_check: Option<bool>,
static_libstdcpp: Option<bool>,
Expand All @@ -432,6 +435,7 @@ struct Llvm {
use_linker: Option<String>,
allow_old_toolchain: Option<bool>,
polly: Option<bool>,
clang: Option<bool>,
download_ci_llvm: Option<StringOrBool>,
}

Expand Down Expand Up @@ -702,6 +706,7 @@ impl Config {
// Store off these values as options because if they're not provided
// we'll infer default values for them later
let mut llvm_assertions = None;
let mut llvm_plugins = None;
let mut debug = None;
let mut debug_assertions = None;
let mut debug_assertions_std = None;
Expand All @@ -724,6 +729,7 @@ impl Config {
}
set(&mut config.ninja_in_file, llvm.ninja);
llvm_assertions = llvm.assertions;
llvm_plugins = llvm.plugins;
llvm_skip_rebuild = llvm_skip_rebuild.or(llvm.skip_rebuild);
set(&mut config.llvm_optimize, llvm.optimize);
set(&mut config.llvm_thin_lto, llvm.thin_lto);
Expand All @@ -744,6 +750,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_clang = llvm.clang.unwrap_or(false);
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 @@ -790,6 +797,8 @@ impl Config {
check_ci_llvm!(llvm.use_linker);
check_ci_llvm!(llvm.allow_old_toolchain);
check_ci_llvm!(llvm.polly);
check_ci_llvm!(llvm.clang);
check_ci_llvm!(llvm.plugins);

// CI-built LLVM can be either dynamic or static.
let ci_llvm = config.out.join(&*config.build.triple).join("ci-llvm");
Expand Down Expand Up @@ -952,6 +961,7 @@ impl Config {

config.llvm_skip_rebuild = llvm_skip_rebuild.unwrap_or(false);
config.llvm_assertions = llvm_assertions.unwrap_or(false);
config.llvm_plugins = llvm_plugins.unwrap_or(false);
config.rust_optimize = optimize.unwrap_or(true);

let default = debug == Some(true);
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def v(*args):
o("profiler", "build.profiler", "build the profiler runtime")
o("full-tools", None, "enable all tools")
o("lld", "rust.lld", "build lld")
o("clang", "llvm.clang", "build clang")
o("missing-tools", "dist.missing-tools", "allow failures when building tools")
o("use-libcxx", "llvm.use-libcxx", "build LLVM with libc++")
o("control-flow-guard", "rust.control-flow-guard", "Enable Control Flow Guard")
Expand All @@ -72,6 +73,7 @@ def v(*args):
o("optimize", "rust.optimize", "build optimized rust code")
o("optimize-llvm", "llvm.optimize", "build optimized LLVM")
o("llvm-assertions", "llvm.assertions", "build LLVM with assertions")
o("llvm-plugins", "llvm.plugins", "build LLVM with plugin interface")
o("debug-assertions", "rust.debug-assertions", "build with debugging assertions")
o("llvm-release-debuginfo", "llvm.release-debuginfo", "build LLVM with debugger metadata")
v("debuginfo-level", "rust.debuginfo-level", "debuginfo level for Rust code")
Expand Down
6 changes: 6 additions & 0 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,12 @@ impl Step for Llvm {
};

let assertions = if builder.config.llvm_assertions { "ON" } else { "OFF" };
let plugins = if builder.config.llvm_plugins { "ON" } else { "OFF" };

cfg.out_dir(&out_dir)
.profile(profile)
.define("LLVM_ENABLE_ASSERTIONS", assertions)
.define("LLVM_ENABLE_PLUGINS", plugins)
.define("LLVM_TARGETS_TO_BUILD", llvm_targets)
.define("LLVM_EXPERIMENTAL_TARGETS_TO_BUILD", llvm_exp_targets)
.define("LLVM_INCLUDE_EXAMPLES", "OFF")
Expand Down Expand Up @@ -265,6 +267,10 @@ impl Step for Llvm {
enabled_llvm_projects.push("polly");
}

if builder.config.llvm_clang {
enabled_llvm_projects.push("clang");
}

// We want libxml to be disabled.
// See https://github.com/rust-lang/rust/pull/50104
cfg.define("LLVM_ENABLE_LIBXML2", "OFF");
Expand Down