forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes rust-lang#3595 by using -fvisibility=hidden and the visibility attribute supported by both gcc and clang rather than the previous gcc-only mechanism for symbol hiding. Also brings over cfg changes from rust-lang#3594 which enable native-lib functionality on all unixes.
- Loading branch information
1 parent
c0eb9ee
commit bfe5595
Showing
14 changed files
with
78 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Only works on Unix targets | ||
//@ignore-target-windows | ||
//@ignore-target-wasm | ||
//@only-on-host | ||
//@normalize-stderr-test: "OS `.*`" -> "$$OS" | ||
|
||
extern "C" { | ||
fn not_exported(); | ||
} | ||
|
||
fn main() { | ||
unsafe { | ||
not_exported(); //~ ERROR: unsupported operation: can't call foreign function `not_exported` | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/tools/miri/tests/native-lib/fail/private_function.stderr
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,15 @@ | ||
error: unsupported operation: can't call foreign function `not_exported` on $OS | ||
--> $DIR/private_function.rs:LL:CC | ||
| | ||
LL | not_exported(); | ||
| ^^^^^^^^^^^^^^ can't call foreign function `not_exported` on $OS | ||
| | ||
= help: if this is a basic API commonly used on this target, please report an issue with Miri | ||
= help: however, note that Miri does not aim to support every FFI function out there; for instance, we will not support APIs for things such as GUIs, scripting languages, or databases | ||
= note: BACKTRACE: | ||
= note: inside `main` at $DIR/private_function.rs:LL:CC | ||
|
||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace | ||
|
||
error: aborting due to 1 previous error | ||
|
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,27 +1,35 @@ | ||
#include <stdio.h> | ||
|
||
int add_one_int(int x) { | ||
// See comments in build_native_lib() | ||
#define EXPORT __attribute__((visibility("default"))) | ||
|
||
EXPORT int add_one_int(int x) { | ||
return 2 + x; | ||
} | ||
|
||
void printer() { | ||
EXPORT void printer(void) { | ||
printf("printing from C\n"); | ||
} | ||
|
||
// function with many arguments, to test functionality when some args are stored | ||
// on the stack | ||
int test_stack_spill(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l) { | ||
EXPORT int test_stack_spill(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l) { | ||
return a+b+c+d+e+f+g+h+i+j+k+l; | ||
} | ||
|
||
unsigned int get_unsigned_int() { | ||
EXPORT unsigned int get_unsigned_int(void) { | ||
return -10; | ||
} | ||
|
||
short add_int16(short x) { | ||
EXPORT short add_int16(short x) { | ||
return x + 3; | ||
} | ||
|
||
long add_short_to_long(short x, long y) { | ||
EXPORT long add_short_to_long(short x, long y) { | ||
return x + y; | ||
} | ||
|
||
// To test that functions not marked with EXPORT cannot be called by Miri. | ||
int not_exported(void) { | ||
return 0; | ||
} |
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