On Fri, Jan 23, 2026 at 11:12 AM Karl Meakin <[email protected]> wrote:
>
> The assembly functions declared in `asm_1.c` and `asm_3` were not marked
> global, so they could not be found by the linker, and would cause the
> `asm_2.c` and `asm_4.c` test to fail. Fix by marking the functions with
> `.globl`.

I don't see these failing.

 Executing on host:
/bajas/pinskia/src/upstream-cross-aarch64/gcc/objdir-stage2/gcc/xgcc
-B/bajas/pinskia/src/upstream-cross-aarch64/gcc/objdir-stage2/gcc/
/home/apinski/src/upstream-cross-aarch64/gcc/gcc/testsuite/gcc.target/aarch64/sve/pcs/asm_2.c
   -fdiagnostics-plain-output  -march=armv8.2-a+sve
-fno-stack-protector -O2 -flto -ffixed-z0 -ffixed-p0  -lm  -o
./asm_2.exe    (timeout = 300)
spawn -ignore SIGHUP
/bajas/pinskia/src/upstream-cross-aarch64/gcc/objdir-stage2/gcc/xgcc
-B/bajas/pinskia/src/upstream-cross-aarch64/gcc/objdir-stage2/gcc/
/home/apinski/src/upstream-cross-aarch64/gcc/gcc/testsuite/gcc.target/aarch64/sve/pcs/asm_2.c
-fdiagnostics-plain-output -march=armv8.2-a+sve -fno-stack-protector
-O2 -flto -ffixed-z0 -ffixed-p0 -lm -o ./asm_2.exe
PASS: gcc.target/aarch64/sve/pcs/asm_2.c -march=armv8.2-a+sve
-fno-stack-protector (test for excess errors)
spawn qemu-aarch64 ./asm_2.exe
PASS: gcc.target/aarch64/sve/pcs/asm_2.c -march=armv8.2-a+sve
-fno-stack-protector execution test


Though I don't think your fix is the full one either.
You also need to mark the inline-asm as defining that symbol.
That is add:
: :":"(NAME ) \
To the inline-asm.

So ASM_FUNCTION define becomes:
#define ASM_FUNCTION(NAME, RET_TYPE, ARG_TYPE, INSN) \
extern RET_TYPE NAME (svbool_t, ARG_TYPE);      \
  asm(                                          \
"       .type   " #NAME ", %%function\n"         \
"      .globl  " #NAME "\n"                    \
#NAME ":\n"                                     \
"       " INSN "\n"                             \
"       ret\n"                                  \
"       .size   " #NAME ", .-" #NAME "\n"       \
: :":"(NAME ) \
)

Ok with the addition I mentioned. (Note you need to double up the % as
this inline-asm is now an extended one).

Also you can replace " #NAME " with `%cc0` too like:
#define ASM_FUNCTION(NAME, RET_TYPE, ARG_TYPE, INSN) \
extern RET_TYPE NAME (svbool_t, ARG_TYPE);      \
  asm(                                          \
"       .type   %cc0, %%function\n"             \
"      .globl  %cc0\n"                    \
"%cc0:\n"                                       \
"       " INSN "\n"                             \
"       ret\n"                                  \
"       .size   %cc0, .-%cc0\n" \
: :":"(NAME ) \
)

Which works also and I think is better and especially if folks will be
using this as a template on how to define an function from an
inline-asm the above is the best form.

Thanks,
Andrew

>
> gcc/testsuite/ChangeLog:
>
>         * gcc.target/aarch64/sve/pcs/asm_1.c
>         * gcc.target/aarch64/sve/pcs/asm_3.c: Fix tests.
> ---
>  gcc/testsuite/gcc.target/aarch64/sve/pcs/asm_1.c | 1 +
>  gcc/testsuite/gcc.target/aarch64/sve/pcs/asm_3.c | 1 +
>  2 files changed, 2 insertions(+)
>
> diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pcs/asm_1.c 
> b/gcc/testsuite/gcc.target/aarch64/sve/pcs/asm_1.c
> index 8be2094dc96..ddf8cff92ce 100644
> --- a/gcc/testsuite/gcc.target/aarch64/sve/pcs/asm_1.c
> +++ b/gcc/testsuite/gcc.target/aarch64/sve/pcs/asm_1.c
> @@ -7,6 +7,7 @@
>  extern RET_TYPE NAME (svbool_t, ARG_TYPE);     \
>    asm(                                         \
>  "      .type   " #NAME ", %function\n"         \
> +"      .globl  " #NAME "\n"                    \
>  #NAME ":\n"                                    \
>  "      " INSN "\n"                             \
>  "      ret\n"                                  \
> diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pcs/asm_3.c 
> b/gcc/testsuite/gcc.target/aarch64/sve/pcs/asm_3.c
> index d5a36e52eab..6869632f8a3 100644
> --- a/gcc/testsuite/gcc.target/aarch64/sve/pcs/asm_3.c
> +++ b/gcc/testsuite/gcc.target/aarch64/sve/pcs/asm_3.c
> @@ -7,6 +7,7 @@
>  extern RET_TYPE NAME (svbool_t, ARG_TYPE);     \
>    asm(                                         \
>  "      .type   " #NAME ", %function\n"         \
> +"      .globl  " #NAME "\n"                    \
>  #NAME ":\n"                                    \
>  "      " INSN "\n"                             \
>  "      ret\n"                                  \
> --
> 2.43.0
>

Reply via email to