Skip to content

Commit

Permalink
GCC: Check if AR works with --plugin and rc
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hjl-tools committed Jan 12, 2021
1 parent eabdd87 commit 03c02f3
Show file tree
Hide file tree
Showing 9 changed files with 260 additions and 4 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2021-01-11 H.J. Lu <[email protected]>

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

2021-01-09 H.J. Lu <[email protected]>

PR binutils/26766
Expand Down
6 changes: 6 additions & 0 deletions config/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2021-01-11 H.J. Lu <[email protected]>

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

2021-01-09 H.J. Lu <[email protected]>

* gcc-plugin.m4 (GCC_PLUGIN_OPTION): New.
Expand Down
12 changes: 12 additions & 0 deletions config/gcc-plugin.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
103 changes: 103 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions libiberty/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2021-01-11 H.J. Lu <[email protected]>

PR ld/27173
* configure: Regenerated.

2021-01-09 H.J. Lu <[email protected]>

* Makefile.in (AR): Add @AR_PLUGIN_OPTION@
Expand Down
103 changes: 103 additions & 0 deletions libiberty/configure
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion libtool.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions zlib/ChangeLog.bin-gdb
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2021-01-11 H.J. Lu <[email protected]>

PR ld/27173
* configure: Regenerated.

2021-01-09 H.J. Lu <[email protected]>

* configure: Regenerated.
Expand Down
14 changes: 11 additions & 3 deletions zlib/configure
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 03c02f3

Please sign in to comment.