-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Partial support for raw-dylib linkage #84171
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
Merged
+481
−20
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Test the behavior of #[link(.., kind = "raw-dylib")] on windows-msvc | ||
|
||
# only-windows | ||
# only-msvc | ||
|
||
-include ../../run-make-fulldeps/tools.mk | ||
|
||
all: | ||
$(call COMPILE_OBJ,"$(TMPDIR)"/extern_1.obj,extern_1.c) | ||
$(call COMPILE_OBJ,"$(TMPDIR)"/extern_2.obj,extern_2.c) | ||
$(CC) "$(TMPDIR)"/extern_1.obj -link -dll -out:"$(TMPDIR)"/extern_1.dll | ||
$(CC) "$(TMPDIR)"/extern_2.obj -link -dll -out:"$(TMPDIR)"/extern_2.dll | ||
ricobbe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$(RUSTC) --crate-type lib --crate-name raw_dylib_test lib.rs | ||
$(RUSTC) --crate-type bin driver.rs -L "$(TMPDIR)" | ||
"$(TMPDIR)"/driver > "$(TMPDIR)"/output.txt | ||
|
||
ifdef RUSTC_BLESS_TEST | ||
cp "$(TMPDIR)"/output.txt output.txt | ||
else | ||
$(DIFF) output.txt "$(TMPDIR)"/output.txt | ||
endif |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
extern crate raw_dylib_test; | ||
|
||
fn main() { | ||
raw_dylib_test::library_function(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <stdio.h> | ||
|
||
__declspec(dllexport) void extern_fn_1() { | ||
printf("extern_fn_1\n"); | ||
fflush(stdout); | ||
} | ||
|
||
__declspec(dllexport) void extern_fn_2() { | ||
printf("extern_fn_2; didn't get the rename\n"); | ||
fflush(stdout); | ||
} | ||
|
||
__declspec(dllexport) void extern_fn_with_long_name() { | ||
printf("extern_fn_with_long_name; got the rename\n"); | ||
fflush(stdout); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <stdio.h> | ||
|
||
__declspec(dllexport) void extern_fn_3() { | ||
printf("extern_fn_3\n"); | ||
fflush(stdout); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#![feature(raw_dylib, native_link_modifiers, native_link_modifiers_verbatim)] | ||
|
||
#[link(name = "extern_1.dll", kind = "raw-dylib", modifiers = "+verbatim")] | ||
extern { | ||
fn extern_fn_1(); | ||
} | ||
|
||
#[link(name = "extern_2", kind = "raw-dylib")] | ||
extern { | ||
fn extern_fn_3(); | ||
} | ||
|
||
pub fn library_function() { | ||
#[link(name = "extern_1", kind = "raw-dylib")] | ||
extern { fn extern_fn_2(); } | ||
|
||
unsafe { | ||
extern_fn_1(); | ||
extern_fn_2(); | ||
extern_fn_3(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
extern_fn_1 | ||
extern_fn_2; didn't get the rename | ||
extern_fn_3 |
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions
8
src/test/ui/feature-gates/feature-gate-raw-dylib-windows-gnu.rs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// gate-test-raw_dylib | ||
// only-windows-gnu | ||
#[link(name = "foo", kind = "raw-dylib")] | ||
//~^ ERROR: kind="raw-dylib" is unstable | ||
//~| WARNING: `#[link(...)]` with `kind = "raw-dylib"` not supported on windows-gnu | ||
extern "C" {} | ||
|
||
fn main() {} |
18 changes: 18 additions & 0 deletions
18
src/test/ui/feature-gates/feature-gate-raw-dylib-windows-gnu.stderr
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
warning: `#[link(...)]` with `kind = "raw-dylib"` not supported on windows-gnu | ||
--> $DIR/feature-gate-raw-dylib-windows-gnu.rs:3:1 | ||
| | ||
LL | #[link(name = "foo", kind = "raw-dylib")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0658]: kind="raw-dylib" is unstable | ||
--> $DIR/feature-gate-raw-dylib-windows-gnu.rs:3:1 | ||
| | ||
LL | #[link(name = "foo", kind = "raw-dylib")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information | ||
= help: add `#![feature(raw_dylib)]` to the crate attributes to enable | ||
|
||
error: aborting due to previous error; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
2 changes: 2 additions & 0 deletions
2
...-2627-raw-dylib/feature-gate-raw-dylib.rs → ...es/feature-gate-raw-dylib-windows-msvc.rs
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
2 changes: 1 addition & 1 deletion
2
...7-raw-dylib/feature-gate-raw-dylib.stderr → ...eature-gate-raw-dylib-windows-msvc.stderr
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// compile-flags:-l raw-dylib=foo | ||
// error-pattern: unknown library kind `raw-dylib`, expected one of dylib, framework, or static | ||
|
||
fn main() { | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
error: unknown library kind `raw-dylib`, expected one of dylib, framework, or static | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// only-windows-gnu | ||
// check-pass | ||
// compile-flags: --crate-type lib | ||
#![feature(raw_dylib)] | ||
//~^ WARNING: the feature `raw_dylib` is incomplete | ||
#[link(name = "foo", kind = "raw-dylib")] | ||
//~^ WARNING: `#[link(...)]` with `kind = "raw-dylib"` not supported on windows-gnu | ||
extern "C" {} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
warning: the feature `raw_dylib` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/raw-dylib-msvc-only.rs:4:12 | ||
| | ||
LL | #![feature(raw_dylib)] | ||
| ^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information | ||
|
||
warning: `#[link(...)]` with `kind = "raw-dylib"` not supported on windows-gnu | ||
--> $DIR/raw-dylib-msvc-only.rs:6:1 | ||
| | ||
LL | #[link(name = "foo", kind = "raw-dylib")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
warning: 2 warnings emitted | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// ignore-windows | ||
// compile-flags: --crate-type lib | ||
#![feature(raw_dylib)] | ||
//~^ WARNING: the feature `raw_dylib` is incomplete | ||
#[link(name = "foo", kind = "raw-dylib")] | ||
//~^ ERROR: `#[link(...)]` with `kind = "raw-dylib"` only supported on Windows | ||
extern "C" {} |
17 changes: 17 additions & 0 deletions
17
src/test/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.stderr
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
warning: the feature `raw_dylib` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/raw-dylib-windows-only.rs:3:12 | ||
| | ||
LL | #![feature(raw_dylib)] | ||
| ^^^^^^^^^ | ||
| | ||
= note: `#[warn(incomplete_features)]` on by default | ||
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information | ||
|
||
error: `#[link(...)]` with `kind = "raw-dylib"` only supported on Windows | ||
--> $DIR/raw-dylib-windows-only.rs:5:1 | ||
| | ||
LL | #[link(name = "foo", kind = "raw-dylib")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error; 1 warning emitted | ||
|
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.
Uh oh!
There was an error while loading. Please reload this page.