11#![ crate_name = "foreign_lib" ]
2- #![ feature( rustc_private) ]
32
43pub mod rustrt {
5- extern crate libc;
6-
74 #[ link( name = "rust_test_helpers" , kind = "static" ) ]
85 extern "C" {
9- pub fn rust_get_test_int ( ) -> libc :: intptr_t ;
6+ pub fn rust_get_test_int ( ) -> isize ;
107 }
118}
129
1310pub mod rustrt2 {
14- extern crate libc;
15-
1611 extern "C" {
17- pub fn rust_get_test_int ( ) -> libc :: intptr_t ;
12+ pub fn rust_get_test_int ( ) -> isize ;
1813 }
1914}
2015
2116pub 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.
2626 extern "C" {
2727 pub fn rust_get_test_int ( ) -> * const u8 ;
2828 }
@@ -32,6 +32,6 @@ pub fn local_uses() {
3232 unsafe {
3333 let x = rustrt:: rust_get_test_int ( ) ;
3434 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( ) ) ;
3636 }
3737}
0 commit comments