Skip to content
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

add enable-warnings flag for llvm, and disable it by default. #108991

Merged
merged 1 commit into from
Mar 15, 2023
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
3 changes: 3 additions & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ changelog-seen = 2
# Whether to build the clang compiler.
#clang = false

# Whether to enable llvm compilation warnings.
#enable-warnings = false

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

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


## [Version 2] - 2020-09-25
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ pub struct Config {
pub llvm_allow_old_toolchain: bool,
pub llvm_polly: bool,
pub llvm_clang: bool,
pub llvm_enable_warnings: bool,
pub llvm_from_ci: bool,
pub llvm_build_config: HashMap<String, String>,

Expand Down Expand Up @@ -688,6 +689,7 @@ define_config! {
allow_old_toolchain: Option<bool> = "allow-old-toolchain",
polly: Option<bool> = "polly",
clang: Option<bool> = "clang",
enable_warnings: Option<bool> = "enable-warnings",
download_ci_llvm: Option<StringOrBool> = "download-ci-llvm",
build_config: Option<HashMap<String, String>> = "build-config",
}
Expand Down Expand Up @@ -1184,6 +1186,7 @@ impl Config {
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_enable_warnings = llvm.enable_warnings.unwrap_or(false);
config.llvm_build_config = llvm.build_config.clone().unwrap_or(Default::default());

let asserts = llvm_assertions.unwrap_or(false);
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/defaults/config.codegen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ compiler-docs = true
# This enables debug-assertions in LLVM,
# catching logic errors in codegen much earlier in the process.
assertions = true
# enable warnings during the llvm compilation
enable-warnings = true

[rust]
# This enables `RUSTC_LOG=debug`, avoiding confusing situations
Expand Down
9 changes: 3 additions & 6 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ impl Step for Llvm {
let assertions = if builder.config.llvm_assertions { "ON" } else { "OFF" };
let plugins = if builder.config.llvm_plugins { "ON" } else { "OFF" };
let enable_tests = if builder.config.llvm_tests { "ON" } else { "OFF" };
let enable_warnings = if builder.config.llvm_enable_warnings { "ON" } else { "OFF" };

cfg.out_dir(&out_dir)
.profile(profile)
Expand All @@ -321,7 +322,8 @@ impl Step for Llvm {
.define("LLVM_ENABLE_Z3_SOLVER", "OFF")
.define("LLVM_PARALLEL_COMPILE_JOBS", builder.jobs().to_string())
.define("LLVM_TARGET_ARCH", target_native.split('-').next().unwrap())
.define("LLVM_DEFAULT_TARGET_TRIPLE", target_native);
.define("LLVM_DEFAULT_TARGET_TRIPLE", target_native)
.define("LLVM_ENABLE_WARNINGS", enable_warnings);

// Parts of our test suite rely on the `FileCheck` tool, which is built by default in
// `build/$TARGET/llvm/build/bin` is but *not* then installed to `build/$TARGET/llvm/bin`.
Expand Down Expand Up @@ -483,11 +485,6 @@ impl Step for Llvm {
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
// tools and libs on all platforms.

Comment on lines -486 to -490
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if builder.config.dry_run() {
return res;
}
Expand Down