On Thu, Jan 14, 2021 at 04:08:20PM -0800, H.J. Lu wrote:
> Here is the updated patch.  OK for master?

Here is my version of the entire patch.

Bootstrapped/regtested on x86_64-linux and i686-linux and additionally
tested with i686-linux --with-arch=i386 and x86_64-linux --with-arch_32=i386
(non-bootstrap) builds to verify -march=i486 additions in that case.

Ok for trunk?

2021-01-15  Jakub Jelinek  <ja...@redhat.com>

        PR target/70454
        * configure.tgt: For i?86 and x86_64 determine if -march=i486 needs to
        be added through preprocessor check on
        __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4.  Determine if try_ifunc is needed
        based on preprocessor check on __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16
        or __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8.

        * configure.tgt: For i?86 and x86_64 determine if -march=i486 needs to
        be added through preprocessor check on
        __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4.

        * configure.tgt: For i?86 and x86_64 determine if -march=i486 needs to
        be added through preprocessor check on
        __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4.

--- libatomic/configure.tgt.jj  2021-01-15 11:08:13.659545929 +0100
+++ libatomic/configure.tgt     2021-01-15 11:21:09.071740967 +0100
@@ -81,32 +81,40 @@ case "${target_cpu}" in
        ARCH=sparc
        ;;
 
-  i[3456]86)
-       case " ${CC} ${CFLAGS} " in
-         *" -m64 "*|*" -mx32 "*)
-           ;;
-         *)
-           if test -z "$with_arch"; then
-             XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
-             XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
-           fi
-       esac
-       ARCH=x86
-       # ??? Detect when -march=i686 is already enabled.
-       try_ifunc=yes
-       ;;
-  x86_64)
-       case " ${CC} ${CFLAGS} " in
-         *" -m32 "*)
+  i[3456]86 | x86_64)
+       cat > conftestx.c <<EOF
+#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+#error need -march=i486
+#endif
+EOF
+       if ${CC} ${CFLAGS} -E conftestx.c > /dev/null 2>&1; then
+         :
+       else
+         if test "${target_cpu}" = x86_64; then
            XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
-           XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
-           ;;
-         *)
-           ;;
-       esac
+         else
+           XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
+         fi
+         XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
+       fi
+       cat > conftestx.c <<EOF
+#ifdef __x86_64__
+#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16
+#error need -mcx16
+#endif
+#else
+#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
+#error need -march=i686
+#endif
+#endif
+EOF
+       if ${CC} ${CFLAGS} -E conftestx.c > /dev/null 2>&1; then
+         try_ifunc=no
+       else
+         try_ifunc=yes
+       fi
+       rm -f conftestx.c
        ARCH=x86
-       # ??? Detect when -mcx16 is already enabled.
-       try_ifunc=yes
        ;;
 
   *)                   ARCH="${target_cpu}" ;;
--- libgomp/configure.tgt.jj    2021-01-15 11:08:13.659545929 +0100
+++ libgomp/configure.tgt       2021-01-15 11:20:54.809902917 +0100
@@ -73,28 +73,23 @@ if test x$enable_linux_futex = xyes; the
        ;;
 
     # Note that bare i386 is not included here.  We need cmpxchg.
-    i[456]86-*-linux*)
+    i[456]86-*-linux* | x86_64-*-linux*)
        config_path="linux/x86 linux posix"
-       case " ${CC} ${CFLAGS} " in
-         *" -m64 "*|*" -mx32 "*)
-           ;;
-         *)
-           if test -z "$with_arch"; then
-             XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
-           fi
-       esac
-       ;;
-
-    # Similar jiggery-pokery for x86_64 multilibs, except here we
-    # can't rely on the --with-arch configure option, since that
-    # applies to the 64-bit side.
-    x86_64-*-linux*)
-       config_path="linux/x86 linux posix"
-       case " ${CC} ${CFLAGS} " in
-         *" -m32 "*)
+       cat > conftestx.c <<EOF
+#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+#error need -march=i486
+#endif
+EOF
+       if ${CC} ${CFLAGS} -E conftestx.c > /dev/null 2>&1; then
+         :
+       else
+         if test "${target_cpu}" = x86_64; then
            XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
-           ;;
-       esac
+         else
+           XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
+         fi
+       fi
+       rm -f conftestx.c
        ;;
 
     # Note that sparcv7 and sparcv8 is not included here.  We need cas.
--- libitm/configure.tgt.jj     2021-01-15 11:08:13.659545929 +0100
+++ libitm/configure.tgt        2021-01-15 11:21:28.611519095 +0100
@@ -59,16 +59,23 @@ case "${target_cpu}" in
 
   arm*)                ARCH=arm ;;
 
-  i[3456]86)
-       case " ${CC} ${CFLAGS} " in
-         *" -m64 "*|*" -mx32 "*)
-           ;;
-         *)
-           if test -z "$with_arch"; then
-             XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
-             XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
-           fi
-       esac
+  i[3456]86 | x86_64)
+       cat > conftestx.c <<EOF
+#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+#error need -march=i486
+#endif
+EOF
+       if ${CC} ${CFLAGS} -E conftestx.c > /dev/null 2>&1; then
+         :
+       else
+         if test "${target_cpu}" = x86_64; then
+           XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
+         else
+           XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
+         fi
+         XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
+       fi
+       rm -f conftestx.c
        XCFLAGS="${XCFLAGS} -mrtm"
        ARCH=x86
        ;;
@@ -103,16 +110,6 @@ case "${target_cpu}" in
        ARCH=sparc
        ;;
 
-  x86_64)
-       case " ${CC} ${CFLAGS} " in
-         *" -m32 "*)
-           XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
-           XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
-           ;;
-       esac
-       XCFLAGS="${XCFLAGS} -mrtm"
-       ARCH=x86
-       ;;
   s390|s390x)
        XCFLAGS="${XCFLAGS} -mzarch -mhtm"
        ARCH=s390


        Jakub

Reply via email to