1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-11-30 11:41:39 +03:00
Files
glibc/sysdeps/riscv/preconfigure
Peter Bergner 47975914fb riscv: Add vector registers to __SYSCALL_CLOBBERS
The Linux kernel ABI specifies that the vector registers are not preserved
across system calls, but the __SYSCALL_CLOBBERS macro doesn't mention them.
This could possibly lead to compilers trying to keep data in the vector
registers across the syscall leading to corruption.  Add the vector registers
to __SYSCALL_CLOBBERS when the vector extension is enabled.  If the vector
extension is enabled, then require GCC 15 or later and RVV 1.0 or later.

Fixes: 36960f0c76 ("RISC-V: Linux Syscall Interface")

Signed-off-by: Peter Bergner <bergner@tenstorrent.com>
2025-11-04 09:18:56 -06:00

75 lines
2.0 KiB
Plaintext

# This file is generated from configure.ac by Autoconf. DO NOT EDIT!
# Local preconfigure fragment for sysdeps/riscv
case "$machine" in
riscv*)
xlen=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_xlen \(.*\)/\1/p'`
flen=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_flen \(.*\)/\1/p'`
float_abi=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_float_abi_\([^ ]*\) .*/\1/p'`
atomic=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | grep '#define __riscv_atomic' | cut -d' ' -f2`
vector=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __riscv_v \(.*\)/\1/p'`
case "$xlen" in
64 | 32)
;;
*)
as_fn_error 1 "Unable to determine XLEN" "$LINENO" 5
;;
esac
case "$flen" in
64)
float_machine=rvd
with_fp_cond=1
;;
32)
as_fn_error 1 "glibc does not yet support systems with the F but not D extensions" "$LINENO" 5
;;
"")
with_fp_cond=0
;;
*)
as_fn_error 1 "Unable to determine FLEN" "$LINENO" 5
;;
esac
case "$float_abi" in
soft)
abi_flen=0
;;
single)
as_fn_error 1 "glibc does not yet support the single floating-point ABI" "$LINENO" 5
;;
double)
abi_flen=64
;;
*)
as_fn_error 1 "Unable to determine floating-point ABI" "$LINENO" 5
;;
esac
case "$atomic" in
__riscv_atomic)
;;
*)
as_fn_error 1 "glibc requires the A extension" "$LINENO" 5
;;
esac
if test -n "$vector"; then
version=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __GNUC__ \(.*\)/\1/p'`
test $version -lt 15 && as_fn_error 1 "glibc requires GCC 15 or later for the V extension" "$LINENO" 5
test $vector -lt "1000000" && as_fn_error 1 "glibc requires at least RVV 1.0 for the V extension" "$LINENO" 5
fi
base_machine=riscv
machine=riscv/rv$xlen/$float_machine
printf "%s\n" "#define RISCV_ABI_XLEN $xlen" >>confdefs.h
printf "%s\n" "#define RISCV_ABI_FLEN $abi_flen" >>confdefs.h
;;
esac