public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH] gcc: Add patch to resolve i*86 tune configuration overrides
@ 2020-12-15  8:34 Nathan Rossi
  2020-12-15 17:11 ` [OE-core] " Khem Raj
  2021-01-15 17:39 ` Khem Raj
  0 siblings, 2 replies; 5+ messages in thread
From: Nathan Rossi @ 2020-12-15  8:34 UTC (permalink / raw)
  To: openembedded-core; +Cc: Nathan Rossi

When compiling gcc-runtime for i686 libatomic, libgomp and libitm are
compiled with additional '-march' and '-mtune' overrides. This typically
does not cause build errors (e.g. core2-32 tune), and results in less
optimally tuned outputs. However with specific TUNE_CCARGS (e.g. has
'-mfpmath=sse' but not '-msse*'), the build errors with conflicting
'-mfpmath' options.

This is caused by gcc-runtime specific configure scripts and Makefile
options that override by adding additional '-march'/'-mtune' args. OE
builds gcc-runtime differently to other build systems, and provides
target specific arch/tune options directly. As such, this change adds a
patch for gcc to remove the specific cases where the args are added.

Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
---
 meta/recipes-devtools/gcc/gcc-10.2.inc             |   1 +
 .../gcc/0001-lib-Remove-i-86-march-overrides.patch | 113 +++++++++++++++++++++
 2 files changed, 114 insertions(+)
 create mode 100644 meta/recipes-devtools/gcc/gcc/0001-lib-Remove-i-86-march-overrides.patch

diff --git a/meta/recipes-devtools/gcc/gcc-10.2.inc b/meta/recipes-devtools/gcc/gcc-10.2.inc
index e88f2ade6d..1e69c91311 100644
--- a/meta/recipes-devtools/gcc/gcc-10.2.inc
+++ b/meta/recipes-devtools/gcc/gcc-10.2.inc
@@ -69,6 +69,7 @@ SRC_URI = "\
            file://0002-aarch64-Introduce-SLS-mitigation-for-RET-and-BR-inst.patch \
            file://0003-aarch64-Mitigate-SLS-for-BLR-instruction.patch \
            file://0001-aarch64-Fix-up-__aarch64_cas16_acq_rel-fallback.patch \
+           file://0001-lib-Remove-i-86-march-overrides.patch \
 "
 SRC_URI[sha256sum] = "b8dd4368bb9c7f0b98188317ee0254dd8cc99d1e3a18d0ff146c855fe16c1d8c"
 
diff --git a/meta/recipes-devtools/gcc/gcc/0001-lib-Remove-i-86-march-overrides.patch b/meta/recipes-devtools/gcc/gcc/0001-lib-Remove-i-86-march-overrides.patch
new file mode 100644
index 0000000000..3f04e121ba
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc/0001-lib-Remove-i-86-march-overrides.patch
@@ -0,0 +1,113 @@
+From 3776789cde95916f95deef48acf9532b0ebf91ae Mon Sep 17 00:00:00 2001
+From: Nathan Rossi <nathan@nathanrossi.com>
+Date: Tue, 15 Dec 2020 11:43:36 +1000
+Subject: [PATCH] lib*: Remove i*86 march overrides
+
+OE does not pass the '--with-arch' option to gccs configure, as such
+some gcc-runtime libraries try to override the value of '-march' and
+'-mtune' which OE already provides. This causes conflicts with other
+i*86 instruction/architecture flags (e.g. -msse* and -mfpmath=*).
+Additionally this caused the following libraries to be built with less
+optimized tune configurations.
+
+Upstream suggests that this should be detecting or otherwise checking if
+the target supports the desired functionality before overriding.
+
+    https://gcc.gnu.org/legacy-ml/gcc-patches/2016-04/msg01344.html
+
+libatomic also overrides the '-march' specifically for IFUNC objects.
+OE already supplies the correct march flag, so remove setting.
+
+Upstream-Status: Inappropriate [OE Specific]
+Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
+---
+ libatomic/Makefile.am   | 1 -
+ libatomic/Makefile.in   | 1 -
+ libatomic/configure.tgt | 9 ---------
+ libgomp/configure.tgt   | 8 --------
+ libitm/configure.tgt    | 9 ---------
+ 5 files changed, 28 deletions(-)
+
+diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am
+index ac1ca64587..5aa16e0699 100644
+--- a/libatomic/Makefile.am
++++ b/libatomic/Makefile.am
+@@ -133,7 +133,6 @@ libatomic_la_LIBADD += $(foreach s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS))
+ libatomic_la_LIBADD += $(addsuffix _8_2_.lo,$(SIZEOBJS))
+ endif
+ if ARCH_I386
+-IFUNC_OPTIONS	     = -march=i586
+ libatomic_la_LIBADD += $(addsuffix _8_1_.lo,$(SIZEOBJS))
+ endif
+ if ARCH_X86_64
+diff --git a/libatomic/Makefile.in b/libatomic/Makefile.in
+index 97df2d7ff0..82c511d420 100644
+--- a/libatomic/Makefile.in
++++ b/libatomic/Makefile.in
+@@ -432,7 +432,6 @@ libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix \
+ 	_$(s)_.lo,$(SIZEOBJS))) $(am__append_1) $(am__append_2) \
+ 	$(am__append_3) $(am__append_4)
+ @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=armv7-a+fp -DHAVE_KERNEL64
+-@ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=i586
+ @ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -mcx16
+ libatomic_convenience_la_SOURCES = $(libatomic_la_SOURCES)
+ libatomic_convenience_la_LIBADD = $(libatomic_la_LIBADD)
+diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
+index 5dd0926d20..3cc41773c3 100644
+--- a/libatomic/configure.tgt
++++ b/libatomic/configure.tgt
+@@ -82,15 +82,6 @@ case "${target_cpu}" in
+ 	;;
+ 
+   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
+diff --git a/libgomp/configure.tgt b/libgomp/configure.tgt
+index 4790a31e39..46c4c958e6 100644
+--- a/libgomp/configure.tgt
++++ b/libgomp/configure.tgt
+@@ -72,14 +72,6 @@ if test x$enable_linux_futex = xyes; then
+     # Note that bare i386 is not included here.  We need cmpxchg.
+     i[456]86-*-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
+diff --git a/libitm/configure.tgt b/libitm/configure.tgt
+index 04109160e9..3d78ea609d 100644
+--- a/libitm/configure.tgt
++++ b/libitm/configure.tgt
+@@ -59,15 +59,6 @@ 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
+ 	XCFLAGS="${XCFLAGS} -mrtm"
+ 	ARCH=x86
+ 	;;
---
2.29.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [OE-core] [PATCH] gcc: Add patch to resolve i*86 tune configuration overrides
  2020-12-15  8:34 [PATCH] gcc: Add patch to resolve i*86 tune configuration overrides Nathan Rossi
@ 2020-12-15 17:11 ` Khem Raj
  2021-01-15 17:39 ` Khem Raj
  1 sibling, 0 replies; 5+ messages in thread
From: Khem Raj @ 2020-12-15 17:11 UTC (permalink / raw)
  To: openembedded-core



On 12/15/20 12:34 AM, Nathan Rossi wrote:
> When compiling gcc-runtime for i686 libatomic, libgomp and libitm are
> compiled with additional '-march' and '-mtune' overrides. This typically
> does not cause build errors (e.g. core2-32 tune), and results in less
> optimally tuned outputs. However with specific TUNE_CCARGS (e.g. has
> '-mfpmath=sse' but not '-msse*'), the build errors with conflicting
> '-mfpmath' options.
> 
> This is caused by gcc-runtime specific configure scripts and Makefile
> options that override by adding additional '-march'/'-mtune' args. OE
> builds gcc-runtime differently to other build systems, and provides
> target specific arch/tune options directly. As such, this change adds a
> patch for gcc to remove the specific cases where the args are added.
> 

looks fine to me.

> Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
> ---
>   meta/recipes-devtools/gcc/gcc-10.2.inc             |   1 +
>   .../gcc/0001-lib-Remove-i-86-march-overrides.patch | 113 +++++++++++++++++++++
>   2 files changed, 114 insertions(+)
>   create mode 100644 meta/recipes-devtools/gcc/gcc/0001-lib-Remove-i-86-march-overrides.patch
> 
> diff --git a/meta/recipes-devtools/gcc/gcc-10.2.inc b/meta/recipes-devtools/gcc/gcc-10.2.inc
> index e88f2ade6d..1e69c91311 100644
> --- a/meta/recipes-devtools/gcc/gcc-10.2.inc
> +++ b/meta/recipes-devtools/gcc/gcc-10.2.inc
> @@ -69,6 +69,7 @@ SRC_URI = "\
>              file://0002-aarch64-Introduce-SLS-mitigation-for-RET-and-BR-inst.patch \
>              file://0003-aarch64-Mitigate-SLS-for-BLR-instruction.patch \
>              file://0001-aarch64-Fix-up-__aarch64_cas16_acq_rel-fallback.patch \
> +           file://0001-lib-Remove-i-86-march-overrides.patch \
>   "
>   SRC_URI[sha256sum] = "b8dd4368bb9c7f0b98188317ee0254dd8cc99d1e3a18d0ff146c855fe16c1d8c"
>   
> diff --git a/meta/recipes-devtools/gcc/gcc/0001-lib-Remove-i-86-march-overrides.patch b/meta/recipes-devtools/gcc/gcc/0001-lib-Remove-i-86-march-overrides.patch
> new file mode 100644
> index 0000000000..3f04e121ba
> --- /dev/null
> +++ b/meta/recipes-devtools/gcc/gcc/0001-lib-Remove-i-86-march-overrides.patch
> @@ -0,0 +1,113 @@
> +From 3776789cde95916f95deef48acf9532b0ebf91ae Mon Sep 17 00:00:00 2001
> +From: Nathan Rossi <nathan@nathanrossi.com>
> +Date: Tue, 15 Dec 2020 11:43:36 +1000
> +Subject: [PATCH] lib*: Remove i*86 march overrides
> +
> +OE does not pass the '--with-arch' option to gccs configure, as such
> +some gcc-runtime libraries try to override the value of '-march' and
> +'-mtune' which OE already provides. This causes conflicts with other
> +i*86 instruction/architecture flags (e.g. -msse* and -mfpmath=*).
> +Additionally this caused the following libraries to be built with less
> +optimized tune configurations.
> +
> +Upstream suggests that this should be detecting or otherwise checking if
> +the target supports the desired functionality before overriding.
> +
> +    https://gcc.gnu.org/legacy-ml/gcc-patches/2016-04/msg01344.html
> +
> +libatomic also overrides the '-march' specifically for IFUNC objects.
> +OE already supplies the correct march flag, so remove setting.
> +
> +Upstream-Status: Inappropriate [OE Specific]
> +Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
> +---
> + libatomic/Makefile.am   | 1 -
> + libatomic/Makefile.in   | 1 -
> + libatomic/configure.tgt | 9 ---------
> + libgomp/configure.tgt   | 8 --------
> + libitm/configure.tgt    | 9 ---------
> + 5 files changed, 28 deletions(-)
> +
> +diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am
> +index ac1ca64587..5aa16e0699 100644
> +--- a/libatomic/Makefile.am
> ++++ b/libatomic/Makefile.am
> +@@ -133,7 +133,6 @@ libatomic_la_LIBADD += $(foreach s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS))
> + libatomic_la_LIBADD += $(addsuffix _8_2_.lo,$(SIZEOBJS))
> + endif
> + if ARCH_I386
> +-IFUNC_OPTIONS	     = -march=i586
> + libatomic_la_LIBADD += $(addsuffix _8_1_.lo,$(SIZEOBJS))
> + endif
> + if ARCH_X86_64
> +diff --git a/libatomic/Makefile.in b/libatomic/Makefile.in
> +index 97df2d7ff0..82c511d420 100644
> +--- a/libatomic/Makefile.in
> ++++ b/libatomic/Makefile.in
> +@@ -432,7 +432,6 @@ libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix \
> + 	_$(s)_.lo,$(SIZEOBJS))) $(am__append_1) $(am__append_2) \
> + 	$(am__append_3) $(am__append_4)
> + @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=armv7-a+fp -DHAVE_KERNEL64
> +-@ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=i586
> + @ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -mcx16
> + libatomic_convenience_la_SOURCES = $(libatomic_la_SOURCES)
> + libatomic_convenience_la_LIBADD = $(libatomic_la_LIBADD)
> +diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
> +index 5dd0926d20..3cc41773c3 100644
> +--- a/libatomic/configure.tgt
> ++++ b/libatomic/configure.tgt
> +@@ -82,15 +82,6 @@ case "${target_cpu}" in
> + 	;;
> +
> +   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
> +diff --git a/libgomp/configure.tgt b/libgomp/configure.tgt
> +index 4790a31e39..46c4c958e6 100644
> +--- a/libgomp/configure.tgt
> ++++ b/libgomp/configure.tgt
> +@@ -72,14 +72,6 @@ if test x$enable_linux_futex = xyes; then
> +     # Note that bare i386 is not included here.  We need cmpxchg.
> +     i[456]86-*-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
> +diff --git a/libitm/configure.tgt b/libitm/configure.tgt
> +index 04109160e9..3d78ea609d 100644
> +--- a/libitm/configure.tgt
> ++++ b/libitm/configure.tgt
> +@@ -59,15 +59,6 @@ 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
> + 	XCFLAGS="${XCFLAGS} -mrtm"
> + 	ARCH=x86
> + 	;;
> ---
> 2.29.2
> 
> 
> 
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [OE-core] [PATCH] gcc: Add patch to resolve i*86 tune configuration overrides
  2020-12-15  8:34 [PATCH] gcc: Add patch to resolve i*86 tune configuration overrides Nathan Rossi
  2020-12-15 17:11 ` [OE-core] " Khem Raj
@ 2021-01-15 17:39 ` Khem Raj
  2021-01-19  1:40   ` Nathan Rossi
  1 sibling, 1 reply; 5+ messages in thread
From: Khem Raj @ 2021-01-15 17:39 UTC (permalink / raw)
  To: Nathan Rossi; +Cc: Patches and discussions about the oe-core layer

Nathan

Can you check if your patch is still needed after

https://github.com/kraj/gcc/commit/0411ae7f08e0f5a8b02ff313d26d27a0f6d1bb34

On Tue, Dec 15, 2020 at 12:35 AM Nathan Rossi <nathan@nathanrossi.com> wrote:
>
> When compiling gcc-runtime for i686 libatomic, libgomp and libitm are
> compiled with additional '-march' and '-mtune' overrides. This typically
> does not cause build errors (e.g. core2-32 tune), and results in less
> optimally tuned outputs. However with specific TUNE_CCARGS (e.g. has
> '-mfpmath=sse' but not '-msse*'), the build errors with conflicting
> '-mfpmath' options.
>
> This is caused by gcc-runtime specific configure scripts and Makefile
> options that override by adding additional '-march'/'-mtune' args. OE
> builds gcc-runtime differently to other build systems, and provides
> target specific arch/tune options directly. As such, this change adds a
> patch for gcc to remove the specific cases where the args are added.
>
> Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
> ---
>  meta/recipes-devtools/gcc/gcc-10.2.inc             |   1 +
>  .../gcc/0001-lib-Remove-i-86-march-overrides.patch | 113 +++++++++++++++++++++
>  2 files changed, 114 insertions(+)
>  create mode 100644 meta/recipes-devtools/gcc/gcc/0001-lib-Remove-i-86-march-overrides.patch
>
> diff --git a/meta/recipes-devtools/gcc/gcc-10.2.inc b/meta/recipes-devtools/gcc/gcc-10.2.inc
> index e88f2ade6d..1e69c91311 100644
> --- a/meta/recipes-devtools/gcc/gcc-10.2.inc
> +++ b/meta/recipes-devtools/gcc/gcc-10.2.inc
> @@ -69,6 +69,7 @@ SRC_URI = "\
>             file://0002-aarch64-Introduce-SLS-mitigation-for-RET-and-BR-inst.patch \
>             file://0003-aarch64-Mitigate-SLS-for-BLR-instruction.patch \
>             file://0001-aarch64-Fix-up-__aarch64_cas16_acq_rel-fallback.patch \
> +           file://0001-lib-Remove-i-86-march-overrides.patch \
>  "
>  SRC_URI[sha256sum] = "b8dd4368bb9c7f0b98188317ee0254dd8cc99d1e3a18d0ff146c855fe16c1d8c"
>
> diff --git a/meta/recipes-devtools/gcc/gcc/0001-lib-Remove-i-86-march-overrides.patch b/meta/recipes-devtools/gcc/gcc/0001-lib-Remove-i-86-march-overrides.patch
> new file mode 100644
> index 0000000000..3f04e121ba
> --- /dev/null
> +++ b/meta/recipes-devtools/gcc/gcc/0001-lib-Remove-i-86-march-overrides.patch
> @@ -0,0 +1,113 @@
> +From 3776789cde95916f95deef48acf9532b0ebf91ae Mon Sep 17 00:00:00 2001
> +From: Nathan Rossi <nathan@nathanrossi.com>
> +Date: Tue, 15 Dec 2020 11:43:36 +1000
> +Subject: [PATCH] lib*: Remove i*86 march overrides
> +
> +OE does not pass the '--with-arch' option to gccs configure, as such
> +some gcc-runtime libraries try to override the value of '-march' and
> +'-mtune' which OE already provides. This causes conflicts with other
> +i*86 instruction/architecture flags (e.g. -msse* and -mfpmath=*).
> +Additionally this caused the following libraries to be built with less
> +optimized tune configurations.
> +
> +Upstream suggests that this should be detecting or otherwise checking if
> +the target supports the desired functionality before overriding.
> +
> +    https://gcc.gnu.org/legacy-ml/gcc-patches/2016-04/msg01344.html
> +
> +libatomic also overrides the '-march' specifically for IFUNC objects.
> +OE already supplies the correct march flag, so remove setting.
> +
> +Upstream-Status: Inappropriate [OE Specific]
> +Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
> +---
> + libatomic/Makefile.am   | 1 -
> + libatomic/Makefile.in   | 1 -
> + libatomic/configure.tgt | 9 ---------
> + libgomp/configure.tgt   | 8 --------
> + libitm/configure.tgt    | 9 ---------
> + 5 files changed, 28 deletions(-)
> +
> +diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am
> +index ac1ca64587..5aa16e0699 100644
> +--- a/libatomic/Makefile.am
> ++++ b/libatomic/Makefile.am
> +@@ -133,7 +133,6 @@ libatomic_la_LIBADD += $(foreach s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS))
> + libatomic_la_LIBADD += $(addsuffix _8_2_.lo,$(SIZEOBJS))
> + endif
> + if ARCH_I386
> +-IFUNC_OPTIONS      = -march=i586
> + libatomic_la_LIBADD += $(addsuffix _8_1_.lo,$(SIZEOBJS))
> + endif
> + if ARCH_X86_64
> +diff --git a/libatomic/Makefile.in b/libatomic/Makefile.in
> +index 97df2d7ff0..82c511d420 100644
> +--- a/libatomic/Makefile.in
> ++++ b/libatomic/Makefile.in
> +@@ -432,7 +432,6 @@ libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix \
> +       _$(s)_.lo,$(SIZEOBJS))) $(am__append_1) $(am__append_2) \
> +       $(am__append_3) $(am__append_4)
> + @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=armv7-a+fp -DHAVE_KERNEL64
> +-@ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=i586
> + @ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -mcx16
> + libatomic_convenience_la_SOURCES = $(libatomic_la_SOURCES)
> + libatomic_convenience_la_LIBADD = $(libatomic_la_LIBADD)
> +diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
> +index 5dd0926d20..3cc41773c3 100644
> +--- a/libatomic/configure.tgt
> ++++ b/libatomic/configure.tgt
> +@@ -82,15 +82,6 @@ case "${target_cpu}" in
> +       ;;
> +
> +   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
> +diff --git a/libgomp/configure.tgt b/libgomp/configure.tgt
> +index 4790a31e39..46c4c958e6 100644
> +--- a/libgomp/configure.tgt
> ++++ b/libgomp/configure.tgt
> +@@ -72,14 +72,6 @@ if test x$enable_linux_futex = xyes; then
> +     # Note that bare i386 is not included here.  We need cmpxchg.
> +     i[456]86-*-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
> +diff --git a/libitm/configure.tgt b/libitm/configure.tgt
> +index 04109160e9..3d78ea609d 100644
> +--- a/libitm/configure.tgt
> ++++ b/libitm/configure.tgt
> +@@ -59,15 +59,6 @@ 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
> +       XCFLAGS="${XCFLAGS} -mrtm"
> +       ARCH=x86
> +       ;;
> ---
> 2.29.2
>
> 
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [OE-core] [PATCH] gcc: Add patch to resolve i*86 tune configuration overrides
  2021-01-15 17:39 ` Khem Raj
@ 2021-01-19  1:40   ` Nathan Rossi
  2021-01-19  5:16     ` Khem Raj
  0 siblings, 1 reply; 5+ messages in thread
From: Nathan Rossi @ 2021-01-19  1:40 UTC (permalink / raw)
  To: Khem Raj; +Cc: Patches and discussions about the oe-core layer

On Sat, 16 Jan 2021 at 03:40, Khem Raj <raj.khem@gmail.com> wrote:
>
> Nathan
>
> Can you check if your patch is still needed after
>
> https://github.com/kraj/gcc/commit/0411ae7f08e0f5a8b02ff313d26d27a0f6d1bb34

Hi Khem,

I tested this change and it resolves the configuration issue. Did you
want the above change backported to replace the oe specific patch?
Since that oe specific patch has already been backported to a number
of releases.

Thanks,
Nathan

>
> On Tue, Dec 15, 2020 at 12:35 AM Nathan Rossi <nathan@nathanrossi.com> wrote:
> >
> > When compiling gcc-runtime for i686 libatomic, libgomp and libitm are
> > compiled with additional '-march' and '-mtune' overrides. This typically
> > does not cause build errors (e.g. core2-32 tune), and results in less
> > optimally tuned outputs. However with specific TUNE_CCARGS (e.g. has
> > '-mfpmath=sse' but not '-msse*'), the build errors with conflicting
> > '-mfpmath' options.
> >
> > This is caused by gcc-runtime specific configure scripts and Makefile
> > options that override by adding additional '-march'/'-mtune' args. OE
> > builds gcc-runtime differently to other build systems, and provides
> > target specific arch/tune options directly. As such, this change adds a
> > patch for gcc to remove the specific cases where the args are added.
> >
> > Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
> > ---
> >  meta/recipes-devtools/gcc/gcc-10.2.inc             |   1 +
> >  .../gcc/0001-lib-Remove-i-86-march-overrides.patch | 113 +++++++++++++++++++++
> >  2 files changed, 114 insertions(+)
> >  create mode 100644 meta/recipes-devtools/gcc/gcc/0001-lib-Remove-i-86-march-overrides.patch
> >
> > diff --git a/meta/recipes-devtools/gcc/gcc-10.2.inc b/meta/recipes-devtools/gcc/gcc-10.2.inc
> > index e88f2ade6d..1e69c91311 100644
> > --- a/meta/recipes-devtools/gcc/gcc-10.2.inc
> > +++ b/meta/recipes-devtools/gcc/gcc-10.2.inc
> > @@ -69,6 +69,7 @@ SRC_URI = "\
> >             file://0002-aarch64-Introduce-SLS-mitigation-for-RET-and-BR-inst.patch \
> >             file://0003-aarch64-Mitigate-SLS-for-BLR-instruction.patch \
> >             file://0001-aarch64-Fix-up-__aarch64_cas16_acq_rel-fallback.patch \
> > +           file://0001-lib-Remove-i-86-march-overrides.patch \
> >  "
> >  SRC_URI[sha256sum] = "b8dd4368bb9c7f0b98188317ee0254dd8cc99d1e3a18d0ff146c855fe16c1d8c"
> >
> > diff --git a/meta/recipes-devtools/gcc/gcc/0001-lib-Remove-i-86-march-overrides.patch b/meta/recipes-devtools/gcc/gcc/0001-lib-Remove-i-86-march-overrides.patch
> > new file mode 100644
> > index 0000000000..3f04e121ba
> > --- /dev/null
> > +++ b/meta/recipes-devtools/gcc/gcc/0001-lib-Remove-i-86-march-overrides.patch
> > @@ -0,0 +1,113 @@
> > +From 3776789cde95916f95deef48acf9532b0ebf91ae Mon Sep 17 00:00:00 2001
> > +From: Nathan Rossi <nathan@nathanrossi.com>
> > +Date: Tue, 15 Dec 2020 11:43:36 +1000
> > +Subject: [PATCH] lib*: Remove i*86 march overrides
> > +
> > +OE does not pass the '--with-arch' option to gccs configure, as such
> > +some gcc-runtime libraries try to override the value of '-march' and
> > +'-mtune' which OE already provides. This causes conflicts with other
> > +i*86 instruction/architecture flags (e.g. -msse* and -mfpmath=*).
> > +Additionally this caused the following libraries to be built with less
> > +optimized tune configurations.
> > +
> > +Upstream suggests that this should be detecting or otherwise checking if
> > +the target supports the desired functionality before overriding.
> > +
> > +    https://gcc.gnu.org/legacy-ml/gcc-patches/2016-04/msg01344.html
> > +
> > +libatomic also overrides the '-march' specifically for IFUNC objects.
> > +OE already supplies the correct march flag, so remove setting.
> > +
> > +Upstream-Status: Inappropriate [OE Specific]
> > +Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
> > +---
> > + libatomic/Makefile.am   | 1 -
> > + libatomic/Makefile.in   | 1 -
> > + libatomic/configure.tgt | 9 ---------
> > + libgomp/configure.tgt   | 8 --------
> > + libitm/configure.tgt    | 9 ---------
> > + 5 files changed, 28 deletions(-)
> > +
> > +diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am
> > +index ac1ca64587..5aa16e0699 100644
> > +--- a/libatomic/Makefile.am
> > ++++ b/libatomic/Makefile.am
> > +@@ -133,7 +133,6 @@ libatomic_la_LIBADD += $(foreach s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS))
> > + libatomic_la_LIBADD += $(addsuffix _8_2_.lo,$(SIZEOBJS))
> > + endif
> > + if ARCH_I386
> > +-IFUNC_OPTIONS      = -march=i586
> > + libatomic_la_LIBADD += $(addsuffix _8_1_.lo,$(SIZEOBJS))
> > + endif
> > + if ARCH_X86_64
> > +diff --git a/libatomic/Makefile.in b/libatomic/Makefile.in
> > +index 97df2d7ff0..82c511d420 100644
> > +--- a/libatomic/Makefile.in
> > ++++ b/libatomic/Makefile.in
> > +@@ -432,7 +432,6 @@ libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix \
> > +       _$(s)_.lo,$(SIZEOBJS))) $(am__append_1) $(am__append_2) \
> > +       $(am__append_3) $(am__append_4)
> > + @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=armv7-a+fp -DHAVE_KERNEL64
> > +-@ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=i586
> > + @ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -mcx16
> > + libatomic_convenience_la_SOURCES = $(libatomic_la_SOURCES)
> > + libatomic_convenience_la_LIBADD = $(libatomic_la_LIBADD)
> > +diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
> > +index 5dd0926d20..3cc41773c3 100644
> > +--- a/libatomic/configure.tgt
> > ++++ b/libatomic/configure.tgt
> > +@@ -82,15 +82,6 @@ case "${target_cpu}" in
> > +       ;;
> > +
> > +   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
> > +diff --git a/libgomp/configure.tgt b/libgomp/configure.tgt
> > +index 4790a31e39..46c4c958e6 100644
> > +--- a/libgomp/configure.tgt
> > ++++ b/libgomp/configure.tgt
> > +@@ -72,14 +72,6 @@ if test x$enable_linux_futex = xyes; then
> > +     # Note that bare i386 is not included here.  We need cmpxchg.
> > +     i[456]86-*-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
> > +diff --git a/libitm/configure.tgt b/libitm/configure.tgt
> > +index 04109160e9..3d78ea609d 100644
> > +--- a/libitm/configure.tgt
> > ++++ b/libitm/configure.tgt
> > +@@ -59,15 +59,6 @@ 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
> > +       XCFLAGS="${XCFLAGS} -mrtm"
> > +       ARCH=x86
> > +       ;;
> > ---
> > 2.29.2
> >
> > 
> >

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [OE-core] [PATCH] gcc: Add patch to resolve i*86 tune configuration overrides
  2021-01-19  1:40   ` Nathan Rossi
@ 2021-01-19  5:16     ` Khem Raj
  0 siblings, 0 replies; 5+ messages in thread
From: Khem Raj @ 2021-01-19  5:16 UTC (permalink / raw)
  To: Nathan Rossi; +Cc: Patches and discussions about the oe-core layer

[-- Attachment #1: Type: text/plain, Size: 8163 bytes --]

I think it will be good to do so

On Mon, Jan 18, 2021 at 5:40 PM Nathan Rossi <nathan@nathanrossi.com> wrote:

> On Sat, 16 Jan 2021 at 03:40, Khem Raj <raj.khem@gmail.com> wrote:
> >
> > Nathan
> >
> > Can you check if your patch is still needed after
> >
> >
> https://github.com/kraj/gcc/commit/0411ae7f08e0f5a8b02ff313d26d27a0f6d1bb34
>
> Hi Khem,
>
> I tested this change and it resolves the configuration issue. Did you
> want the above change backported to replace the oe specific patch?
> Since that oe specific patch has already been backported to a number
> of releases.
>
> Thanks,
> Nathan
>
> >
> > On Tue, Dec 15, 2020 at 12:35 AM Nathan Rossi <nathan@nathanrossi.com>
> wrote:
> > >
> > > When compiling gcc-runtime for i686 libatomic, libgomp and libitm are
> > > compiled with additional '-march' and '-mtune' overrides. This
> typically
> > > does not cause build errors (e.g. core2-32 tune), and results in less
> > > optimally tuned outputs. However with specific TUNE_CCARGS (e.g. has
> > > '-mfpmath=sse' but not '-msse*'), the build errors with conflicting
> > > '-mfpmath' options.
> > >
> > > This is caused by gcc-runtime specific configure scripts and Makefile
> > > options that override by adding additional '-march'/'-mtune' args. OE
> > > builds gcc-runtime differently to other build systems, and provides
> > > target specific arch/tune options directly. As such, this change adds a
> > > patch for gcc to remove the specific cases where the args are added.
> > >
> > > Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
> > > ---
> > >  meta/recipes-devtools/gcc/gcc-10.2.inc             |   1 +
> > >  .../gcc/0001-lib-Remove-i-86-march-overrides.patch | 113
> +++++++++++++++++++++
> > >  2 files changed, 114 insertions(+)
> > >  create mode 100644
> meta/recipes-devtools/gcc/gcc/0001-lib-Remove-i-86-march-overrides.patch
> > >
> > > diff --git a/meta/recipes-devtools/gcc/gcc-10.2.inc
> b/meta/recipes-devtools/gcc/gcc-10.2.inc
> > > index e88f2ade6d..1e69c91311 100644
> > > --- a/meta/recipes-devtools/gcc/gcc-10.2.inc
> > > +++ b/meta/recipes-devtools/gcc/gcc-10.2.inc
> > > @@ -69,6 +69,7 @@ SRC_URI = "\
> > >
>  file://0002-aarch64-Introduce-SLS-mitigation-for-RET-and-BR-inst.patch \
> > >             file://0003-aarch64-Mitigate-SLS-for-BLR-instruction.patch
> \
> > >
>  file://0001-aarch64-Fix-up-__aarch64_cas16_acq_rel-fallback.patch \
> > > +           file://0001-lib-Remove-i-86-march-overrides.patch \
> > >  "
> > >  SRC_URI[sha256sum] =
> "b8dd4368bb9c7f0b98188317ee0254dd8cc99d1e3a18d0ff146c855fe16c1d8c"
> > >
> > > diff --git
> a/meta/recipes-devtools/gcc/gcc/0001-lib-Remove-i-86-march-overrides.patch
> b/meta/recipes-devtools/gcc/gcc/0001-lib-Remove-i-86-march-overrides.patch
> > > new file mode 100644
> > > index 0000000000..3f04e121ba
> > > --- /dev/null
> > > +++
> b/meta/recipes-devtools/gcc/gcc/0001-lib-Remove-i-86-march-overrides.patch
> > > @@ -0,0 +1,113 @@
> > > +From 3776789cde95916f95deef48acf9532b0ebf91ae Mon Sep 17 00:00:00 2001
> > > +From: Nathan Rossi <nathan@nathanrossi.com>
> > > +Date: Tue, 15 Dec 2020 11:43:36 +1000
> > > +Subject: [PATCH] lib*: Remove i*86 march overrides
> > > +
> > > +OE does not pass the '--with-arch' option to gccs configure, as such
> > > +some gcc-runtime libraries try to override the value of '-march' and
> > > +'-mtune' which OE already provides. This causes conflicts with other
> > > +i*86 instruction/architecture flags (e.g. -msse* and -mfpmath=*).
> > > +Additionally this caused the following libraries to be built with less
> > > +optimized tune configurations.
> > > +
> > > +Upstream suggests that this should be detecting or otherwise checking
> if
> > > +the target supports the desired functionality before overriding.
> > > +
> > > +    https://gcc.gnu.org/legacy-ml/gcc-patches/2016-04/msg01344.html
> > > +
> > > +libatomic also overrides the '-march' specifically for IFUNC objects.
> > > +OE already supplies the correct march flag, so remove setting.
> > > +
> > > +Upstream-Status: Inappropriate [OE Specific]
> > > +Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
> > > +---
> > > + libatomic/Makefile.am   | 1 -
> > > + libatomic/Makefile.in   | 1 -
> > > + libatomic/configure.tgt | 9 ---------
> > > + libgomp/configure.tgt   | 8 --------
> > > + libitm/configure.tgt    | 9 ---------
> > > + 5 files changed, 28 deletions(-)
> > > +
> > > +diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am
> > > +index ac1ca64587..5aa16e0699 100644
> > > +--- a/libatomic/Makefile.am
> > > ++++ b/libatomic/Makefile.am
> > > +@@ -133,7 +133,6 @@ libatomic_la_LIBADD += $(foreach
> s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS))
> > > + libatomic_la_LIBADD += $(addsuffix _8_2_.lo,$(SIZEOBJS))
> > > + endif
> > > + if ARCH_I386
> > > +-IFUNC_OPTIONS      = -march=i586
> > > + libatomic_la_LIBADD += $(addsuffix _8_1_.lo,$(SIZEOBJS))
> > > + endif
> > > + if ARCH_X86_64
> > > +diff --git a/libatomic/Makefile.in b/libatomic/Makefile.in
> > > +index 97df2d7ff0..82c511d420 100644
> > > +--- a/libatomic/Makefile.in
> > > ++++ b/libatomic/Makefile.in
> > > +@@ -432,7 +432,6 @@ libatomic_la_LIBADD = $(foreach
> s,$(SIZES),$(addsuffix \
> > > +       _$(s)_.lo,$(SIZEOBJS))) $(am__append_1) $(am__append_2) \
> > > +       $(am__append_3) $(am__append_4)
> > > + @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS =
> -march=armv7-a+fp -DHAVE_KERNEL64
> > > +-@ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=i586
> > > + @ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -mcx16
> > > + libatomic_convenience_la_SOURCES = $(libatomic_la_SOURCES)
> > > + libatomic_convenience_la_LIBADD = $(libatomic_la_LIBADD)
> > > +diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
> > > +index 5dd0926d20..3cc41773c3 100644
> > > +--- a/libatomic/configure.tgt
> > > ++++ b/libatomic/configure.tgt
> > > +@@ -82,15 +82,6 @@ case "${target_cpu}" in
> > > +       ;;
> > > +
> > > +   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
> > > +diff --git a/libgomp/configure.tgt b/libgomp/configure.tgt
> > > +index 4790a31e39..46c4c958e6 100644
> > > +--- a/libgomp/configure.tgt
> > > ++++ b/libgomp/configure.tgt
> > > +@@ -72,14 +72,6 @@ if test x$enable_linux_futex = xyes; then
> > > +     # Note that bare i386 is not included here.  We need cmpxchg.
> > > +     i[456]86-*-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
> > > +diff --git a/libitm/configure.tgt b/libitm/configure.tgt
> > > +index 04109160e9..3d78ea609d 100644
> > > +--- a/libitm/configure.tgt
> > > ++++ b/libitm/configure.tgt
> > > +@@ -59,15 +59,6 @@ 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
> > > +       XCFLAGS="${XCFLAGS} -mrtm"
> > > +       ARCH=x86
> > > +       ;;
> > > ---
> > > 2.29.2
> > >
> > > 
> > >
>

[-- Attachment #2: Type: text/html, Size: 10907 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-19  5:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-15  8:34 [PATCH] gcc: Add patch to resolve i*86 tune configuration overrides Nathan Rossi
2020-12-15 17:11 ` [OE-core] " Khem Raj
2021-01-15 17:39 ` Khem Raj
2021-01-19  1:40   ` Nathan Rossi
2021-01-19  5:16     ` Khem Raj

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox