[gcc r16-9449] testsuite, c, Darwin: Fix Mach-O issues in toplevel asm tests.

Iain D Sandoe via Gcc-cvs <[email protected]> Wed, 29 Jul 2026 21:55:03 +0000 (GMT)
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:8d6a080d93d01564dfcdf25c3b20a91b91ff119c

commit r16-9449-g8d6a080d93d01564dfcdf25c3b20a91b91ff119c
Author: Iain Sandoe <[email protected]>
Date:   Fri Jun 26 11:41:38 2026 +0100

    testsuite, c, Darwin: Fix Mach-O issues in toplevel asm tests.
    
    Current Darwin no longer supports non-pie executables, leading to spurious
    fails because of linker warnings; skip these cases.
    
    Several of the tests also needed updates for Mach-O ABI (e.g asm directive
    spellings or USER_LABEL_PREFIX).  This fixes the UNRESOLVED cases but not
    the actual fail of toplevel-simple-asm-2.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/lto/toplevel-extended-asm-2_0.c: Fix Mach-O syntax.
            * gcc.dg/lto/toplevel-extended-asm-2_1.c: Likewise.
            * gcc.dg/lto/toplevel-simple-asm-2_1.c: Fix Mach-O syntax.
    
    Signed-off-by: Iain Sandoe <[email protected]>
    (cherry picked from commit 6984448d0d785c63736fa78fad0146fbd4c86c62)

Diff:
---
 gcc/testsuite/gcc.dg/lto/toplevel-extended-asm-2_0.c | 8 ++++++++
 gcc/testsuite/gcc.dg/lto/toplevel-extended-asm-2_1.c | 8 ++++++++
 gcc/testsuite/gcc.dg/lto/toplevel-simple-asm-2_1.c   | 9 +++++++++
 3 files changed, 25 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/lto/toplevel-extended-asm-2_0.c b/gcc/testsuite/gcc.dg/lto/toplevel-extended-asm-2_0.c
index 089ce2e04609..f3690d5675f5 100644
--- a/gcc/testsuite/gcc.dg/lto/toplevel-extended-asm-2_0.c
+++ b/gcc/testsuite/gcc.dg/lto/toplevel-extended-asm-2_0.c
@@ -6,7 +6,15 @@ extern int use_statics ();
 extern int asm_var;
 
 static int a;
+#if __APPLE__
+#if __LP64__
+asm ("%cc0: .quad 0" :: ":"(&a));
+#else
+asm ("%cc0: .long 0" :: ":"(&a));
+#endif
+#else
 asm (".local %cc0\n %cc0: .long 0" :: ":"(&a));
+#endif
 
 int main() {
   return a + use_statics ();
diff --git a/gcc/testsuite/gcc.dg/lto/toplevel-extended-asm-2_1.c b/gcc/testsuite/gcc.dg/lto/toplevel-extended-asm-2_1.c
index f0a6ec3fdf5a..9d70ad5a5da7 100644
--- a/gcc/testsuite/gcc.dg/lto/toplevel-extended-asm-2_1.c
+++ b/gcc/testsuite/gcc.dg/lto/toplevel-extended-asm-2_1.c
@@ -7,7 +7,15 @@ extern int asm_var;
 asm("%cc0:" :: ":" (&asm_var));
 
 static int a;
+#if __APPLE__
+#if __LP64__
+asm ("%cc0: .quad 0" :: ":"(&a));
+#else
+asm ("%cc0: .long 0" :: ":"(&a));
+#endif
+#else
 asm (".local %cc0\n %cc0: .long 0" :: ":"(&a));
+#endif
 
 int use_statics () {
   static_asm_fn ();
diff --git a/gcc/testsuite/gcc.dg/lto/toplevel-simple-asm-2_1.c b/gcc/testsuite/gcc.dg/lto/toplevel-simple-asm-2_1.c
index 1d7c37989637..f37e17d52ec7 100644
--- a/gcc/testsuite/gcc.dg/lto/toplevel-simple-asm-2_1.c
+++ b/gcc/testsuite/gcc.dg/lto/toplevel-simple-asm-2_1.c
@@ -1,10 +1,19 @@
 extern void static_asm_fn ();
 extern int static_asm_var;
+#if __APPLE__
+asm("_static_asm_fn:");
+asm("_static_asm_var:");
+#else
 asm("static_asm_fn:");
 asm("static_asm_var:");
+#endif
 
 extern int asm_var;
+#if __APPLE__
+asm(".globl _asm_var\n_asm_var:");
+#else
 asm(".global asm_var\nasm_var:");
+#endif
 
 int use_statics () {
   static_asm_fn ();