Skip to content

Pass -Werror when building the LLVM wrapper #143807

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rperier
Copy link
Contributor

@rperier rperier commented Jul 11, 2025

cc #109712

@rustbot
Copy link
Collaborator

rustbot commented Jul 11, 2025

r? @cuviper

rustbot has assigned @cuviper.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 11, 2025
@cuviper
Copy link
Member

cuviper commented Jul 11, 2025

I disagree with applying -Werror wholesale, because that can break anyone who happens to use a different C++ compiler than what we already tested with, especially for new warnings that may not even be real problems, or may be caused by external headers out of our control.

Maybe we could inject -Werror only for Rust CI, where we control the entire build environment.

@rperier
Copy link
Contributor Author

rperier commented Jul 11, 2025

Even if warnings are not enabled ? Well, even if you can still get warnings that are not parts of -Wall and -Wextra...
I understand now what @jyn514 meant by "in CI". I gonna to investigate to find how to inject this only for Rust CI.

@Noratrieb
Copy link
Member

note that this here isn't actually building llvm, it's just building rustc's wrapper. the actual LLVM build happens in src/bootstrap

@cuviper
Copy link
Member

cuviper commented Jul 11, 2025

I gonna to investigate to find how to inject this only for Rust CI.

I don't think it needs to be sophisticated -- maybe just check for the CI environment variable, which has precedent:

if std::env::var_os("CI").is_some() {

@Noratrieb
Copy link
Member

Bootstrap has existing methods for checking whether it's in rust-lang/rust CI, maybe you could reuse those by piping through environment variables or something like that

@Noratrieb Noratrieb changed the title Pass -Werror when building LLVM Pass -Werror when building the LLVM wrapper Jul 12, 2025
@rperier
Copy link
Contributor Author

rperier commented Jul 12, 2025

Boostrap has existing types and methods for checking whether it's in rust-lang/rust CI, that's the CiEnv enum. However, it seems that .github/workflows/ci.yml calls src/ci/docker/run.sh at some point. The docker script wrapper set the environment variable CI before running the container. That's the variable that is used later by compiler/rustc_codegen_llvm/src/llvm_util.rs. Checking for the presence of the CI environment variable looks simpler, as we already have everything we need, in my humble opinion.

Enabling warning_into_errors() only whether it's in rust-lang/rust CI,
so deprecated uses of LLVM methods can be treated as errors.
@rperier rperier force-pushed the rustc_llvm_werror branch from ae1ee6e to 8271991 Compare July 12, 2025 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants