-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 support for nounused
--extern flag
#96067
Conversation
r? @cjgillot (rust-highfive has picked a reviewer for you, use r? to override) |
@compiler-errors friendlyping |
@@ -0,0 +1,7 @@ | |||
// check-pass |
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.
you may be able to use revisions to consolidate this into one test, but I guess I won't block this on that.
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.
What do you mean?
@@ -908,6 +908,10 @@ impl<'a> CrateLoader<'a> { | |||
// Don't worry about pathless `--extern foo` sysroot references | |||
continue; | |||
} | |||
if entry.nounused_dep { |
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.
hmm... would something like ignore_unused
be a better name for this? I know the convention in other compilers is X
and noX
for enabling or disabling X
, but it's kinda hard to understand whether nounused
is denying unused or allowing unused.
@jsgf: any strong thoughts about the name |
@compiler-errors > Yeah, in general I don't like negative options, but this seemed 1) in keeping with the other --extern flags (single compact word, eg Since this is an option that's almost entirely for other tooling to use - users never type I'd expect Cargo, for example, to maybe support an |
@bors r+ |
📌 Commit 439c68c5a2cde5dec24a004c3752398302f348ad has been approved by |
@jsgf what is the exact use case you want to achieve with that flag? Something like an |
⌛ Testing commit 439c68c5a2cde5dec24a004c3752398302f348ad with merge 60a900f0b6e3c486ebc3074ddbcb21f459ddf9d7... |
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
@est31 My specific use case is Buck builds that have all the dependencies explicitly specified, including the sysroot ones. So to do this:
This all works pretty well. But since we also have But it seems like a generally useful feature at the same level as (The larger plan is to make Rust and C++ builds uniform, so we can have a C++ linker link Rust by having all the Rust dependencies fully represented to Buck so it can pass them to the linker.) |
Thanks for the explanation! The feature is useful in general, but it's always helpful to have a record of it, say 5 years later or so, when wondering "why was this added". |
(rebase to master to see if it clears the test failure) |
@bors r+ |
📌 Commit b19ee8d6d5a7c17cc66754381b0df245fe5ada86 has been approved by |
⌛ Testing commit b19ee8d6d5a7c17cc66754381b0df245fe5ada86 with merge afc30b9cf01692fac85a277a6213cdeab46ca2b4... |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
This adds `nounused` to the set of extern flags: `--extern nounused:core=/path/to/core/libcore.rlib`. The effect of this flag is to suppress `unused-crate-dependencies` warnings relating to the crate.
Updated failing test. |
@bors r+ |
📌 Commit 9102edf has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (b759b22): comparison url. Summary: This benchmark run did not return any relevant results. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. |
I posted #98400 to track the stabilization of this option. |
This adds
nounused
to the set of extern flags:--extern nounused:core=/path/to/core/libcore.rlib
.The effect of this flag is to suppress
unused-crate-dependencies
warnings relating to the crate.