Auto merge of #87619 - 12101111:fix-native_link_modifiers_bundle, r=petrochenkov

Fix feature gate checking of static-nobundle and native_link_modifiers

Feature native_link_modifiers_bundle don't need feature static-nobundle
to work.

Also check the feature gates when using native_link_modifiers from command line options. Current nighly compiler don't check those feature gate.

```
> touch lib.rs
> rustc +nightly lib.rs -L /usr/lib -l static:+bundle=dl --crate-type=rlib
> rustc +nightly lib.rs -L /usr/lib -l dylib:+as-needed=dl --crate-type=dylib -Ctarget-feature=-crt-static
> rustc +nightly lib.rs -L /usr/lib -l static:-bundle=dl --crate-type=rlib
error[E0658]: kind="static-nobundle" is unstable
  |
  = note: see issue #37403 <https://github.com/rust-lang/rust/issues/37403> for more information
  = help: add `#![feature(static_nobundle)]` to the crate attributes to enable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.

```

First found this in https://github.com/rust-lang/rust/pull/85600#discussion_r676612655
This commit is contained in:
bors 2021-08-09 03:59:30 +00:00
commit 7b52ad00cb
8 changed files with 75 additions and 43 deletions

View file

@ -0,0 +1,10 @@
// Test native_link_modifiers_bundle don't need static-nobundle
// check-pass
#![feature(native_link_modifiers)]
#![feature(native_link_modifiers_bundle)]
#[link(name = "foo", kind = "static", modifiers = "-bundle")]
extern "C" {}
fn main() {}

View file

@ -0,0 +1,3 @@
// compile-flags: -l static:-bundle=nonexistent
fn main() {}

View file

@ -0,0 +1,2 @@
error: linking modifiers are currently unstable, the `-Z unstable-options` flag must also be passed to use it

View file

@ -1,6 +1,4 @@
//~ ERROR kind="static-nobundle" is unstable
// Test the behavior of rustc when non-existent library is statically linked
// check-pass
// compile-flags: -l static-nobundle=nonexistent
fn main() {}

View file

@ -1,10 +1,2 @@
warning: library kind `static-nobundle` has been superseded by specifying `-bundle` on library kind `static`. Try `static:-bundle`
error[E0658]: kind="static-nobundle" is unstable
|
= note: see issue #37403 <https://github.com/rust-lang/rust/issues/37403> for more information
= help: add `#![feature(static_nobundle)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.

View file

@ -5,10 +5,10 @@ LL | #[link(name = "foo", kind = "static-nobundle")]
| ^^^^^^^^^^^^^^^^^^^^^^^^
error[E0658]: kind="static-nobundle" is unstable
--> $DIR/feature-gate-static-nobundle.rs:1:1
--> $DIR/feature-gate-static-nobundle.rs:1:22
|
LL | #[link(name = "foo", kind = "static-nobundle")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #37403 <https://github.com/rust-lang/rust/issues/37403> for more information
= help: add `#![feature(static_nobundle)]` to the crate attributes to enable