From: Aleksandar Rakic <aleksandar.ra...@htecgroup.com> This patch introduces a new configure-time option --with-multi-buildlist to allow fine-grained control over which multilib variants are built.
The option accepts a path to a file containing a list of multilib directories to be included in the build. Each line in the file should contain a single multilib directory name, matching those generated by the compiler's --print-multi-lib output. This mechanism is target-independent and enables users to reduce build time and binary size by excluding unnecessary multilib variants. It is especially useful for embedded targets with constrained environments or vendor-specific requirements. The option is propagated to both host and target configuration stages, and used in config-ml.in and gcc/Makefile.in to filter the multilib list. Documentation for this feature is added to gcc/doc/install.texi. * config-ml.in: Use with_multi_buildlist to build multidirs. Skip configuration for subdir returned by --print-multi-directory. * configure: Regenerate. * configure.ac: Pass through with_multi_buildlist to host and target. gcc/ * Makefile.in: Add with_multi_buildlist for multilib configuration control. Use with_multi_buildlist to filter multilib directories in fixinc_list. * configure: Regenerate. * configure.ac: Restrict the installed fixedincludes multilibs. * doc/install.texi: Add --with-multi-buildlist configure option for multilib filtering. * genmultilib: Remove error for reuse of nonexistent multilibs. This change allows reuse rules to reference multilib variants that are not currently built. This is useful in configurations where the set of built multilibs is filtered via --with-multi-buildlist. Previously, genmultilib would emit an error and abort if a reuse rule referenced a multilib that was not present. With this change, such rules are silently ignored, enabling more flexible and vendor-specific reuse setups. Cherry-picked 2b2481cc71284ad9db3dff60bd6cab2be678e87e from https://github.com/MIPS/gcc Signed-off-by: Robert Suchanek <robert.sucha...@imgtec.com> Signed-off-by: Chao-ying Fu <c...@mips.com> Signed-off-by: Aleksandar Rakic <aleksandar.ra...@htecgroup.com> --- config-ml.in | 9 ++++++++- configure | 10 ++++++++++ configure.ac | 10 ++++++++++ gcc/Makefile.in | 4 ++++ gcc/configure | 8 ++++++-- gcc/configure.ac | 3 +++ gcc/doc/install.texi | 24 ++++++++++++++++++++++++ gcc/genmultilib | 3 --- 8 files changed, 65 insertions(+), 6 deletions(-) diff --git a/config-ml.in b/config-ml.in index 645cac822fd..c496c83b9c0 100644 --- a/config-ml.in +++ b/config-ml.in @@ -230,6 +230,7 @@ done # Target libraries are configured for the host they run on, so we check # $host here, not $target. +# Use a filtered multilib list if requested. case "${host}" in arm-*-*) @@ -597,7 +598,8 @@ else fi if [ -z "${with_multisubdir}" ]; then - ml_subdir= + ml_top_subdir=`${CC-gcc} --print-multi-directory 2>/dev/null` + ml_subdir=/$ml_top_subdir ml_builddotdot= : # ml_srcdotdot= # already set else @@ -676,6 +678,11 @@ if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then for ml_dir in ${multidirs}; do + if [ "${ml_dir}" == "${ml_top_subdir}" ]; then + echo "Skipping configure in multilib subdir ${ml_dir}" + continue + fi + if [ "${ml_verbose}" = --verbose ]; then echo "Running configure in multilib subdir ${ml_dir}" echo "pwd: `${PWDCMD-pwd}`" diff --git a/configure b/configure index a2e86731b08..f8f6752247c 100755 --- a/configure +++ b/configure @@ -11338,6 +11338,16 @@ if test x${enable_multilib} = x ; then target_configargs="--enable-multilib ${target_configargs}" fi +# Pass through with_multi_buildlist to host and target. 'gcc' needs it for the +# fixed includes which are multilib'd and target libraries need it as they use +# config-ml.in. +if test x${with_multi_buildlist} != x ; then + target_configargs="--with-multi-buildlist=${with_multi_buildlist} \ + ${target_configargs}" + host_configargs="--with-multi-buildlist=${with_multi_buildlist} \ + ${host_configargs}" +fi + # Pass --with-newlib if appropriate. Note that target_configdirs has # changed from the earlier setting of with_newlib. if test x${with_newlib} != xno && echo " ${target_configdirs} " | grep " newlib " > /dev/null 2>&1 && test -d ${srcdir}/newlib ; then diff --git a/configure.ac b/configure.ac index 25419a1d2ab..97bd1a4d507 100644 --- a/configure.ac +++ b/configure.ac @@ -3577,6 +3577,16 @@ if test x${enable_multilib} = x ; then target_configargs="--enable-multilib ${target_configargs}" fi +# Pass through with_multi_buildlist to host and target. 'gcc' needs it for the +# fixed includes which are multilib'd and target libraries need it as they use +# config-ml.in. +if test x${with_multi_buildlist} != x ; then + target_configargs="--with-multi-buildlist=${with_multi_buildlist} \ + ${target_configargs}" + host_configargs="--with-multi-buildlist=${with_multi_buildlist} \ + ${host_configargs}" +fi + # Pass --with-newlib if appropriate. Note that target_configdirs has # changed from the earlier setting of with_newlib. if test x${with_newlib} != xno && echo " ${target_configdirs} " | grep " newlib " > /dev/null 2>&1 && test -d ${srcdir}/newlib ; then diff --git a/gcc/Makefile.in b/gcc/Makefile.in index e8b2a38c8b3..3ebdc5e9517 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -642,6 +642,9 @@ else endif endif +# Multilib control +with_multi_buildlist = @with_multi_buildlist@ + # ------------------------ # Installation directories # ------------------------ @@ -3383,6 +3386,7 @@ fixinc_list: s-fixinc_list; @true s-fixinc_list : $(GCC_PASSES) # Build up a list of multilib directories and corresponding sysroot # suffixes, in form sysroot;multilib. +# Use a filtered multilib list if requested. if $(GCC_FOR_TARGET) -print-sysroot-headers-suffix > /dev/null 2>&1; then \ set -e; for ml in `$(GCC_FOR_TARGET) -print-multi-lib`; do \ multi_dir=`echo $${ml} | sed -e 's/;.*$$//'`; \ diff --git a/gcc/configure b/gcc/configure index 150ab616414..1341e1cbd3f 100755 --- a/gcc/configure +++ b/gcc/configure @@ -853,6 +853,7 @@ enable_fixed_point enable_decimal_float DEFAULT_INSNEMIT_PARTITIONS DEFAULT_MATCHPD_PARTITIONS +with_multi_buildlist with_float with_cpu enable_multiarch @@ -7870,6 +7871,9 @@ $as_echo "$enable_multiarch$ma_msg_suffix" >&6; } +# needed for restricting the fixedincludes multilibs that we install + + # default stack clash protection guard size as power of twos in bytes. # Please keep these in sync with params.def. stk_clash_min=12 @@ -21454,7 +21458,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 21457 "configure" +#line 21461 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -21560,7 +21564,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 21563 "configure" +#line 21567 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/gcc/configure.ac b/gcc/configure.ac index bdb22d53e2c..ee98191411e 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -877,6 +877,9 @@ AC_MSG_RESULT($enable_multiarch$ma_msg_suffix) AC_SUBST(with_cpu) AC_SUBST(with_float) +# needed for restricting the fixedincludes multilibs that we install +AC_SUBST(with_multi_buildlist) + # default stack clash protection guard size as power of twos in bytes. # Please keep these in sync with params.def. stk_clash_min=12 diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi index 705440ffd33..25306481860 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -1509,6 +1509,30 @@ medlow code model; rv64ima with lp64 and medany code model rv64ima-lp64--;--cmodel=medlow,medany @end smallexample +@item --with-multi-buildlist=@var{file} +Specify a file containing a list of multilib directories to build. + +Each line in the file should contain a single multilib directory name, +as printed by @code{gcc --print-multi-lib}. Only the listed directories +will be built and installed. + +This option is useful for reducing build time and binary size by +excluding unnecessary multilib variants. It is especially beneficial +for embedded targets or vendor-specific toolchains. + +Example file contents: + +@smallexample +mips-r6-hard/lib +mips-r6-soft/lib32 +mipsel-r6-hard/lib64 +@end smallexample + +This option is target-independent and can be used with any architecture +that supports multilibs. It is passed to both host and target +configuration stages and used during fixed includes installation and +multilib directory generation. + @item --with-endian=@var{endians} Specify what endians to use. Currently only implemented for sh*-*-*. diff --git a/gcc/genmultilib b/gcc/genmultilib index 85b241cd72a..5df8148e031 100644 --- a/gcc/genmultilib +++ b/gcc/genmultilib @@ -500,9 +500,6 @@ for rrule in ${multilib_reuse}; do echo "The rule ${rrule} contains an option absent from MULTILIB_OPTIONS." >&2 exit 1 fi - else - echo "The rule ${rrule} is trying to reuse nonexistent multilib." >&2 - exit 1 fi done -- 2.34.1