public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Enable PGO/LTO build for binutils+gdb
@ 2020-10-29 19:11 H.J. Lu
  2020-10-29 19:11 ` [PATCH 1/3] GCC: Pass --plugin to AR and RANLIB H.J. Lu
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: H.J. Lu @ 2020-10-29 19:11 UTC (permalink / raw)
  To: binutils; +Cc: gcc-patches, Martin Liska

Add the --enable-pgo-build[=lto] configure option.  When binutils+gdb
is not built together with GCC, --enable-pgo-build enables the PGO build:

0. Pass --plugin to AR and RANLIB.
1. First build with -fprofile-generate.
2. Use "make maybe-check-*" to generate profiling data.
3. Use "make clean" to remove the previous build.
4. Rebuild with -fprofile-use.


H.J. Lu (3):
  GCC: Pass --plugin to AR and RANLIB
  Binutils: Pass --plugin to AR and RANLIB
  Support the PGO build for binutils+gdb

 Makefile.in            |  63 ++++++++++++-
 Makefile.tpl           |  63 ++++++++++++-
 bfd/configure          |  27 +++++-
 binutils/configure     |  27 +++++-
 config/gcc-plugin.m4   |  28 ++++++
 configure              | 139 ++++++++++++++++++++++++++-
 configure.ac           |  80 ++++++++++++++++
 gas/configure          |  27 +++++-
 gprof/configure        |  27 +++++-
 ld/configure           |  27 +++++-
 libctf/configure       |  27 +++++-
 libiberty/Makefile.in  |   5 +-
 libiberty/aclocal.m4   |   1 +
 libiberty/configure    |  37 ++++++++
 libiberty/configure.ac |  12 +++
 libtool.m4             |  25 ++++-
 opcodes/configure      |  27 +++++-
 zlib/configure         | 206 ++++++++++++++++++++++++++++++++++++++++-
 18 files changed, 818 insertions(+), 30 deletions(-)

-- 
2.28.0


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

* [PATCH 1/3] GCC: Pass --plugin to AR and RANLIB
  2020-10-29 19:11 [PATCH 0/3] Enable PGO/LTO build for binutils+gdb H.J. Lu
@ 2020-10-29 19:11 ` H.J. Lu
  2021-01-11 14:58   ` Luis Machado
  2020-10-29 19:11 ` [PATCH 2/3] Binutils: " H.J. Lu
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: H.J. Lu @ 2020-10-29 19:11 UTC (permalink / raw)
  To: binutils; +Cc: gcc-patches, Martin Liska

Detect GCC LTO plugin.  Pass --plugin to AR and RANLIB to support LTO
build.

	* Makefile.tpl (AR): Add @AR_PLUGIN_OPTION@
	(RANLIB): Add @RANLIB_PLUGIN_OPTION@.
	* configure.ac: Include config/gcc-plugin.m4.
	AC_SUBST AR_PLUGIN_OPTION and RANLIB_PLUGIN_OPTION.
	* libtool.m4 (_LT_CMD_OLD_ARCHIVE): Pass --plugin to AR and
	RANLIB if possible.
	* Makefile.in: Regenerated.
	* configure: Likewise.

config/

	* gcc-plugin.m4 (GCC_PLUGIN_OPTION): New.

libiberty/

	* Makefile.in (AR): Add @AR_PLUGIN_OPTION@
	(RANLIB): Add @RANLIB_PLUGIN_OPTION@.
	(configure_deps): Depend on ../config/gcc-plugin.m4.
	* aclocal.m4: Include ../config/gcc-plugin.m4.
	* configure.ac: AC_SUBST AR_PLUGIN_OPTION and
	RANLIB_PLUGIN_OPTION.
	* configure: Regenerated.

zlib/

	* configure: Regenerated.
---
 Makefile.in            |   5 +-
 Makefile.tpl           |   5 +-
 config/gcc-plugin.m4   |  28 ++++++
 configure              |  39 ++++++++
 configure.ac           |  15 +++
 libiberty/Makefile.in  |   5 +-
 libiberty/aclocal.m4   |   1 +
 libiberty/configure    |  37 ++++++++
 libiberty/configure.ac |  12 +++
 libtool.m4             |  25 ++++-
 zlib/configure         | 206 ++++++++++++++++++++++++++++++++++++++++-
 11 files changed, 368 insertions(+), 10 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index fe34132f9e..978e777338 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -387,7 +387,7 @@ MAKEINFOFLAGS = --split-size=5000000
 # ---------------------------------------------
 
 AS = @AS@
-AR = @AR@
+AR = @AR@ @AR_PLUGIN_OPTION@
 AR_FLAGS = rc
 CC = @CC@
 CXX = @CXX@
@@ -396,7 +396,7 @@ LD = @LD@
 LIPO = @LIPO@
 NM = @NM@
 OBJDUMP = @OBJDUMP@
-RANLIB = @RANLIB@
+RANLIB = @RANLIB@ @RANLIB_PLUGIN_OPTION@
 READELF = @READELF@
 STRIP = @STRIP@
 WINDRES = @WINDRES@
@@ -52633,6 +52633,7 @@ AUTOCONF = autoconf
 $(srcdir)/configure: @MAINT@ $(srcdir)/configure.ac $(srcdir)/config/acx.m4 \
 	$(srcdir)/config/override.m4 $(srcdir)/config/proginstall.m4 \
 	$(srcdir)/config/elf.m4 $(srcdir)/config/isl.m4 \
+	$(srcdir)/config/gcc-plugin.m4 \
 	$(srcdir)/libtool.m4 $(srcdir)/ltoptions.m4 $(srcdir)/ltsugar.m4 \
 	$(srcdir)/ltversion.m4 $(srcdir)/lt~obsolete.m4
 	cd $(srcdir) && $(AUTOCONF)
diff --git a/Makefile.tpl b/Makefile.tpl
index 5b118a8ba4..a280a1498c 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -390,7 +390,7 @@ MAKEINFOFLAGS = --split-size=5000000
 # ---------------------------------------------
 
 AS = @AS@
-AR = @AR@
+AR = @AR@ @AR_PLUGIN_OPTION@
 AR_FLAGS = rc
 CC = @CC@
 CXX = @CXX@
@@ -399,7 +399,7 @@ LD = @LD@
 LIPO = @LIPO@
 NM = @NM@
 OBJDUMP = @OBJDUMP@
-RANLIB = @RANLIB@
+RANLIB = @RANLIB@ @RANLIB_PLUGIN_OPTION@
 READELF = @READELF@
 STRIP = @STRIP@
 WINDRES = @WINDRES@
@@ -1967,6 +1967,7 @@ AUTOCONF = autoconf
 $(srcdir)/configure: @MAINT@ $(srcdir)/configure.ac $(srcdir)/config/acx.m4 \
 	$(srcdir)/config/override.m4 $(srcdir)/config/proginstall.m4 \
 	$(srcdir)/config/elf.m4 $(srcdir)/config/isl.m4 \
+	$(srcdir)/config/gcc-plugin.m4 \
 	$(srcdir)/libtool.m4 $(srcdir)/ltoptions.m4 $(srcdir)/ltsugar.m4 \
 	$(srcdir)/ltversion.m4 $(srcdir)/lt~obsolete.m4
 	cd $(srcdir) && $(AUTOCONF)
diff --git a/config/gcc-plugin.m4 b/config/gcc-plugin.m4
index 8f27871911..c5b72e9a13 100644
--- a/config/gcc-plugin.m4
+++ b/config/gcc-plugin.m4
@@ -124,3 +124,31 @@ AC_DEFUN([GCC_ENABLE_PLUGINS],
      fi
    fi
 ])
+
+dnl
+dnl
+dnl GCC_PLUGIN_OPTION
+dnl    (SHELL-CODE_HANDLER)
+dnl
+AC_DEFUN([GCC_PLUGIN_OPTION],[dnl
+AC_MSG_CHECKING([for -plugin option])
+
+plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
+plugin_option=
+for plugin in $plugin_names; do
+  plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
+  if test x$plugin_so = x$plugin; then
+    plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
+  fi
+  if test x$plugin_so != x$plugin; then
+    plugin_option="--plugin $plugin_so"
+    break
+  fi
+done
+if test -n "$plugin_option"; then
+  $1="$plugin_option"
+  AC_MSG_RESULT($plugin_option)
+else
+  AC_MSG_RESULT([no])
+fi
+])
diff --git a/configure b/configure
index 68779feb42..4c9297d378 100755
--- a/configure
+++ b/configure
@@ -616,6 +616,8 @@ GFORTRAN_FOR_TARGET
 GCC_FOR_TARGET
 CXX_FOR_TARGET
 CC_FOR_TARGET
+RANLIB_PLUGIN_OPTION
+AR_PLUGIN_OPTION
 READELF
 OBJDUMP
 OBJCOPY
@@ -10007,6 +10009,43 @@ fi
 
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -plugin option" >&5
+$as_echo_n "checking for -plugin option... " >&6; }
+
+plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
+plugin_option=
+for plugin in $plugin_names; do
+  plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
+  if test x$plugin_so = x$plugin; then
+    plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
+  fi
+  if test x$plugin_so != x$plugin; then
+    plugin_option="--plugin $plugin_so"
+    break
+  fi
+done
+if test -n "$plugin_option"; then
+  PLUGIN_OPTION="$plugin_option"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $plugin_option" >&5
+$as_echo "$plugin_option" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+AR_PLUGIN_OPTION=
+RANLIB_PLUGIN_OPTION=
+if test -n "$PLUGIN_OPTION"; then
+  if $AR --help 2>&1 | grep -q "\--plugin"; then
+    AR_PLUGIN_OPTION="$PLUGIN_OPTION"
+  fi
+  if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
+    RANLIB_PLUGIN_OPTION="$PLUGIN_OPTION"
+  fi
+fi
+
+
+
 # Target tools.
 
 # Check whether --with-build-time-tools was given.
diff --git a/configure.ac b/configure.ac
index d16a275768..7c4bdff0fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,6 +23,7 @@ m4_include(config/acx.m4)
 m4_include(config/override.m4)
 m4_include(config/proginstall.m4)
 m4_include(config/elf.m4)
+m4_include(config/gcc-plugin.m4)
 m4_include([libtool.m4])
 m4_include([ltoptions.m4])
 m4_include([ltsugar.m4])
@@ -3376,6 +3377,20 @@ AC_SUBST(CXX)
 AC_SUBST(CFLAGS)
 AC_SUBST(CXXFLAGS)
 
+GCC_PLUGIN_OPTION(PLUGIN_OPTION)
+AR_PLUGIN_OPTION=
+RANLIB_PLUGIN_OPTION=
+if test -n "$PLUGIN_OPTION"; then
+  if $AR --help 2>&1 | grep -q "\--plugin"; then
+    AR_PLUGIN_OPTION="$PLUGIN_OPTION"
+  fi
+  if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
+    RANLIB_PLUGIN_OPTION="$PLUGIN_OPTION"
+  fi
+fi
+AC_SUBST(AR_PLUGIN_OPTION)
+AC_SUBST(RANLIB_PLUGIN_OPTION)
+
 # Target tools.
 AC_ARG_WITH([build-time-tools], 
   [AS_HELP_STRING([--with-build-time-tools=PATH],
diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index 895f701bcd..0ffcdc1c53 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -49,13 +49,13 @@ mkinstalldirs = $(SHELL) $(libiberty_topdir)/mkinstalldirs
 # Some compilers can't handle cc -c blah.c -o foo/blah.o.
 OUTPUT_OPTION = @OUTPUT_OPTION@
 
-AR = @AR@
+AR = @AR@ @AR_PLUGIN_OPTION@
 AR_FLAGS = rc
 
 CC = @CC@
 CFLAGS = @CFLAGS@
 CPPFLAGS = @CPPFLAGS@
-RANLIB = @RANLIB@
+RANLIB = @RANLIB@ @RANLIB_PLUGIN_OPTION@
 MAKEINFO = @MAKEINFO@
 PERL = @PERL@
 
@@ -485,6 +485,7 @@ configure_deps = $(srcdir)/aclocal.m4 \
 	$(srcdir)/../config/acx.m4 \
 	$(srcdir)/../config/cet.m4 \
 	$(srcdir)/../config/enable.m4 \
+	$(srcdir)/../config/gcc-plugin.m4 \
 	$(srcdir)/../config/no-executables.m4 \
 	$(srcdir)/../config/override.m4 \
 	$(srcdir)/../config/picflag.m4 \
diff --git a/libiberty/aclocal.m4 b/libiberty/aclocal.m4
index 34c0a5bab6..b2e54d9e32 100644
--- a/libiberty/aclocal.m4
+++ b/libiberty/aclocal.m4
@@ -1,6 +1,7 @@
 sinclude(../config/acx.m4)
 sinclude(../config/cet.m4)
 sinclude(../config/enable.m4)
+sinclude(../config/gcc-plugin.m4)
 sinclude(../config/no-executables.m4)
 sinclude(../config/override.m4)
 sinclude(../config/picflag.m4)
diff --git a/libiberty/configure b/libiberty/configure
index ff93c9ee9a..4406ccb35a 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -645,6 +645,8 @@ CPPFLAGS
 LDFLAGS
 CFLAGS
 CC
+RANLIB_PLUGIN_OPTION
+AR_PLUGIN_OPTION
 RANLIB
 AR
 host_os
@@ -2932,6 +2934,41 @@ else
 fi
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -plugin option" >&5
+$as_echo_n "checking for -plugin option... " >&6; }
+
+plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
+plugin_option=
+for plugin in $plugin_names; do
+  plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
+  if test x$plugin_so = x$plugin; then
+    plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
+  fi
+  if test x$plugin_so != x$plugin; then
+    plugin_option="--plugin $plugin_so"
+    break
+  fi
+done
+if test -n "$plugin_option"; then
+  PLUGIN_OPTION="$plugin_option"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $plugin_option" >&5
+$as_echo "$plugin_option" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+if test -n "$PLUGIN_OPTION"; then
+  if $AR --help 2>&1 | grep -q "\--plugin"; then
+    AR_PLUGIN_OPTION="$PLUGIN_OPTION"
+
+  fi
+  if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
+    RANLIB_PLUGIN_OPTION="$PLUGIN_OPTION"
+
+  fi
+fi
+
 # Add --enable-multilib to configure.
 # Default to --enable-multilib
 # Check whether --enable-multilib was given.
diff --git a/libiberty/configure.ac b/libiberty/configure.ac
index 4e2599c14a..38ae8ab3a6 100644
--- a/libiberty/configure.ac
+++ b/libiberty/configure.ac
@@ -108,6 +108,18 @@ dnl to call AC_CHECK_PROG.
 AC_CHECK_TOOL(AR, ar)
 AC_CHECK_TOOL(RANLIB, ranlib, :)
 
+GCC_PLUGIN_OPTION(PLUGIN_OPTION)
+if test -n "$PLUGIN_OPTION"; then
+  if $AR --help 2>&1 | grep -q "\--plugin"; then
+    AR_PLUGIN_OPTION="$PLUGIN_OPTION"
+    AC_SUBST(AR_PLUGIN_OPTION)
+  fi
+  if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
+    RANLIB_PLUGIN_OPTION="$PLUGIN_OPTION"
+    AC_SUBST(RANLIB_PLUGIN_OPTION)
+  fi
+fi
+
 dnl When switching to automake, replace the following with AM_ENABLE_MULTILIB.
 # Add --enable-multilib to configure.
 # Default to --enable-multilib
diff --git a/libtool.m4 b/libtool.m4
index 434530059f..c24453fc75 100644
--- a/libtool.m4
+++ b/libtool.m4
@@ -1323,8 +1323,26 @@ need_locks="$enable_libtool_lock"
 # _LT_CMD_OLD_ARCHIVE
 # -------------------
 m4_defun([_LT_CMD_OLD_ARCHIVE],
-[AC_CHECK_TOOL(AR, ar, false)
+[plugin_option=
+plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
+for plugin in $plugin_names; do
+  plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
+  if test x$plugin_so = x$plugin; then
+    plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
+  fi
+  if test x$plugin_so != x$plugin; then
+    plugin_option="--plugin $plugin_so"
+    break
+  fi
+done
+
+AC_CHECK_TOOL(AR, ar, false)
 test -z "$AR" && AR=ar
+if test -n "$plugin_option"; then
+  if $AR --help 2>&1 | grep -q "\--plugin"; then
+    AR="$AR $plugin_option"
+  fi
+fi
 test -z "$AR_FLAGS" && AR_FLAGS=cru
 _LT_DECL([], [AR], [1], [The archiver])
 _LT_DECL([], [AR_FLAGS], [1])
@@ -1335,6 +1353,11 @@ _LT_DECL([], [STRIP], [1], [A symbol stripping program])
 
 AC_CHECK_TOOL(RANLIB, ranlib, :)
 test -z "$RANLIB" && RANLIB=:
+if test -n "$plugin_option" && test "$RANLIB" != ":"; then
+  if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
+    RANLIB="$RANLIB $plugin_option"
+  fi
+fi
 _LT_DECL([], [RANLIB], [1],
     [Commands used to install an old-style archive])
 
diff --git a/zlib/configure b/zlib/configure
index de6fa7e996..0d7763b104 100755
--- a/zlib/configure
+++ b/zlib/configure
@@ -5407,6 +5407,19 @@ test -z "$deplibs_check_method" && deplibs_check_method=unknown
 
 
 
+plugin_option=
+plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
+for plugin in $plugin_names; do
+  plugin_so=`${CC} ${CFLAGS} --print-prog-name plugin`
+  if  x$plugin_so = x$plugin ; then
+    plugin_so=`${CC} ${CFLAGS} --print-file-name plugin`
+  fi
+  if  x$plugin_so != x$plugin ; then
+    plugin_option="--plugin $plugin_so"
+    break
+  fi
+done
+
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ar; ac_word=$2
@@ -5500,6 +5513,98 @@ else
 fi
 
 test -z "$AR" && AR=ar
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}"$AR $plugin_option"", so it can be a program name with args.
+set dummy ${ac_tool_prefix}"$AR $plugin_option"; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AR+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AR"; then
+  ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_AR="${ac_tool_prefix}"$AR $plugin_option""
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+$as_echo "$AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_AR"; then
+  ac_ct_AR=$AR
+  # Extract the first word of ""$AR $plugin_option"", so it can be a program name with args.
+set dummy "$AR $plugin_option"; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_AR+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_AR"; then
+  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_AR=""$AR $plugin_option""
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+$as_echo "$ac_ct_AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_AR" = x; then
+    AR="$AR"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    AR=$ac_ct_AR
+  fi
+else
+  AR="$ac_cv_prog_AR"
+fi
+
 test -z "$AR_FLAGS" && AR_FLAGS=cru
 
 
@@ -5703,7 +5808,102 @@ else
   RANLIB="$ac_cv_prog_RANLIB"
 fi
 
-test -z "$RANLIB" && RANLIB=:
+if test -z "$RANLIB"; then
+  RANLIB=:
+else
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}"$RANLIB $plugin_option"", so it can be a program name with args.
+set dummy ${ac_tool_prefix}"$RANLIB $plugin_option"; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_RANLIB+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_RANLIB="${ac_tool_prefix}"$RANLIB $plugin_option""
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
+$as_echo "$RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+  ac_ct_RANLIB=$RANLIB
+  # Extract the first word of ""$RANLIB $plugin_option"", so it can be a program name with args.
+set dummy "$RANLIB $plugin_option"; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_RANLIB"; then
+  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_RANLIB=""$RANLIB $plugin_option""
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
+$as_echo "$ac_ct_RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_RANLIB" = x; then
+    RANLIB="$RANLIB"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    RANLIB=$ac_ct_RANLIB
+  fi
+else
+  RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+fi
 
 
 
@@ -10644,7 +10844,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10647 "configure"
+#line 10847 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10750,7 +10950,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10753 "configure"
+#line 10953 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
-- 
2.28.0


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

* [PATCH 2/3] Binutils: Pass --plugin to AR and RANLIB
  2020-10-29 19:11 [PATCH 0/3] Enable PGO/LTO build for binutils+gdb H.J. Lu
  2020-10-29 19:11 ` [PATCH 1/3] GCC: Pass --plugin to AR and RANLIB H.J. Lu
@ 2020-10-29 19:11 ` H.J. Lu
  2020-10-29 19:11 ` [PATCH 3/3] Support the PGO build for binutils+gdb H.J. Lu
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: H.J. Lu @ 2020-10-29 19:11 UTC (permalink / raw)
  To: binutils; +Cc: gcc-patches, Martin Liska

Detect GCC LTO plugin.  Pass --plugin to AR and RANLIB to support LTO
build.

bfd/

	* configure: Regenerated.

binutils/

	* configure: Regenerated.

gas/

	* configure: Regenerated.

gprof/

	* configure: Regenerated.

ld/

	* configure: Regenerated.

libctf/

	* configure: Regenerated.

opcodes/

	* configure: Regenerated.
---
 bfd/configure      | 27 +++++++++++++++++++++++++--
 binutils/configure | 27 +++++++++++++++++++++++++--
 gas/configure      | 27 +++++++++++++++++++++++++--
 gprof/configure    | 27 +++++++++++++++++++++++++--
 ld/configure       | 27 +++++++++++++++++++++++++--
 libctf/configure   | 27 +++++++++++++++++++++++++--
 opcodes/configure  | 27 +++++++++++++++++++++++++--
 7 files changed, 175 insertions(+), 14 deletions(-)

diff --git a/bfd/configure b/bfd/configure
index 864e78851c..c518d9e5be 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -6824,6 +6824,19 @@ test -z "$deplibs_check_method" && deplibs_check_method=unknown
 
 
 
+plugin_option=
+plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
+for plugin in $plugin_names; do
+  plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
+  if test x$plugin_so = x$plugin; then
+    plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
+  fi
+  if test x$plugin_so != x$plugin; then
+    plugin_option="--plugin $plugin_so"
+    break
+  fi
+done
+
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ar; ac_word=$2
@@ -6917,6 +6930,11 @@ else
 fi
 
 test -z "$AR" && AR=ar
+if test -n "$plugin_option"; then
+  if $AR --help 2>&1 | grep -q "\--plugin"; then
+    AR="$AR $plugin_option"
+  fi
+fi
 test -z "$AR_FLAGS" && AR_FLAGS=cru
 
 
@@ -7121,6 +7139,11 @@ else
 fi
 
 test -z "$RANLIB" && RANLIB=:
+if test -n "$plugin_option" && test "$RANLIB" != ":"; then
+  if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
+    RANLIB="$RANLIB $plugin_option"
+  fi
+fi
 
 
 
@@ -11729,7 +11752,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11732 "configure"
+#line 11755 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11835,7 +11858,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11838 "configure"
+#line 11861 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/binutils/configure b/binutils/configure
index 7c3113c6af..c4d19e406e 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -6616,6 +6616,19 @@ test -z "$deplibs_check_method" && deplibs_check_method=unknown
 
 
 
+plugin_option=
+plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
+for plugin in $plugin_names; do
+  plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
+  if test x$plugin_so = x$plugin; then
+    plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
+  fi
+  if test x$plugin_so != x$plugin; then
+    plugin_option="--plugin $plugin_so"
+    break
+  fi
+done
+
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ar; ac_word=$2
@@ -6709,6 +6722,11 @@ else
 fi
 
 test -z "$AR" && AR=ar
+if test -n "$plugin_option"; then
+  if $AR --help 2>&1 | grep -q "\--plugin"; then
+    AR="$AR $plugin_option"
+  fi
+fi
 test -z "$AR_FLAGS" && AR_FLAGS=cru
 
 
@@ -6913,6 +6931,11 @@ else
 fi
 
 test -z "$RANLIB" && RANLIB=:
+if test -n "$plugin_option" && test "$RANLIB" != ":"; then
+  if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
+    RANLIB="$RANLIB $plugin_option"
+  fi
+fi
 
 
 
@@ -11552,7 +11575,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11555 "configure"
+#line 11578 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11658,7 +11681,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11661 "configure"
+#line 11684 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gas/configure b/gas/configure
index c1fff579c6..6b87cc2401 100755
--- a/gas/configure
+++ b/gas/configure
@@ -6408,6 +6408,19 @@ test -z "$deplibs_check_method" && deplibs_check_method=unknown
 
 
 
+plugin_option=
+plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
+for plugin in $plugin_names; do
+  plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
+  if test x$plugin_so = x$plugin; then
+    plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
+  fi
+  if test x$plugin_so != x$plugin; then
+    plugin_option="--plugin $plugin_so"
+    break
+  fi
+done
+
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ar; ac_word=$2
@@ -6501,6 +6514,11 @@ else
 fi
 
 test -z "$AR" && AR=ar
+if test -n "$plugin_option"; then
+  if $AR --help 2>&1 | grep -q "\--plugin"; then
+    AR="$AR $plugin_option"
+  fi
+fi
 test -z "$AR_FLAGS" && AR_FLAGS=cru
 
 
@@ -6705,6 +6723,11 @@ else
 fi
 
 test -z "$RANLIB" && RANLIB=:
+if test -n "$plugin_option" && test "$RANLIB" != ":"; then
+  if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
+    RANLIB="$RANLIB $plugin_option"
+  fi
+fi
 
 
 
@@ -11344,7 +11367,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11347 "configure"
+#line 11370 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11450,7 +11473,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11453 "configure"
+#line 11476 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gprof/configure b/gprof/configure
index 6fd9974466..4aaab18a42 100755
--- a/gprof/configure
+++ b/gprof/configure
@@ -6255,6 +6255,19 @@ test -z "$deplibs_check_method" && deplibs_check_method=unknown
 
 
 
+plugin_option=
+plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
+for plugin in $plugin_names; do
+  plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
+  if test x$plugin_so = x$plugin; then
+    plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
+  fi
+  if test x$plugin_so != x$plugin; then
+    plugin_option="--plugin $plugin_so"
+    break
+  fi
+done
+
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ar; ac_word=$2
@@ -6348,6 +6361,11 @@ else
 fi
 
 test -z "$AR" && AR=ar
+if test -n "$plugin_option"; then
+  if $AR --help 2>&1 | grep -q "\--plugin"; then
+    AR="$AR $plugin_option"
+  fi
+fi
 test -z "$AR_FLAGS" && AR_FLAGS=cru
 
 
@@ -6552,6 +6570,11 @@ else
 fi
 
 test -z "$RANLIB" && RANLIB=:
+if test -n "$plugin_option" && test "$RANLIB" != ":"; then
+  if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
+    RANLIB="$RANLIB $plugin_option"
+  fi
+fi
 
 
 
@@ -11191,7 +11214,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11194 "configure"
+#line 11217 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11297,7 +11320,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11300 "configure"
+#line 11323 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/ld/configure b/ld/configure
index bd869cc8fd..947de62357 100755
--- a/ld/configure
+++ b/ld/configure
@@ -7106,6 +7106,19 @@ test -z "$deplibs_check_method" && deplibs_check_method=unknown
 
 
 
+plugin_option=
+plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
+for plugin in $plugin_names; do
+  plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
+  if test x$plugin_so = x$plugin; then
+    plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
+  fi
+  if test x$plugin_so != x$plugin; then
+    plugin_option="--plugin $plugin_so"
+    break
+  fi
+done
+
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ar; ac_word=$2
@@ -7199,6 +7212,11 @@ else
 fi
 
 test -z "$AR" && AR=ar
+if test -n "$plugin_option"; then
+  if $AR --help 2>&1 | grep -q "\--plugin"; then
+    AR="$AR $plugin_option"
+  fi
+fi
 test -z "$AR_FLAGS" && AR_FLAGS=cru
 
 
@@ -7403,6 +7421,11 @@ else
 fi
 
 test -z "$RANLIB" && RANLIB=:
+if test -n "$plugin_option" && test "$RANLIB" != ":"; then
+  if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
+    RANLIB="$RANLIB $plugin_option"
+  fi
+fi
 
 
 
@@ -12043,7 +12066,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12046 "configure"
+#line 12069 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12149,7 +12172,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12152 "configure"
+#line 12175 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/libctf/configure b/libctf/configure
index 3fcb2f9416..cd8d82e6f0 100755
--- a/libctf/configure
+++ b/libctf/configure
@@ -6613,6 +6613,19 @@ test -z "$deplibs_check_method" && deplibs_check_method=unknown
 
 
 
+plugin_option=
+plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
+for plugin in $plugin_names; do
+  plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
+  if test x$plugin_so = x$plugin; then
+    plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
+  fi
+  if test x$plugin_so != x$plugin; then
+    plugin_option="--plugin $plugin_so"
+    break
+  fi
+done
+
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ar; ac_word=$2
@@ -6706,6 +6719,11 @@ else
 fi
 
 test -z "$AR" && AR=ar
+if test -n "$plugin_option"; then
+  if $AR --help 2>&1 | grep -q "\--plugin"; then
+    AR="$AR $plugin_option"
+  fi
+fi
 test -z "$AR_FLAGS" && AR_FLAGS=cru
 
 
@@ -6910,6 +6928,11 @@ else
 fi
 
 test -z "$RANLIB" && RANLIB=:
+if test -n "$plugin_option" && test "$RANLIB" != ":"; then
+  if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
+    RANLIB="$RANLIB $plugin_option"
+  fi
+fi
 
 
 
@@ -11519,7 +11542,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11522 "configure"
+#line 11545 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11625,7 +11648,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11628 "configure"
+#line 11651 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/opcodes/configure b/opcodes/configure
index b9bddf8cba..aa0f943568 100755
--- a/opcodes/configure
+++ b/opcodes/configure
@@ -6533,6 +6533,19 @@ test -z "$deplibs_check_method" && deplibs_check_method=unknown
 
 
 
+plugin_option=
+plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
+for plugin in $plugin_names; do
+  plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
+  if test x$plugin_so = x$plugin; then
+    plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
+  fi
+  if test x$plugin_so != x$plugin; then
+    plugin_option="--plugin $plugin_so"
+    break
+  fi
+done
+
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
 set dummy ${ac_tool_prefix}ar; ac_word=$2
@@ -6626,6 +6639,11 @@ else
 fi
 
 test -z "$AR" && AR=ar
+if test -n "$plugin_option"; then
+  if $AR --help 2>&1 | grep -q "\--plugin"; then
+    AR="$AR $plugin_option"
+  fi
+fi
 test -z "$AR_FLAGS" && AR_FLAGS=cru
 
 
@@ -6830,6 +6848,11 @@ else
 fi
 
 test -z "$RANLIB" && RANLIB=:
+if test -n "$plugin_option" && test "$RANLIB" != ":"; then
+  if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
+    RANLIB="$RANLIB $plugin_option"
+  fi
+fi
 
 
 
@@ -11439,7 +11462,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11442 "configure"
+#line 11465 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11545,7 +11568,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11548 "configure"
+#line 11571 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
-- 
2.28.0


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

* [PATCH 3/3] Support the PGO build for binutils+gdb
  2020-10-29 19:11 [PATCH 0/3] Enable PGO/LTO build for binutils+gdb H.J. Lu
  2020-10-29 19:11 ` [PATCH 1/3] GCC: Pass --plugin to AR and RANLIB H.J. Lu
  2020-10-29 19:11 ` [PATCH 2/3] Binutils: " H.J. Lu
@ 2020-10-29 19:11 ` H.J. Lu
  2020-12-17 16:16   ` Matthias Klose
  2020-12-17 16:54   ` Matthias Klose
  2020-11-16 13:11 ` PING [PATCH 0/3] Enable PGO/LTO " H.J. Lu
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 13+ messages in thread
From: H.J. Lu @ 2020-10-29 19:11 UTC (permalink / raw)
  To: binutils; +Cc: gcc-patches, Martin Liska

Add the --enable-pgo-build[=lto] configure option.  When binutils+gdb
is not built together with GCC, --enable-pgo-build enables the PGO build:

1. First build with -fprofile-generate.
2. Use "make maybe-check-*" to generate profiling data.
3. Use "make clean" to remove the previous build.
4. Rebuild with -fprofile-use.

With --enable-pgo-build=lto, -flto=jobserver is used together with
-fprofile-generate and -fprofile-use.  Add '+' to the command line for
recursive make to support -flto=jobserver.

NB: --enable-pgo-build=lto enables the PGO build with LTO while
--enable-lto enables LTO support in toolchain.

	PR binutils/26766
	* Makefile.tpl (BUILD_CFLAGS): New.
	(CFLAGS): Append $(BUILD_CFLAGS).
	(CXXFLAGS): Likewise.
	(PGO_BUILD_GEN_FLAGS_TO_PASS): New.
	(PGO_BUILD_TRAINING_CFLAGS): Likewise.
	(PGO_BUILD_TRAINING_CXXFLAGS): Likewise.
	(PGO_BUILD_TRAINING_FLAGS_TO_PASS): Likewise.
	(PGO_BUILD_USE_FLAGS_TO_PASS): Likewise.
	(PGO-TRAINING-TARGETS): Likewise.
	(PGO_BUILD_TRAINING): Likewise.
	(all): Add '+' to the command line for recursive make.  Support
	the PGO build.
	* configure.ac: Add --enable-pgo-build[=lto].
	AC_SUBST PGO_BUILD_GEN_CFLAGS, PGO_BUILD_USE_CFLAGS and
	PGO_BUILD_LTO_CFLAGS.  Enable the PGO build in Makefile.
	* Makefile.in: Regenerated.
	* configure: Likewise.
---
 Makefile.in  |  58 ++++++++++++++++++++++++++++--
 Makefile.tpl |  58 ++++++++++++++++++++++++++++--
 configure    | 100 +++++++++++++++++++++++++++++++++++++++++++++++++--
 configure.ac |  65 +++++++++++++++++++++++++++++++++
 4 files changed, 275 insertions(+), 6 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 978e777338..2b0633a177 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -412,6 +412,45 @@ CXXFLAGS = @CXXFLAGS@
 LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates
 GOCFLAGS = $(CFLAGS)
 
+# Pass additional PGO and LTO compiler options to the PGO build.
+BUILD_CFLAGS = $(PGO_BUILD_CFLAGS) $(PGO_BUILD_LTO_CFLAGS)
+override CFLAGS += $(BUILD_CFLAGS)
+override CXXFLAGS += $(BUILD_CFLAGS)
+
+# Additional PGO and LTO compiler options to generate profiling data
+# for the PGO build.
+PGO_BUILD_GEN_FLAGS_TO_PASS = \
+	PGO_BUILD_CFLAGS="@PGO_BUILD_GEN_CFLAGS@" \
+	PGO_BUILD_LTO_CFLAGS="@PGO_BUILD_LTO_CFLAGS@"
+
+# NB: Filter out any compiler options which may fail PGO training runs.
+PGO_BUILD_TRAINING_CFLAGS:= \
+	$(filter-out -Werror=%,$(CFLAGS))
+PGO_BUILD_TRAINING_CXXFLAGS:=\
+	$(filter-out -Werror=%,$(CXXFLAGS))
+PGO_BUILD_TRAINING_CFLAGS:= \
+	$(filter-out -Wall,$(PGO_BUILD_TRAINING_CFLAGS))
+PGO_BUILD_TRAINING_CXXFLAGS:= \
+	$(filter-out -Wall,$(PGO_BUILD_TRAINING_CXXFLAGS))
+PGO_BUILD_TRAINING_CFLAGS:= \
+	$(filter-out -specs=%,$(PGO_BUILD_TRAINING_CFLAGS))
+PGO_BUILD_TRAINING_CXXFLAGS:= \
+	$(filter-out -specs=%,$(PGO_BUILD_TRAINING_CXXFLAGS))
+PGO_BUILD_TRAINING_FLAGS_TO_PASS = \
+	CFLAGS_FOR_TARGET="$(PGO_BUILD_TRAINING_CFLAGS)" \
+	CXXFLAGS_FOR_TARGET="$(PGO_BUILD_TRAINING_CXXFLAGS)"
+
+# Additional PGO and LTO compiler options to use profiling data for the
+# PGO build.
+PGO_BUILD_USE_FLAGS_TO_PASS = \
+	PGO_BUILD_CFLAGS="@PGO_BUILD_USE_CFLAGS@" \
+	PGO_BUILD_LTO_CFLAGS="@PGO_BUILD_LTO_CFLAGS@"
+
+# PGO training targets for the PGO build.  FIXME: Add gold tests to
+# training.
+PGO-TRAINING-TARGETS = binutils gas gdb ld sim
+PGO_BUILD_TRAINING = $(addprefix maybe-check-,$(PGO-TRAINING-TARGETS))
+
 CREATE_GCOV = create_gcov
 
 TFLAGS =
@@ -985,6 +1024,12 @@ configure-target:  \
 
 # The target built for a native non-bootstrap build.
 .PHONY: all
+
+# --enable-pgo-build enables the PGO build.
+# 1. First build with -fprofile-generate.
+# 2. Use "make maybe-check-*" to generate profiling data.
+# 3. Use "make clean" to remove the previous build.
+# 4. Rebuild with -fprofile-use.
 all:
 @if gcc-bootstrap
 	[ -f stage_final ] || echo stage3 > stage_final
@@ -993,7 +1038,7 @@ all:
 	$(MAKE) $(RECURSE_FLAGS_TO_PASS) `cat stage_final`-bubble
 @endif gcc-bootstrap
 	@: $(MAKE); $(unstage)
-	@r=`${PWD_COMMAND}`; export r; \
+	+@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 @if gcc-bootstrap
 	if [ -f stage_last ]; then \
@@ -1001,7 +1046,16 @@ all:
 	  $(MAKE) $(TARGET_FLAGS_TO_PASS) all-host all-target; \
 	else \
 @endif gcc-bootstrap
-	  $(MAKE) $(RECURSE_FLAGS_TO_PASS) all-host all-target \
+	  $(MAKE) $(RECURSE_FLAGS_TO_PASS) \
+		$(PGO_BUILD_GEN_FLAGS_TO_PASS) all-host all-target \
+@if pgo-build
+	&& $(MAKE) $(RECURSE_FLAGS_TO_PASS) \
+		$(PGO_BUILD_TRAINING_FLAGS_TO_PASS) \
+		$(PGO_BUILD_TRAINING) \
+	&& $(MAKE) $(RECURSE_FLAGS_TO_PASS) clean \
+	&& $(MAKE) $(RECURSE_FLAGS_TO_PASS) \
+		$(PGO_BUILD_USE_FLAGS_TO_PASS) all-host all-target \
+@endif pgo-build
 @if gcc-bootstrap
 	    ; \
 	fi \
diff --git a/Makefile.tpl b/Makefile.tpl
index a280a1498c..38f0b021f4 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -415,6 +415,45 @@ CXXFLAGS = @CXXFLAGS@
 LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates
 GOCFLAGS = $(CFLAGS)
 
+# Pass additional PGO and LTO compiler options to the PGO build.
+BUILD_CFLAGS = $(PGO_BUILD_CFLAGS) $(PGO_BUILD_LTO_CFLAGS)
+override CFLAGS += $(BUILD_CFLAGS)
+override CXXFLAGS += $(BUILD_CFLAGS)
+
+# Additional PGO and LTO compiler options to generate profiling data
+# for the PGO build.
+PGO_BUILD_GEN_FLAGS_TO_PASS = \
+	PGO_BUILD_CFLAGS="@PGO_BUILD_GEN_CFLAGS@" \
+	PGO_BUILD_LTO_CFLAGS="@PGO_BUILD_LTO_CFLAGS@"
+
+# NB: Filter out any compiler options which may fail PGO training runs.
+PGO_BUILD_TRAINING_CFLAGS:= \
+	$(filter-out -Werror=%,$(CFLAGS))
+PGO_BUILD_TRAINING_CXXFLAGS:=\
+	$(filter-out -Werror=%,$(CXXFLAGS))
+PGO_BUILD_TRAINING_CFLAGS:= \
+	$(filter-out -Wall,$(PGO_BUILD_TRAINING_CFLAGS))
+PGO_BUILD_TRAINING_CXXFLAGS:= \
+	$(filter-out -Wall,$(PGO_BUILD_TRAINING_CXXFLAGS))
+PGO_BUILD_TRAINING_CFLAGS:= \
+	$(filter-out -specs=%,$(PGO_BUILD_TRAINING_CFLAGS))
+PGO_BUILD_TRAINING_CXXFLAGS:= \
+	$(filter-out -specs=%,$(PGO_BUILD_TRAINING_CXXFLAGS))
+PGO_BUILD_TRAINING_FLAGS_TO_PASS = \
+	CFLAGS_FOR_TARGET="$(PGO_BUILD_TRAINING_CFLAGS)" \
+	CXXFLAGS_FOR_TARGET="$(PGO_BUILD_TRAINING_CXXFLAGS)"
+
+# Additional PGO and LTO compiler options to use profiling data for the
+# PGO build.
+PGO_BUILD_USE_FLAGS_TO_PASS = \
+	PGO_BUILD_CFLAGS="@PGO_BUILD_USE_CFLAGS@" \
+	PGO_BUILD_LTO_CFLAGS="@PGO_BUILD_LTO_CFLAGS@"
+
+# PGO training targets for the PGO build.  FIXME: Add gold tests to
+# training.
+PGO-TRAINING-TARGETS = binutils gas gdb ld sim
+PGO_BUILD_TRAINING = $(addprefix maybe-check-,$(PGO-TRAINING-TARGETS))
+
 CREATE_GCOV = create_gcov
 
 TFLAGS =
@@ -719,6 +758,12 @@ configure-target: [+
 
 # The target built for a native non-bootstrap build.
 .PHONY: all
+
+# --enable-pgo-build enables the PGO build.
+# 1. First build with -fprofile-generate.
+# 2. Use "make maybe-check-*" to generate profiling data.
+# 3. Use "make clean" to remove the previous build.
+# 4. Rebuild with -fprofile-use.
 all:
 @if gcc-bootstrap
 	[ -f stage_final ] || echo stage3 > stage_final
@@ -727,7 +772,7 @@ all:
 	$(MAKE) $(RECURSE_FLAGS_TO_PASS) `cat stage_final`-bubble
 @endif gcc-bootstrap
 	@: $(MAKE); $(unstage)
-	@r=`${PWD_COMMAND}`; export r; \
+	+@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 @if gcc-bootstrap
 	if [ -f stage_last ]; then \
@@ -735,7 +780,16 @@ all:
 	  $(MAKE) $(TARGET_FLAGS_TO_PASS) all-host all-target; \
 	else \
 @endif gcc-bootstrap
-	  $(MAKE) $(RECURSE_FLAGS_TO_PASS) all-host all-target \
+	  $(MAKE) $(RECURSE_FLAGS_TO_PASS) \
+		$(PGO_BUILD_GEN_FLAGS_TO_PASS) all-host all-target \
+@if pgo-build
+	&& $(MAKE) $(RECURSE_FLAGS_TO_PASS) \
+		$(PGO_BUILD_TRAINING_FLAGS_TO_PASS) \
+		$(PGO_BUILD_TRAINING) \
+	&& $(MAKE) $(RECURSE_FLAGS_TO_PASS) clean \
+	&& $(MAKE) $(RECURSE_FLAGS_TO_PASS) \
+		$(PGO_BUILD_USE_FLAGS_TO_PASS) all-host all-target \
+@endif pgo-build
 @if gcc-bootstrap
 	    ; \
 	fi \
diff --git a/configure b/configure
index 4c9297d378..6d25001fdb 100755
--- a/configure
+++ b/configure
@@ -692,6 +692,9 @@ extra_mpc_gmp_configure_flags
 extra_mpfr_configure_flags
 gmpinc
 gmplibs
+PGO_BUILD_LTO_CFLAGS
+PGO_BUILD_USE_CFLAGS
+PGO_BUILD_GEN_CFLAGS
 do_compare
 GNATMAKE
 GNATBIND
@@ -792,6 +795,7 @@ enable_libssp
 enable_libstdcxx
 enable_liboffloadmic
 enable_bootstrap
+enable_pgo_build
 with_mpc
 with_mpc_include
 with_mpc_lib
@@ -1522,6 +1526,8 @@ Optional Features:
   --enable-liboffloadmic=ARG
                           build liboffloadmic [ARG={no,host,target}]
   --enable-bootstrap      enable bootstrapping [yes if native build]
+  --enable-pgo-build[=lto]
+                          enable the PGO build
   --disable-isl-version-check
                           disable check for isl version
   --enable-lto            enable link time optimization support
@@ -5422,6 +5428,91 @@ if test "$enable_bootstrap:$GXX" = "yes:yes"; then
   CXX="$CXX -std=gnu++98"
 fi
 
+# Check whether --enable-pgo-build was given.
+if test "${enable_pgo_build+set}" = set; then :
+  enableval=$enable_pgo_build; enable_pgo_build=$enableval
+else
+  enable_pgo_build=no
+fi
+
+
+# Issue errors and warnings for invalid/strange PGO build combinations.
+case "$have_compiler:$host:$target:$enable_pgo_build" in
+  *:*:*:no) ;;
+
+  # Allow the PGO build only if we aren't building a compiler and
+  # we are in a native configuration.
+  no:$build:$build:yes | no:$build:$build:lto) ;;
+
+  # Disallow the PGO bootstrap if we are building a compiler.
+  yes:*:*:yes | yes:*:*:lto)
+    as_fn_error $? "cannot perform the PGO bootstrap when building a compiler" "$LINENO" 5 ;;
+
+  *)
+    as_fn_error $? "invalid option for --enable-pgo-build" "$LINENO" 5
+    ;;
+esac
+
+if test "$enable_pgo_build" != "no"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -fprofile-generate" >&5
+$as_echo_n "checking whether the compiler supports -fprofile-generate... " >&6; }
+  old_CFLAGS="$CFLAGS"
+  PGO_BUILD_GEN_CFLAGS="-fprofile-generate"
+  CFLAGS="$CFLAGS $PGO_BUILD_CFLAGS"
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int foo;
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  PGO_BUILD_GEN_CFLAGS=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  CFLAGS="$old_CFLAGS"
+  if test -n "$PGO_BUILD_GEN_CFLAGS"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+    PGO_BUILD_USE_CFLAGS="-fprofile-use"
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+    as_fn_error $? "cannot perform the PGO build without -fprofile-generate" "$LINENO" 5
+  fi
+
+  if test "$enable_pgo_build" = "lto"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -flto=jobserver" >&5
+$as_echo_n "checking whether the compiler supports -flto=jobserver... " >&6; }
+    old_CFLAGS="$CFLAGS"
+    PGO_BUILD_LTO_CFLAGS="-flto=jobserver"
+    CFLAGS="$CFLAGS $PGO_BUILD_LTO_CFLAGS"
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int foo;
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  PGO_BUILD_LTO_CFLAGS=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    CFLAGS="$old_CFLAGS"
+    if test -n "$PGO_BUILD_LTO_CFLAGS"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: LTO is disabled for the PGO build" >&5
+$as_echo "$as_me: WARNING: LTO is disabled for the PGO build" >&2;}
+    fi
+  fi
+fi
+
+
+
+
 # Used for setting $lt_cv_objdir
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
 $as_echo_n "checking for objdir... " >&6; }
@@ -5611,8 +5702,7 @@ if test -d ${srcdir}/gcc && test "x$have_gmp" = xno; then
   # Check for the recommended and required versions of GMP.
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the correct version of gmp.h" >&5
 $as_echo_n "checking for the correct version of gmp.h... " >&6; }
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include "gmp.h"
 int
@@ -7331,6 +7421,12 @@ extrasub_target="$extrasub_target
 /^@unless /d
 /^@endunless /d"
 
+if test "$enable_pgo_build" != "no"; then
+  extrasub_build="$extrasub_build
+/^@if pgo-build\$/d
+/^@endif pgo-build\$/d"
+fi
+
 # Create the serialization dependencies.  This uses a temporary file.
 
 # Check whether --enable-serial-configure was given.
diff --git a/configure.ac b/configure.ac
index 7c4bdff0fa..eea9a21099 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1375,6 +1375,65 @@ if test "$enable_bootstrap:$GXX" = "yes:yes"; then
   CXX="$CXX -std=gnu++98"
 fi
 
+AC_ARG_ENABLE([pgo-build],
+[AS_HELP_STRING([--enable-pgo-build[[=lto]]],
+		[enable the PGO build])],
+[enable_pgo_build=$enableval],
+[enable_pgo_build=no])
+
+# Issue errors and warnings for invalid/strange PGO build combinations.
+case "$have_compiler:$host:$target:$enable_pgo_build" in
+  *:*:*:no) ;;
+
+  # Allow the PGO build only if we aren't building a compiler and
+  # we are in a native configuration.
+  no:$build:$build:yes | no:$build:$build:lto) ;;
+
+  # Disallow the PGO bootstrap if we are building a compiler.
+  yes:*:*:yes | yes:*:*:lto)
+    AC_MSG_ERROR([cannot perform the PGO bootstrap when building a compiler]) ;;
+
+  *)
+    AC_MSG_ERROR([invalid option for --enable-pgo-build])
+    ;;
+esac
+
+if test "$enable_pgo_build" != "no"; then
+  AC_MSG_CHECKING([whether the compiler supports -fprofile-generate])
+  old_CFLAGS="$CFLAGS"
+  PGO_BUILD_GEN_CFLAGS="-fprofile-generate"
+  CFLAGS="$CFLAGS $PGO_BUILD_CFLAGS"
+  AC_COMPILE_IFELSE([AC_LANG_SOURCE([int foo;])],,
+		    [PGO_BUILD_GEN_CFLAGS=])
+  CFLAGS="$old_CFLAGS"
+  if test -n "$PGO_BUILD_GEN_CFLAGS"; then
+    AC_MSG_RESULT([yes])
+    PGO_BUILD_USE_CFLAGS="-fprofile-use"
+  else
+    AC_MSG_RESULT([no])
+    AC_MSG_ERROR([cannot perform the PGO build without -fprofile-generate])
+  fi
+
+  if test "$enable_pgo_build" = "lto"; then
+    AC_MSG_CHECKING([whether the compiler supports -flto=jobserver])
+    old_CFLAGS="$CFLAGS"
+    PGO_BUILD_LTO_CFLAGS="-flto=jobserver"
+    CFLAGS="$CFLAGS $PGO_BUILD_LTO_CFLAGS"
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([int foo;])],,
+		      [PGO_BUILD_LTO_CFLAGS=])
+    CFLAGS="$old_CFLAGS"
+    if test -n "$PGO_BUILD_LTO_CFLAGS"; then
+      AC_MSG_RESULT([yes])
+    else
+      AC_MSG_RESULT([no])
+      AC_MSG_WARN([LTO is disabled for the PGO build])
+    fi
+  fi
+fi
+AC_SUBST(PGO_BUILD_GEN_CFLAGS)
+AC_SUBST(PGO_BUILD_USE_CFLAGS)
+AC_SUBST(PGO_BUILD_LTO_CFLAGS)
+
 # Used for setting $lt_cv_objdir
 _LT_CHECK_OBJDIR
 
@@ -2847,6 +2906,12 @@ extrasub_target="$extrasub_target
 /^@unless /d
 /^@endunless /d"
 
+if test "$enable_pgo_build" != "no"; then
+  extrasub_build="$extrasub_build
+/^@if pgo-build\$/d
+/^@endif pgo-build\$/d"
+fi
+
 # Create the serialization dependencies.  This uses a temporary file.
 
 AC_ARG_ENABLE([serial-configure],
-- 
2.28.0


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

* PING [PATCH 0/3] Enable PGO/LTO build for binutils+gdb
  2020-10-29 19:11 [PATCH 0/3] Enable PGO/LTO build for binutils+gdb H.J. Lu
                   ` (2 preceding siblings ...)
  2020-10-29 19:11 ` [PATCH 3/3] Support the PGO build for binutils+gdb H.J. Lu
@ 2020-11-16 13:11 ` H.J. Lu
  2020-11-27 15:21 ` Martin Liška
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: H.J. Lu @ 2020-11-16 13:11 UTC (permalink / raw)
  To: Binutils; +Cc: GCC Patches, Martin Liska

On Thu, Oct 29, 2020 at 12:11 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> Add the --enable-pgo-build[=lto] configure option.  When binutils+gdb
> is not built together with GCC, --enable-pgo-build enables the PGO build:
>
> 0. Pass --plugin to AR and RANLIB.
> 1. First build with -fprofile-generate.
> 2. Use "make maybe-check-*" to generate profiling data.
> 3. Use "make clean" to remove the previous build.
> 4. Rebuild with -fprofile-use.
>
>
> H.J. Lu (3):
>   GCC: Pass --plugin to AR and RANLIB
>   Binutils: Pass --plugin to AR and RANLIB
>   Support the PGO build for binutils+gdb
>
>  Makefile.in            |  63 ++++++++++++-
>  Makefile.tpl           |  63 ++++++++++++-
>  bfd/configure          |  27 +++++-
>  binutils/configure     |  27 +++++-
>  config/gcc-plugin.m4   |  28 ++++++
>  configure              | 139 ++++++++++++++++++++++++++-
>  configure.ac           |  80 ++++++++++++++++
>  gas/configure          |  27 +++++-
>  gprof/configure        |  27 +++++-
>  ld/configure           |  27 +++++-
>  libctf/configure       |  27 +++++-
>  libiberty/Makefile.in  |   5 +-
>  libiberty/aclocal.m4   |   1 +
>  libiberty/configure    |  37 ++++++++
>  libiberty/configure.ac |  12 +++
>  libtool.m4             |  25 ++++-
>  opcodes/configure      |  27 +++++-
>  zlib/configure         | 206 ++++++++++++++++++++++++++++++++++++++++-
>  18 files changed, 818 insertions(+), 30 deletions(-)
>

Any comments, objections?

-- 
H.J.

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

* Re: [PATCH 0/3] Enable PGO/LTO build for binutils+gdb
  2020-10-29 19:11 [PATCH 0/3] Enable PGO/LTO build for binutils+gdb H.J. Lu
                   ` (3 preceding siblings ...)
  2020-11-16 13:11 ` PING [PATCH 0/3] Enable PGO/LTO " H.J. Lu
@ 2020-11-27 15:21 ` Martin Liška
  2020-12-15 17:10 ` PING^1 " H.J. Lu
  2020-12-19  9:27 ` Matthias Klose
  6 siblings, 0 replies; 13+ messages in thread
From: Martin Liška @ 2020-11-27 15:21 UTC (permalink / raw)
  To: H.J. Lu, binutils; +Cc: gcc-patches

On 10/29/20 8:11 PM, H.J. Lu wrote:
> Add the --enable-pgo-build[=lto] configure option.  When binutils+gdb
> is not built together with GCC, --enable-pgo-build enables the PGO build:

I would like to support the patch. It significantly speeds up gas for free
(based on my measurements).

Thanks,
Martin

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

* PING^1 [PATCH 0/3] Enable PGO/LTO build for binutils+gdb
  2020-10-29 19:11 [PATCH 0/3] Enable PGO/LTO build for binutils+gdb H.J. Lu
                   ` (4 preceding siblings ...)
  2020-11-27 15:21 ` Martin Liška
@ 2020-12-15 17:10 ` H.J. Lu
  2020-12-19  9:27 ` Matthias Klose
  6 siblings, 0 replies; 13+ messages in thread
From: H.J. Lu @ 2020-12-15 17:10 UTC (permalink / raw)
  To: Binutils, GDB; +Cc: GCC Patches, Martin Liska

On Thu, Oct 29, 2020 at 12:11 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> Add the --enable-pgo-build[=lto] configure option.  When binutils+gdb
> is not built together with GCC, --enable-pgo-build enables the PGO build:
>
> 0. Pass --plugin to AR and RANLIB.
> 1. First build with -fprofile-generate.
> 2. Use "make maybe-check-*" to generate profiling data.
> 3. Use "make clean" to remove the previous build.
> 4. Rebuild with -fprofile-use.
>
>
> H.J. Lu (3):
>   GCC: Pass --plugin to AR and RANLIB
>   Binutils: Pass --plugin to AR and RANLIB
>   Support the PGO build for binutils+gdb
>
>  Makefile.in            |  63 ++++++++++++-
>  Makefile.tpl           |  63 ++++++++++++-
>  bfd/configure          |  27 +++++-
>  binutils/configure     |  27 +++++-
>  config/gcc-plugin.m4   |  28 ++++++
>  configure              | 139 ++++++++++++++++++++++++++-
>  configure.ac           |  80 ++++++++++++++++
>  gas/configure          |  27 +++++-
>  gprof/configure        |  27 +++++-
>  ld/configure           |  27 +++++-
>  libctf/configure       |  27 +++++-
>  libiberty/Makefile.in  |   5 +-
>  libiberty/aclocal.m4   |   1 +
>  libiberty/configure    |  37 ++++++++
>  libiberty/configure.ac |  12 +++
>  libtool.m4             |  25 ++++-
>  opcodes/configure      |  27 +++++-
>  zlib/configure         | 206 ++++++++++++++++++++++++++++++++++++++++-
>  18 files changed, 818 insertions(+), 30 deletions(-)
>

Any comments from GCC and GDB:

https://sourceware.org/pipermail/binutils/2020-October/113943.html

-- 
H.J.

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

* Re: [PATCH 3/3] Support the PGO build for binutils+gdb
  2020-10-29 19:11 ` [PATCH 3/3] Support the PGO build for binutils+gdb H.J. Lu
@ 2020-12-17 16:16   ` Matthias Klose
  2020-12-17 16:54   ` Matthias Klose
  1 sibling, 0 replies; 13+ messages in thread
From: Matthias Klose @ 2020-12-17 16:16 UTC (permalink / raw)
  To: H.J. Lu, binutils; +Cc: gcc-patches

On 10/29/20 8:11 PM, H.J. Lu via Binutils wrote:

> diff --git a/Makefile.tpl b/Makefile.tpl
> index a280a1498c..38f0b021f4 100644
> --- a/Makefile.tpl
> +++ b/Makefile.tpl
> +@if pgo-build
> +	&& $(MAKE) $(RECURSE_FLAGS_TO_PASS) \

shouldn't make called with -i here? you're not interested letting some test
failures to stop the build.

> +		$(PGO_BUILD_TRAINING_FLAGS_TO_PASS) \
> +		$(PGO_BUILD_TRAINING) \
> +	&& $(MAKE) $(RECURSE_FLAGS_TO_PASS) clean \
> +	&& $(MAKE) $(RECURSE_FLAGS_TO_PASS) \
> +		$(PGO_BUILD_USE_FLAGS_TO_PASS) all-host all-target \
> +@endif pgo-build
>  @if gcc-bootstrap
>  	    ; \
>  	fi \

Matthias

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

* Re: [PATCH 3/3] Support the PGO build for binutils+gdb
  2020-10-29 19:11 ` [PATCH 3/3] Support the PGO build for binutils+gdb H.J. Lu
  2020-12-17 16:16   ` Matthias Klose
@ 2020-12-17 16:54   ` Matthias Klose
  1 sibling, 0 replies; 13+ messages in thread
From: Matthias Klose @ 2020-12-17 16:54 UTC (permalink / raw)
  To: H.J. Lu, binutils; +Cc: gcc-patches

On 10/29/20 8:11 PM, H.J. Lu via Binutils wrote:
> diff --git a/configure.ac b/configure.ac
> index 7c4bdff0fa..eea9a21099 100644
> --- a/configure.ac
> +++ b/configure.ac
> +  if test "$enable_pgo_build" = "lto"; then
> +    AC_MSG_CHECKING([whether the compiler supports -flto=jobserver])
> +    old_CFLAGS="$CFLAGS"
> +    PGO_BUILD_LTO_CFLAGS="-flto=jobserver"

that should add -ffat-lto-objects unless you are configuring with --disable-static.

> +    CFLAGS="$CFLAGS $PGO_BUILD_LTO_CFLAGS"
> +    AC_COMPILE_IFELSE([AC_LANG_SOURCE([int foo;])],,
> +		      [PGO_BUILD_LTO_CFLAGS=])
> +    CFLAGS="$old_CFLAGS"
> +    if test -n "$PGO_BUILD_LTO_CFLAGS"; then
> +      AC_MSG_RESULT([yes])
> +    else
> +      AC_MSG_RESULT([no])
> +      AC_MSG_WARN([LTO is disabled for the PGO build])
> +    fi
> +  fi

Matthias

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

* Re: [PATCH 0/3] Enable PGO/LTO build for binutils+gdb
  2020-10-29 19:11 [PATCH 0/3] Enable PGO/LTO build for binutils+gdb H.J. Lu
                   ` (5 preceding siblings ...)
  2020-12-15 17:10 ` PING^1 " H.J. Lu
@ 2020-12-19  9:27 ` Matthias Klose
  2020-12-19 13:21   ` H.J. Lu
  6 siblings, 1 reply; 13+ messages in thread
From: Matthias Klose @ 2020-12-19  9:27 UTC (permalink / raw)
  To: H.J. Lu, binutils

On 10/29/20 8:11 PM, H.J. Lu via Binutils wrote:
> Add the --enable-pgo-build[=lto] configure option.  When binutils+gdb
> is not built together with GCC, --enable-pgo-build enables the PGO build:

with this patch applied, and configuring with --enable-pgo-build=lto, I see some
regressions on ppc64el, sh4, hppa, sparc64 and riscv64:

Test results, compared with installed binutils:
W: [ld-bootstrap/bootstrap.exp] REGRESSION (PASS -> FAIL): bootstrap
W: [ld-bootstrap/bootstrap.exp] REGRESSION (PASS -> FAIL): bootstrap with strip
W: [ld-bootstrap/bootstrap.exp] REGRESSION (PASS -> FAIL): bootstrap with
-Wl,--traditional-format
W: [ld-bootstrap/bootstrap.exp] REGRESSION (PASS -> FAIL): bootstrap with
-Wl,--no-keep-memory
W: [ld-bootstrap/bootstrap.exp] REGRESSION (PASS -> FAIL): bootstrap with
-Wl,--relax

same on all these architectures (hppa doesn't show the first two). Checked for
ppc64el that these go away without a pgo+lto configuration.

Matthias

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

* Re: [PATCH 0/3] Enable PGO/LTO build for binutils+gdb
  2020-12-19  9:27 ` Matthias Klose
@ 2020-12-19 13:21   ` H.J. Lu
  0 siblings, 0 replies; 13+ messages in thread
From: H.J. Lu @ 2020-12-19 13:21 UTC (permalink / raw)
  To: Matthias Klose; +Cc: Binutils

On Sat, Dec 19, 2020 at 1:27 AM Matthias Klose <doko@ubuntu.com> wrote:
>
> On 10/29/20 8:11 PM, H.J. Lu via Binutils wrote:
> > Add the --enable-pgo-build[=lto] configure option.  When binutils+gdb
> > is not built together with GCC, --enable-pgo-build enables the PGO build:
>
> with this patch applied, and configuring with --enable-pgo-build=lto, I see some
> regressions on ppc64el, sh4, hppa, sparc64 and riscv64:
>
> Test results, compared with installed binutils:
> W: [ld-bootstrap/bootstrap.exp] REGRESSION (PASS -> FAIL): bootstrap
> W: [ld-bootstrap/bootstrap.exp] REGRESSION (PASS -> FAIL): bootstrap with strip
> W: [ld-bootstrap/bootstrap.exp] REGRESSION (PASS -> FAIL): bootstrap with
> -Wl,--traditional-format
> W: [ld-bootstrap/bootstrap.exp] REGRESSION (PASS -> FAIL): bootstrap with
> -Wl,--no-keep-memory
> W: [ld-bootstrap/bootstrap.exp] REGRESSION (PASS -> FAIL): bootstrap with
> -Wl,--relax
>
> same on all these architectures (hppa doesn't show the first two). Checked for
> ppc64el that these go away without a pgo+lto configuration.

Please send me one failed ld.log.

-- 
H.J.

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

* Re: [PATCH 1/3] GCC: Pass --plugin to AR and RANLIB
  2020-10-29 19:11 ` [PATCH 1/3] GCC: Pass --plugin to AR and RANLIB H.J. Lu
@ 2021-01-11 14:58   ` Luis Machado
  2021-01-11 16:48     ` Hans-Peter Nilsson
  0 siblings, 1 reply; 13+ messages in thread
From: Luis Machado @ 2021-01-11 14:58 UTC (permalink / raw)
  To: H.J. Lu, binutils; +Cc: gcc-patches

This seems to have broken the builds on AArch64-Linux Ubuntu 18.04.

make[2]: Entering directory 'binutils-gdb-master-bionic/libiberty'
rm -f ./libiberty.a pic/./libiberty.a noasan/./libiberty.a
ar --plugin /usr/lib/gcc/aarch64-linux-gnu/7/liblto_plugin.so rc 
./libiberty.a \
   ./regex.o ./cplus-dem.o ./cp-demangle.o ./md5.o ./sha1.o ./alloca.o 
./argv.o ./bsearch_r.o ./choose-temp.o ./concat.o ./cp-demint.o 
./crc32.o ./d-demangle.o ./dwarfnames.o ./dyn-string.o ./fdmatch.o 
./fibheap.o ./filedescriptor.o ./filename_cmp.o ./floatformat.o 
./fnmatch.o ./fopen_unlocked.o ./getopt.o ./getopt1.o ./getpwd.o 
./getruntime.o ./hashtab.o ./hex.o ./lbasename.o ./lrealpath.o 
./make-relative-prefix.o ./make-temp-file.o ./objalloc.o ./obstack.o 
./partition.o ./pexecute.o ./physmem.o ./pex-common.o ./pex-one.o 
./pex-unix.o ./vprintf-support.o ./rust-demangle.o ./safe-ctype.o 
./simple-object.o ./simple-object-coff.o ./simple-object-elf.o 
./simple-object-mach-o.o ./simple-object-xcoff.o ./sort.o ./spaces.o 
./splay-tree.o ./stack-limit.o ./strerror.o ./strsignal.o 
./timeval-utils.o ./unlink-if-ordinary.o ./xasprintf.o ./xatexit.o 
./xexit.o ./xmalloc.o ./xmemdup.o ./xstrdup.o ./xstrerror.o ./xstrndup.o 
./xvasprintf.o  ./setproctitle.o
ar: no operation specified
Makefile:252: recipe for target 'libiberty.a' failed
make[2]: *** [libiberty.a] Error 1

Reverting that patch makes the build OK again.

On 10/29/20 4:11 PM, H.J. Lu via Binutils wrote:
> Detect GCC LTO plugin.  Pass --plugin to AR and RANLIB to support LTO
> build.
> 
> 	* Makefile.tpl (AR): Add @AR_PLUGIN_OPTION@
> 	(RANLIB): Add @RANLIB_PLUGIN_OPTION@.
> 	* configure.ac: Include config/gcc-plugin.m4.
> 	AC_SUBST AR_PLUGIN_OPTION and RANLIB_PLUGIN_OPTION.
> 	* libtool.m4 (_LT_CMD_OLD_ARCHIVE): Pass --plugin to AR and
> 	RANLIB if possible.
> 	* Makefile.in: Regenerated.
> 	* configure: Likewise.
> 
> config/
> 
> 	* gcc-plugin.m4 (GCC_PLUGIN_OPTION): New.
> 
> libiberty/
> 
> 	* Makefile.in (AR): Add @AR_PLUGIN_OPTION@
> 	(RANLIB): Add @RANLIB_PLUGIN_OPTION@.
> 	(configure_deps): Depend on ../config/gcc-plugin.m4.
> 	* aclocal.m4: Include ../config/gcc-plugin.m4.
> 	* configure.ac: AC_SUBST AR_PLUGIN_OPTION and
> 	RANLIB_PLUGIN_OPTION.
> 	* configure: Regenerated.
> 
> zlib/
> 
> 	* configure: Regenerated.
> ---
>   Makefile.in            |   5 +-
>   Makefile.tpl           |   5 +-
>   config/gcc-plugin.m4   |  28 ++++++
>   configure              |  39 ++++++++
>   configure.ac           |  15 +++
>   libiberty/Makefile.in  |   5 +-
>   libiberty/aclocal.m4   |   1 +
>   libiberty/configure    |  37 ++++++++
>   libiberty/configure.ac |  12 +++
>   libtool.m4             |  25 ++++-
>   zlib/configure         | 206 ++++++++++++++++++++++++++++++++++++++++-
>   11 files changed, 368 insertions(+), 10 deletions(-)
> 
> diff --git a/Makefile.in b/Makefile.in
> index fe34132f9e..978e777338 100644
> --- a/Makefile.in
> +++ b/Makefile.in
> @@ -387,7 +387,7 @@ MAKEINFOFLAGS = --split-size=5000000
>   # ---------------------------------------------
>   
>   AS = @AS@
> -AR = @AR@
> +AR = @AR@ @AR_PLUGIN_OPTION@
>   AR_FLAGS = rc
>   CC = @CC@
>   CXX = @CXX@
> @@ -396,7 +396,7 @@ LD = @LD@
>   LIPO = @LIPO@
>   NM = @NM@
>   OBJDUMP = @OBJDUMP@
> -RANLIB = @RANLIB@
> +RANLIB = @RANLIB@ @RANLIB_PLUGIN_OPTION@
>   READELF = @READELF@
>   STRIP = @STRIP@
>   WINDRES = @WINDRES@
> @@ -52633,6 +52633,7 @@ AUTOCONF = autoconf
>   $(srcdir)/configure: @MAINT@ $(srcdir)/configure.ac $(srcdir)/config/acx.m4 \
>   	$(srcdir)/config/override.m4 $(srcdir)/config/proginstall.m4 \
>   	$(srcdir)/config/elf.m4 $(srcdir)/config/isl.m4 \
> +	$(srcdir)/config/gcc-plugin.m4 \
>   	$(srcdir)/libtool.m4 $(srcdir)/ltoptions.m4 $(srcdir)/ltsugar.m4 \
>   	$(srcdir)/ltversion.m4 $(srcdir)/lt~obsolete.m4
>   	cd $(srcdir) && $(AUTOCONF)
> diff --git a/Makefile.tpl b/Makefile.tpl
> index 5b118a8ba4..a280a1498c 100644
> --- a/Makefile.tpl
> +++ b/Makefile.tpl
> @@ -390,7 +390,7 @@ MAKEINFOFLAGS = --split-size=5000000
>   # ---------------------------------------------
>   
>   AS = @AS@
> -AR = @AR@
> +AR = @AR@ @AR_PLUGIN_OPTION@
>   AR_FLAGS = rc
>   CC = @CC@
>   CXX = @CXX@
> @@ -399,7 +399,7 @@ LD = @LD@
>   LIPO = @LIPO@
>   NM = @NM@
>   OBJDUMP = @OBJDUMP@
> -RANLIB = @RANLIB@
> +RANLIB = @RANLIB@ @RANLIB_PLUGIN_OPTION@
>   READELF = @READELF@
>   STRIP = @STRIP@
>   WINDRES = @WINDRES@
> @@ -1967,6 +1967,7 @@ AUTOCONF = autoconf
>   $(srcdir)/configure: @MAINT@ $(srcdir)/configure.ac $(srcdir)/config/acx.m4 \
>   	$(srcdir)/config/override.m4 $(srcdir)/config/proginstall.m4 \
>   	$(srcdir)/config/elf.m4 $(srcdir)/config/isl.m4 \
> +	$(srcdir)/config/gcc-plugin.m4 \
>   	$(srcdir)/libtool.m4 $(srcdir)/ltoptions.m4 $(srcdir)/ltsugar.m4 \
>   	$(srcdir)/ltversion.m4 $(srcdir)/lt~obsolete.m4
>   	cd $(srcdir) && $(AUTOCONF)
> diff --git a/config/gcc-plugin.m4 b/config/gcc-plugin.m4
> index 8f27871911..c5b72e9a13 100644
> --- a/config/gcc-plugin.m4
> +++ b/config/gcc-plugin.m4
> @@ -124,3 +124,31 @@ AC_DEFUN([GCC_ENABLE_PLUGINS],
>        fi
>      fi
>   ])
> +
> +dnl
> +dnl
> +dnl GCC_PLUGIN_OPTION
> +dnl    (SHELL-CODE_HANDLER)
> +dnl
> +AC_DEFUN([GCC_PLUGIN_OPTION],[dnl
> +AC_MSG_CHECKING([for -plugin option])
> +
> +plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
> +plugin_option=
> +for plugin in $plugin_names; do
> +  plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
> +  if test x$plugin_so = x$plugin; then
> +    plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
> +  fi
> +  if test x$plugin_so != x$plugin; then
> +    plugin_option="--plugin $plugin_so"
> +    break
> +  fi
> +done
> +if test -n "$plugin_option"; then
> +  $1="$plugin_option"
> +  AC_MSG_RESULT($plugin_option)
> +else
> +  AC_MSG_RESULT([no])
> +fi
> +])
> diff --git a/configure b/configure
> index 68779feb42..4c9297d378 100755
> --- a/configure
> +++ b/configure
> @@ -616,6 +616,8 @@ GFORTRAN_FOR_TARGET
>   GCC_FOR_TARGET
>   CXX_FOR_TARGET
>   CC_FOR_TARGET
> +RANLIB_PLUGIN_OPTION
> +AR_PLUGIN_OPTION
>   READELF
>   OBJDUMP
>   OBJCOPY
> @@ -10007,6 +10009,43 @@ fi
>   
>   
>   
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -plugin option" >&5
> +$as_echo_n "checking for -plugin option... " >&6; }
> +
> +plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
> +plugin_option=
> +for plugin in $plugin_names; do
> +  plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
> +  if test x$plugin_so = x$plugin; then
> +    plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
> +  fi
> +  if test x$plugin_so != x$plugin; then
> +    plugin_option="--plugin $plugin_so"
> +    break
> +  fi
> +done
> +if test -n "$plugin_option"; then
> +  PLUGIN_OPTION="$plugin_option"
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $plugin_option" >&5
> +$as_echo "$plugin_option" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +
> +AR_PLUGIN_OPTION=
> +RANLIB_PLUGIN_OPTION=
> +if test -n "$PLUGIN_OPTION"; then
> +  if $AR --help 2>&1 | grep -q "\--plugin"; then
> +    AR_PLUGIN_OPTION="$PLUGIN_OPTION"
> +  fi
> +  if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
> +    RANLIB_PLUGIN_OPTION="$PLUGIN_OPTION"
> +  fi
> +fi
> +
> +
> +
>   # Target tools.
>   
>   # Check whether --with-build-time-tools was given.
> diff --git a/configure.ac b/configure.ac
> index d16a275768..7c4bdff0fa 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -23,6 +23,7 @@ m4_include(config/acx.m4)
>   m4_include(config/override.m4)
>   m4_include(config/proginstall.m4)
>   m4_include(config/elf.m4)
> +m4_include(config/gcc-plugin.m4)
>   m4_include([libtool.m4])
>   m4_include([ltoptions.m4])
>   m4_include([ltsugar.m4])
> @@ -3376,6 +3377,20 @@ AC_SUBST(CXX)
>   AC_SUBST(CFLAGS)
>   AC_SUBST(CXXFLAGS)
>   
> +GCC_PLUGIN_OPTION(PLUGIN_OPTION)
> +AR_PLUGIN_OPTION=
> +RANLIB_PLUGIN_OPTION=
> +if test -n "$PLUGIN_OPTION"; then
> +  if $AR --help 2>&1 | grep -q "\--plugin"; then
> +    AR_PLUGIN_OPTION="$PLUGIN_OPTION"
> +  fi
> +  if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
> +    RANLIB_PLUGIN_OPTION="$PLUGIN_OPTION"
> +  fi
> +fi
> +AC_SUBST(AR_PLUGIN_OPTION)
> +AC_SUBST(RANLIB_PLUGIN_OPTION)
> +
>   # Target tools.
>   AC_ARG_WITH([build-time-tools],
>     [AS_HELP_STRING([--with-build-time-tools=PATH],
> diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
> index 895f701bcd..0ffcdc1c53 100644
> --- a/libiberty/Makefile.in
> +++ b/libiberty/Makefile.in
> @@ -49,13 +49,13 @@ mkinstalldirs = $(SHELL) $(libiberty_topdir)/mkinstalldirs
>   # Some compilers can't handle cc -c blah.c -o foo/blah.o.
>   OUTPUT_OPTION = @OUTPUT_OPTION@
>   
> -AR = @AR@
> +AR = @AR@ @AR_PLUGIN_OPTION@
>   AR_FLAGS = rc
>   
>   CC = @CC@
>   CFLAGS = @CFLAGS@
>   CPPFLAGS = @CPPFLAGS@
> -RANLIB = @RANLIB@
> +RANLIB = @RANLIB@ @RANLIB_PLUGIN_OPTION@
>   MAKEINFO = @MAKEINFO@
>   PERL = @PERL@
>   
> @@ -485,6 +485,7 @@ configure_deps = $(srcdir)/aclocal.m4 \
>   	$(srcdir)/../config/acx.m4 \
>   	$(srcdir)/../config/cet.m4 \
>   	$(srcdir)/../config/enable.m4 \
> +	$(srcdir)/../config/gcc-plugin.m4 \
>   	$(srcdir)/../config/no-executables.m4 \
>   	$(srcdir)/../config/override.m4 \
>   	$(srcdir)/../config/picflag.m4 \
> diff --git a/libiberty/aclocal.m4 b/libiberty/aclocal.m4
> index 34c0a5bab6..b2e54d9e32 100644
> --- a/libiberty/aclocal.m4
> +++ b/libiberty/aclocal.m4
> @@ -1,6 +1,7 @@
>   sinclude(../config/acx.m4)
>   sinclude(../config/cet.m4)
>   sinclude(../config/enable.m4)
> +sinclude(../config/gcc-plugin.m4)
>   sinclude(../config/no-executables.m4)
>   sinclude(../config/override.m4)
>   sinclude(../config/picflag.m4)
> diff --git a/libiberty/configure b/libiberty/configure
> index ff93c9ee9a..4406ccb35a 100755
> --- a/libiberty/configure
> +++ b/libiberty/configure
> @@ -645,6 +645,8 @@ CPPFLAGS
>   LDFLAGS
>   CFLAGS
>   CC
> +RANLIB_PLUGIN_OPTION
> +AR_PLUGIN_OPTION
>   RANLIB
>   AR
>   host_os
> @@ -2932,6 +2934,41 @@ else
>   fi
>   
>   
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -plugin option" >&5
> +$as_echo_n "checking for -plugin option... " >&6; }
> +
> +plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
> +plugin_option=
> +for plugin in $plugin_names; do
> +  plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
> +  if test x$plugin_so = x$plugin; then
> +    plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
> +  fi
> +  if test x$plugin_so != x$plugin; then
> +    plugin_option="--plugin $plugin_so"
> +    break
> +  fi
> +done
> +if test -n "$plugin_option"; then
> +  PLUGIN_OPTION="$plugin_option"
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $plugin_option" >&5
> +$as_echo "$plugin_option" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +
> +if test -n "$PLUGIN_OPTION"; then
> +  if $AR --help 2>&1 | grep -q "\--plugin"; then
> +    AR_PLUGIN_OPTION="$PLUGIN_OPTION"
> +
> +  fi
> +  if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
> +    RANLIB_PLUGIN_OPTION="$PLUGIN_OPTION"
> +
> +  fi
> +fi
> +
>   # Add --enable-multilib to configure.
>   # Default to --enable-multilib
>   # Check whether --enable-multilib was given.
> diff --git a/libiberty/configure.ac b/libiberty/configure.ac
> index 4e2599c14a..38ae8ab3a6 100644
> --- a/libiberty/configure.ac
> +++ b/libiberty/configure.ac
> @@ -108,6 +108,18 @@ dnl to call AC_CHECK_PROG.
>   AC_CHECK_TOOL(AR, ar)
>   AC_CHECK_TOOL(RANLIB, ranlib, :)
>   
> +GCC_PLUGIN_OPTION(PLUGIN_OPTION)
> +if test -n "$PLUGIN_OPTION"; then
> +  if $AR --help 2>&1 | grep -q "\--plugin"; then
> +    AR_PLUGIN_OPTION="$PLUGIN_OPTION"
> +    AC_SUBST(AR_PLUGIN_OPTION)
> +  fi
> +  if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
> +    RANLIB_PLUGIN_OPTION="$PLUGIN_OPTION"
> +    AC_SUBST(RANLIB_PLUGIN_OPTION)
> +  fi
> +fi
> +
>   dnl When switching to automake, replace the following with AM_ENABLE_MULTILIB.
>   # Add --enable-multilib to configure.
>   # Default to --enable-multilib
> diff --git a/libtool.m4 b/libtool.m4
> index 434530059f..c24453fc75 100644
> --- a/libtool.m4
> +++ b/libtool.m4
> @@ -1323,8 +1323,26 @@ need_locks="$enable_libtool_lock"
>   # _LT_CMD_OLD_ARCHIVE
>   # -------------------
>   m4_defun([_LT_CMD_OLD_ARCHIVE],
> -[AC_CHECK_TOOL(AR, ar, false)
> +[plugin_option=
> +plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
> +for plugin in $plugin_names; do
> +  plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
> +  if test x$plugin_so = x$plugin; then
> +    plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
> +  fi
> +  if test x$plugin_so != x$plugin; then
> +    plugin_option="--plugin $plugin_so"
> +    break
> +  fi
> +done
> +
> +AC_CHECK_TOOL(AR, ar, false)
>   test -z "$AR" && AR=ar
> +if test -n "$plugin_option"; then
> +  if $AR --help 2>&1 | grep -q "\--plugin"; then
> +    AR="$AR $plugin_option"
> +  fi
> +fi
>   test -z "$AR_FLAGS" && AR_FLAGS=cru
>   _LT_DECL([], [AR], [1], [The archiver])
>   _LT_DECL([], [AR_FLAGS], [1])
> @@ -1335,6 +1353,11 @@ _LT_DECL([], [STRIP], [1], [A symbol stripping program])
>   
>   AC_CHECK_TOOL(RANLIB, ranlib, :)
>   test -z "$RANLIB" && RANLIB=:
> +if test -n "$plugin_option" && test "$RANLIB" != ":"; then
> +  if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
> +    RANLIB="$RANLIB $plugin_option"
> +  fi
> +fi
>   _LT_DECL([], [RANLIB], [1],
>       [Commands used to install an old-style archive])
>   
> diff --git a/zlib/configure b/zlib/configure
> index de6fa7e996..0d7763b104 100755
> --- a/zlib/configure
> +++ b/zlib/configure
> @@ -5407,6 +5407,19 @@ test -z "$deplibs_check_method" && deplibs_check_method=unknown
>   
>   
>   
> +plugin_option=
> +plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
> +for plugin in $plugin_names; do
> +  plugin_so=`${CC} ${CFLAGS} --print-prog-name plugin`
> +  if  x$plugin_so = x$plugin ; then
> +    plugin_so=`${CC} ${CFLAGS} --print-file-name plugin`
> +  fi
> +  if  x$plugin_so != x$plugin ; then
> +    plugin_option="--plugin $plugin_so"
> +    break
> +  fi
> +done
> +
>   if test -n "$ac_tool_prefix"; then
>     # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
>   set dummy ${ac_tool_prefix}ar; ac_word=$2
> @@ -5500,6 +5513,98 @@ else
>   fi
>   
>   test -z "$AR" && AR=ar
> +if test -n "$ac_tool_prefix"; then
> +  # Extract the first word of "${ac_tool_prefix}"$AR $plugin_option"", so it can be a program name with args.
> +set dummy ${ac_tool_prefix}"$AR $plugin_option"; ac_word=$2
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
> +$as_echo_n "checking for $ac_word... " >&6; }
> +if ${ac_cv_prog_AR+:} false; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -n "$AR"; then
> +  ac_cv_prog_AR="$AR" # Let the user override the test.
> +else
> +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
> +for as_dir in $PATH
> +do
> +  IFS=$as_save_IFS
> +  test -z "$as_dir" && as_dir=.
> +    for ac_exec_ext in '' $ac_executable_extensions; do
> +  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
> +    ac_cv_prog_AR="${ac_tool_prefix}"$AR $plugin_option""
> +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
> +    break 2
> +  fi
> +done
> +  done
> +IFS=$as_save_IFS
> +
> +fi
> +fi
> +AR=$ac_cv_prog_AR
> +if test -n "$AR"; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
> +$as_echo "$AR" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +
> +
> +fi
> +if test -z "$ac_cv_prog_AR"; then
> +  ac_ct_AR=$AR
> +  # Extract the first word of ""$AR $plugin_option"", so it can be a program name with args.
> +set dummy "$AR $plugin_option"; ac_word=$2
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
> +$as_echo_n "checking for $ac_word... " >&6; }
> +if ${ac_cv_prog_ac_ct_AR+:} false; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -n "$ac_ct_AR"; then
> +  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
> +else
> +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
> +for as_dir in $PATH
> +do
> +  IFS=$as_save_IFS
> +  test -z "$as_dir" && as_dir=.
> +    for ac_exec_ext in '' $ac_executable_extensions; do
> +  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
> +    ac_cv_prog_ac_ct_AR=""$AR $plugin_option""
> +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
> +    break 2
> +  fi
> +done
> +  done
> +IFS=$as_save_IFS
> +
> +fi
> +fi
> +ac_ct_AR=$ac_cv_prog_ac_ct_AR
> +if test -n "$ac_ct_AR"; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
> +$as_echo "$ac_ct_AR" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +
> +  if test "x$ac_ct_AR" = x; then
> +    AR="$AR"
> +  else
> +    case $cross_compiling:$ac_tool_warned in
> +yes:)
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
> +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
> +ac_tool_warned=yes ;;
> +esac
> +    AR=$ac_ct_AR
> +  fi
> +else
> +  AR="$ac_cv_prog_AR"
> +fi
> +
>   test -z "$AR_FLAGS" && AR_FLAGS=cru
>   
>   
> @@ -5703,7 +5808,102 @@ else
>     RANLIB="$ac_cv_prog_RANLIB"
>   fi
>   
> -test -z "$RANLIB" && RANLIB=:
> +if test -z "$RANLIB"; then
> +  RANLIB=:
> +else
> +  if test -n "$ac_tool_prefix"; then
> +  # Extract the first word of "${ac_tool_prefix}"$RANLIB $plugin_option"", so it can be a program name with args.
> +set dummy ${ac_tool_prefix}"$RANLIB $plugin_option"; ac_word=$2
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
> +$as_echo_n "checking for $ac_word... " >&6; }
> +if ${ac_cv_prog_RANLIB+:} false; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -n "$RANLIB"; then
> +  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
> +else
> +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
> +for as_dir in $PATH
> +do
> +  IFS=$as_save_IFS
> +  test -z "$as_dir" && as_dir=.
> +    for ac_exec_ext in '' $ac_executable_extensions; do
> +  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
> +    ac_cv_prog_RANLIB="${ac_tool_prefix}"$RANLIB $plugin_option""
> +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
> +    break 2
> +  fi
> +done
> +  done
> +IFS=$as_save_IFS
> +
> +fi
> +fi
> +RANLIB=$ac_cv_prog_RANLIB
> +if test -n "$RANLIB"; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
> +$as_echo "$RANLIB" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +
> +
> +fi
> +if test -z "$ac_cv_prog_RANLIB"; then
> +  ac_ct_RANLIB=$RANLIB
> +  # Extract the first word of ""$RANLIB $plugin_option"", so it can be a program name with args.
> +set dummy "$RANLIB $plugin_option"; ac_word=$2
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
> +$as_echo_n "checking for $ac_word... " >&6; }
> +if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -n "$ac_ct_RANLIB"; then
> +  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
> +else
> +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
> +for as_dir in $PATH
> +do
> +  IFS=$as_save_IFS
> +  test -z "$as_dir" && as_dir=.
> +    for ac_exec_ext in '' $ac_executable_extensions; do
> +  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
> +    ac_cv_prog_ac_ct_RANLIB=""$RANLIB $plugin_option""
> +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
> +    break 2
> +  fi
> +done
> +  done
> +IFS=$as_save_IFS
> +
> +fi
> +fi
> +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
> +if test -n "$ac_ct_RANLIB"; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
> +$as_echo "$ac_ct_RANLIB" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +
> +  if test "x$ac_ct_RANLIB" = x; then
> +    RANLIB="$RANLIB"
> +  else
> +    case $cross_compiling:$ac_tool_warned in
> +yes:)
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
> +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
> +ac_tool_warned=yes ;;
> +esac
> +    RANLIB=$ac_ct_RANLIB
> +  fi
> +else
> +  RANLIB="$ac_cv_prog_RANLIB"
> +fi
> +
> +fi
>   
>   
>   
> @@ -10644,7 +10844,7 @@ else
>     lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>     lt_status=$lt_dlunknown
>     cat > conftest.$ac_ext <<_LT_EOF
> -#line 10647 "configure"
> +#line 10847 "configure"
>   #include "confdefs.h"
>   
>   #if HAVE_DLFCN_H
> @@ -10750,7 +10950,7 @@ else
>     lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>     lt_status=$lt_dlunknown
>     cat > conftest.$ac_ext <<_LT_EOF
> -#line 10753 "configure"
> +#line 10953 "configure"
>   #include "confdefs.h"
>   
>   #if HAVE_DLFCN_H
> 

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

* Re: [PATCH 1/3] GCC: Pass --plugin to AR and RANLIB
  2021-01-11 14:58   ` Luis Machado
@ 2021-01-11 16:48     ` Hans-Peter Nilsson
  0 siblings, 0 replies; 13+ messages in thread
From: Hans-Peter Nilsson @ 2021-01-11 16:48 UTC (permalink / raw)
  To: hjl.tools; +Cc: Luis Machado, binutils, gcc-patches

> From: Luis Machado via Gcc-patches <gcc-patches@gcc.gnu.org>
> Date: Mon, 11 Jan 2021 15:58:43 +0100

> This seems to have broken the builds on AArch64-Linux Ubuntu 18.04.
> 
> make[2]: Entering directory 'binutils-gdb-master-bionic/libiberty'
> rm -f ./libiberty.a pic/./libiberty.a noasan/./libiberty.a
> ar --plugin /usr/lib/gcc/aarch64-linux-gnu/7/liblto_plugin.so rc 
> ./libiberty.a \
>    ./regex.o ./cplus-dem.o ./cp-demangle.o ./md5.o ./sha1.o ./alloca.o 
> ./argv.o ./bsearch_r.o ./choose-temp.o ./concat.o ./cp-demint.o 
> ./crc32.o ./d-demangle.o ./dwarfnames.o ./dyn-string.o ./fdmatch.o 
> ./fibheap.o ./filedescriptor.o ./filename_cmp.o ./floatformat.o 
> ./fnmatch.o ./fopen_unlocked.o ./getopt.o ./getopt1.o ./getpwd.o 
> ./getruntime.o ./hashtab.o ./hex.o ./lbasename.o ./lrealpath.o 
> ./make-relative-prefix.o ./make-temp-file.o ./objalloc.o ./obstack.o 
> ./partition.o ./pexecute.o ./physmem.o ./pex-common.o ./pex-one.o 
> ./pex-unix.o ./vprintf-support.o ./rust-demangle.o ./safe-ctype.o 
> ./simple-object.o ./simple-object-coff.o ./simple-object-elf.o 
> ./simple-object-mach-o.o ./simple-object-xcoff.o ./sort.o ./spaces.o 
> ./splay-tree.o ./stack-limit.o ./strerror.o ./strsignal.o 
> ./timeval-utils.o ./unlink-if-ordinary.o ./xasprintf.o ./xatexit.o 
> ./xexit.o ./xmalloc.o ./xmemdup.o ./xstrdup.o ./xstrerror.o ./xstrndup.o 
> ./xvasprintf.o  ./setproctitle.o
> ar: no operation specified
> Makefile:252: recipe for target 'libiberty.a' failed
> make[2]: *** [libiberty.a] Error 1

Also seen in my binutils autotester testing
a9fd212a2416..af019bfde9b1, for "all" cross-targets
(mmix-knuth-mmixware, cris-axis-linux-gnu, cris-axis-elf) *and*
for native, stock Debian 9 x86_64.

The native build attempt was configured with
<path>/binutils-gdb-git/configure --enable-plugins \
 --disable-gdb --disable-gdbserver --disable-libdecnumber --disable-readline --disable-sim \
 --with-sysroot=/ --with-system-zlib --prefix=/usr/local --with-local-prefix=/usr/local
and the build failed with "make", as quoted.

brgds, H-P

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

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

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-29 19:11 [PATCH 0/3] Enable PGO/LTO build for binutils+gdb H.J. Lu
2020-10-29 19:11 ` [PATCH 1/3] GCC: Pass --plugin to AR and RANLIB H.J. Lu
2021-01-11 14:58   ` Luis Machado
2021-01-11 16:48     ` Hans-Peter Nilsson
2020-10-29 19:11 ` [PATCH 2/3] Binutils: " H.J. Lu
2020-10-29 19:11 ` [PATCH 3/3] Support the PGO build for binutils+gdb H.J. Lu
2020-12-17 16:16   ` Matthias Klose
2020-12-17 16:54   ` Matthias Klose
2020-11-16 13:11 ` PING [PATCH 0/3] Enable PGO/LTO " H.J. Lu
2020-11-27 15:21 ` Martin Liška
2020-12-15 17:10 ` PING^1 " H.J. Lu
2020-12-19  9:27 ` Matthias Klose
2020-12-19 13:21   ` 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).