diff mbox series

[1/2] Sync with binutils: GCC: Pass --plugin to AR and RANLIB

Message ID 20211113163353.5374-2-hjl.tools@gmail.com
State New
Headers show
Series Sync with binutils for building binutils with LTO: | expand

Commit Message

H.J. Lu Nov. 13, 2021, 4:33 p.m. UTC
Sync with binutils for building binutils with LTO:

From 50ad1254d5030d0804cbf89c758359ae202e8d55 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sat, 9 Jan 2021 06:43:11 -0800
Subject: [PATCH] GCC: Pass --plugin to AR and RANLIB

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.
	* configure.ac: AC_SUBST AR_PLUGIN_OPTION and
	RANLIB_PLUGIN_OPTION.
	* aclocal.m4: Regenerated.
	* configure: Likewise.

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         | 29 ++++++++++++++++++++++++++---
 11 files changed, 191 insertions(+), 10 deletions(-)

Comments

Jeff Law Nov. 23, 2021, 12:29 a.m. UTC | #1
On 11/13/2021 9:33 AM, H.J. Lu via Gcc-patches wrote:
> Sync with binutils for building binutils with LTO:
>
>  From 50ad1254d5030d0804cbf89c758359ae202e8d55 Mon Sep 17 00:00:00 2001
> From: "H.J. Lu" <hjl.tools@gmail.com>
> Date: Sat, 9 Jan 2021 06:43:11 -0800
> Subject: [PATCH] GCC: Pass --plugin to AR and RANLIB
>
> 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.
> 	* configure.ac: AC_SUBST AR_PLUGIN_OPTION and
> 	RANLIB_PLUGIN_OPTION.
> 	* aclocal.m4: Regenerated.
> 	* configure: Likewise.
>
> zlib/
>
> 	* configure: Regenerated.
I thought the plugins were automatically loaded if they're in the right 
place in the filesystem.  Wouldn't that make this patch unnecessary?  Am 
I missing something?

jeff
H.J. Lu Nov. 23, 2021, 2:29 a.m. UTC | #2
On Mon, Nov 22, 2021 at 4:29 PM Jeff Law <jeffreyalaw@gmail.com> wrote:
>
>
>
> On 11/13/2021 9:33 AM, H.J. Lu via Gcc-patches wrote:
> > Sync with binutils for building binutils with LTO:
> >
> >  From 50ad1254d5030d0804cbf89c758359ae202e8d55 Mon Sep 17 00:00:00 2001
> > From: "H.J. Lu" <hjl.tools@gmail.com>
> > Date: Sat, 9 Jan 2021 06:43:11 -0800
> > Subject: [PATCH] GCC: Pass --plugin to AR and RANLIB
> >
> > 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.
> >       * configure.ac: AC_SUBST AR_PLUGIN_OPTION and
> >       RANLIB_PLUGIN_OPTION.
> >       * aclocal.m4: Regenerated.
> >       * configure: Likewise.
> >
> > zlib/
> >
> >       * configure: Regenerated.
> I thought the plugins were automatically loaded if they're in the right
> place in the filesystem.  Wouldn't that make this patch unnecessary?  Am
> I missing something?
>

It only works for system GCC and binutils.  It doesn't work for non-system
GCC nor binutils since either GCC plugin isn't installed in the binutils plugin
search patch.
Jeff Law Dec. 14, 2021, 11:30 p.m. UTC | #3
On 11/22/2021 7:29 PM, H.J. Lu wrote:
> On Mon, Nov 22, 2021 at 4:29 PM Jeff Law <jeffreyalaw@gmail.com> wrote:
>>
>>
>> On 11/13/2021 9:33 AM, H.J. Lu via Gcc-patches wrote:
>>> Sync with binutils for building binutils with LTO:
>>>
>>>   From 50ad1254d5030d0804cbf89c758359ae202e8d55 Mon Sep 17 00:00:00 2001
>>> From: "H.J. Lu" <hjl.tools@gmail.com>
>>> Date: Sat, 9 Jan 2021 06:43:11 -0800
>>> Subject: [PATCH] GCC: Pass --plugin to AR and RANLIB
>>>
>>> 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.
>>>        * configure.ac: AC_SUBST AR_PLUGIN_OPTION and
>>>        RANLIB_PLUGIN_OPTION.
>>>        * aclocal.m4: Regenerated.
>>>        * configure: Likewise.
>>>
>>> zlib/
>>>
>>>        * configure: Regenerated.
>> I thought the plugins were automatically loaded if they're in the right
>> place in the filesystem.  Wouldn't that make this patch unnecessary?  Am
>> I missing something?
>>
> It only works for system GCC and binutils.  It doesn't work for non-system
> GCC nor binutils since either GCC plugin isn't installed in the binutils plugin
> search patch.
Ah.  So this is primarily useful if GCC was installed into a path 
different than the system binutils expects to find the plugin? Does it 
work properly in cross environments or at least do no harm in those 
kinds of builds?

Jeff
H.J. Lu Dec. 15, 2021, 12:29 a.m. UTC | #4
On Tue, Dec 14, 2021 at 3:30 PM Jeff Law <jeffreyalaw@gmail.com> wrote:
>
>
>
> On 11/22/2021 7:29 PM, H.J. Lu wrote:
> > On Mon, Nov 22, 2021 at 4:29 PM Jeff Law <jeffreyalaw@gmail.com> wrote:
> >>
> >>
> >> On 11/13/2021 9:33 AM, H.J. Lu via Gcc-patches wrote:
> >>> Sync with binutils for building binutils with LTO:
> >>>
> >>>   From 50ad1254d5030d0804cbf89c758359ae202e8d55 Mon Sep 17 00:00:00 2001
> >>> From: "H.J. Lu" <hjl.tools@gmail.com>
> >>> Date: Sat, 9 Jan 2021 06:43:11 -0800
> >>> Subject: [PATCH] GCC: Pass --plugin to AR and RANLIB
> >>>
> >>> 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.
> >>>        * configure.ac: AC_SUBST AR_PLUGIN_OPTION and
> >>>        RANLIB_PLUGIN_OPTION.
> >>>        * aclocal.m4: Regenerated.
> >>>        * configure: Likewise.
> >>>
> >>> zlib/
> >>>
> >>>        * configure: Regenerated.
> >> I thought the plugins were automatically loaded if they're in the right
> >> place in the filesystem.  Wouldn't that make this patch unnecessary?  Am
> >> I missing something?
> >>
> > It only works for system GCC and binutils.  It doesn't work for non-system
> > GCC nor binutils since either GCC plugin isn't installed in the binutils plugin
> > search patch.
> Ah.  So this is primarily useful if GCC was installed into a path
> different than the system binutils expects to find the plugin? Does it

Yes.

> work properly in cross environments or at least do no harm in those
> kinds of builds?
>

I believe so.
Jeff Law Dec. 15, 2021, 5:33 p.m. UTC | #5
On 11/13/2021 9:33 AM, H.J. Lu via Gcc-patches wrote:
> Sync with binutils for building binutils with LTO:
>
>  From 50ad1254d5030d0804cbf89c758359ae202e8d55 Mon Sep 17 00:00:00 2001
> From: "H.J. Lu" <hjl.tools@gmail.com>
> Date: Sat, 9 Jan 2021 06:43:11 -0800
> Subject: [PATCH] GCC: Pass --plugin to AR and RANLIB
>
> 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.
> 	* configure.ac: AC_SUBST AR_PLUGIN_OPTION and
> 	RANLIB_PLUGIN_OPTION.
> 	* aclocal.m4: Regenerated.
> 	* configure: Likewise.
>
> zlib/
>
> 	* configure: Regenerated.
OK.  Thanks for your patience.

Jeff
Sandra Loosemore Dec. 16, 2021, 3:37 a.m. UTC | #6
On 11/13/21 9:33 AM, H.J. Lu via Gcc-patches wrote:
> Sync with binutils for building binutils with LTO:
> 
>  From 50ad1254d5030d0804cbf89c758359ae202e8d55 Mon Sep 17 00:00:00 2001
> From: "H.J. Lu" <hjl.tools@gmail.com>
> Date: Sat, 9 Jan 2021 06:43:11 -0800
> Subject: [PATCH] GCC: Pass --plugin to AR and RANLIB
> 
> 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.
> 	* configure.ac: AC_SUBST AR_PLUGIN_OPTION and
> 	RANLIB_PLUGIN_OPTION.
> 	* aclocal.m4: Regenerated.
> 	* configure: Likewise.
> 
> zlib/
> 
> 	* configure: Regenerated.

This patch appears to have broken my nios2-linux-gnu target, 
x86_64-linux-gnu host cross build:

x86_64-linux-gnu-ar  --plugin 
/usr/local/tools/gcc-2021/bin/../libexec/gcc/x86_64-linux-gnu/9.3.1/liblto_plugin.so 
--plugin 
/usr/local/tools/gcc-2021/bin/../libexec/gcc/x86_64-linux-gnu/9.3.1/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
x86_64-linux-gnu-ar: no operation specified

This is ar version 2.32.51.  I also tried with an older set of host 
tools using ar 2.25.51 and saw the same failure.

-Sandra
H.J. Lu Dec. 16, 2021, 4:28 a.m. UTC | #7
On Wed, Dec 15, 2021 at 7:38 PM Sandra Loosemore
<sandra@codesourcery.com> wrote:
>
> On 11/13/21 9:33 AM, H.J. Lu via Gcc-patches wrote:
> > Sync with binutils for building binutils with LTO:
> >
> >  From 50ad1254d5030d0804cbf89c758359ae202e8d55 Mon Sep 17 00:00:00 2001
> > From: "H.J. Lu" <hjl.tools@gmail.com>
> > Date: Sat, 9 Jan 2021 06:43:11 -0800
> > Subject: [PATCH] GCC: Pass --plugin to AR and RANLIB
> >
> > 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.
> >       * configure.ac: AC_SUBST AR_PLUGIN_OPTION and
> >       RANLIB_PLUGIN_OPTION.
> >       * aclocal.m4: Regenerated.
> >       * configure: Likewise.
> >
> > zlib/
> >
> >       * configure: Regenerated.
>
> This patch appears to have broken my nios2-linux-gnu target,
> x86_64-linux-gnu host cross build:
>
> x86_64-linux-gnu-ar  --plugin
> /usr/local/tools/gcc-2021/bin/../libexec/gcc/x86_64-linux-gnu/9.3.1/liblto_plugin.so
> --plugin
> /usr/local/tools/gcc-2021/bin/../libexec/gcc/x86_64-linux-gnu/9.3.1/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
> x86_64-linux-gnu-ar: no operation specified
>
> This is ar version 2.32.51.  I also tried with an older set of host
> tools using ar 2.25.51 and saw the same failure.
>
> -Sandra

I built nios2-linux-gnu cross compiler using glibc build-many-glibcs.py
script:

/usr/bin/time /export/project/tools-build/glibc-many/src/glibc/scripts/build-man
y-glibcs.py  -j 96 /export/project/tools-build/glibc-many \
  compilers nios2-linux-gnu
make[1]: Entering directory '/export/project/tools-build/glibc-many/build'
PASS: compilers-nios2-linux-gnu check-host-libraries
PASS: compilers-nios2-linux-gnu binutils rm
PASS: compilers-nios2-linux-gnu binutils mkdir
PASS: compilers-nios2-linux-gnu binutils configure
make[1]: Leaving directory '/export/project/tools-build/glibc-many/build'
PASS: compilers-nios2-linux-gnu binutils build
PASS: compilers-nios2-linux-gnu binutils install
make[1]: Entering directory '/export/project/tools-build/glibc-many/build'
PASS: compilers-nios2-linux-gnu binutils cleanup
PASS: compilers-nios2-linux-gnu linux rm
PASS: compilers-nios2-linux-gnu linux mkdir
make[1]: Leaving directory '/export/project/tools-build/glibc-many/build'
PASS: compilers-nios2-linux-gnu linux install-headers
make[1]: Entering directory '/export/project/tools-build/glibc-many/build'
PASS: compilers-nios2-linux-gnu linux cleanup
PASS: compilers-nios2-linux-gnu gcc-first rm
PASS: compilers-nios2-linux-gnu gcc-first mkdir
PASS: compilers-nios2-linux-gnu gcc-first configure
make[1]: Leaving directory '/export/project/tools-build/glibc-many/build'
PASS: compilers-nios2-linux-gnu gcc-first build
PASS: compilers-nios2-linux-gnu gcc-first install
make[1]: Entering directory '/export/project/tools-build/glibc-many/build'
PASS: compilers-nios2-linux-gnu gcc-first cleanup
PASS: compilers-nios2-linux-gnu glibc nios2-linux-gnu rm
PASS: compilers-nios2-linux-gnu glibc nios2-linux-gnu mkdir
PASS: compilers-nios2-linux-gnu glibc nios2-linux-gnu configure
make[1]: Leaving directory '/export/project/tools-build/glibc-many/build'
PASS: compilers-nios2-linux-gnu glibc nios2-linux-gnu build
PASS: compilers-nios2-linux-gnu glibc nios2-linux-gnu install
make[1]: Entering directory '/export/project/tools-build/glibc-many/build'
PASS: compilers-nios2-linux-gnu glibc nios2-linux-gnu mkdir-lib
PASS: compilers-nios2-linux-gnu glibc nios2-linux-gnu cleanup
PASS: compilers-nios2-linux-gnu gcc rm
PASS: compilers-nios2-linux-gnu gcc mkdir
PASS: compilers-nios2-linux-gnu gcc configure
make[1]: Leaving directory '/export/project/tools-build/glibc-many/build'
PASS: compilers-nios2-linux-gnu gcc build
PASS: compilers-nios2-linux-gnu gcc install
make[1]: Entering directory '/export/project/tools-build/glibc-many/build'
PASS: compilers-nios2-linux-gnu gcc cleanup
PASS: compilers-nios2-linux-gnu done
make[1]: Leaving directory '/export/project/tools-build/glibc-many/build'

using glibc master, binutils master and gcc master.   Is there a way
to reproduce it with build-many-glibcs.py?
H.J. Lu Dec. 16, 2021, 4:38 a.m. UTC | #8
On Wed, Dec 15, 2021 at 8:28 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Wed, Dec 15, 2021 at 7:38 PM Sandra Loosemore
> <sandra@codesourcery.com> wrote:
> >
> > On 11/13/21 9:33 AM, H.J. Lu via Gcc-patches wrote:
> > > Sync with binutils for building binutils with LTO:
> > >
> > >  From 50ad1254d5030d0804cbf89c758359ae202e8d55 Mon Sep 17 00:00:00 2001
> > > From: "H.J. Lu" <hjl.tools@gmail.com>
> > > Date: Sat, 9 Jan 2021 06:43:11 -0800
> > > Subject: [PATCH] GCC: Pass --plugin to AR and RANLIB
> > >
> > > 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.
> > >       * configure.ac: AC_SUBST AR_PLUGIN_OPTION and
> > >       RANLIB_PLUGIN_OPTION.
> > >       * aclocal.m4: Regenerated.
> > >       * configure: Likewise.
> > >
> > > zlib/
> > >
> > >       * configure: Regenerated.
> >
> > This patch appears to have broken my nios2-linux-gnu target,
> > x86_64-linux-gnu host cross build:
> >
> > x86_64-linux-gnu-ar  --plugin
> > /usr/local/tools/gcc-2021/bin/../libexec/gcc/x86_64-linux-gnu/9.3.1/liblto_plugin.so
> > --plugin
> > /usr/local/tools/gcc-2021/bin/../libexec/gcc/x86_64-linux-gnu/9.3.1/liblto_plugin.so

Let me revert this patch for now since this doesn't work with GCC bootstrap
which needs to pass the newly built plugin to AR and RANLIB.

> > 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
> > x86_64-linux-gnu-ar: no operation specified
> >
> > This is ar version 2.32.51.  I also tried with an older set of host
> > tools using ar 2.25.51 and saw the same failure.
> >
> > -Sandra
>
> I built nios2-linux-gnu cross compiler using glibc build-many-glibcs.py
> script:
>
> /usr/bin/time /export/project/tools-build/glibc-many/src/glibc/scripts/build-man
> y-glibcs.py  -j 96 /export/project/tools-build/glibc-many \
>   compilers nios2-linux-gnu
> make[1]: Entering directory '/export/project/tools-build/glibc-many/build'
> PASS: compilers-nios2-linux-gnu check-host-libraries
> PASS: compilers-nios2-linux-gnu binutils rm
> PASS: compilers-nios2-linux-gnu binutils mkdir
> PASS: compilers-nios2-linux-gnu binutils configure
> make[1]: Leaving directory '/export/project/tools-build/glibc-many/build'
> PASS: compilers-nios2-linux-gnu binutils build
> PASS: compilers-nios2-linux-gnu binutils install
> make[1]: Entering directory '/export/project/tools-build/glibc-many/build'
> PASS: compilers-nios2-linux-gnu binutils cleanup
> PASS: compilers-nios2-linux-gnu linux rm
> PASS: compilers-nios2-linux-gnu linux mkdir
> make[1]: Leaving directory '/export/project/tools-build/glibc-many/build'
> PASS: compilers-nios2-linux-gnu linux install-headers
> make[1]: Entering directory '/export/project/tools-build/glibc-many/build'
> PASS: compilers-nios2-linux-gnu linux cleanup
> PASS: compilers-nios2-linux-gnu gcc-first rm
> PASS: compilers-nios2-linux-gnu gcc-first mkdir
> PASS: compilers-nios2-linux-gnu gcc-first configure
> make[1]: Leaving directory '/export/project/tools-build/glibc-many/build'
> PASS: compilers-nios2-linux-gnu gcc-first build
> PASS: compilers-nios2-linux-gnu gcc-first install
> make[1]: Entering directory '/export/project/tools-build/glibc-many/build'
> PASS: compilers-nios2-linux-gnu gcc-first cleanup
> PASS: compilers-nios2-linux-gnu glibc nios2-linux-gnu rm
> PASS: compilers-nios2-linux-gnu glibc nios2-linux-gnu mkdir
> PASS: compilers-nios2-linux-gnu glibc nios2-linux-gnu configure
> make[1]: Leaving directory '/export/project/tools-build/glibc-many/build'
> PASS: compilers-nios2-linux-gnu glibc nios2-linux-gnu build
> PASS: compilers-nios2-linux-gnu glibc nios2-linux-gnu install
> make[1]: Entering directory '/export/project/tools-build/glibc-many/build'
> PASS: compilers-nios2-linux-gnu glibc nios2-linux-gnu mkdir-lib
> PASS: compilers-nios2-linux-gnu glibc nios2-linux-gnu cleanup
> PASS: compilers-nios2-linux-gnu gcc rm
> PASS: compilers-nios2-linux-gnu gcc mkdir
> PASS: compilers-nios2-linux-gnu gcc configure
> make[1]: Leaving directory '/export/project/tools-build/glibc-many/build'
> PASS: compilers-nios2-linux-gnu gcc build
> PASS: compilers-nios2-linux-gnu gcc install
> make[1]: Entering directory '/export/project/tools-build/glibc-many/build'
> PASS: compilers-nios2-linux-gnu gcc cleanup
> PASS: compilers-nios2-linux-gnu done
> make[1]: Leaving directory '/export/project/tools-build/glibc-many/build'
>
> using glibc master, binutils master and gcc master.   Is there a way
> to reproduce it with build-many-glibcs.py?
>
> --
> H.J.
Sandra Loosemore Dec. 16, 2021, 5:34 a.m. UTC | #9
On 12/15/21 9:28 PM, H.J. Lu wrote:

> I built nios2-linux-gnu cross compiler using glibc build-many-glibcs.py
> script:
> 
> [snip]
> 
> using glibc master, binutils master and gcc master.   Is there a way
> to reproduce it with build-many-glibcs.py?

If it requires host tools built from binutils master, that is no good. 
We build our cross-tools using a host toolchain built from an older, 
stable branch.  Some other developers build GCC cross-compilers using 
whatever version of the host tools are provided by their OS distro.

FWIW, the --help output for both ar 2.32.51 and 2.25.51 indicates that 
--plugin is supposed to come *after* the command options, not before, 
which is where your Makefile changes are putting it.  E.g.

$ x86_64-linux-gnu-ar --help
Usage: x86_64-linux-gnu-ar [emulation options] 
[-]{dmpqrstx}[abcDfilMNoOPsSTuvV] [--plugin <name>] [member-name] 
[count] archive-file file...
        x86_64-linux-gnu-ar -M [<mri-script]

-Sandra
diff mbox series

Patch

diff --git a/Makefile.in b/Makefile.in
index 860cf8f067b..13067e97327 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -415,7 +415,7 @@  MAKEINFOFLAGS = --split-size=5000000
 # ---------------------------------------------
 
 AS = @AS@
-AR = @AR@
+AR = @AR@ @AR_PLUGIN_OPTION@
 AR_FLAGS = rc
 CC = @CC@
 CXX = @CXX@
@@ -426,7 +426,7 @@  LIPO = @LIPO@
 NM = @NM@
 OBJDUMP = @OBJDUMP@
 OTOOL = @OTOOL@
-RANLIB = @RANLIB@
+RANLIB = @RANLIB@ @RANLIB_PLUGIN_OPTION@
 READELF = @READELF@
 STRIP = @STRIP@
 WINDRES = @WINDRES@
@@ -63384,6 +63384,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 213052f8226..f785b84ec9c 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -418,7 +418,7 @@  MAKEINFOFLAGS = --split-size=5000000
 # ---------------------------------------------
 
 AS = @AS@
-AR = @AR@
+AR = @AR@ @AR_PLUGIN_OPTION@
 AR_FLAGS = rc
 CC = @CC@
 CXX = @CXX@
@@ -429,7 +429,7 @@  LIPO = @LIPO@
 NM = @NM@
 OBJDUMP = @OBJDUMP@
 OTOOL = @OTOOL@
-RANLIB = @RANLIB@
+RANLIB = @RANLIB@ @RANLIB_PLUGIN_OPTION@
 READELF = @READELF@
 STRIP = @STRIP@
 WINDRES = @WINDRES@
@@ -2027,6 +2027,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 8f278719118..c5b72e9a13d 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 58979d6e3b1..ea3111a8020 100755
--- a/configure
+++ b/configure
@@ -619,6 +619,8 @@  GFORTRAN_FOR_TARGET
 GCC_FOR_TARGET
 CXX_FOR_TARGET
 CC_FOR_TARGET
+RANLIB_PLUGIN_OPTION
+AR_PLUGIN_OPTION
 READELF
 OTOOL
 OBJDUMP
@@ -12600,6 +12602,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 550e6993b59..1ca83d30a55 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,6 +24,7 @@  m4_include(config/override.m4)
 m4_include(config/proginstall.m4)
 m4_include(config/elf.m4)
 m4_include(config/ax_cxx_compile_stdcxx.m4)
+m4_include(config/gcc-plugin.m4)
 m4_include([libtool.m4])
 m4_include([ltoptions.m4])
 m4_include([ltsugar.m4])
@@ -3493,6 +3494,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 884cc6c4af2..6916b735df3 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -50,13 +50,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@
 
@@ -505,6 +505,7 @@  aclocal_deps = \
 	$(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 3378316dced..0757688d52a 100644
--- a/libiberty/aclocal.m4
+++ b/libiberty/aclocal.m4
@@ -15,6 +15,7 @@  m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun
 m4_include([../config/acx.m4])
 m4_include([../config/cet.m4])
 m4_include([../config/enable.m4])
+m4_include([../config/gcc-plugin.m4])
 m4_include([../config/no-executables.m4])
 m4_include([../config/picflag.m4])
 m4_include([../config/warnings.m4])
diff --git a/libiberty/configure b/libiberty/configure
index 3c7e588b16b..4d793dbebeb 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
@@ -2929,6 +2931,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 4b78c1830c7..3d26857cb9f 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 17f8e5f3074..efa62bfcbf0 100644
--- a/libtool.m4
+++ b/libtool.m4
@@ -1325,8 +1325,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])
@@ -1337,6 +1355,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 f489f31bc70..8ce61b11119 100755
--- a/zlib/configure
+++ b/zlib/configure
@@ -4169,7 +4169,7 @@  case "$host" in
     case "$enable_cet" in
       auto)
 	# Check if target supports multi-byte NOPs
-	# and if assembler supports CET insn.
+	# and if compiler and assembler support CET insn.
 	cet_save_CFLAGS="$CFLAGS"
 	CFLAGS="$CFLAGS -fcf-protection"
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -5502,6 +5502,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
@@ -5595,6 +5608,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
 
 
@@ -5799,6 +5817,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
 
 
 
@@ -10735,7 +10758,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10748 "configure"
+#line 10761 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10841,7 +10864,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10854 "configure"
+#line 10867 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H