public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Check if AR works with --plugin and rc
@ 2021-01-11 16:57 H.J. Lu
  2021-01-11 16:57 ` [PATCH 1/2] GCC: " H.J. Lu
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: H.J. Lu @ 2021-01-11 16:57 UTC (permalink / raw)
  To: binutils; +Cc: gcc-patches, Joel Brobecker, gdb-patches

AR from older binutils doesn't work with --plugin and rc:

[hjl@gnu-cfl-2 bin]$ touch foo.c
[hjl@gnu-cfl-2 bin]$ ar --plugin /usr/libexec/gcc/x86_64-redhat-linux/10/liblto_plugin.so rc libfoo.a foo.c
[hjl@gnu-cfl-2 bin]$ ./ar --plugin /usr/libexec/gcc/x86_64-redhat-linux/10/liblto_plugin.so rc libfoo.a foo.c
./ar: no operation specified
[hjl@gnu-cfl-2 bin]$ ./ar --version
GNU ar (Linux/GNU Binutils) 2.29.51.0.1.20180112
Copyright (C) 2018 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.
[hjl@gnu-cfl-2 bin]$

Check if AR works with --plugin and rc before passing --plugin to AR and
RANLIB.

Tested:

1. Binutils build
2. ./src-release.sh gdb
3. ./src-release.sh binutils 

with binutils 2.30.

H.J. Lu (2):
  GCC: Check if AR works with --plugin and rc
  Binutils: Check if AR works with --plugin and rc

 bfd/configure        |  13 ++++--
 binutils/configure   |  13 ++++--
 config/gcc-plugin.m4 |  12 +++++
 configure            | 102 +++++++++++++++++++++++++++++++++++++++++++
 gas/configure        |  13 ++++--
 gprof/configure      |  13 ++++--
 ld/configure         |  13 ++++--
 libctf/configure     |  13 ++++--
 libiberty/configure  | 102 +++++++++++++++++++++++++++++++++++++++++++
 libtool.m4           |   9 +++-
 opcodes/configure    |  13 ++++--
 zlib/configure       |  13 ++++--
 12 files changed, 304 insertions(+), 25 deletions(-)

-- 
2.29.2


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

* [PATCH 1/2] GCC: Check if AR works with --plugin and rc
  2021-01-11 16:57 [PATCH 0/2] Check if AR works with --plugin and rc H.J. Lu
@ 2021-01-11 16:57 ` H.J. Lu
  2021-01-11 23:27   ` Alan Modra
  2021-01-11 16:57 ` [PATCH 2/2] Binutils: " H.J. Lu
  2021-01-11 23:05 ` [PATCH 0/2] " Alan Modra
  2 siblings, 1 reply; 9+ messages in thread
From: H.J. Lu @ 2021-01-11 16:57 UTC (permalink / raw)
  To: binutils; +Cc: gcc-patches, Joel Brobecker, gdb-patches

AR from older binutils doesn't work with --plugin and rc:

[hjl@gnu-cfl-2 bin]$ touch foo.c
[hjl@gnu-cfl-2 bin]$ ar --plugin /usr/libexec/gcc/x86_64-redhat-linux/10/liblto_plugin.so rc libfoo.a foo.c
[hjl@gnu-cfl-2 bin]$ ./ar --plugin /usr/libexec/gcc/x86_64-redhat-linux/10/liblto_plugin.so rc libfoo.a foo.c
./ar: no operation specified
[hjl@gnu-cfl-2 bin]$ ./ar --version
GNU ar (Linux/GNU Binutils) 2.29.51.0.1.20180112
Copyright (C) 2018 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.
[hjl@gnu-cfl-2 bin]$

Check if AR works with --plugin and rc before passing --plugin to AR and
RANLIB.

	PR ld/27173
	* configure: Regenerated.

config/

	PR ld/27173
	* gcc-plugin.m4 (GCC_PLUGIN_OPTION): Check if AR works with
	--plugin and rc before enabling --plugin.

libiberty/

	PR ld/27173
	* configure: Regenerated.

zlib/

	PR ld/27173
	* configure: Regenerated.
---
 config/gcc-plugin.m4 |  12 +++++
 configure            | 102 +++++++++++++++++++++++++++++++++++++++++++
 libiberty/configure  | 102 +++++++++++++++++++++++++++++++++++++++++++
 libtool.m4           |   9 +++-
 zlib/configure       |  13 ++++--
 5 files changed, 234 insertions(+), 4 deletions(-)

diff --git a/config/gcc-plugin.m4 b/config/gcc-plugin.m4
index c5b72e9a13d..798a2054edd 100644
--- a/config/gcc-plugin.m4
+++ b/config/gcc-plugin.m4
@@ -145,6 +145,18 @@ for plugin in $plugin_names; do
     break
   fi
 done
+dnl Check if ${AR} $plugin_option rc works.
+AC_CHECK_TOOL(AR, ar)
+if test "${AR}" = "" ; then
+  AC_MSG_ERROR([Required archive tool 'ar' not found on PATH.])
+fi
+touch conftest.c
+${AR} $plugin_option rc conftest.a conftest.c
+if test "$?" != 0; then
+  echo "Failed: ${AR} $plugin_option rc"
+  plugin_option=
+fi
+rm -f conftest.*
 if test -n "$plugin_option"; then
   $1="$plugin_option"
   AC_MSG_RESULT($plugin_option)
diff --git a/configure b/configure
index a75bc26978c..c44184f72ff 100755
--- a/configure
+++ b/configure
@@ -10120,6 +10120,108 @@ for plugin in $plugin_names; do
     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
+{ $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"
+    $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", so it can be a program name with args.
+set dummy ar; 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"
+    $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=""
+  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
+
+if test "${AR}" = "" ; then
+  as_fn_error $? "Required archive tool 'ar' not found on PATH." "$LINENO" 5
+fi
+touch conftest.c
+${AR} $plugin_option rc conftest.a conftest.c
+if test "$?" != 0; then
+  echo "Failed: ${AR} $plugin_option rc"
+  plugin_option=
+fi
+rm -f conftest.*
 if test -n "$plugin_option"; then
   PLUGIN_OPTION="$plugin_option"
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $plugin_option" >&5
diff --git a/libiberty/configure b/libiberty/configure
index 5d7aee38903..ae50e97d0c4 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -2949,6 +2949,108 @@ for plugin in $plugin_names; do
     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
+{ $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"
+    $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", so it can be a program name with args.
+set dummy ar; 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"
+    $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=""
+  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
+
+if test "${AR}" = "" ; then
+  as_fn_error $? "Required archive tool 'ar' not found on PATH." "$LINENO" 5
+fi
+touch conftest.c
+${AR} $plugin_option rc conftest.a conftest.c
+if test "$?" != 0; then
+  echo "Failed: ${AR} $plugin_option rc"
+  plugin_option=
+fi
+rm -f conftest.*
 if test -n "$plugin_option"; then
   PLUGIN_OPTION="$plugin_option"
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $plugin_option" >&5
diff --git a/libtool.m4 b/libtool.m4
index 3672e9516e2..150971974c1 100644
--- a/libtool.m4
+++ b/libtool.m4
@@ -1340,7 +1340,14 @@ 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"
+    touch conftest.c
+    $AR $plugin_option rc conftest.a conftest.c
+    if test "$?" != 0; then
+      echo "Failed: $AR $plugin_option rc"
+    else
+      AR="$AR $plugin_option"
+    fi
+    rm -f conftest.*
   fi
 fi
 test -z "$AR_FLAGS" && AR_FLAGS=cru
diff --git a/zlib/configure b/zlib/configure
index 79a79c5d9e7..9e8126e35d1 100755
--- a/zlib/configure
+++ b/zlib/configure
@@ -5515,7 +5515,14 @@ 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"
+    touch conftest.c
+    $AR $plugin_option rc conftest.a conftest.c
+    if test "$?" != 0; then
+      echo "Failed: $AR $plugin_option rc"
+    else
+      AR="$AR $plugin_option"
+    fi
+    rm -f conftest.*
   fi
 fi
 test -z "$AR_FLAGS" && AR_FLAGS=cru
@@ -10657,7 +10664,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10660 "configure"
+#line 10667 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10763,7 +10770,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10766 "configure"
+#line 10773 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
-- 
2.29.2


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

* [PATCH 2/2] Binutils: Check if AR works with --plugin and rc
  2021-01-11 16:57 [PATCH 0/2] Check if AR works with --plugin and rc H.J. Lu
  2021-01-11 16:57 ` [PATCH 1/2] GCC: " H.J. Lu
@ 2021-01-11 16:57 ` H.J. Lu
  2021-01-11 23:05 ` [PATCH 0/2] " Alan Modra
  2 siblings, 0 replies; 9+ messages in thread
From: H.J. Lu @ 2021-01-11 16:57 UTC (permalink / raw)
  To: binutils; +Cc: gcc-patches, Joel Brobecker, gdb-patches

Check if AR works with --plugin and rc before passing --plugin to AR and
RANLIB.

bfd/

	PR ld/27173

binutils/

	PR ld/27173
	* configure: Regenerated.

gas/

	PR ld/27173
	* configure: Regenerated.

gprof/

	PR ld/27173
	* configure: Regenerated.

ld/

	PR ld/27173
	* configure: Regenerated.

libctf/

	PR ld/27173
	* configure: Regenerated.

opcodes/

	PR ld/27173
	* configure: Regenerated.
---
 bfd/configure      | 13 ++++++++++---
 binutils/configure | 13 ++++++++++---
 gas/configure      | 13 ++++++++++---
 gprof/configure    | 13 ++++++++++---
 ld/configure       | 13 ++++++++++---
 libctf/configure   | 13 ++++++++++---
 opcodes/configure  | 13 ++++++++++---
 7 files changed, 70 insertions(+), 21 deletions(-)

diff --git a/bfd/configure b/bfd/configure
index 4b8dede2150..6142cb26f50 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -6932,7 +6932,14 @@ 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"
+    touch conftest.c
+    $AR $plugin_option rc conftest.a conftest.c
+    if test "$?" != 0; then
+      echo "Failed: $AR $plugin_option rc"
+    else
+      AR="$AR $plugin_option"
+    fi
+    rm -f conftest.*
   fi
 fi
 test -z "$AR_FLAGS" && AR_FLAGS=cru
@@ -11742,7 +11749,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11745 "configure"
+#line 11752 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11848,7 +11855,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11851 "configure"
+#line 11858 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/binutils/configure b/binutils/configure
index f1b80648d3f..249aa16c6fc 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -6728,7 +6728,14 @@ 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"
+    touch conftest.c
+    $AR $plugin_option rc conftest.a conftest.c
+    if test "$?" != 0; then
+      echo "Failed: $AR $plugin_option rc"
+    else
+      AR="$AR $plugin_option"
+    fi
+    rm -f conftest.*
   fi
 fi
 test -z "$AR_FLAGS" && AR_FLAGS=cru
@@ -11569,7 +11576,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11572 "configure"
+#line 11579 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11675,7 +11682,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11678 "configure"
+#line 11685 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gas/configure b/gas/configure
index 43ac48491db..57aef39de28 100755
--- a/gas/configure
+++ b/gas/configure
@@ -6516,7 +6516,14 @@ 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"
+    touch conftest.c
+    $AR $plugin_option rc conftest.a conftest.c
+    if test "$?" != 0; then
+      echo "Failed: $AR $plugin_option rc"
+    else
+      AR="$AR $plugin_option"
+    fi
+    rm -f conftest.*
   fi
 fi
 test -z "$AR_FLAGS" && AR_FLAGS=cru
@@ -11357,7 +11364,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11360 "configure"
+#line 11367 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11463,7 +11470,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11466 "configure"
+#line 11473 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gprof/configure b/gprof/configure
index ce3a1d5bd11..30dc9257368 100755
--- a/gprof/configure
+++ b/gprof/configure
@@ -6363,7 +6363,14 @@ 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"
+    touch conftest.c
+    $AR $plugin_option rc conftest.a conftest.c
+    if test "$?" != 0; then
+      echo "Failed: $AR $plugin_option rc"
+    else
+      AR="$AR $plugin_option"
+    fi
+    rm -f conftest.*
   fi
 fi
 test -z "$AR_FLAGS" && AR_FLAGS=cru
@@ -11204,7 +11211,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11207 "configure"
+#line 11214 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11310,7 +11317,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11313 "configure"
+#line 11320 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/ld/configure b/ld/configure
index d7cd782957f..e551a2e431b 100755
--- a/ld/configure
+++ b/ld/configure
@@ -7214,7 +7214,14 @@ 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"
+    touch conftest.c
+    $AR $plugin_option rc conftest.a conftest.c
+    if test "$?" != 0; then
+      echo "Failed: $AR $plugin_option rc"
+    else
+      AR="$AR $plugin_option"
+    fi
+    rm -f conftest.*
   fi
 fi
 test -z "$AR_FLAGS" && AR_FLAGS=cru
@@ -12056,7 +12063,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12059 "configure"
+#line 12066 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12162,7 +12169,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12165 "configure"
+#line 12172 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/libctf/configure b/libctf/configure
index 3d2f22528d3..b4e6a4cc1f2 100755
--- a/libctf/configure
+++ b/libctf/configure
@@ -6720,7 +6720,14 @@ 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"
+    touch conftest.c
+    $AR $plugin_option rc conftest.a conftest.c
+    if test "$?" != 0; then
+      echo "Failed: $AR $plugin_option rc"
+    else
+      AR="$AR $plugin_option"
+    fi
+    rm -f conftest.*
   fi
 fi
 test -z "$AR_FLAGS" && AR_FLAGS=cru
@@ -11531,7 +11538,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11534 "configure"
+#line 11541 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11637,7 +11644,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11640 "configure"
+#line 11647 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/opcodes/configure b/opcodes/configure
index 92b4b2247d6..6149d0529b5 100755
--- a/opcodes/configure
+++ b/opcodes/configure
@@ -6641,7 +6641,14 @@ 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"
+    touch conftest.c
+    $AR $plugin_option rc conftest.a conftest.c
+    if test "$?" != 0; then
+      echo "Failed: $AR $plugin_option rc"
+    else
+      AR="$AR $plugin_option"
+    fi
+    rm -f conftest.*
   fi
 fi
 test -z "$AR_FLAGS" && AR_FLAGS=cru
@@ -11452,7 +11459,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11455 "configure"
+#line 11462 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11558,7 +11565,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11561 "configure"
+#line 11568 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
-- 
2.29.2


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

* Re: [PATCH 0/2] Check if AR works with --plugin and rc
  2021-01-11 16:57 [PATCH 0/2] Check if AR works with --plugin and rc H.J. Lu
  2021-01-11 16:57 ` [PATCH 1/2] GCC: " H.J. Lu
  2021-01-11 16:57 ` [PATCH 2/2] Binutils: " H.J. Lu
@ 2021-01-11 23:05 ` Alan Modra
  2021-01-11 23:08   ` H.J. Lu
  2 siblings, 1 reply; 9+ messages in thread
From: Alan Modra @ 2021-01-11 23:05 UTC (permalink / raw)
  To: H.J. Lu; +Cc: binutils, gcc-patches, gdb-patches, Joel Brobecker

On Mon, Jan 11, 2021 at 08:57:04AM -0800, H.J. Lu via Binutils wrote:
> Check if AR works with --plugin and rc before passing --plugin to AR and
> RANLIB.

Thanks for looking at this, but next time please assign the bug to
yourself.  I fixed the bug too this morning, before seeing your
email.

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: [PATCH 0/2] Check if AR works with --plugin and rc
  2021-01-11 23:05 ` [PATCH 0/2] " Alan Modra
@ 2021-01-11 23:08   ` H.J. Lu
  0 siblings, 0 replies; 9+ messages in thread
From: H.J. Lu @ 2021-01-11 23:08 UTC (permalink / raw)
  To: Alan Modra; +Cc: Binutils, GCC Patches, GDB, Joel Brobecker

On Mon, Jan 11, 2021 at 3:05 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Mon, Jan 11, 2021 at 08:57:04AM -0800, H.J. Lu via Binutils wrote:
> > Check if AR works with --plugin and rc before passing --plugin to AR and
> > RANLIB.
>
> Thanks for looking at this, but next time please assign the bug to
> yourself.  I fixed the bug too this morning, before seeing your
> email.

Will do.

-- 
H.J.

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

* Re: [PATCH 1/2] GCC: Check if AR works with --plugin and rc
  2021-01-11 16:57 ` [PATCH 1/2] GCC: " H.J. Lu
@ 2021-01-11 23:27   ` Alan Modra
  2021-01-12  0:07     ` V2 " H.J. Lu
  0 siblings, 1 reply; 9+ messages in thread
From: Alan Modra @ 2021-01-11 23:27 UTC (permalink / raw)
  To: H.J. Lu; +Cc: binutils, gcc-patches, gdb-patches, Joel Brobecker

On Mon, Jan 11, 2021 at 08:57:05AM -0800, H.J. Lu via Binutils wrote:
> diff --git a/config/gcc-plugin.m4 b/config/gcc-plugin.m4
> index c5b72e9a13d..798a2054edd 100644
> --- a/config/gcc-plugin.m4
> +++ b/config/gcc-plugin.m4
> @@ -145,6 +145,18 @@ for plugin in $plugin_names; do
>      break
>    fi
>  done
> +dnl Check if ${AR} $plugin_option rc works.
> +AC_CHECK_TOOL(AR, ar)
> +if test "${AR}" = "" ; then
> +  AC_MSG_ERROR([Required archive tool 'ar' not found on PATH.])
> +fi
> +touch conftest.c
> +${AR} $plugin_option rc conftest.a conftest.c
> +if test "$?" != 0; then
> +  echo "Failed: ${AR} $plugin_option rc"

Use AC_MSG_ERROR rather than echo.

> +  plugin_option=
> +fi
> +rm -f conftest.*
>  if test -n "$plugin_option"; then
>    $1="$plugin_option"
>    AC_MSG_RESULT($plugin_option)

> diff --git a/libtool.m4 b/libtool.m4
> index 3672e9516e2..150971974c1 100644
> --- a/libtool.m4
> +++ b/libtool.m4
> @@ -1340,7 +1340,14 @@ 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"
> +    touch conftest.c
> +    $AR $plugin_option rc conftest.a conftest.c
> +    if test "$?" != 0; then
> +      echo "Failed: $AR $plugin_option rc"

AC_MSG_ERROR again.

> +    else
> +      AR="$AR $plugin_option"
> +    fi
> +    rm -f conftest.*
>    fi
>  fi
>  test -z "$AR_FLAGS" && AR_FLAGS=cru

-- 
Alan Modra
Australia Development Lab, IBM

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

* V2 [PATCH 1/2] GCC: Check if AR works with --plugin and rc
  2021-01-11 23:27   ` Alan Modra
@ 2021-01-12  0:07     ` H.J. Lu
  2021-01-12  0:22       ` Alan Modra
  0 siblings, 1 reply; 9+ messages in thread
From: H.J. Lu @ 2021-01-12  0:07 UTC (permalink / raw)
  To: Alan Modra; +Cc: Binutils, GCC Patches, GDB, Joel Brobecker

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

On Mon, Jan 11, 2021 at 3:27 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Mon, Jan 11, 2021 at 08:57:05AM -0800, H.J. Lu via Binutils wrote:
> > diff --git a/config/gcc-plugin.m4 b/config/gcc-plugin.m4
> > index c5b72e9a13d..798a2054edd 100644
> > --- a/config/gcc-plugin.m4
> > +++ b/config/gcc-plugin.m4
> > @@ -145,6 +145,18 @@ for plugin in $plugin_names; do
> >      break
> >    fi
> >  done
> > +dnl Check if ${AR} $plugin_option rc works.
> > +AC_CHECK_TOOL(AR, ar)
> > +if test "${AR}" = "" ; then
> > +  AC_MSG_ERROR([Required archive tool 'ar' not found on PATH.])
> > +fi
> > +touch conftest.c
> > +${AR} $plugin_option rc conftest.a conftest.c
> > +if test "$?" != 0; then
> > +  echo "Failed: ${AR} $plugin_option rc"
>
> Use AC_MSG_ERROR rather than echo.
>
> > +  plugin_option=
> > +fi
> > +rm -f conftest.*
> >  if test -n "$plugin_option"; then
> >    $1="$plugin_option"
> >    AC_MSG_RESULT($plugin_option)
>
> > diff --git a/libtool.m4 b/libtool.m4
> > index 3672e9516e2..150971974c1 100644
> > --- a/libtool.m4
> > +++ b/libtool.m4
> > @@ -1340,7 +1340,14 @@ 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"
> > +    touch conftest.c
> > +    $AR $plugin_option rc conftest.a conftest.c
> > +    if test "$?" != 0; then
> > +      echo "Failed: $AR $plugin_option rc"
>
> AC_MSG_ERROR again.

These are not fatal errors.  Here is the updated patch to use
AC_MSG_WARN instead.  OK for master?

-- 
H.J.

[-- Attachment #2: 0001-GCC-Check-if-AR-works-with-plugin-and-rc.patch --]
[-- Type: text/x-patch, Size: 10721 bytes --]

From 90e4f853ef5b0291d7cc514fffc80794a91b7012 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Mon, 11 Jan 2021 08:22:35 -0800
Subject: [PATCH] GCC: Check if AR works with --plugin and rc

AR from older binutils doesn't work with --plugin and rc:

[hjl@gnu-cfl-2 bin]$ touch foo.c
[hjl@gnu-cfl-2 bin]$ ar --plugin /usr/libexec/gcc/x86_64-redhat-linux/10/liblto_plugin.so rc libfoo.a foo.c
[hjl@gnu-cfl-2 bin]$ ./ar --plugin /usr/libexec/gcc/x86_64-redhat-linux/10/liblto_plugin.so rc libfoo.a foo.c
./ar: no operation specified
[hjl@gnu-cfl-2 bin]$ ./ar --version
GNU ar (Linux/GNU Binutils) 2.29.51.0.1.20180112
Copyright (C) 2018 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.
[hjl@gnu-cfl-2 bin]$

Check if AR works with --plugin and rc before passing --plugin to AR and
RANLIB.

	PR ld/27173
	* configure: Regenerated.
	* libtool.m4 (_LT_CMD_OLD_ARCHIVE): Check if AR works with
	--plugin and rc before enabling --plugin.

config/

	PR ld/27173
	* gcc-plugin.m4 (GCC_PLUGIN_OPTION): Check if AR works with
	--plugin and rc before enabling --plugin.

libiberty/

	PR ld/27173
	* configure: Regenerated.

zlib/

	PR ld/27173
	* configure: Regenerated.
---
 config/gcc-plugin.m4 |  12 +++++
 configure            | 103 +++++++++++++++++++++++++++++++++++++++++++
 libiberty/configure  | 103 +++++++++++++++++++++++++++++++++++++++++++
 libtool.m4           |   9 +++-
 zlib/configure       |  14 ++++--
 5 files changed, 237 insertions(+), 4 deletions(-)

diff --git a/config/gcc-plugin.m4 b/config/gcc-plugin.m4
index c5b72e9a13d..ca98d674912 100644
--- a/config/gcc-plugin.m4
+++ b/config/gcc-plugin.m4
@@ -145,6 +145,18 @@ for plugin in $plugin_names; do
     break
   fi
 done
+dnl Check if ${AR} $plugin_option rc works.
+AC_CHECK_TOOL(AR, ar)
+if test "${AR}" = "" ; then
+  AC_MSG_ERROR([Required archive tool 'ar' not found on PATH.])
+fi
+touch conftest.c
+${AR} $plugin_option rc conftest.a conftest.c
+if test "$?" != 0; then
+  AC_MSG_WARN([Failed: $AR $plugin_option rc])
+  plugin_option=
+fi
+rm -f conftest.*
 if test -n "$plugin_option"; then
   $1="$plugin_option"
   AC_MSG_RESULT($plugin_option)
diff --git a/configure b/configure
index a75bc26978c..5437ef12c72 100755
--- a/configure
+++ b/configure
@@ -10120,6 +10120,109 @@ for plugin in $plugin_names; do
     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
+{ $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"
+    $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", so it can be a program name with args.
+set dummy ar; 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"
+    $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=""
+  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
+
+if test "${AR}" = "" ; then
+  as_fn_error $? "Required archive tool 'ar' not found on PATH." "$LINENO" 5
+fi
+touch conftest.c
+${AR} $plugin_option rc conftest.a conftest.c
+if test "$?" != 0; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Failed: $AR $plugin_option rc" >&5
+$as_echo "$as_me: WARNING: Failed: $AR $plugin_option rc" >&2;}
+  plugin_option=
+fi
+rm -f conftest.*
 if test -n "$plugin_option"; then
   PLUGIN_OPTION="$plugin_option"
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $plugin_option" >&5
diff --git a/libiberty/configure b/libiberty/configure
index 5d7aee38903..160b8c9e8b1 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -2949,6 +2949,109 @@ for plugin in $plugin_names; do
     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
+{ $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"
+    $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", so it can be a program name with args.
+set dummy ar; 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"
+    $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=""
+  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
+
+if test "${AR}" = "" ; then
+  as_fn_error $? "Required archive tool 'ar' not found on PATH." "$LINENO" 5
+fi
+touch conftest.c
+${AR} $plugin_option rc conftest.a conftest.c
+if test "$?" != 0; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Failed: $AR $plugin_option rc" >&5
+$as_echo "$as_me: WARNING: Failed: $AR $plugin_option rc" >&2;}
+  plugin_option=
+fi
+rm -f conftest.*
 if test -n "$plugin_option"; then
   PLUGIN_OPTION="$plugin_option"
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $plugin_option" >&5
diff --git a/libtool.m4 b/libtool.m4
index 3672e9516e2..9a13f3b117a 100644
--- a/libtool.m4
+++ b/libtool.m4
@@ -1340,7 +1340,14 @@ 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"
+    touch conftest.c
+    $AR $plugin_option rc conftest.a conftest.c
+    if test "$?" != 0; then
+      AC_MSG_WARN([Failed: $AR $plugin_option rc])
+    else
+      AR="$AR $plugin_option"
+    fi
+    rm -f conftest.*
   fi
 fi
 test -z "$AR_FLAGS" && AR_FLAGS=cru
diff --git a/zlib/configure b/zlib/configure
index 79a79c5d9e7..695819cd54b 100755
--- a/zlib/configure
+++ b/zlib/configure
@@ -5515,7 +5515,15 @@ 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"
+    touch conftest.c
+    $AR $plugin_option rc conftest.a conftest.c
+    if test "$?" != 0; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Failed: $AR $plugin_option rc" >&5
+$as_echo "$as_me: WARNING: Failed: $AR $plugin_option rc" >&2;}
+    else
+      AR="$AR $plugin_option"
+    fi
+    rm -f conftest.*
   fi
 fi
 test -z "$AR_FLAGS" && AR_FLAGS=cru
@@ -10657,7 +10665,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10660 "configure"
+#line 10668 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10763,7 +10771,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10766 "configure"
+#line 10774 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
-- 
2.29.2


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

* Re: V2 [PATCH 1/2] GCC: Check if AR works with --plugin and rc
  2021-01-12  0:07     ` V2 " H.J. Lu
@ 2021-01-12  0:22       ` Alan Modra
  2021-01-12  0:24         ` H.J. Lu
  0 siblings, 1 reply; 9+ messages in thread
From: Alan Modra @ 2021-01-12  0:22 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Binutils, GCC Patches, GDB, Joel Brobecker

On Mon, Jan 11, 2021 at 04:07:22PM -0800, H.J. Lu wrote:
> These are not fatal errors.  Here is the updated patch to use
> AC_MSG_WARN instead.  OK for master?

OK by me.  Please squash the two patches.

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: V2 [PATCH 1/2] GCC: Check if AR works with --plugin and rc
  2021-01-12  0:22       ` Alan Modra
@ 2021-01-12  0:24         ` H.J. Lu
  0 siblings, 0 replies; 9+ messages in thread
From: H.J. Lu @ 2021-01-12  0:24 UTC (permalink / raw)
  To: Alan Modra; +Cc: Binutils, GCC Patches, GDB, Joel Brobecker

On Mon, Jan 11, 2021 at 4:22 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Mon, Jan 11, 2021 at 04:07:22PM -0800, H.J. Lu wrote:
> > These are not fatal errors.  Here is the updated patch to use
> > AC_MSG_WARN instead.  OK for master?
>
> OK by me.  Please squash the two patches.
>

I will keep 2 separate since I am hoping the first one can go into GCC.

-- 
H.J.

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

end of thread, other threads:[~2021-01-12  0:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-11 16:57 [PATCH 0/2] Check if AR works with --plugin and rc H.J. Lu
2021-01-11 16:57 ` [PATCH 1/2] GCC: " H.J. Lu
2021-01-11 23:27   ` Alan Modra
2021-01-12  0:07     ` V2 " H.J. Lu
2021-01-12  0:22       ` Alan Modra
2021-01-12  0:24         ` H.J. Lu
2021-01-11 16:57 ` [PATCH 2/2] Binutils: " H.J. Lu
2021-01-11 23:05 ` [PATCH 0/2] " Alan Modra
2021-01-11 23:08   ` 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).