Skip to content

Commit 2e7249f

Browse files
committed
add enable-warnings flag for llvm
Signed-off-by: ozkanonur <[email protected]>
1 parent 0058748 commit 2e7249f

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

config.example.toml

+3
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ changelog-seen = 2
146146
# Whether to build the clang compiler.
147147
#clang = false
148148

149+
# Whether to enable llvm compilation warnings.
150+
#enable-warnings = false
151+
149152
# Custom CMake defines to set when building LLVM.
150153
#build-config = {}
151154

src/bootstrap/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
2525
- If you have Rust already installed, `x.py` will now infer the host target
2626
from the default rust toolchain. [#78513](https://github.com/rust-lang/rust/pull/78513)
2727
- Add options for enabling overflow checks, one for std (`overflow-checks-std`) and one for everything else (`overflow-checks`). Both default to false.
28+
- Add llvm option `enable-warnings` to have control on llvm compilation warnings. Default to false.
2829

2930

3031
## [Version 2] - 2020-09-25

src/bootstrap/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ pub struct Config {
133133
pub llvm_allow_old_toolchain: bool,
134134
pub llvm_polly: bool,
135135
pub llvm_clang: bool,
136+
pub llvm_enable_warnings: bool,
136137
pub llvm_from_ci: bool,
137138
pub llvm_build_config: HashMap<String, String>,
138139

@@ -688,6 +689,7 @@ define_config! {
688689
allow_old_toolchain: Option<bool> = "allow-old-toolchain",
689690
polly: Option<bool> = "polly",
690691
clang: Option<bool> = "clang",
692+
enable_warnings: Option<bool> = "enable-warnings",
691693
download_ci_llvm: Option<StringOrBool> = "download-ci-llvm",
692694
build_config: Option<HashMap<String, String>> = "build-config",
693695
}
@@ -1184,6 +1186,7 @@ impl Config {
11841186
config.llvm_allow_old_toolchain = llvm.allow_old_toolchain.unwrap_or(false);
11851187
config.llvm_polly = llvm.polly.unwrap_or(false);
11861188
config.llvm_clang = llvm.clang.unwrap_or(false);
1189+
config.llvm_enable_warnings = llvm.enable_warnings.unwrap_or(false);
11871190
config.llvm_build_config = llvm.build_config.clone().unwrap_or(Default::default());
11881191

11891192
let asserts = llvm_assertions.unwrap_or(false);

src/bootstrap/defaults/config.codegen.toml

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ compiler-docs = true
77
# This enables debug-assertions in LLVM,
88
# catching logic errors in codegen much earlier in the process.
99
assertions = true
10+
# enable warnings during the llvm compilation
11+
enable-warnings = true
1012

1113
[rust]
1214
# This enables `RUSTC_LOG=debug`, avoiding confusing situations

src/bootstrap/native.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ impl Step for Llvm {
304304
let assertions = if builder.config.llvm_assertions { "ON" } else { "OFF" };
305305
let plugins = if builder.config.llvm_plugins { "ON" } else { "OFF" };
306306
let enable_tests = if builder.config.llvm_tests { "ON" } else { "OFF" };
307+
let enable_warnings = if builder.config.llvm_enable_warnings { "ON" } else { "OFF" };
307308

308309
cfg.out_dir(&out_dir)
309310
.profile(profile)
@@ -321,7 +322,8 @@ impl Step for Llvm {
321322
.define("LLVM_ENABLE_Z3_SOLVER", "OFF")
322323
.define("LLVM_PARALLEL_COMPILE_JOBS", builder.jobs().to_string())
323324
.define("LLVM_TARGET_ARCH", target_native.split('-').next().unwrap())
324-
.define("LLVM_DEFAULT_TARGET_TRIPLE", target_native);
325+
.define("LLVM_DEFAULT_TARGET_TRIPLE", target_native)
326+
.define("LLVM_ENABLE_WARNINGS", enable_warnings);
325327

326328
// Parts of our test suite rely on the `FileCheck` tool, which is built by default in
327329
// `build/$TARGET/llvm/build/bin` is but *not* then installed to `build/$TARGET/llvm/bin`.
@@ -483,11 +485,6 @@ impl Step for Llvm {
483485
cfg.define(key, val);
484486
}
485487

486-
// FIXME: we don't actually need to build all LLVM tools and all LLVM
487-
// libraries here, e.g., we just want a few components and a few
488-
// tools. Figure out how to filter them down and only build the right
489-
// tools and libs on all platforms.
490-
491488
if builder.config.dry_run() {
492489
return res;
493490
}

0 commit comments

Comments
 (0)