Skip to content

Commit 7e5b7b7

Browse files
keith-packardnashif
authored andcommitted
gcc: Add --enable-multilib-space option
This option adds a per-multilib variant that specifies -Os instead of the default. Signed-off-by: Keith Packard <[email protected]>
1 parent e9ec67b commit 7e5b7b7

File tree

5 files changed

+60
-6
lines changed

5 files changed

+60
-6
lines changed

config-ml.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ eval scan_arguments "${ac_configure_args}"
175175
unset scan_arguments
176176

177177
# Only do this if --enable-multilib.
178-
if [ "${enable_multilib}" = yes ]; then
178+
if [ "${enable_multilib}" = yes -o "${enable_multilib_space}" = yes ]; then
179179

180180
# Compute whether this is the library's top level directory
181181
# (ie: not a multilib subdirectory, and not a subdirectory like newlib/src).

gcc/Makefile.in

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2296,25 +2296,47 @@ libgcc.mvars: config.status Makefile specs xgcc$(exeext)
22962296

22972297
mv tmp-libgcc.mvars libgcc.mvars
22982298

2299+
ifeq (@enable_multilib_space@,yes)
2300+
MULTILIB_OPTIONS += Os
2301+
MULTILIB_DIRNAMES += space
2302+
MULTILIB_MATCHES += Os=Oz
2303+
2304+
MULTILIB_OSDIRNAMES_SPACE = $(MULTILIB_OSDIRNAMES)\
2305+
$(if $(findstring =,$(MULTILIB_OSDIRNAMES)),\
2306+
$(foreach OSD,$(MULTILIB_OSDIRNAMES),$(subst =,/Os=,$(OSD))/space),\
2307+
$(if $(MULTILIB_OSDIRNAMES),space,))
2308+
MULTILIB_REQUIRED_SPACE = $(if $(MULTILIB_REQUIRED),Os $(foreach REQ, $(MULTILIB_REQUIRED), $(REQ) $(REQ)/Os),)
2309+
MULTILIB_EXCEPTIONS_SPACE = $(foreach EXC, $(MULTILIB_EXCEPTIONS), $(EXC) $(EXC)/Os)
2310+
MULTILIB_REUSE_SPACE = $(foreach REU, $(MULTILIB_REUSE), $(REU) $(subst =,/Os=,$(REU))/Os)
2311+
MULTILIB_ENABLE = yes
2312+
else
2313+
MULTILIB_OSDIRNAMES_SPACE = $(MULTILIB_OSDIRNAMES)
2314+
MULTILIB_REQUIRED_SPACE = $(MULTILIB_REQUIRED)
2315+
MULTILIB_EXCEPTIONS_SPACE = $(MULTILIB_EXCEPTIONS)
2316+
MULTILIB_REUSE_SPACE = $(MULTILIB_REUSE)
2317+
MULTILIB_ENABLE = @enable_multilib@
2318+
endif
2319+
22992320
# Use the genmultilib shell script to generate the information the gcc
23002321
# driver program needs to select the library directory based on the
23012322
# switches.
23022323
multilib.h: s-mlib; @true
23032324
s-mlib: $(srcdir)/genmultilib Makefile
23042325
if test @enable_multilib@ = yes \
2326+
|| test @enable_multilib_space@ = yes \
23052327
|| test -n "$(MULTILIB_OSDIRNAMES)"; then \
23062328
$(SHELL) $(srcdir)/genmultilib \
23072329
"$(MULTILIB_OPTIONS)" \
23082330
"$(MULTILIB_DIRNAMES)" \
23092331
"$(MULTILIB_MATCHES)" \
2310-
"$(MULTILIB_EXCEPTIONS)" \
2332+
"$(MULTILIB_EXCEPTIONS_SPACE)" \
23112333
"$(MULTILIB_EXTRA_OPTS)" \
23122334
"$(MULTILIB_EXCLUSIONS)" \
2313-
"$(MULTILIB_OSDIRNAMES)" \
2314-
"$(MULTILIB_REQUIRED)" \
2335+
"$(MULTILIB_OSDIRNAMES_SPACE)" \
2336+
"$(MULTILIB_REQUIRED_SPACE)" \
23152337
"$(if $(MULTILIB_OSDIRNAMES),,$(MULTIARCH_DIRNAME))" \
2316-
"$(MULTILIB_REUSE)" \
2317-
"@enable_multilib@" \
2338+
"$(MULTILIB_REUSE_SPACE)" \
2339+
"$(MULTILIB_ENABLE)" \
23182340
> tmp-mlib.h; \
23192341
else \
23202342
$(SHELL) $(srcdir)/genmultilib '' '' '' '' '' '' '' '' \

gcc/configure

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,7 @@ DEFAULT_MATCHPD_PARTITIONS
857857
with_float
858858
with_cpu
859859
enable_multiarch
860+
enable_multilib_space
860861
enable_multilib
861862
coverage_flags
862863
valgrind_command
@@ -979,6 +980,7 @@ enable_coverage
979980
enable_gather_detailed_mem_stats
980981
enable_valgrind_annotations
981982
enable_multilib
983+
enable_multilib_space
982984
enable_multiarch
983985
with_stack_clash_protection_guard_size
984986
with_matchpd_partitions
@@ -1720,6 +1722,7 @@ Optional Features:
17201722
--enable-valgrind-annotations
17211723
enable valgrind runtime interaction
17221724
--enable-multilib enable library support for multiple ABIs
1725+
--enable-multilib-space enable extra -Os variant for every multilib ABI
17231726
--enable-multiarch enable support for multiarch paths
17241727
--enable-__cxa_atexit enable __cxa_atexit for C++
17251728
--enable-decimal-float={no,yes,bid,dpd}
@@ -7840,6 +7843,16 @@ fi
78407843

78417844

78427845

7846+
# Determine whether or not -Os multilibs are enabled.
7847+
# Check whether --enable-multilib-space was given.
7848+
if test "${enable_multilib_space+set}" = set; then :
7849+
enableval=$enable_multilib_space;
7850+
else
7851+
enable_multilib_space=no
7852+
fi
7853+
7854+
7855+
78437856
# Determine whether or not multiarch is enabled.
78447857
# Check whether --enable-multiarch was given.
78457858
if test "${enable_multiarch+set}" = set; then :

gcc/configure.ac

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,13 @@ AC_ARG_ENABLE(multilib,
852852
[], [enable_multilib=yes])
853853
AC_SUBST(enable_multilib)
854854

855+
# Determine whether or not -Os multilibs are enabled.
856+
AC_ARG_ENABLE(multilib-space,
857+
[AS_HELP_STRING([--enable-multilib-space],
858+
[enable extra -Os variant for every multilib ABI])],
859+
[], [enable_multilib_space=no])
860+
AC_SUBST(enable_multilib_space)
861+
855862
# Determine whether or not multiarch is enabled.
856863
AC_ARG_ENABLE(multiarch,
857864
[AS_HELP_STRING([--enable-multiarch],

gcc/doc/install.texi

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,18 @@ for aarch64*-*-*, amdgcn*-*-*, arm*-*-*, loongarch*-*-*, riscv*-*-*, sh*-*-*
12681268
and x86-64-*-linux*. The accepted values and meaning for each target is given
12691269
below.
12701270

1271+
@item --enable-multilib-space
1272+
Double the set of target libraries built by building two versions of
1273+
each specified by the options above, one using @option{-O2 }and
1274+
another using @option{-Os}. During linking, the @option{-O2} variant
1275+
will be selected by default. Select the @option{-Os} variant by
1276+
including @option{-Os} or @option{-Oz} in the linker command
1277+
line. Note: because multilib selection only looks for the presence of
1278+
compiler flags (unlike options controlling the compiler optimization
1279+
level), a subsequent optimization flag other than @option{-Os} or or
1280+
@option{-Oz} will not switch back to the @option{-O2} library
1281+
versions.
1282+
12711283
@table @code
12721284
@item aarch64*-*-*
12731285
@var{list} is a comma separated list of @code{ilp32}, and @code{lp64}

0 commit comments

Comments
 (0)