-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 unstable rustc-check-cfg
build script output
#10539
Conversation
r? @ehuss (rust-highfive has picked a reviewer for you, use r? to override) |
☔ The latest upstream changes (presumably #10486) made this pull request unmergeable. Please resolve the merge conflicts. |
3679ccc
to
637a7a5
Compare
☔ The latest upstream changes (presumably #10609) made this pull request unmergeable. Please resolve the merge conflicts. |
637a7a5
to
ca984f6
Compare
☔ The latest upstream changes (presumably #10611) made this pull request unmergeable. Please resolve the merge conflicts. |
ca984f6
to
9d5c359
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to pass the --check-cfg
flag to rustdoc, was that intentional?
9d5c359
to
76fff18
Compare
No, not at all. Fixed and added a test for it. I also fixed or responded to the review comments. |
100429f
to
63ee29f
Compare
src/cargo/core/compiler/mod.rs
Outdated
if !output.check_cfgs.is_empty() { | ||
rustdoc.arg("-Zunstable-options"); | ||
for check_cfg in &output.check_cfgs { | ||
rustdoc.arg("--check-cfg").arg(check_cfg); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see a little bit of cleanup to add the --cfg
flag handling in rustc
and rustdoc
. It looks like there is a bit of duplication and inconsistency around handling build-script flags (like --cfg
, --check-cfg
, and env
).
A rough outline of the changes I'm thinking:
- Add a new function to
cargo::core::compiler
that will handle adding these common flags. I think it might have the signature of something likefn add_custom_flags(cmd: &mut ProcessBuilder, build_script_outputs: &BuildScriptOutputs, metadata: Option<Metadata>)
- Move all of
add_custom_env
to that function. - Move all of
--cfg
flag handling to that function. - Move all of
--check-cfg
flag handling to that function. - Use that function in both
rustc
andrustdoc
removing the duplicate code.
How does that sound?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ehuss Sound good. Do you want to do it in this PR or as a follow-up ? (I feel like it doesn't really make sense to do it in this PR, but your call)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is good because it is adding the --check-cfg
arg.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (expect for doc-tests because of it's specificity that make it unable to use the new function).
63ee29f
to
276c6d1
Compare
Thanks! @bors r+ |
📌 Commit f2a1e43 has been approved by |
☀️ Test successful - checks-actions |
Update cargo 10 commits in a4c1cd0eb6b18082a7e693f5a665548fe1534be4..39ad1039d9e3e1746177bf5d134af4c164f95528 2022-05-20 00:55:25 +0000 to 2022-05-25 00:50:02 +0000 * doc: discuss build script instruction order (rust-lang/cargo#10600) * Require http-registry URLs to end with a '/' (rust-lang/cargo#10698) * No printing executable names when running tests and benchmarks with json message format (rust-lang/cargo#10691) * Restore proper error for crate not in local reg (rust-lang/cargo#10683) * Update libcurl (rust-lang/cargo#10696) * Fixed small typos (rust-lang/cargo#10693) * fix bugs with `workspace` key and `update_toml` (rust-lang/cargo#10685) * Bump to 0.64.0, update changelog (rust-lang/cargo#10687) * List C compiler as a build dependency in README (rust-lang/cargo#10678) * Add unstable `rustc-check-cfg` build script output (rust-lang/cargo#10539) r? `@ehuss`
…weihanglo Fix panic when running cargo tree on a package with a cross compiled bindep ### What does this PR try to resolve? This is an attempt to close out `@rukai's` [PR](#13207 (comment)) for #12358 and #10593 by adjusting the new integration test and resolving merge conflicts. I have also separated the changes into atomic commits as per [previous review](#13207 (comment)). ### How should we test and review this PR? The integration test that has been edited here is sufficient, plus the new integration test that confirms a more specific case where `cargo tree` throws an error. ### Additional information I have confirmed the test `artifact_dep_target_specified` fails on master branch and succeeds on this branch. The first commit fixes the panic and the integration test. Commits 2 and 3 add other tests that confirm behaviour mentioned in related issues. Commits: 1. [Fix panic when running cargo tree on a package with a cross compiled bindep](5c5ea78) - fixes some panics and changes the integration test to succeed 2. [test: cargo tree panic on artifact dep target deactivated](ed294ab) - adds test to confirm the behaviour for the specific panic from [#10539 (comment)](#10593 (comment))
This PR adds a new build script output as unstable behind
-Zcheck-cfg=output
:rustc-check-cfg
.What does this PR try to resolve?
This PR add a way to add to use the unstable
--check-cfg
command line option ofrustc
andrustdoc
.It was discover in Bump bootstrap compiler to 1.61.0 beta that
rustc_llvm
sets some customcfg
from a build script and because--check-cfg=values()
is globally enable in the Rust codebase that cause the compilation to fail. For now no values are checked in stage 0 for the entire codebase which is a shame and should be fixed with the addition of this feature.How should we test and review this PR?
Commits are separated in: implementation, tests and doc.
Testing should simply be done by adding a valid
cargo:rustc-check-cfg
in a build script.Watch the added tests or doc to have an example.
Additional information
This PR is also the logical next step after
-Zcheck-cfg-features
.