From 9facf0bf72acf6cbf6ecb6c28c4b5364efc6b83f Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 5 Oct 2023 19:41:41 +0000 Subject: [PATCH 1/2] Properly export function defined in test which uses global_asm!() Currently the test passes with the LLVM backend as the codegen unit partitioning logic happens to place both the global_asm!() and the function which calls the function defined by the global_asm!() in the same CGU. With the Cranelift backend it breaks however as it will place all assembly in separate codegen units to be passed to an external linker. --- tests/ui/asm/x86_64/issue-96797.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/ui/asm/x86_64/issue-96797.rs b/tests/ui/asm/x86_64/issue-96797.rs index 951dd949b3251..17985d7e8c8fa 100644 --- a/tests/ui/asm/x86_64/issue-96797.rs +++ b/tests/ui/asm/x86_64/issue-96797.rs @@ -11,7 +11,14 @@ use std::arch::global_asm; #[no_mangle] fn my_func() {} -global_asm!("call_foobar: jmp {}", sym foobar); +global_asm!(" +.globl call_foobar +.type call_foobar,@function +.section .text.call_foobar,\"ax\",@progbits +call_foobar: jmp {} +.size call_foobar, .-call_foobar +.text +", sym foobar); fn foobar() {} From ecf271cfb6224fae07a2b096bfbae22c6112b011 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 6 Oct 2023 11:02:11 +0000 Subject: [PATCH 2/2] Use pushsection/popsection --- tests/ui/asm/x86_64/issue-96797.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ui/asm/x86_64/issue-96797.rs b/tests/ui/asm/x86_64/issue-96797.rs index 17985d7e8c8fa..6c22c2f6c9463 100644 --- a/tests/ui/asm/x86_64/issue-96797.rs +++ b/tests/ui/asm/x86_64/issue-96797.rs @@ -14,10 +14,10 @@ fn my_func() {} global_asm!(" .globl call_foobar .type call_foobar,@function -.section .text.call_foobar,\"ax\",@progbits +.pushsection .text.call_foobar,\"ax\",@progbits call_foobar: jmp {} .size call_foobar, .-call_foobar -.text +.popsection ", sym foobar); fn foobar() {}