Message ID | 20240612023014.3003329-1-hjl.tools@gmail.com |
---|---|
State | New |
Headers | show |
Series | x86: Properly set x86 minimum ISA level [BZ #31883] | expand |
On Tue, Jun 11, 2024 at 9:30 PM H.J. Lu <hjl.tools@gmail.com> wrote: > > Properly set libc_cv_have_x86_isa_level in shell for MINIMUM_X86_ISA_LEVEL > defined as > > (__X86_ISA_V1 + __X86_ISA_V2 + __X86_ISA_V3 + __X86_ISA_V4) > > Also set __X86_ISA_V2 to 1 for i386 if __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 > is defined. There are no changes in config.h nor in config.make on x86-64. > On i386, -march=x86-64-v2 with GCC generates > > #define MINIMUM_X86_ISA_LEVEL 2 > > in config.h and > > have-x86-isa-level = 2 > > in config.make. This fixes BZ #31883. > > Signed-off-by: H.J. Lu <hjl.tools@gmail.com> > --- > sysdeps/x86/configure | 4 +++- > sysdeps/x86/configure.ac | 4 +++- > sysdeps/x86/isa-level.h | 6 +++++- > 3 files changed, 11 insertions(+), 3 deletions(-) > > diff --git a/sysdeps/x86/configure b/sysdeps/x86/configure > index 1e2325d0d7..04c6ba3e6c 100644 > --- a/sysdeps/x86/configure > +++ b/sysdeps/x86/configure > @@ -141,8 +141,10 @@ libc_cv_have_x86_isa_level=3 > libc_cv_have_x86_isa_level=2 > #elif defined __x86_64__ > libc_cv_have_x86_isa_level=baseline > +#elif MINIMUM_X86_ISA_LEVEL == 1 > +libc_cv_have_x86_isa_level=1 > #else > -libc_cv_have_x86_isa_level=MINIMUM_X86_ISA_LEVEL > +libc_cv_have_x86_isa_level=0 > #endif > EOF > eval `${CC-cc} $CFLAGS $CPPFLAGS $ISAFLAG -I$srcdir -E conftest.c | grep libc_cv_have_x86_isa_level` > diff --git a/sysdeps/x86/configure.ac b/sysdeps/x86/configure.ac > index 0b32fdfd4f..8a259d3971 100644 > --- a/sysdeps/x86/configure.ac > +++ b/sysdeps/x86/configure.ac > @@ -98,8 +98,10 @@ libc_cv_have_x86_isa_level=3 > libc_cv_have_x86_isa_level=2 > #elif defined __x86_64__ > libc_cv_have_x86_isa_level=baseline > +#elif MINIMUM_X86_ISA_LEVEL == 1 > +libc_cv_have_x86_isa_level=1 > #else > -libc_cv_have_x86_isa_level=MINIMUM_X86_ISA_LEVEL > +libc_cv_have_x86_isa_level=0 > #endif > EOF > eval `${CC-cc} $CFLAGS $CPPFLAGS $ISAFLAG -I$srcdir -E conftest.c | grep libc_cv_have_x86_isa_level` > diff --git a/sysdeps/x86/isa-level.h b/sysdeps/x86/isa-level.h > index 2c7f74212b..fe1f0924e4 100644 > --- a/sysdeps/x86/isa-level.h > +++ b/sysdeps/x86/isa-level.h > @@ -35,7 +35,11 @@ > # define __X86_ISA_V1 0 > #endif > > -#if __X86_ISA_V1 && defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 \ > +#if __X86_ISA_V1 \ > + && ((defined __x86_64__ \ > + && defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16) \ > + || (!defined __x86_64__ \ > + && defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8)) \ looks correct, but a bit ugly. How about: ``` // X86_64 #if (defined __x86_64__) && (defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16) #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP 1 // X86 #elif !(defined __x86_64__) && (defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8) #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP 1 #endif #if __X86_ISA_V1 && defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP ... ``` ? > && defined HAVE_X86_LAHF_SAHF && defined __POPCNT__ && defined __SSE3__ \ > && defined __SSSE3__ && defined __SSE4_1__ && defined __SSE4_2__ > /* NB: ISAs in x86-64 ISA level v2 are used. */ > -- > 2.45.2 >
diff --git a/sysdeps/x86/configure b/sysdeps/x86/configure index 1e2325d0d7..04c6ba3e6c 100644 --- a/sysdeps/x86/configure +++ b/sysdeps/x86/configure @@ -141,8 +141,10 @@ libc_cv_have_x86_isa_level=3 libc_cv_have_x86_isa_level=2 #elif defined __x86_64__ libc_cv_have_x86_isa_level=baseline +#elif MINIMUM_X86_ISA_LEVEL == 1 +libc_cv_have_x86_isa_level=1 #else -libc_cv_have_x86_isa_level=MINIMUM_X86_ISA_LEVEL +libc_cv_have_x86_isa_level=0 #endif EOF eval `${CC-cc} $CFLAGS $CPPFLAGS $ISAFLAG -I$srcdir -E conftest.c | grep libc_cv_have_x86_isa_level` diff --git a/sysdeps/x86/configure.ac b/sysdeps/x86/configure.ac index 0b32fdfd4f..8a259d3971 100644 --- a/sysdeps/x86/configure.ac +++ b/sysdeps/x86/configure.ac @@ -98,8 +98,10 @@ libc_cv_have_x86_isa_level=3 libc_cv_have_x86_isa_level=2 #elif defined __x86_64__ libc_cv_have_x86_isa_level=baseline +#elif MINIMUM_X86_ISA_LEVEL == 1 +libc_cv_have_x86_isa_level=1 #else -libc_cv_have_x86_isa_level=MINIMUM_X86_ISA_LEVEL +libc_cv_have_x86_isa_level=0 #endif EOF eval `${CC-cc} $CFLAGS $CPPFLAGS $ISAFLAG -I$srcdir -E conftest.c | grep libc_cv_have_x86_isa_level` diff --git a/sysdeps/x86/isa-level.h b/sysdeps/x86/isa-level.h index 2c7f74212b..fe1f0924e4 100644 --- a/sysdeps/x86/isa-level.h +++ b/sysdeps/x86/isa-level.h @@ -35,7 +35,11 @@ # define __X86_ISA_V1 0 #endif -#if __X86_ISA_V1 && defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 \ +#if __X86_ISA_V1 \ + && ((defined __x86_64__ \ + && defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16) \ + || (!defined __x86_64__ \ + && defined __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8)) \ && defined HAVE_X86_LAHF_SAHF && defined __POPCNT__ && defined __SSE3__ \ && defined __SSSE3__ && defined __SSE4_1__ && defined __SSE4_2__ /* NB: ISAs in x86-64 ISA level v2 are used. */
Properly set libc_cv_have_x86_isa_level in shell for MINIMUM_X86_ISA_LEVEL defined as (__X86_ISA_V1 + __X86_ISA_V2 + __X86_ISA_V3 + __X86_ISA_V4) Also set __X86_ISA_V2 to 1 for i386 if __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 is defined. There are no changes in config.h nor in config.make on x86-64. On i386, -march=x86-64-v2 with GCC generates #define MINIMUM_X86_ISA_LEVEL 2 in config.h and have-x86-isa-level = 2 in config.make. This fixes BZ #31883. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> --- sysdeps/x86/configure | 4 +++- sysdeps/x86/configure.ac | 4 +++- sysdeps/x86/isa-level.h | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-)