about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-04-17 18:01:41 +0200
committerGitHub <noreply@github.com>2024-04-17 18:01:41 +0200
commitabbe0d0e478eee3a599fe363e622d63967f4c4a0 (patch)
treeae7f6863ce1f6ad9d39bbf87564084f74d98ae18
parent116c0f7288ece419d00d18f9f5e1eee42fbb5863 (diff)
parent6298d8f8fa304a28e6a12709c788060f4fedbcdb (diff)
downloadrust-abbe0d0e478eee3a599fe363e622d63967f4c4a0.tar.gz
rust-abbe0d0e478eee3a599fe363e622d63967f4c4a0.zip
Rollup merge of #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.
-rw-r--r--tests/ui/abi/anon-extern-mod.rs6
-rw-r--r--tests/ui/abi/c-stack-as-value.rs6
-rw-r--r--tests/ui/abi/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs5
-rw-r--r--tests/ui/abi/foreign/auxiliary/foreign_lib.rs24
-rw-r--r--tests/ui/abi/foreign/foreign-dupe.rs3
-rw-r--r--tests/ui/abi/foreign/foreign-no-abi.rs21
-rw-r--r--tests/ui/attributes/item-attributes.rs2
-rw-r--r--tests/ui/extern/issue-1251.rs5
8 files changed, 18 insertions, 54 deletions
diff --git a/tests/ui/abi/anon-extern-mod.rs b/tests/ui/abi/anon-extern-mod.rs
index a424f93f637..bb3739bc4af 100644
--- a/tests/ui/abi/anon-extern-mod.rs
+++ b/tests/ui/abi/anon-extern-mod.rs
@@ -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() {
diff --git a/tests/ui/abi/c-stack-as-value.rs b/tests/ui/abi/c-stack-as-value.rs
index 6ea2051b05b..401bc132b6e 100644
--- a/tests/ui/abi/c-stack-as-value.rs
+++ b/tests/ui/abi/c-stack-as-value.rs
@@ -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;
     }
 }
 
diff --git a/tests/ui/abi/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs b/tests/ui/abi/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs
index 5cbf8093c5c..559c40546a8 100644
--- a/tests/ui/abi/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs
+++ b/tests/ui/abi/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs
@@ -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;
 }
diff --git a/tests/ui/abi/foreign/auxiliary/foreign_lib.rs b/tests/ui/abi/foreign/auxiliary/foreign_lib.rs
index 3c649b778bd..74a95b96e9f 100644
--- a/tests/ui/abi/foreign/auxiliary/foreign_lib.rs
+++ b/tests/ui/abi/foreign/auxiliary/foreign_lib.rs
@@ -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());
     }
 }
diff --git a/tests/ui/abi/foreign/foreign-dupe.rs b/tests/ui/abi/foreign/foreign-dupe.rs
index 1b6df0892c7..3473d436cb4 100644
--- a/tests/ui/abi/foreign/foreign-dupe.rs
+++ b/tests/ui/abi/foreign/foreign-dupe.rs
@@ -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());
     }
 }
diff --git a/tests/ui/abi/foreign/foreign-no-abi.rs b/tests/ui/abi/foreign/foreign-no-abi.rs
deleted file mode 100644
index 4ac47df29a7..00000000000
--- a/tests/ui/abi/foreign/foreign-no-abi.rs
+++ /dev/null
@@ -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();
-    }
-}
diff --git a/tests/ui/attributes/item-attributes.rs b/tests/ui/attributes/item-attributes.rs
index 7fe7fdd9758..daab1bccb2c 100644
--- a/tests/ui/attributes/item-attributes.rs
+++ b/tests/ui/attributes/item-attributes.rs
@@ -148,7 +148,7 @@ mod test_foreign_items {
             #![rustc_dummy]
 
             #[rustc_dummy]
-            fn rust_get_test_int() -> u32;
+            fn rust_get_test_int() -> isize;
         }
     }
 }
diff --git a/tests/ui/extern/issue-1251.rs b/tests/ui/extern/issue-1251.rs
index da2b8be7bc1..5581bddaddc 100644
--- a/tests/ui/extern/issue-1251.rs
+++ b/tests/ui/extern/issue-1251.rs
@@ -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;
     }
 }