Skip to content

Couple of test suite fixes for cg_clif #142955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,6 @@ rm tests/ui/process/process-panic-after-fork.rs # same
cp ../dist/bin/rustdoc-clif ../dist/bin/rustdoc # some tests expect bin/rustdoc to exist

cat <<EOF | git apply -
diff --git a/tests/run-make/linker-warning/rmake.rs b/tests/run-make/linker-warning/rmake.rs
index 30387af428c..f7895b12961 100644
--- a/tests/run-make/linker-warning/rmake.rs
+++ b/tests/run-make/linker-warning/rmake.rs
@@ -57,7 +57,8 @@ fn main() {
.actual_text("(linker error)", out.stderr())
- .normalize(r#"/rustc[^/]*/"#, "/rustc/")
+ .normalize(r#"/tmp/rustc[^/]*/"#, "/tmp/rustc/")
+ .normalize("libpanic_abort", "libpanic_unwind")
.normalize(
regex::escape(run_make_support::build_root().to_str().unwrap()),
"/build-root",
)
.normalize(r#""[^"]*\/symbols.o""#, "\\"/symbols.o\\"")
diff --git a/src/tools/compiletest/src/runtest/run_make.rs b/src/tools/compiletest/src/runtest/run_make.rs
index 073116933bd..c3e4578204d 100644
--- a/src/tools/compiletest/src/runtest/run_make.rs
Expand Down
10 changes: 9 additions & 1 deletion tests/run-make/bin-emit-no-symbols/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ fn panic(_: &PanicInfo) -> ! {
}

#[lang = "eh_personality"]
fn eh() {}
fn eh(
_version: i32,
_actions: i32,
_exception_class: u64,
_exception_object: *mut (),
_context: *mut (),
) -> i32 {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This signature does technically depend on the exact unwinding mechanism used, but it is unlikely that cg_clif will support an unwinding mechanism that needs a different signature for the foreseeable future and cg_llvm doesn't care about signature mismatches anyway.

loop {}
}

#[alloc_error_handler]
fn oom(_: Layout) -> ! {
Expand Down
8 changes: 7 additions & 1 deletion tests/run-make/crate-circular-deps-link/a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ extern "C" fn __rust_foreign_exception() -> ! {
}

#[lang = "eh_personality"]
fn eh_personality() {
fn eh_personality(
_version: i32,
_actions: i32,
_exception_class: u64,
_exception_object: *mut (),
_context: *mut (),
) -> i32 {
loop {}
}
3 changes: 2 additions & 1 deletion tests/run-make/linker-warning/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ fn main() {
diff()
.expected_file("short-error.txt")
.actual_text("(linker error)", out.stderr())
.normalize(r#"/rustc[^/]*/"#, "/rustc/")
.normalize(r#"/rustc[^/_-]*/"#, "/rustc/")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't exactly match the patch I had been carrying on the cg_clif side, but it should be more robust against future moves of the temp directory.

.normalize("libpanic_abort", "libpanic_unwind")
.normalize(
regex::escape(run_make_support::build_root().to_str().unwrap()),
"/build-root",
Expand Down
8 changes: 7 additions & 1 deletion tests/run-make/no-alloc-shim/foo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ fn panic_handler(_: &core::panic::PanicInfo) -> ! {
}

#[no_mangle]
extern "C" fn rust_eh_personality() {
extern "C" fn rust_eh_personality(
_version: i32,
_actions: i32,
_exception_class: u64,
_exception_object: *mut (),
_context: *mut (),
) -> i32 {
loop {}
}

Expand Down
13 changes: 11 additions & 2 deletions tests/ui/allocator/no_std-alloc-error-handler-custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
//@ compile-flags:-C panic=abort
//@ aux-build:helper.rs

#![feature(rustc_private, lang_items)]
#![feature(rustc_private, lang_items, panic_unwind)]
#![feature(alloc_error_handler)]
#![no_std]
#![no_main]

extern crate alloc;
extern crate libc;
extern crate unwind; // For _Unwind_Resume

// ARM targets need these symbols
#[no_mangle]
Expand Down Expand Up @@ -70,7 +71,15 @@ fn panic(panic_info: &core::panic::PanicInfo) -> ! {
// in these libraries will refer to `rust_eh_personality` if LLVM can not *prove* the contents won't
// unwind. So, for this test case we will define the symbol.
#[lang = "eh_personality"]
extern "C" fn rust_eh_personality() {}
extern "C" fn rust_eh_personality(
_version: i32,
_actions: i32,
_exception_class: u64,
_exception_object: *mut (),
_context: *mut (),
) -> i32 {
loop {}
}

#[derive(Default, Debug)]
struct Page(#[allow(dead_code)] [[u64; 32]; 16]);
Expand Down
13 changes: 11 additions & 2 deletions tests/ui/allocator/no_std-alloc-error-handler-default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
//@ compile-flags:-C panic=abort
//@ aux-build:helper.rs

#![feature(rustc_private, lang_items)]
#![feature(rustc_private, lang_items, panic_unwind)]
#![no_std]
#![no_main]

extern crate alloc;
extern crate libc;
extern crate unwind; // For _Unwind_Resume

// ARM targets need these symbols
#[no_mangle]
Expand Down Expand Up @@ -57,7 +58,15 @@ fn panic(panic_info: &core::panic::PanicInfo) -> ! {
// in these libraries will refer to `rust_eh_personality` if LLVM can not *prove* the contents won't
// unwind. So, for this test case we will define the symbol.
#[lang = "eh_personality"]
extern "C" fn rust_eh_personality() {}
extern "C" fn rust_eh_personality(
_version: i32,
_actions: i32,
_exception_class: u64,
_exception_object: *mut (),
_context: *mut (),
) -> i32 {
loop {}
}

#[derive(Default, Debug)]
struct Page(#[allow(dead_code)] [[u64; 32]; 16]);
Expand Down
10 changes: 9 additions & 1 deletion tests/ui/extern-flag/auxiliary/panic_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ pub fn begin_panic_handler(_info: &core::panic::PanicInfo<'_>) -> ! {
}

#[lang = "eh_personality"]
extern "C" fn eh_personality() {}
extern "C" fn eh_personality(
_version: i32,
_actions: i32,
_exception_class: u64,
_exception_object: *mut (),
_context: *mut (),
) -> i32 {
loop {}
}
12 changes: 12 additions & 0 deletions tests/ui/no_std/simple-runs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//@ compile-flags: -Cpanic=abort
//@ ignore-wasm different `main` convention

#![feature(lang_items)]
#![no_std]
#![no_main]

Expand Down Expand Up @@ -35,6 +36,17 @@ fn panic_handler(_info: &PanicInfo<'_>) -> ! {
loop {}
}

#[lang = "eh_personality"]
extern "C" fn rust_eh_personality(
_version: i32,
_actions: i32,
_exception_class: u64,
_exception_object: *mut (),
_context: *mut (),
) -> i32 {
loop {}
}

#[no_mangle]
extern "C" fn main(_argc: c_int, _argv: *const *const c_char) -> c_int {
0
Expand Down
10 changes: 9 additions & 1 deletion tests/ui/panic-runtime/incompatible-type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,12 @@ pub fn test(_: DropMe) {
}

#[rustc_std_internal_symbol]
pub unsafe extern "C" fn rust_eh_personality() {}
pub unsafe extern "C" fn rust_eh_personality(
_version: i32,
_actions: i32,
_exception_class: u64,
_exception_object: *mut (),
_context: *mut (),
) -> i32 {
loop {}
}
Loading