Suppress noisy build script warnings#4046
Open
pauldraper wants to merge 2 commits into
Open
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
edd527a to
0f5334e
Compare
`cargo::warning=` lines emitted by `build.rs` are forwarded to stderr unconditionally, which is noisy for `-sys` crates like `zstd-sys` and `aws-lc-sys` whose warnings the consumer cannot act on (issue bazelbuild#3880). Add two ways to silence them: - `//cargo/settings:emit_build_script_warnings` (default `auto`): a global flag with values `on` / `auto` / `off`. `on` forces emit, `off` silences build-wide, `auto` defers to the per-target attr. - `cargo_build_script(emit_warnings = ...)` (default `True`): a per-target attribute that silences a single build script when the global flag is `auto`. The runner reads `RULES_RUST_SUPPRESS_BUILD_SCRIPT_WARNINGS` from its env to decide.
Render `emit_warnings = False` on every generated `cargo_build_script` target, matching Cargo's default behavior for registry/git crates (warnings are only surfaced when the build fails or under `-vv`). Users can re-enable per-target with additive build content if they need the output, or globally with the new `//cargo/settings:emit_build_script_warnings=on` flag. Existing checked-in 3rdparty BUILD files will pick up the change on the next `crates_vendor` run; no manual edits required. Refs bazelbuild#3880.
0f5334e to
b5ad05c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3880.
cargo::warning=lines frombuild.rsare forwarded to stderr unconditionally, which is noisy for-syscrates such aszstd-sys,aws-lc-sys,openssl-sys. Under Cargo these warnings are hidden for registry/git deps unless the build fails or the user passes-vv; under rules_rust the user always sees them.This PR adds two complementary fixes (both discussed on the issue):
--@rules_rust//cargo/settings:emit_build_script_warnings(defaultauto). Values:on— emit for every target, overriding any per-target opt-out (useful for debugging an-syscrate).auto— respect the per-targetemit_warningsattribute.crate_universe-generated targets opt out, so registry crates stay quiet (matching Cargo); first-party targets emit by default.off— silence build-wide.cargo_build_script(emit_warnings = ...)(defaultTrue).crate_universerenders generatedcargo_build_scripttargets withemit_warnings = False. Honored only when the global flag isauto.