diff mbox

[build,libgo,libstdc++] Build libgo with -Wa,-nH if possible (PR go/78978)

Message ID yddk2a9c16w.fsf@CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth Jan. 5, 2017, 9:20 a.m. UTC
As could have been expected, the static libgo.a causes the same problem
with hardware capabilities on Solaris/x86 as was solved for libgo.so
with

	https://gcc.gnu.org/ml/gcc-patches/2016-12/msg00726.html

Instead of trying to pass -mclear-hwcap with -static-libgo, it was
deemed easier to solve both problems the same way and disable hwcaps
support in the assembler in the first place.

This has already been done in libstdc++, so I've moved the corresponding
autoconf macro to config/hwcaps.m4 and adapted it to set HWCAP_CFLAGS
instead of HWCAP_FLAGS to better differntiate from HWCAP_LDFLAGS.
Everything else is straightforward, I believe.

Bootstrapped without regressions on i386-pc-solaris2.1[02] with as/ld
(where as supports -nH) and sparc-sun-solaris2.12 with as/ld (where as
doesn't, or rather it's called -hwcap={1|0}), and the libgo
runtime/pprof failure is gone.

Ok for mainline?

Once approved, how should we proceed with checking?  Ian, will you take
care of the libgo part once the rest is in?

Thanks.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2017-01-04  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	libgo:
	PR go/78978
	* Makefile.am (AM_CFLAGS): Add HWCAP_CFLAGS.
	* configure.ac: Call GCC_CHECK_ASSEMBLER_HWCAP.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.

	Revert:
	2016-12-09  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* configure.ac: Call GCC_CHECK_LINKER_HWCAP.
	* Makefile.am (AM_LDFLAGS): Initialize to HWCAP_LDFLAGS.
	[USING_SPLIT_STACK]: Add to AM_LDFLAGS.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.

	libstdc++-v3:
	PR go/78978
	* acinclude.m4 (GLIBCXX_CHECK_ASSEMBLER_HWCAP): Remove.
	* configure.ac: Call GCC_CHECK_ASSEMBLER_HWCAP instead of
	GLIBCXX_CHECK_ASSEMBLER_HWCAP.
	* fragment.am (CONFIG_CXXFLAGS): Use HWCAP_CFLAGS instead of
	HWCAP_FLAGS.
	* aclocal.m4: Regenerate.
	* configure: Regenerate.
	* Makefile.in, doc/Makefile.in, include/Makefile.in,
	libsupc++/Makefile.in, po/Makefile.in, python/Makefile.in,
	src/Makefile.in, src/c++11/Makefile.in, src/c++98/Makefile.in,
	src/filesystem/Makefile.in, testsuite/Makefile.in: Regenerate.

	config:
	PR go/78978
	* hwcaps.m4 (GCC_CHECK_ASSEMBLER_HWCAP): New macro.

Comments

Jonathan Wakely Jan. 5, 2017, 11:50 a.m. UTC | #1
On 05/01/17 10:20 +0100, Rainer Orth wrote:
>As could have been expected, the static libgo.a causes the same problem

>with hardware capabilities on Solaris/x86 as was solved for libgo.so

>with

>

>	https://gcc.gnu.org/ml/gcc-patches/2016-12/msg00726.html

>

>Instead of trying to pass -mclear-hwcap with -static-libgo, it was

>deemed easier to solve both problems the same way and disable hwcaps

>support in the assembler in the first place.

>

>This has already been done in libstdc++, so I've moved the corresponding

>autoconf macro to config/hwcaps.m4 and adapted it to set HWCAP_CFLAGS

>instead of HWCAP_FLAGS to better differntiate from HWCAP_LDFLAGS.

>Everything else is straightforward, I believe.

>

>Bootstrapped without regressions on i386-pc-solaris2.1[02] with as/ld

>(where as supports -nH) and sparc-sun-solaris2.12 with as/ld (where as

>doesn't, or rather it's called -hwcap={1|0}), and the libgo

>runtime/pprof failure is gone.

>

>Ok for mainline?


I can't approve the whole thing, but moving the macro out of libstdc++
is OK.
diff mbox

Patch

# HG changeset patch
# Parent  d2202c84f6ecdf3980dc94ba513be676b4015819
Build libgo with -Wa,-nH if possible (PR go/78978)

diff --git a/config/hwcaps.m4 b/config/hwcaps.m4
--- a/config/hwcaps.m4
+++ b/config/hwcaps.m4
@@ -1,3 +1,35 @@ 
+dnl
+dnl Check if the assembler used supports disabling generation of hardware
+dnl capabilities.  This is only supported by Solaris as at the moment.
+dnl
+dnl Defines:
+dnl  HWCAP_CFLAGS='-Wa,-nH' if possible.
+dnl
+AC_DEFUN([GCC_CHECK_ASSEMBLER_HWCAP], [
+  test -z "$HWCAP_CFLAGS" && HWCAP_CFLAGS=''
+
+  # Restrict the test to Solaris, other assemblers (e.g. AIX as) have -nH
+  # with a different meaning.
+  case ${target_os} in
+    solaris2*)
+      ac_save_CFLAGS="$CFLAGS"
+      CFLAGS="$CFLAGS -Wa,-nH"
+
+      AC_MSG_CHECKING([for as that supports -Wa,-nH])
+      AC_TRY_COMPILE([], [return 0;], [ac_hwcap_flags=yes],[ac_hwcap_flags=no])
+      if test "$ac_hwcap_flags" = "yes"; then
+	HWCAP_CFLAGS="-Wa,-nH $HWCAP_CFLAGS"
+      fi
+      AC_MSG_RESULT($ac_hwcap_flags)
+
+      CFLAGS="$ac_save_CFLAGS"
+      ;;
+  esac
+
+  AC_SUBST(HWCAP_CFLAGS)
+])
+
+
 dnl
 dnl Check if the linker used supports linker maps to clear hardware
 dnl capabilities.  This is only supported on Solaris at the moment.
diff --git a/libgo/Makefile.am b/libgo/Makefile.am
--- a/libgo/Makefile.am
+++ b/libgo/Makefile.am
@@ -42,14 +42,12 @@  ACLOCAL_AMFLAGS = -I ./config -I ../conf
 
 AM_CFLAGS = -fexceptions -fnon-call-exceptions -fplan9-extensions \
 	$(SPLIT_STACK) $(WARN_CFLAGS) \
-	$(STRINGOPS_FLAG) $(OSCFLAGS) \
+	$(STRINGOPS_FLAG) $(HWCAP_CFLAGS) $(OSCFLAGS) \
 	-I $(srcdir)/../libgcc -I $(srcdir)/../libbacktrace \
 	-I $(MULTIBUILDTOP)../../gcc/include
 
-AM_LDFLAGS = $(HWCAP_LDFLAGS)
-
 if USING_SPLIT_STACK
-AM_LDFLAGS += -XCClinker $(SPLIT_STACK)
+AM_LDFLAGS = -XCClinker $(SPLIT_STACK)
 endif
 
 # Multilib support.
diff --git a/libgo/configure.ac b/libgo/configure.ac
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -421,9 +421,6 @@  case "$target" in
 esac
 AC_SUBST(OSCFLAGS)
 
-dnl Check linker hardware capability support.
-GCC_CHECK_LINKER_HWCAP
-
 case "$target" in
     *86*-*-solaris2.1[[1-9]]*)
 	# Link with -shared-libgcc on Solaris 11+/x86 as a workaround for
@@ -433,6 +430,9 @@  case "$target" in
 esac
 AC_SUBST(OSLDFLAGS)
     
+# Check if assembler supports disabling hardware capability support.
+GCC_CHECK_ASSEMBLER_HWCAP
+
 dnl Use -fsplit-stack when compiling C code if available.
 AC_CACHE_CHECK([whether -fsplit-stack is supported],
 [libgo_cv_c_split_stack_supported],
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -169,38 +169,6 @@  AC_DEFUN([GLIBCXX_CHECK_COMPILER_FEATURE
 
 
 dnl
-dnl Check if the assembler used supports disabling generation of hardware
-dnl capabilities.  This is only supported by Sun as at the moment.
-dnl
-dnl Defines:
-dnl  HWCAP_FLAGS='-Wa,-nH' if possible.
-dnl
-AC_DEFUN([GLIBCXX_CHECK_ASSEMBLER_HWCAP], [
-  test -z "$HWCAP_FLAGS" && HWCAP_FLAGS=''
-
-  # Restrict the test to Solaris, other assemblers (e.g. AIX as) have -nH
-  # with a different meaning.
-  case ${target_os} in
-    solaris2*)
-      ac_save_CFLAGS="$CFLAGS"
-      CFLAGS="$CFLAGS -Wa,-nH"
-
-      AC_MSG_CHECKING([for as that supports -Wa,-nH])
-      AC_TRY_COMPILE([], [return 0;], [ac_hwcap_flags=yes],[ac_hwcap_flags=no])
-      if test "$ac_hwcap_flags" = "yes"; then
-	HWCAP_FLAGS="-Wa,-nH $HWCAP_FLAGS"
-      fi
-      AC_MSG_RESULT($ac_hwcap_flags)
-
-      CFLAGS="$ac_save_CFLAGS"
-      ;;
-  esac
-
-  AC_SUBST(HWCAP_FLAGS)
-])
-
-
-dnl
 dnl If GNU ld is in use, check to see if tricky linker opts can be used.  If
 dnl the native linker is in use, all variables will be defined to something
 dnl safe (like an empty string).
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -400,7 +400,7 @@  AC_SUBST(LONG_DOUBLE_COMPAT_FLAGS)
 GLIBCXX_CONDITIONAL(GLIBCXX_LDBL_COMPAT, test $ac_ldbl_compat = yes)
 
 # Check if assembler supports disabling hardware capability support.
-GLIBCXX_CHECK_ASSEMBLER_HWCAP
+GCC_CHECK_ASSEMBLER_HWCAP
 
 # Check if assembler supports rdrand opcode.
 GLIBCXX_CHECK_X86_RDRAND
diff --git a/libstdc++-v3/fragment.am b/libstdc++-v3/fragment.am
--- a/libstdc++-v3/fragment.am
+++ b/libstdc++-v3/fragment.am
@@ -28,7 +28,7 @@  endif
 # These bits are all figured out from configure.  Look in acinclude.m4
 # or configure.ac to see how they are set.  See GLIBCXX_EXPORT_FLAGS.
 CONFIG_CXXFLAGS = \
-	$(SECTION_FLAGS) $(HWCAP_FLAGS) -frandom-seed=$@
+	$(SECTION_FLAGS) $(HWCAP_CFLAGS) -frandom-seed=$@
 
 WARN_CXXFLAGS = \
 	$(WARN_FLAGS) $(WERROR_FLAG) -fdiagnostics-show-location=once