1
1
#![ crate_name = "foreign_lib" ]
2
- #![ feature( rustc_private) ]
3
2
4
3
pub mod rustrt {
5
- extern crate libc;
6
-
7
4
#[ link( name = "rust_test_helpers" , kind = "static" ) ]
8
5
extern "C" {
9
- pub fn rust_get_test_int ( ) -> libc :: intptr_t ;
6
+ pub fn rust_get_test_int ( ) -> isize ;
10
7
}
11
8
}
12
9
13
10
pub mod rustrt2 {
14
- extern crate libc;
15
-
16
11
extern "C" {
17
- pub fn rust_get_test_int ( ) -> libc :: intptr_t ;
12
+ pub fn rust_get_test_int ( ) -> isize ;
18
13
}
19
14
}
20
15
21
16
pub mod rustrt3 {
22
- // Different type, but same ABI (on all supported platforms).
23
- // Ensures that we don't ICE or trigger LLVM asserts when
24
- // importing the same symbol under different types.
25
- // See https://github.com/rust-lang/rust/issues/32740.
17
+ // The point of this test is to ensure that we don't ICE or trigger LLVM asserts when importing
18
+ // the same symbol with different types. This is not really possible to test portably; there is
19
+ // no different signature we can come up with that is different to LLVM but which for sure has
20
+ // the same behavior on all platforms. The signed-ness of integers is ignored by LLVM as well
21
+ // as pointee types. So the only ways to make our signatures differ are to use
22
+ // differently-sized integers which is definitely an ABI mismatch, or to rely on pointers and
23
+ // isize/usize having the same ABI, which is wrong on CHERI and probably other niche platforms.
24
+ // If this test causes you trouble, please file an issue.
25
+ // See https://github.com/rust-lang/rust/issues/32740 for the bug that prompted this test.
26
26
extern "C" {
27
27
pub fn rust_get_test_int ( ) -> * const u8 ;
28
28
}
@@ -32,6 +32,6 @@ pub fn local_uses() {
32
32
unsafe {
33
33
let x = rustrt:: rust_get_test_int ( ) ;
34
34
assert_eq ! ( x, rustrt2:: rust_get_test_int( ) ) ;
35
- assert_eq ! ( x as * const _ , rustrt3:: rust_get_test_int( ) ) ;
35
+ assert_eq ! ( x as * const u8 , rustrt3:: rust_get_test_int( ) ) ;
36
36
}
37
37
}
0 commit comments