From 8f6827ffb7031abec81a1db40a0b6cbcf8a464af Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Tue, 20 Jul 2021 02:38:39 +0200 Subject: [PATCH] add two new build flags to build clang and enable llvm plugins --- config.toml.example | 6 ++++++ src/bootstrap/config.rs | 10 ++++++++++ src/bootstrap/configure.py | 2 ++ src/bootstrap/native.rs | 6 ++++++ 4 files changed, 24 insertions(+) diff --git a/config.toml.example b/config.toml.example index 775133f2ab3..c2d51c140b4 100644 --- a/config.toml.example +++ b/config.toml.example @@ -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 ... @@ -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 # ============================================================================= diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 4b3c25b02c2..fdddc1dbbaf 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -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, @@ -104,6 +105,7 @@ pub struct Config { pub llvm_use_linker: Option, pub llvm_allow_old_toolchain: bool, pub llvm_polly: bool, + pub llvm_clang: bool, pub llvm_from_ci: bool, pub use_lld: bool, @@ -415,6 +417,7 @@ struct Llvm { thin_lto: Option, release_debuginfo: Option, assertions: Option, + plugins: Option, ccache: Option, version_check: Option, static_libstdcpp: Option, @@ -432,6 +435,7 @@ struct Llvm { use_linker: Option, allow_old_toolchain: Option, polly: Option, + clang: Option, download_ci_llvm: Option, } @@ -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; @@ -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); @@ -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); @@ -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"); @@ -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); diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 8d9f169e6c5..a1941efb562 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -57,6 +57,7 @@ o("cargo-native-static", "build.cargo-native-static", "static native libraries i 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") @@ -72,6 +73,7 @@ v("llvm-libunwind", "rust.llvm-libunwind", "use LLVM libunwind") 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") diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index b8a1513f2a6..d32426afb0b 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -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") @@ -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");