From 2db9de37823a97aaa3e1d1037fc8fd1c7c09ca6f Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Thu, 16 Apr 2026 21:14:22 +0200 Subject: [PATCH] add `ignore-cross-compile` to run-make test --- .../naked-dead-code-elimination/main.rs | 14 +++++++++---- .../naked-dead-code-elimination/rmake.rs | 21 +++++++++++++++++-- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/tests/run-make/naked-dead-code-elimination/main.rs b/tests/run-make/naked-dead-code-elimination/main.rs index 83da62d31458..5df2691e5b44 100644 --- a/tests/run-make/naked-dead-code-elimination/main.rs +++ b/tests/run-make/naked-dead-code-elimination/main.rs @@ -7,6 +7,16 @@ extern "C" fn used() { naked_asm!("ret") } +#[unsafe(no_mangle)] +extern "C" fn used_clothed() -> i32 { + 41 +} + +pub fn main() { + std::hint::black_box(used()); + std::hint::black_box(used_clothed()); +} + #[unsafe(no_mangle)] extern "C" fn unused_clothed() -> i32 { 42 @@ -36,7 +46,3 @@ extern "C" fn unused_link_section() { extern "C" fn unused_link_section_clothed() -> i32 { 43 } - -fn main() { - used(); -} diff --git a/tests/run-make/naked-dead-code-elimination/rmake.rs b/tests/run-make/naked-dead-code-elimination/rmake.rs index a29212084b12..1be22de367c9 100644 --- a/tests/run-make/naked-dead-code-elimination/rmake.rs +++ b/tests/run-make/naked-dead-code-elimination/rmake.rs @@ -1,13 +1,30 @@ +//@ ignore-cross-compile //@ needs-asm-support use run_make_support::symbols::object_contains_any_symbol; use run_make_support::{bin_name, rustc}; fn main() { - rustc().input("main.rs").opt().function_sections(true).run(); - let bin = bin_name("main"); + rustc().input("main.rs").opt().function_sections(false).run(); + + // Check that the naked symbol is eliminated when the "clothed" one is. + + assert_eq!( + object_contains_any_symbol(&bin, &["unused_clothed"]), + object_contains_any_symbol(&bin, &["unused"]) + ); + + assert_eq!( + object_contains_any_symbol(&bin, &["unused_link_section_clothed"]), + object_contains_any_symbol(&bin, &["unused_link_section"]) + ); + + // --- + + rustc().input("main.rs").opt().function_sections(true).run(); + // Check that the naked symbol is eliminated when the "clothed" one is. assert_eq!(