Skip to content

Commit d8d5dac

Browse files
hjl-toolsvapier
authored andcommitted
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. * aclocal.m4: Include ../config/gcc-plugin.m4. * configure.ac: AC_SUBST AR_PLUGIN_OPTION and RANLIB_PLUGIN_OPTION. * configure: Regenerated. zlib/ * configure: Regenerated.
1 parent 4a3b4d5 commit d8d5dac

File tree

22 files changed

+512
-37
lines changed

22 files changed

+512
-37
lines changed

Makefile.in

+3-2
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ MAKEINFOFLAGS = --split-size=5000000
392392
# ---------------------------------------------
393393

394394
AS = @AS@
395-
AR = @AR@
395+
AR = @AR@ @AR_PLUGIN_OPTION@
396396
AR_FLAGS = rc
397397
CC = @CC@
398398
CXX = @CXX@
@@ -402,7 +402,7 @@ LIPO = @LIPO@
402402
NM = @NM@
403403
OBJCOPY = @OBJCOPY@
404404
OBJDUMP = @OBJDUMP@
405-
RANLIB = @RANLIB@
405+
RANLIB = @RANLIB@ @RANLIB_PLUGIN_OPTION@
406406
READELF = @READELF@
407407
STRIP = @STRIP@
408408
WINDRES = @WINDRES@
@@ -56457,6 +56457,7 @@ AUTOCONF = autoconf
5645756457
$(srcdir)/configure: @MAINT@ $(srcdir)/configure.ac $(srcdir)/config/acx.m4 \
5645856458
$(srcdir)/config/override.m4 $(srcdir)/config/proginstall.m4 \
5645956459
$(srcdir)/config/elf.m4 $(srcdir)/config/isl.m4 \
56460+
$(srcdir)/config/gcc-plugin.m4 \
5646056461
$(srcdir)/libtool.m4 $(srcdir)/ltoptions.m4 $(srcdir)/ltsugar.m4 \
5646156462
$(srcdir)/ltversion.m4 $(srcdir)/lt~obsolete.m4
5646256463
cd $(srcdir) && $(AUTOCONF)

Makefile.tpl

+3-2
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ MAKEINFOFLAGS = --split-size=5000000
395395
# ---------------------------------------------
396396

397397
AS = @AS@
398-
AR = @AR@
398+
AR = @AR@ @AR_PLUGIN_OPTION@
399399
AR_FLAGS = rc
400400
CC = @CC@
401401
CXX = @CXX@
@@ -405,7 +405,7 @@ LIPO = @LIPO@
405405
NM = @NM@
406406
OBJCOPY = @OBJCOPY@
407407
OBJDUMP = @OBJDUMP@
408-
RANLIB = @RANLIB@
408+
RANLIB = @RANLIB@ @RANLIB_PLUGIN_OPTION@
409409
READELF = @READELF@
410410
STRIP = @STRIP@
411411
WINDRES = @WINDRES@
@@ -1972,6 +1972,7 @@ AUTOCONF = autoconf
19721972
$(srcdir)/configure: @MAINT@ $(srcdir)/configure.ac $(srcdir)/config/acx.m4 \
19731973
$(srcdir)/config/override.m4 $(srcdir)/config/proginstall.m4 \
19741974
$(srcdir)/config/elf.m4 $(srcdir)/config/isl.m4 \
1975+
$(srcdir)/config/gcc-plugin.m4 \
19751976
$(srcdir)/libtool.m4 $(srcdir)/ltoptions.m4 $(srcdir)/ltsugar.m4 \
19761977
$(srcdir)/ltversion.m4 $(srcdir)/lt~obsolete.m4
19771978
cd $(srcdir) && $(AUTOCONF)

config/gcc-plugin.m4

+28
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,31 @@ AC_DEFUN([GCC_ENABLE_PLUGINS],
111111
fi
112112
fi
113113
])
114+
115+
dnl
116+
dnl
117+
dnl GCC_PLUGIN_OPTION
118+
dnl (SHELL-CODE_HANDLER)
119+
dnl
120+
AC_DEFUN([GCC_PLUGIN_OPTION],[dnl
121+
AC_MSG_CHECKING([for -plugin option])
122+
123+
plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
124+
plugin_option=
125+
for plugin in $plugin_names; do
126+
plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
127+
if test x$plugin_so = x$plugin; then
128+
plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
129+
fi
130+
if test x$plugin_so != x$plugin; then
131+
plugin_option="--plugin $plugin_so"
132+
break
133+
fi
134+
done
135+
if test -n "$plugin_option"; then
136+
$1="$plugin_option"
137+
AC_MSG_RESULT($plugin_option)
138+
else
139+
AC_MSG_RESULT([no])
140+
fi
141+
])

configure

+39
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,8 @@ GCJ_FOR_TARGET
618618
GCC_FOR_TARGET
619619
CXX_FOR_TARGET
620620
CC_FOR_TARGET
621+
RANLIB_PLUGIN_OPTION
622+
AR_PLUGIN_OPTION
621623
READELF
622624
OBJDUMP
623625
OBJCOPY
@@ -10007,6 +10009,43 @@ fi
1000710009

1000810010

1000910011

10012+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -plugin option" >&5
10013+
$as_echo_n "checking for -plugin option... " >&6; }
10014+
10015+
plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
10016+
plugin_option=
10017+
for plugin in $plugin_names; do
10018+
plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
10019+
if test x$plugin_so = x$plugin; then
10020+
plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
10021+
fi
10022+
if test x$plugin_so != x$plugin; then
10023+
plugin_option="--plugin $plugin_so"
10024+
break
10025+
fi
10026+
done
10027+
if test -n "$plugin_option"; then
10028+
PLUGIN_OPTION="$plugin_option"
10029+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $plugin_option" >&5
10030+
$as_echo "$plugin_option" >&6; }
10031+
else
10032+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10033+
$as_echo "no" >&6; }
10034+
fi
10035+
10036+
AR_PLUGIN_OPTION=
10037+
RANLIB_PLUGIN_OPTION=
10038+
if test -n "$PLUGIN_OPTION"; then
10039+
if $AR --help 2>&1 | grep -q "\--plugin"; then
10040+
AR_PLUGIN_OPTION="$PLUGIN_OPTION"
10041+
fi
10042+
if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
10043+
RANLIB_PLUGIN_OPTION="$PLUGIN_OPTION"
10044+
fi
10045+
fi
10046+
10047+
10048+
1001010049
# Target tools.
1001110050

1001210051
# Check whether --with-build-time-tools was given.

configure.ac

+15
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ m4_include(config/acx.m4)
2323
m4_include(config/override.m4)
2424
m4_include(config/proginstall.m4)
2525
m4_include(config/elf.m4)
26+
m4_include(config/gcc-plugin.m4)
2627
m4_include([libtool.m4])
2728
m4_include([ltoptions.m4])
2829
m4_include([ltsugar.m4])
@@ -3394,6 +3395,20 @@ AC_SUBST(CXX)
33943395
AC_SUBST(CFLAGS)
33953396
AC_SUBST(CXXFLAGS)
33963397

3398+
GCC_PLUGIN_OPTION(PLUGIN_OPTION)
3399+
AR_PLUGIN_OPTION=
3400+
RANLIB_PLUGIN_OPTION=
3401+
if test -n "$PLUGIN_OPTION"; then
3402+
if $AR --help 2>&1 | grep -q "\--plugin"; then
3403+
AR_PLUGIN_OPTION="$PLUGIN_OPTION"
3404+
fi
3405+
if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
3406+
RANLIB_PLUGIN_OPTION="$PLUGIN_OPTION"
3407+
fi
3408+
fi
3409+
AC_SUBST(AR_PLUGIN_OPTION)
3410+
AC_SUBST(RANLIB_PLUGIN_OPTION)
3411+
33973412
# Target tools.
33983413
AC_ARG_WITH([build-time-tools],
33993414
[AS_HELP_STRING([--with-build-time-tools=PATH],

libtool.m4

+24-1
Original file line numberDiff line numberDiff line change
@@ -1323,8 +1323,26 @@ need_locks="$enable_libtool_lock"
13231323
# _LT_CMD_OLD_ARCHIVE
13241324
# -------------------
13251325
m4_defun([_LT_CMD_OLD_ARCHIVE],
1326-
[AC_CHECK_TOOL(AR, ar, false)
1326+
[plugin_option=
1327+
plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
1328+
for plugin in $plugin_names; do
1329+
plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
1330+
if test x$plugin_so = x$plugin; then
1331+
plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
1332+
fi
1333+
if test x$plugin_so != x$plugin; then
1334+
plugin_option="--plugin $plugin_so"
1335+
break
1336+
fi
1337+
done
1338+
1339+
AC_CHECK_TOOL(AR, ar, false)
13271340
test -z "$AR" && AR=ar
1341+
if test -n "$plugin_option"; then
1342+
if $AR --help 2>&1 | grep -q "\--plugin"; then
1343+
AR="$AR $plugin_option"
1344+
fi
1345+
fi
13281346
test -z "$AR_FLAGS" && AR_FLAGS=cru
13291347
_LT_DECL([], [AR], [1], [The archiver])
13301348
_LT_DECL([], [AR_FLAGS], [1])
@@ -1335,6 +1353,11 @@ _LT_DECL([], [STRIP], [1], [A symbol stripping program])
13351353
13361354
AC_CHECK_TOOL(RANLIB, ranlib, :)
13371355
test -z "$RANLIB" && RANLIB=:
1356+
if test -n "$plugin_option" && test "$RANLIB" != ":"; then
1357+
if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
1358+
RANLIB="$RANLIB $plugin_option"
1359+
fi
1360+
fi
13381361
_LT_DECL([], [RANLIB], [1],
13391362
[Commands used to install an old-style archive])
13401363

newlib/configure

+25-2
Original file line numberDiff line numberDiff line change
@@ -6626,6 +6626,19 @@ test -z "$deplibs_check_method" && deplibs_check_method=unknown
66266626
66276627
66286628
6629+
plugin_option=
6630+
plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
6631+
for plugin in $plugin_names; do
6632+
plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
6633+
if test x$plugin_so = x$plugin; then
6634+
plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
6635+
fi
6636+
if test x$plugin_so != x$plugin; then
6637+
plugin_option="--plugin $plugin_so"
6638+
break
6639+
fi
6640+
done
6641+
66296642
if test -n "$ac_tool_prefix"; then
66306643
# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
66316644
set dummy ${ac_tool_prefix}ar; ac_word=$2
@@ -6719,6 +6732,11 @@ else
67196732
fi
67206733
67216734
test -z "$AR" && AR=ar
6735+
if test -n "$plugin_option"; then
6736+
if $AR --help 2>&1 | grep -q "\--plugin"; then
6737+
AR="$AR $plugin_option"
6738+
fi
6739+
fi
67226740
test -z "$AR_FLAGS" && AR_FLAGS=cru
67236741
67246742
@@ -6923,6 +6941,11 @@ else
69236941
fi
69246942
69256943
test -z "$RANLIB" && RANLIB=:
6944+
if test -n "$plugin_option" && test "$RANLIB" != ":"; then
6945+
if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
6946+
RANLIB="$RANLIB $plugin_option"
6947+
fi
6948+
fi
69266949
69276950
69286951
@@ -11818,7 +11841,7 @@ else
1181811841
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1181911842
lt_status=$lt_dlunknown
1182011843
cat > conftest.$ac_ext <<_LT_EOF
11821-
#line 11821 "configure"
11844+
#line 11844 "configure"
1182211845
#include "confdefs.h"
1182311846
1182411847
#if HAVE_DLFCN_H
@@ -11924,7 +11947,7 @@ else
1192411947
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1192511948
lt_status=$lt_dlunknown
1192611949
cat > conftest.$ac_ext <<_LT_EOF
11927-
#line 11927 "configure"
11950+
#line 11950 "configure"
1192811951
#include "confdefs.h"
1192911952
1193011953
#if HAVE_DLFCN_H

newlib/iconvdata/configure

+25-2
Original file line numberDiff line numberDiff line change
@@ -6201,6 +6201,19 @@ test -z "$deplibs_check_method" && deplibs_check_method=unknown
62016201

62026202

62036203

6204+
plugin_option=
6205+
plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
6206+
for plugin in $plugin_names; do
6207+
plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
6208+
if test x$plugin_so = x$plugin; then
6209+
plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
6210+
fi
6211+
if test x$plugin_so != x$plugin; then
6212+
plugin_option="--plugin $plugin_so"
6213+
break
6214+
fi
6215+
done
6216+
62046217
if test -n "$ac_tool_prefix"; then
62056218
# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
62066219
set dummy ${ac_tool_prefix}ar; ac_word=$2
@@ -6294,6 +6307,11 @@ else
62946307
fi
62956308

62966309
test -z "$AR" && AR=ar
6310+
if test -n "$plugin_option"; then
6311+
if $AR --help 2>&1 | grep -q "\--plugin"; then
6312+
AR="$AR $plugin_option"
6313+
fi
6314+
fi
62976315
test -z "$AR_FLAGS" && AR_FLAGS=cru
62986316

62996317

@@ -6498,6 +6516,11 @@ else
64986516
fi
64996517

65006518
test -z "$RANLIB" && RANLIB=:
6519+
if test -n "$plugin_option" && test "$RANLIB" != ":"; then
6520+
if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
6521+
RANLIB="$RANLIB $plugin_option"
6522+
fi
6523+
fi
65016524

65026525

65036526

@@ -11393,7 +11416,7 @@ else
1139311416
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1139411417
lt_status=$lt_dlunknown
1139511418
cat > conftest.$ac_ext <<_LT_EOF
11396-
#line 11396 "configure"
11419+
#line 11419 "configure"
1139711420
#include "confdefs.h"
1139811421

1139911422
#if HAVE_DLFCN_H
@@ -11499,7 +11522,7 @@ else
1149911522
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1150011523
lt_status=$lt_dlunknown
1150111524
cat > conftest.$ac_ext <<_LT_EOF
11502-
#line 11502 "configure"
11525+
#line 11525 "configure"
1150311526
#include "confdefs.h"
1150411527

1150511528
#if HAVE_DLFCN_H

newlib/libc/configure

+25-2
Original file line numberDiff line numberDiff line change
@@ -6325,6 +6325,19 @@ test -z "$deplibs_check_method" && deplibs_check_method=unknown
63256325

63266326

63276327

6328+
plugin_option=
6329+
plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
6330+
for plugin in $plugin_names; do
6331+
plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
6332+
if test x$plugin_so = x$plugin; then
6333+
plugin_so=`${CC} ${CFLAGS} --print-file-name $plugin`
6334+
fi
6335+
if test x$plugin_so != x$plugin; then
6336+
plugin_option="--plugin $plugin_so"
6337+
break
6338+
fi
6339+
done
6340+
63286341
if test -n "$ac_tool_prefix"; then
63296342
# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
63306343
set dummy ${ac_tool_prefix}ar; ac_word=$2
@@ -6418,6 +6431,11 @@ else
64186431
fi
64196432

64206433
test -z "$AR" && AR=ar
6434+
if test -n "$plugin_option"; then
6435+
if $AR --help 2>&1 | grep -q "\--plugin"; then
6436+
AR="$AR $plugin_option"
6437+
fi
6438+
fi
64216439
test -z "$AR_FLAGS" && AR_FLAGS=cru
64226440

64236441

@@ -6622,6 +6640,11 @@ else
66226640
fi
66236641

66246642
test -z "$RANLIB" && RANLIB=:
6643+
if test -n "$plugin_option" && test "$RANLIB" != ":"; then
6644+
if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
6645+
RANLIB="$RANLIB $plugin_option"
6646+
fi
6647+
fi
66256648

66266649

66276650

@@ -11517,7 +11540,7 @@ else
1151711540
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1151811541
lt_status=$lt_dlunknown
1151911542
cat > conftest.$ac_ext <<_LT_EOF
11520-
#line 11520 "configure"
11543+
#line 11543 "configure"
1152111544
#include "confdefs.h"
1152211545

1152311546
#if HAVE_DLFCN_H
@@ -11623,7 +11646,7 @@ else
1162311646
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1162411647
lt_status=$lt_dlunknown
1162511648
cat > conftest.$ac_ext <<_LT_EOF
11626-
#line 11626 "configure"
11649+
#line 11649 "configure"
1162711650
#include "confdefs.h"
1162811651

1162911652
#if HAVE_DLFCN_H

0 commit comments

Comments
 (0)