public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: newlib@sourceware.org
Subject: [PATCH 4/7] GCC: Check if AR works with --plugin and rc
Date: Sat,  1 Jan 2022 15:05:51 -0500	[thread overview]
Message-ID: <20220101200554.16454-5-vapier@gentoo.org> (raw)
In-Reply-To: <20220101200554.16454-1-vapier@gentoo.org>

From: "H.J. Lu" <hjl.tools@gmail.com>

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 ++++++++++++
 libtool.m4           |  9 ++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/config/gcc-plugin.m4 b/config/gcc-plugin.m4
index 5e907ca5c45d..23c95be278e5 100644
--- a/config/gcc-plugin.m4
+++ b/config/gcc-plugin.m4
@@ -132,6 +132,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/libtool.m4 b/libtool.m4
index 3672e9516e28..9a13f3b117aa 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
-- 
2.33.0


  parent reply	other threads:[~2022-01-01 20:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-01 20:05 [PATCH 0/7] Sync top-level files for libtool.m4 updates Mike Frysinger
2022-01-01 20:05 ` [PATCH 1/7] Bump to autoconf 2.69 and automake 1.15.1 Mike Frysinger
2022-01-01 20:05 ` [PATCH 2/7] libtool.m4: update GNU/Hurd test from upstream. In upstream libtool, 47a889a4ca20 ("Improve GNU/Hurd support.") fixed detection of shlibpath_overrides_runpath, thus avoiding unnecessary relink. This backports it Mike Frysinger
2022-01-01 20:05 ` [PATCH 3/7] GCC: Pass --plugin to AR and RANLIB Mike Frysinger
2022-01-01 20:05 ` Mike Frysinger [this message]
2022-01-01 20:05 ` [PATCH 5/7] Add support for the haiku operating system. These are the os support patches we have been grooming and maintaining for quite a few years over on git.haiku-os.org. All of these architectures are working and most have been stable for quite some time Mike Frysinger
2022-01-01 20:05 ` [PATCH 6/7] libtool.m4: augment symcode for Solaris 11 Mike Frysinger
2022-01-01 20:05 ` [PATCH 7/7] libtool.m4: fix nm BSD flag detection Mike Frysinger
2022-01-07  9:59 ` [PATCH 0/7] Sync top-level files for libtool.m4 updates Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220101200554.16454-5-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).