Remove libc from rust_get_test_int uses

This commit is contained in:
Ben Kimock 2024-04-15 23:46:27 -04:00
parent 1dea922ea6
commit 6298d8f8fa
8 changed files with 18 additions and 54 deletions

View file

@ -1,13 +1,9 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
#![feature(rustc_private)]
extern crate libc;
#[link(name = "rust_test_helpers", kind = "static")]
extern "C" {
fn rust_get_test_int() -> libc::intptr_t;
fn rust_get_test_int() -> isize;
}
pub fn main() {

View file

@ -1,14 +1,10 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
#![feature(rustc_private)]
mod rustrt {
extern crate libc;
#[link(name = "rust_test_helpers", kind = "static")]
extern "C" {
pub fn rust_get_test_int() -> libc::intptr_t;
pub fn rust_get_test_int() -> isize;
}
}

View file

@ -1,9 +1,6 @@
#![crate_name = "anonexternmod"]
#![feature(rustc_private)]
extern crate libc;
#[link(name = "rust_test_helpers", kind = "static")]
extern "C" {
pub fn rust_get_test_int() -> libc::intptr_t;
pub fn rust_get_test_int() -> isize;
}

View file

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

View file

@ -4,13 +4,12 @@
// Check that we can still call duplicated extern (imported) functions
// which were declared in another crate. See issues #32740 and #32783.
extern crate foreign_lib;
pub fn main() {
unsafe {
let x = foreign_lib::rustrt::rust_get_test_int();
assert_eq!(x, foreign_lib::rustrt2::rust_get_test_int());
assert_eq!(x as *const _, foreign_lib::rustrt3::rust_get_test_int());
assert_eq!(x as *const u8, foreign_lib::rustrt3::rust_get_test_int());
}
}

View file

@ -1,21 +0,0 @@
//@ run-pass
// ABI is cdecl by default
//@ pretty-expanded FIXME #23616
#![feature(rustc_private)]
mod rustrt {
extern crate libc;
#[link(name = "rust_test_helpers", kind = "static")]
extern "C" {
pub fn rust_get_test_int() -> libc::intptr_t;
}
}
pub fn main() {
unsafe {
rustrt::rust_get_test_int();
}
}

View file

@ -148,7 +148,7 @@ pub mod rustrt {
#![rustc_dummy]
#[rustc_dummy]
fn rust_get_test_int() -> u32;
fn rust_get_test_int() -> isize;
}
}
}

View file

@ -2,13 +2,10 @@
#![allow(unused_attributes)]
#![allow(dead_code)]
//@ pretty-expanded FIXME #23616
#![feature(rustc_private)]
mod rustrt {
extern crate libc;
extern "C" {
pub fn rust_get_test_int() -> libc::intptr_t;
pub fn rust_get_test_int() -> isize;
}
}