From 9f78a7c1d0963282608da836b840f0d5ae1c478e Mon Sep 17 00:00:00 2001 From: Sunil K Pandey Date: Tue, 13 Feb 2024 12:23:14 -0800 Subject: x86_64: Exclude SSE, AVX and FMA4 variants in libm multiarch When glibc is built with ISA level 3 or higher by default, the resulting glibc binaries won't run on SSE or FMA4 processors. Exclude SSE, AVX and FMA4 variants in libm multiarch when ISA level 3 or higher is enabled by default. When glibc is built with ISA level 2 enabled by default, only keep SSE4.1 variant. Fixes BZ 31335. NB: elf/tst-valgrind-smoke test fails with ISA level 4, because valgrind doesn't support AVX512 instructions: https://bugs.kde.org/show_bug.cgi?id=383010 Reviewed-by: H.J. Lu --- sysdeps/x86/configure.ac | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'sysdeps/x86/configure.ac') diff --git a/sysdeps/x86/configure.ac b/sysdeps/x86/configure.ac index 437a506..78ff7c8 100644 --- a/sysdeps/x86/configure.ac +++ b/sysdeps/x86/configure.ac @@ -72,6 +72,7 @@ if test $libc_cv_include_x86_isa_level = yes; then fi]) if test $libc_cv_have_x86_lahf_sahf = yes; then AC_DEFINE(HAVE_X86_LAHF_SAHF) + ISAFLAG="-DHAVE_X86_LAHF_SAHF" fi AC_CACHE_CHECK([for MOVBE instruction support], libc_cv_have_x86_movbe, [dnl @@ -81,8 +82,31 @@ if test $libc_cv_include_x86_isa_level = yes; then fi]) if test $libc_cv_have_x86_movbe = yes; then AC_DEFINE(HAVE_X86_MOVBE) + ISAFLAG="$ISAFLAG -DHAVE_X86_MOVBE" fi + + # Check for ISA level support. + AC_CACHE_CHECK([for ISA level support], + libc_cv_have_x86_isa_level, [dnl +cat > conftest.c < +#if MINIMUM_X86_ISA_LEVEL >= 4 +libc_cv_have_x86_isa_level=4 +#elif MINIMUM_X86_ISA_LEVEL == 3 +libc_cv_have_x86_isa_level=3 +#elif MINIMUM_X86_ISA_LEVEL == 2 +libc_cv_have_x86_isa_level=2 +#else +libc_cv_have_x86_isa_level=baseline +#endif +EOF + eval `${CC-cc} $CFLAGS $CPPFLAGS $ISAFLAG -I$srcdir -E conftest.c | grep libc_cv_have_x86_isa_level` + rm -rf conftest*]) +else + libc_cv_have_x86_isa_level=baseline fi +LIBC_CONFIG_VAR([have-x86-isa-level], [$libc_cv_have_x86_isa_level]) +LIBC_CONFIG_VAR([x86-isa-level-3-or-above], [3 4]) LIBC_CONFIG_VAR([enable-x86-isa-level], [$libc_cv_include_x86_isa_level]) dnl Static PIE is supported. -- cgit v1.1