* [PATCH 0/3] Build x86 libitm/libgomp/libatomic with -march=i486 or better
@ 2021-01-14 21:04 H.J. Lu
2021-01-14 21:04 ` [PATCH 1/3] Build x86 libitm " H.J. Lu
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: H.J. Lu @ 2021-01-14 21:04 UTC (permalink / raw)
To: gcc-patches; +Cc: Uros Bizjak, Jakub Jelinek
Starting from
commit 77d372abec0fbf2cfe922e3140ee3410248f979e
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Thu Jan 14 05:56:46 2021 -0800
x86: Error on -fcf-protection with incompatible target
GCC issues an error on -fcf-protection with incompatible target. CET
is enabled in run-time libraries on x86 when GCC is configured with
--with-arch=XXX
where XXX enables SSE2. But libitm/libgomp/libatomic are hardcoded to
compile with -march=i486 which is incompatible with CET. We should
compile libitm/libgomp/libatomic -march=i486 only if the default -march=
is lower than i486.
H.J. Lu (3):
Build x86 libitm with -march=i486 or better
Build x86 libgomp with -march=i486 or better
Build x86 libatomic with -march=i486 or better
libatomic/configure.tgt | 73 ++++++++++++++++++++++++++++-------------
libgomp/configure.tgt | 36 +++++++++-----------
libitm/configure.tgt | 39 +++++++++++-----------
3 files changed, 85 insertions(+), 63 deletions(-)
--
2.29.2
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/3] Build x86 libitm with -march=i486 or better
2021-01-14 21:04 [PATCH 0/3] Build x86 libitm/libgomp/libatomic with -march=i486 or better H.J. Lu
@ 2021-01-14 21:04 ` H.J. Lu
2021-01-14 21:04 ` [PATCH 2/3] Build x86 libgomp " H.J. Lu
2021-01-14 21:04 ` [PATCH 3/3] Build x86 libatomic " H.J. Lu
2 siblings, 0 replies; 10+ messages in thread
From: H.J. Lu @ 2021-01-14 21:04 UTC (permalink / raw)
To: gcc-patches; +Cc: Uros Bizjak, Jakub Jelinek
If x86 libitm isn't compiled with -march=i486 or better, append
-march=i486 XCFLAGS for x86 libitm build.
PR target/70454
* configure.tgt (XCFLAGS): Append -march=i486 to compile x86
libitm if needed.
---
libitm/configure.tgt | 39 +++++++++++++++++++--------------------
1 file changed, 19 insertions(+), 20 deletions(-)
diff --git a/libitm/configure.tgt b/libitm/configure.tgt
index 6ac206f1005..316896c1b31 100644
--- a/libitm/configure.tgt
+++ b/libitm/configure.tgt
@@ -59,16 +59,25 @@ 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)
+ # Need i486 or better.
+ cat > conftestx.c <<EOF
+#if defined __x86_64__ || defined __i486__ || defined __pentium__ \
+ || defined __pentiumpro__ || defined __pentium4__ \
+ || defined __geode__ || defined __SSE__
+# error Need i486 or better
+#endif
+EOF
+ if ${CC} ${CFLAGS} -c -o conftestx.o conftestx.c > /dev/null 2>&1; then
+ if test "${target_cpu}" = x86_64; then
+ XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
+ XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
+ else
+ XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
+ XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
+ fi
+ fi
+ rm -f conftestx.c conftestx.o
XCFLAGS="${XCFLAGS} -mrtm"
ARCH=x86
;;
@@ -103,16 +112,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
--
2.29.2
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/3] Build x86 libgomp with -march=i486 or better
2021-01-14 21:04 [PATCH 0/3] Build x86 libitm/libgomp/libatomic with -march=i486 or better H.J. Lu
2021-01-14 21:04 ` [PATCH 1/3] Build x86 libitm " H.J. Lu
@ 2021-01-14 21:04 ` H.J. Lu
2021-01-14 21:04 ` [PATCH 3/3] Build x86 libatomic " H.J. Lu
2 siblings, 0 replies; 10+ messages in thread
From: H.J. Lu @ 2021-01-14 21:04 UTC (permalink / raw)
To: gcc-patches; +Cc: Uros Bizjak, Jakub Jelinek
If x86 libgomp isn't compiled with -march=i486 or better, append
-march=i486 XCFLAGS for x86 libgomp build.
PR target/70454
* configure.tgt (XCFLAGS): Append -march=i486 to compile x86
libgomp if needed.
---
libgomp/configure.tgt | 36 ++++++++++++++++--------------------
1 file changed, 16 insertions(+), 20 deletions(-)
diff --git a/libgomp/configure.tgt b/libgomp/configure.tgt
index 1863287fa0d..83b5f92727d 100644
--- a/libgomp/configure.tgt
+++ b/libgomp/configure.tgt
@@ -73,28 +73,24 @@ if test x$enable_linux_futex = xyes; then
;;
# 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}"
+ # Need i486 or better.
+ cat > conftestx.c <<EOF
+#if defined __x86_64__ || defined __i486__ || defined __pentium__ \
+ || defined __pentiumpro__ || defined __pentium4__ \
+ || defined __geode__ || defined __SSE__
+# error Need i486 or better
+#endif
+EOF
+ if ${CC} ${CFLAGS} -c -o conftestx.o conftestx.c > /dev/null 2>&1; then
+ if test "${target_cpu}" = x86_64; then
+ XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
+ else
+ 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 "*)
- XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
- ;;
- esac
+ fi
+ rm -f conftestx.c conftestx.o
;;
# Note that sparcv7 and sparcv8 is not included here. We need cas.
--
2.29.2
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 3/3] Build x86 libatomic with -march=i486 or better
2021-01-14 21:04 [PATCH 0/3] Build x86 libitm/libgomp/libatomic with -march=i486 or better H.J. Lu
2021-01-14 21:04 ` [PATCH 1/3] Build x86 libitm " H.J. Lu
2021-01-14 21:04 ` [PATCH 2/3] Build x86 libgomp " H.J. Lu
@ 2021-01-14 21:04 ` H.J. Lu
2021-01-14 23:01 ` Jakub Jelinek
2 siblings, 1 reply; 10+ messages in thread
From: H.J. Lu @ 2021-01-14 21:04 UTC (permalink / raw)
To: gcc-patches; +Cc: Uros Bizjak, Jakub Jelinek
If x86 libatomic isn't compiled with -march=i486 or better, append
-march=i486 XCFLAGS for x86 libatomic build. Set try_ifunc to yes
if -mcx16 isn't used to compile x86-64 libatomic or -march=i686 or
better isn't used to compile x86 libatomic.
PR target/70454
* configure.tgt (XCFLAGS): Append -march=i486 to compile x86
libatomic if needed.
(try_ifunc): Set to yes only if needed.
---
libatomic/configure.tgt | 73 ++++++++++++++++++++++++++++-------------
1 file changed, 50 insertions(+), 23 deletions(-)
diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
index 2f24817b454..1f3a3ad6c7c 100644
--- a/libatomic/configure.tgt
+++ b/libatomic/configure.tgt
@@ -81,32 +81,59 @@ 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)
+ # Need i486 or better.
+ cat > conftestx.c <<EOF
+#if defined __x86_64__ || defined __i486__ || defined __pentium__ \
+ || defined __pentiumpro__ || defined __pentium4__ \
+ || defined __geode__ || defined __SSE__
+# error Need i486 or better
+#endif
+EOF
+ if ${CC} ${CFLAGS} -c -o conftestx.o conftestx.c > /dev/null 2>&1; then
+ 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}"
+ XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
+ fi
+ fi
+ # Detect if -march=i686/-mcx16 is already enabled.
+ cat > conftestx.c <<EOF
+#if defined __x86_64__
+__int128_t v = 0;
+__int128_t expected = 0;
+__int128_t max = ~0;
+__int128_t desired = ~0;
+__int128_t zero = 0;
+
+int
+foo (void)
+{
+ return !__atomic_compare_exchange_n (&v, &expected, max, 0,
+ __ATOMIC_RELAXED,
+ __ATOMIC_RELAXED);
+}
+#else
+# if defined __pentiumpro__ || defined __pentium4__ || defined __SSE__
+asm ("# has i686");
+# endif
+#endif
+EOF
+ if ${CC} ${CFLAGS} -S -o conftestx.s conftestx.c > /dev/null 2>&1; then
+ if ${GREP} cmpxchg16b conftestx.s >/dev/null; then
+ # This is the 64-bit library.
+ try_ifunc=no
+ elif ${GREP} i686 conftestx.s >/dev/null; then
+ # This is the 32-bit library.
+ try_ifunc=no
+ else
+ try_ifunc=yes
+ fi
+ fi
+ rm -f conftestx.c conftestx.o conftestx.s
ARCH=x86
- # ??? Detect when -mcx16 is already enabled.
- try_ifunc=yes
;;
*) ARCH="${target_cpu}" ;;
--
2.29.2
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] Build x86 libatomic with -march=i486 or better
2021-01-14 21:04 ` [PATCH 3/3] Build x86 libatomic " H.J. Lu
@ 2021-01-14 23:01 ` Jakub Jelinek
2021-01-15 0:08 ` V2 " H.J. Lu
0 siblings, 1 reply; 10+ messages in thread
From: Jakub Jelinek @ 2021-01-14 23:01 UTC (permalink / raw)
To: H.J. Lu; +Cc: gcc-patches, Uros Bizjak
On Thu, Jan 14, 2021 at 01:04:31PM -0800, H.J. Lu via Gcc-patches wrote:
> If x86 libatomic isn't compiled with -march=i486 or better, append
> -march=i486 XCFLAGS for x86 libatomic build. Set try_ifunc to yes
> if -mcx16 isn't used to compile x86-64 libatomic or -march=i686 or
> better isn't used to compile x86 libatomic.
>
> PR target/70454
> * configure.tgt (XCFLAGS): Append -march=i486 to compile x86
> libatomic if needed.
> (try_ifunc): Set to yes only if needed.
> ---
> libatomic/configure.tgt | 73 ++++++++++++++++++++++++++++-------------
> 1 file changed, 50 insertions(+), 23 deletions(-)
>
> diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
> index 2f24817b454..1f3a3ad6c7c 100644
> --- a/libatomic/configure.tgt
> +++ b/libatomic/configure.tgt
> @@ -81,32 +81,59 @@ 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)
> + # Need i486 or better.
> + cat > conftestx.c <<EOF
> +#if defined __x86_64__ || defined __i486__ || defined __pentium__ \
> + || defined __pentiumpro__ || defined __pentium4__ \
> + || defined __geode__ || defined __SSE__
> +# error Need i486 or better
> +#endif
Rather than hoping we got all the defines right, wouldn't it be better to
compile with -S a testcase like:
int
foo (int *p, int x, int y)
{
return __sync_val_compare_and_swap (p, x, y);
}
and if there is __sync_val_compare_and_swap_4 in the assembly assume
-march=i486 needs to be added?
I.e. test for what exactly we need (working atomics).
Jakub
^ permalink raw reply [flat|nested] 10+ messages in thread
* V2 [PATCH 3/3] Build x86 libatomic with -march=i486 or better
2021-01-14 23:01 ` Jakub Jelinek
@ 2021-01-15 0:08 ` H.J. Lu
2021-01-15 7:59 ` Jakub Jelinek
2021-01-15 11:54 ` [PATCH] libatomic, libgomp, libitc: Fix bootstrap [PR70454] Jakub Jelinek
0 siblings, 2 replies; 10+ messages in thread
From: H.J. Lu @ 2021-01-15 0:08 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: GCC Patches, Uros Bizjak
[-- Attachment #1: Type: text/plain, Size: 2294 bytes --]
On Thu, Jan 14, 2021 at 3:01 PM Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Thu, Jan 14, 2021 at 01:04:31PM -0800, H.J. Lu via Gcc-patches wrote:
> > If x86 libatomic isn't compiled with -march=i486 or better, append
> > -march=i486 XCFLAGS for x86 libatomic build. Set try_ifunc to yes
> > if -mcx16 isn't used to compile x86-64 libatomic or -march=i686 or
> > better isn't used to compile x86 libatomic.
> >
> > PR target/70454
> > * configure.tgt (XCFLAGS): Append -march=i486 to compile x86
> > libatomic if needed.
> > (try_ifunc): Set to yes only if needed.
> > ---
> > libatomic/configure.tgt | 73 ++++++++++++++++++++++++++++-------------
> > 1 file changed, 50 insertions(+), 23 deletions(-)
> >
> > diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
> > index 2f24817b454..1f3a3ad6c7c 100644
> > --- a/libatomic/configure.tgt
> > +++ b/libatomic/configure.tgt
> > @@ -81,32 +81,59 @@ 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)
> > + # Need i486 or better.
> > + cat > conftestx.c <<EOF
> > +#if defined __x86_64__ || defined __i486__ || defined __pentium__ \
> > + || defined __pentiumpro__ || defined __pentium4__ \
> > + || defined __geode__ || defined __SSE__
> > +# error Need i486 or better
> > +#endif
>
> Rather than hoping we got all the defines right, wouldn't it be better to
> compile with -S a testcase like:
> int
> foo (int *p, int x, int y)
> {
> return __sync_val_compare_and_swap (p, x, y);
> }
> and if there is __sync_val_compare_and_swap_4 in the assembly assume
> -march=i486 needs to be added?
> I.e. test for what exactly we need (working atomics).
>
> Jakub
>
Here is the updated patch. OK for master?
Thanks.
--
H.J.
[-- Attachment #2: 0001-Build-x86-libatomic-with-march-i486-or-better.patch --]
[-- Type: text/x-patch, Size: 2972 bytes --]
From f847185c4faa94b6dbb52327c13d5d5bfec9b259 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Mon, 2 May 2016 09:44:07 -0700
Subject: [PATCH] Build x86 libatomic with -march=i486 or better
If x86 libatomic isn't compiled with -march=i486 or better, append
-march=i486 XCFLAGS for x86 libatomic build. Set try_ifunc to yes
if -mcx16 isn't used to compile x86-64 libatomic or -march=i686 or
better isn't used to compile x86 libatomic.
PR target/70454
* configure.tgt (XCFLAGS): Append -march=i486 to compile x86
libatomic if needed.
(try_ifunc): Set to yes only if needed.
---
libatomic/configure.tgt | 74 ++++++++++++++++++++++++++++-------------
1 file changed, 51 insertions(+), 23 deletions(-)
diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
index 2f24817b454..3530c992264 100644
--- a/libatomic/configure.tgt
+++ b/libatomic/configure.tgt
@@ -81,32 +81,60 @@ 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)
+ # Need i486 or better.
+ cat > conftestx.c <<EOF
+int
+foo (int *p, int x, int y)
+{
+ return __sync_val_compare_and_swap (p, x, y);
+}
+EOF
+ if ${CC} ${CFLAGS} -S conftestx.c > /dev/null 2>&1 \
+ && grep -q __sync_val_compare_and_swap conftestx.s /dev/null; then
+ 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}"
+ XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
+ fi
+ fi
+ # Detect if -march=i686/-mcx16 is already enabled.
+ cat > conftestx.c <<EOF
+#if defined __x86_64__
+__int128_t v = 0;
+__int128_t expected = 0;
+__int128_t max = ~0;
+__int128_t desired = ~0;
+__int128_t zero = 0;
+
+int
+foo (void)
+{
+ return !__atomic_compare_exchange_n (&v, &expected, max, 0,
+ __ATOMIC_RELAXED,
+ __ATOMIC_RELAXED);
+}
+#else
+# if defined __pentiumpro__ || defined __pentium4__ || defined __SSE__
+asm ("# has i686");
+# endif
+#endif
+EOF
+ if ${CC} ${CFLAGS} -S -o conftestx.s conftestx.c > /dev/null 2>&1; then
+ if grep cmpxchg16b conftestx.s >/dev/null; then
+ # This is the 64-bit library.
+ try_ifunc=no
+ elif grep i686 conftestx.s >/dev/null; then
+ # This is the 32-bit library.
+ try_ifunc=no
+ else
+ try_ifunc=yes
+ fi
+ fi
+ rm -f conftestx.c conftestx.s
ARCH=x86
- # ??? Detect when -mcx16 is already enabled.
- try_ifunc=yes
;;
*) ARCH="${target_cpu}" ;;
--
2.29.2
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: V2 [PATCH 3/3] Build x86 libatomic with -march=i486 or better
2021-01-15 0:08 ` V2 " H.J. Lu
@ 2021-01-15 7:59 ` Jakub Jelinek
2021-01-15 11:54 ` [PATCH] libatomic, libgomp, libitc: Fix bootstrap [PR70454] Jakub Jelinek
1 sibling, 0 replies; 10+ messages in thread
From: Jakub Jelinek @ 2021-01-15 7:59 UTC (permalink / raw)
To: H.J. Lu; +Cc: GCC Patches, Uros Bizjak
On Thu, Jan 14, 2021 at 04:08:20PM -0800, H.J. Lu wrote:
I think best would be to revert the i386-options.c change
until this is all fixed, keeping the trunk broken too long is undesirable.
Second, I didn't mean to talk specifically about libatomic, but about all
the 3 configure.tgt changes.
And while for the i486 and cmpxchg16b cases you now use a functional test,
for the i686 test you still use macros, and I don't e.g. see how __SSE__ is
relevant, one could have in CFLAGS -march=skylake-avx512 -mno-sse and it
wouldn't be considered an i686.
Now that I look at it, I think what you should be looking at is whether
the compiler with the ${CC} ${CFLAGS} predefines:
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 - if not, then -march=i486 needs to be
added,
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 for 32-bit code resp.
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 for 64-bit code, then
maybe try_ifunc=no (but it needs verification that the code will in the end
always use cmpxchg8b or cmpxchg16b rather than never).
Jakub
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] libatomic, libgomp, libitc: Fix bootstrap [PR70454]
2021-01-15 0:08 ` V2 " H.J. Lu
2021-01-15 7:59 ` Jakub Jelinek
@ 2021-01-15 11:54 ` Jakub Jelinek
2021-01-15 12:07 ` Richard Biener
1 sibling, 1 reply; 10+ messages in thread
From: Jakub Jelinek @ 2021-01-15 11:54 UTC (permalink / raw)
To: Richard Biener, Uros Bizjak, H.J. Lu; +Cc: GCC Patches
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 <jakub@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
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] libatomic, libgomp, libitc: Fix bootstrap [PR70454]
2021-01-15 11:54 ` [PATCH] libatomic, libgomp, libitc: Fix bootstrap [PR70454] Jakub Jelinek
@ 2021-01-15 12:07 ` Richard Biener
2021-01-15 12:35 ` H.J. Lu
0 siblings, 1 reply; 10+ messages in thread
From: Richard Biener @ 2021-01-15 12:07 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Uros Bizjak, H.J. Lu, GCC Patches
On Fri, 15 Jan 2021, Jakub Jelinek wrote:
> 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?
OK.
Thanks,
Richard.
> 2021-01-15 Jakub Jelinek <jakub@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
>
>
--
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] libatomic, libgomp, libitc: Fix bootstrap [PR70454]
2021-01-15 12:07 ` Richard Biener
@ 2021-01-15 12:35 ` H.J. Lu
0 siblings, 0 replies; 10+ messages in thread
From: H.J. Lu @ 2021-01-15 12:35 UTC (permalink / raw)
To: Richard Biener; +Cc: Jakub Jelinek, Uros Bizjak, GCC Patches
On Fri, Jan 15, 2021 at 4:07 AM Richard Biener <rguenther@suse.de> wrote:
>
> On Fri, 15 Jan 2021, Jakub Jelinek wrote:
>
> > 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?
>
> OK.
>
Thanks.
--
H.J.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-01-15 12:35 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-14 21:04 [PATCH 0/3] Build x86 libitm/libgomp/libatomic with -march=i486 or better H.J. Lu
2021-01-14 21:04 ` [PATCH 1/3] Build x86 libitm " H.J. Lu
2021-01-14 21:04 ` [PATCH 2/3] Build x86 libgomp " H.J. Lu
2021-01-14 21:04 ` [PATCH 3/3] Build x86 libatomic " H.J. Lu
2021-01-14 23:01 ` Jakub Jelinek
2021-01-15 0:08 ` V2 " H.J. Lu
2021-01-15 7:59 ` Jakub Jelinek
2021-01-15 11:54 ` [PATCH] libatomic, libgomp, libitc: Fix bootstrap [PR70454] Jakub Jelinek
2021-01-15 12:07 ` Richard Biener
2021-01-15 12:35 ` H.J. Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).