Skip to content

Commit c378752

Browse files
keith-packardstephanosio
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 5d8708c commit c378752

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
@@ -2179,25 +2179,47 @@ libgcc.mvars: config.status Makefile specs xgcc$(exeext)
21792179

21802180
mv tmp-libgcc.mvars libgcc.mvars
21812181

2182+
ifeq (@enable_multilib_space@,yes)
2183+
MULTILIB_OPTIONS += Os
2184+
MULTILIB_DIRNAMES += space
2185+
MULTILIB_MATCHES += Os=Oz
2186+
2187+
MULTILIB_OSDIRNAMES_SPACE = $(MULTILIB_OSDIRNAMES)\
2188+
$(if $(findstring =,$(MULTILIB_OSDIRNAMES)),\
2189+
$(foreach OSD,$(MULTILIB_OSDIRNAMES),$(subst =,/Os=,$(OSD))/space),\
2190+
$(if $(MULTILIB_OSDIRNAMES),space,))
2191+
MULTILIB_REQUIRED_SPACE = $(if $(MULTILIB_REQUIRED),Os $(foreach REQ, $(MULTILIB_REQUIRED), $(REQ) $(REQ)/Os),)
2192+
MULTILIB_EXCEPTIONS_SPACE = $(foreach EXC, $(MULTILIB_EXCEPTIONS), $(EXC) $(EXC)/Os)
2193+
MULTILIB_REUSE_SPACE = $(foreach REU, $(MULTILIB_REUSE), $(REU) $(subst =,/Os=,$(REU))/Os)
2194+
MULTILIB_ENABLE = yes
2195+
else
2196+
MULTILIB_OSDIRNAMES_SPACE = $(MULTILIB_OSDIRNAMES)
2197+
MULTILIB_REQUIRED_SPACE = $(MULTILIB_REQUIRED)
2198+
MULTILIB_EXCEPTIONS_SPACE = $(MULTILIB_EXCEPTIONS)
2199+
MULTILIB_REUSE_SPACE = $(MULTILIB_REUSE)
2200+
MULTILIB_ENABLE = @multilib@
2201+
endif
2202+
21822203
# Use the genmultilib shell script to generate the information the gcc
21832204
# driver program needs to select the library directory based on the
21842205
# switches.
21852206
multilib.h: s-mlib; @true
21862207
s-mlib: $(srcdir)/genmultilib Makefile
21872208
if test @enable_multilib@ = yes \
2209+
|| test @enable_multilib_space@ = yes \
21882210
|| test -n "$(MULTILIB_OSDIRNAMES)"; then \
21892211
$(SHELL) $(srcdir)/genmultilib \
21902212
"$(MULTILIB_OPTIONS)" \
21912213
"$(MULTILIB_DIRNAMES)" \
21922214
"$(MULTILIB_MATCHES)" \
2193-
"$(MULTILIB_EXCEPTIONS)" \
2215+
"$(MULTILIB_EXCEPTIONS_SPACE)" \
21942216
"$(MULTILIB_EXTRA_OPTS)" \
21952217
"$(MULTILIB_EXCLUSIONS)" \
2196-
"$(MULTILIB_OSDIRNAMES)" \
2197-
"$(MULTILIB_REQUIRED)" \
2218+
"$(MULTILIB_OSDIRNAMES_SPACE)" \
2219+
"$(MULTILIB_REQUIRED_SPACE)" \
21982220
"$(if $(MULTILIB_OSDIRNAMES),,$(MULTIARCH_DIRNAME))" \
2199-
"$(MULTILIB_REUSE)" \
2200-
"@enable_multilib@" \
2221+
"$(MULTILIB_REUSE_SPACE)" \
2222+
"$(MULTILIB_ENABLE)" \
22012223
> tmp-mlib.h; \
22022224
else \
22032225
$(SHELL) $(srcdir)/genmultilib '' '' '' '' '' '' '' '' \

gcc/configure

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,7 @@ enable_decimal_float
838838
with_float
839839
with_cpu
840840
enable_multiarch
841+
enable_multilib_space
841842
enable_multilib
842843
coverage_flags
843844
valgrind_command
@@ -960,6 +961,7 @@ enable_coverage
960961
enable_gather_detailed_mem_stats
961962
enable_valgrind_annotations
962963
enable_multilib
964+
enable_multilib_space
963965
enable_multiarch
964966
with_stack_clash_protection_guard_size
965967
enable___cxa_atexit
@@ -1691,6 +1693,7 @@ Optional Features:
16911693
--enable-valgrind-annotations
16921694
enable valgrind runtime interaction
16931695
--enable-multilib enable library support for multiple ABIs
1696+
--enable-multilib-space enable extra -Os variant for every multilib ABI
16941697
--enable-multiarch enable support for multiarch paths
16951698
--enable-__cxa_atexit enable __cxa_atexit for C++
16961699
--enable-decimal-float={no,yes,bid,dpd}
@@ -7816,6 +7819,16 @@ fi
78167819

78177820

78187821

7822+
# Determine whether or not -Os multilibs are enabled.
7823+
# Check whether --enable-multilib-space was given.
7824+
if test "${enable_multilib_space+set}" = set; then :
7825+
enableval=$enable_multilib_space;
7826+
else
7827+
enable_multilib_space=no
7828+
fi
7829+
7830+
7831+
78197832
# Determine whether or not multiarch is enabled.
78207833
# Check whether --enable-multiarch was given.
78217834
if test "${enable_multiarch+set}" = set; then :

gcc/configure.ac

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,13 @@ AC_ARG_ENABLE(multilib,
868868
[], [enable_multilib=yes])
869869
AC_SUBST(enable_multilib)
870870

871+
# Determine whether or not -Os multilibs are enabled.
872+
AC_ARG_ENABLE(multilib-space,
873+
[AS_HELP_STRING([--enable-multilib-space],
874+
[enable extra -Os variant for every multilib ABI])],
875+
[], [enable_multilib_space=no])
876+
AC_SUBST(enable_multilib_space)
877+
871878
# Determine whether or not multiarch is enabled.
872879
AC_ARG_ENABLE(multiarch,
873880
[AS_HELP_STRING([--enable-multiarch],

gcc/doc/install.texi

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,18 @@ for aarch64*-*-*, arm*-*-*, loongarch64-*-*, riscv*-*-*, sh*-*-* and
11751175
x86-64-*-linux*. The accepted values and meaning for each target is given
11761176
below.
11771177

1178+
@item --enable-multilib-space
1179+
Double the set of target libraries built by building two versions of
1180+
each specified by the options above, one using @option{-O2 }and
1181+
another using @option{-Os}. During linking, the @option{-O2} variant
1182+
will be selected by default. Select the @option{-Os} variant by
1183+
including @option{-Os} or @option{-Oz} in the linker command
1184+
line. Note: because multilib selection only looks for the presence of
1185+
compiler flags (unlike options controlling the compiler optimization
1186+
level), a subsequent optimization flag other than @option{-Os} or or
1187+
@option{-Oz} will not switch back to the @option{-O2} library
1188+
versions.
1189+
11781190
@table @code
11791191
@item aarch64*-*-*
11801192
@var{list} is a comma separated list of @code{ilp32}, and @code{lp64}

0 commit comments

Comments
 (0)