Skip to content

Commit

Permalink
Unrolled build for rust-lang#124073
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#124073 - saethlin:rust-get-test-int, r=wesleywiser

Remove libc from rust_get_test_int uses

`rust_test_helpers.c` has a few unfortunate signatures which have made some of our UI tests _technically_ need the `libc` crate. This is my attempt to evict the need of `libc` for `rust_get_test_int`.

I've deleted `tests/ui/abi/foreign/foreign-no-abi.rs` because the test was originally written to check that `native mod` will compile without an ABI specifier. `native mod` was removed years before 1.0 and the test hasn't checked for anything for a long time.
  • Loading branch information
rust-timer authored Apr 17, 2024
2 parents 00ed4ed + 6298d8f commit 5051ac6
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 54 deletions.
6 changes: 1 addition & 5 deletions tests/ui/abi/anon-extern-mod.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
6 changes: 1 addition & 5 deletions tests/ui/abi/c-stack-as-value.rs
Original file line number Diff line number Diff line change
@@ -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;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
24 changes: 12 additions & 12 deletions tests/ui/abi/foreign/auxiliary/foreign_lib.rs
Original file line number Diff line number Diff line change
@@ -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;
}
Expand All @@ -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());
}
}
3 changes: 1 addition & 2 deletions tests/ui/abi/foreign/foreign-dupe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
21 changes: 0 additions & 21 deletions tests/ui/abi/foreign/foreign-no-abi.rs

This file was deleted.

2 changes: 1 addition & 1 deletion tests/ui/attributes/item-attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ mod test_foreign_items {
#![rustc_dummy]

#[rustc_dummy]
fn rust_get_test_int() -> u32;
fn rust_get_test_int() -> isize;
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions tests/ui/extern/issue-1251.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 5051ac6

Please sign in to comment.