forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#131966 - ChrisDenton:bare-link, r=<try>
Allow #[link(kind = "dylib")] without a name This PR allows `#[link(kind = "dylib")]` without a library name (see the [dllimport RFC](https://rust-lang.github.io/rfcs/1717-dllimport.html) for how this affects `extern {}` blocks). This will need a lang fcp but I wanted to investigate how feasible this is. I want a bare `kind` to act the same as any other `#[link]` for the purposes of applying (or not) dllimport so it gets added to the same array. However, this then means they need to be filtered out from normal queries. To facilitate this I've added a wrapper type for the `NativeLib` container and a separate query for `is_dllimport`. try-job: x86_64-msvc try-job: x86_64-mingw
- Loading branch information
Showing
14 changed files
with
144 additions
and
55 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -490,6 +490,7 @@ symbols! { | |
avx512f, | ||
await_macro, | ||
bang, | ||
bare_link_kind, | ||
begin_panic, | ||
bench, | ||
bin, | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#![crate_type = "cdylib"] | ||
|
||
#[no_mangle] | ||
pub static FOO: u32 = 0xFEDCBA98; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//@ run-pass | ||
//@ aux-build:bare_link_kind_cdylib.rs | ||
|
||
#![feature(bare_link_kind)] | ||
|
||
#[link(kind = "dylib")] | ||
extern "C" { | ||
static FOO: u32; | ||
} | ||
|
||
#[cfg_attr(not(target_env = "msvc"), link(name = "bare_link_kind_cdylib", kind = "dylib"))] | ||
#[cfg_attr(target_env = "msvc", link(name = "bare_link_kind_cdylib.dll", kind = "dylib"))] | ||
extern "C" {} | ||
|
||
fn main() { | ||
unsafe { | ||
assert_eq!(FOO, 0xFEDCBA98); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#[link(kind = "dylib")] //~ ERROR `#[link]` attribute requires a `name = "string"` argument | ||
extern "C" { | ||
static FOO: u32; | ||
} | ||
|
||
fn main() {} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
error[E0459]: `#[link]` attribute requires a `name = "string"` argument | ||
--> $DIR/feature-gate-bare-link-kind.rs:1:1 | ||
| | ||
LL | #[link(kind = "dylib")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ missing `name` argument | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0459`. |