Commit ccd34d41 by Kito Cheng Committed by Kito Cheng

RISC-V: Add configure option: --with-multilib-generator to flexible config multi-lib settings.

 - Able to configure complex multi-lib rule in configure time, without modify
   any in-tree source.

 - I was consider to implmenet this into `--with-multilib-list` option,
   but I am not sure who will using that with riscv*-*-elf*, so I decide to
   using another option name for that.

 - --with-multilib-generator will pass arguments to multilib-generator, and
   then using the generated multi-lib config file to build the toolchain.

   e.g. Build riscv gcc, default arch/abi is rv64gc/lp64, and build multilib
       for rv32imafd/ilp32 and rv32i/ilp32; rv32ic/ilp32 will reuse
       rv32i/ilp32.
    $ <GCC-SRC>/configure \
       --target=riscv64-elf \
       --with-arch=rv64gc --with-abi=lp64 \
       --with-multilib-generator=rv32i-ilp32--c;rv32imafd-ilp32--

V3 Changes:

 - Rename --with-multilib-config to --with-multilib-generator
 - Check --with-multilib-generator and --with-multilib-list can't be used at
   same time.

V2 Changes:

 - Fix --with-multilib-config hanling on non riscv*-*-elf* triple.

gcc/ChangeLog:

	* config.gcc (riscv*-*-*): Handle --with-multilib-generator.
	* configure: Regen.
	* configure.ac: Add --with-multilib-generator.
	* config/riscv/multilib-generator: Exit when parsing arch string error.
	* config/riscv/t-withmultilib-generator: New.
	* doc/install.texi: Document --with-multilib-generator.
parent d7706b0a
...@@ -2450,11 +2450,13 @@ riscv*-*-elf* | riscv*-*-rtems*) ...@@ -2450,11 +2450,13 @@ riscv*-*-elf* | riscv*-*-rtems*)
tmake_file="${tmake_file} riscv/t-rtems" tmake_file="${tmake_file} riscv/t-rtems"
;; ;;
*) *)
if test "x${with_multilib_generator}" == xdefault; then
case "x${enable_multilib}" in case "x${enable_multilib}" in
xno) ;; xno) ;;
xyes) tmake_file="${tmake_file} riscv/t-elf-multilib" ;; xyes) tmake_file="${tmake_file} riscv/t-elf-multilib" ;;
*) echo "Unknown value for enable_multilib"; exit 1 *) echo "Unknown value for enable_multilib"; exit 1
esac esac
fi
esac esac
tmake_file="${tmake_file} riscv/t-riscv" tmake_file="${tmake_file} riscv/t-riscv"
gnu_ld=yes gnu_ld=yes
...@@ -4581,6 +4583,30 @@ case "${target}" in ...@@ -4581,6 +4583,30 @@ case "${target}" in
exit 1 exit 1
;; ;;
esac esac
# Handle --with-multilib-generator.
if test "x${with_multilib_generator}" != xdefault; then
if test "x${with_multilib_list}" != xdefault; then
echo "--with-multilib-list= can't used with --with-multilib-generator= at same time" 1>&2
exit 1
fi
case "${target}" in
riscv*-*-elf*)
if ${srcdir}/config/riscv/multilib-generator \
`echo ${with_multilib_generator} | sed 's/;/ /g'`\
> t-multilib-config;
then
tmake_file="${tmake_file} riscv/t-withmultilib-generator"
else
echo "invalid option for --with-multilib-generator" 1>&2
exit 1
fi
;;
*)
echo "--with-multilib-generator= is not supported for ${target}, only supported for riscv*-*-elf*" 1>&2
exit 1
;;
esac
fi
# Handle --with-multilib-list. # Handle --with-multilib-list.
if test "x${with_multilib_list}" != xdefault; then if test "x${with_multilib_list}" != xdefault; then
......
...@@ -194,7 +194,14 @@ def expand_combination(ext): ...@@ -194,7 +194,14 @@ def expand_combination(ext):
return ext return ext
for cfg in sys.argv[1:]: for cfg in sys.argv[1:]:
try:
(arch, abi, extra, ext) = cfg.split('-') (arch, abi, extra, ext) = cfg.split('-')
except:
print ("Invalid configure string %s, <arch>-<abi>-<extra>-<extensions>\n"
"<extra> and <extensions> can be empty, "
"e.g. rv32imafd-ilp32--" % cfg)
sys.exit(1)
arch = arch_canonicalize (arch) arch = arch_canonicalize (arch)
arches[arch] = 1 arches[arch] = 1
abis[abi] = 1 abis[abi] = 1
......
# t-multilib-config will generated in build folder by configure script.
include t-multilib-config
...@@ -969,6 +969,7 @@ with_documentation_root_url ...@@ -969,6 +969,7 @@ with_documentation_root_url
with_changes_root_url with_changes_root_url
enable_languages enable_languages
with_multilib_list with_multilib_list
with_multilib_generator
with_zstd with_zstd
with_zstd_include with_zstd_include
with_zstd_lib with_zstd_lib
...@@ -1806,6 +1807,8 @@ Optional Packages: ...@@ -1806,6 +1807,8 @@ Optional Packages:
--with-changes-root-url=URL --with-changes-root-url=URL
Root for GCC changes URLs Root for GCC changes URLs
--with-multilib-list select multilibs (AArch64, SH and x86-64 only) --with-multilib-list select multilibs (AArch64, SH and x86-64 only)
--with-multilib-generator
Multi-libs configuration string (RISC-V only)
--with-zstd=PATH specify prefix directory for installed zstd library. --with-zstd=PATH specify prefix directory for installed zstd library.
Equivalent to --with-zstd-include=PATH/include plus Equivalent to --with-zstd-include=PATH/include plus
--with-zstd-lib=PATH/lib --with-zstd-lib=PATH/lib
...@@ -8006,6 +8009,15 @@ else ...@@ -8006,6 +8009,15 @@ else
fi fi
# Check whether --with-multilib-generator was given.
if test "${with_multilib_generator+set}" = set; then :
withval=$with_multilib_generator; :
else
with_multilib_generator=default
fi
# ------------------------- # -------------------------
# Checks for other programs # Checks for other programs
# ------------------------- # -------------------------
...@@ -19020,7 +19032,7 @@ else ...@@ -19020,7 +19032,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF cat > conftest.$ac_ext <<_LT_EOF
#line 19023 "configure" #line 19035 "configure"
#include "confdefs.h" #include "confdefs.h"
#if HAVE_DLFCN_H #if HAVE_DLFCN_H
...@@ -19126,7 +19138,7 @@ else ...@@ -19126,7 +19138,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF cat > conftest.$ac_ext <<_LT_EOF
#line 19129 "configure" #line 19141 "configure"
#include "confdefs.h" #include "confdefs.h"
#if HAVE_DLFCN_H #if HAVE_DLFCN_H
......
...@@ -1110,6 +1110,11 @@ AC_ARG_WITH(multilib-list, ...@@ -1110,6 +1110,11 @@ AC_ARG_WITH(multilib-list,
:, :,
with_multilib_list=default) with_multilib_list=default)
AC_ARG_WITH(multilib-generator,
[AS_HELP_STRING([--with-multilib-generator], [Multi-libs configuration string (RISC-V only)])],
:,
with_multilib_generator=default)
# ------------------------- # -------------------------
# Checks for other programs # Checks for other programs
# ------------------------- # -------------------------
......
...@@ -1250,6 +1250,37 @@ If @option{--with-multilib-list} is not given, then only 32-bit and ...@@ -1250,6 +1250,37 @@ If @option{--with-multilib-list} is not given, then only 32-bit and
64-bit run-time libraries will be enabled. 64-bit run-time libraries will be enabled.
@end table @end table
@item --with-multilib-generator=@var{config}
Specify what multilibs to build. @var{config} is a semicolon separated list of
values, possibly consisting of a single value. Currently only implemented
for riscv*-*-elf*. The accepted values and meanings are given below.
Every config is constructed with four components: architecture string, ABI,
reuse rule with architecture string and reuse rule with sub-extension.
Example 1: Add multi-lib suppport for rv32i with ilp32.
@smallexample
rv32i-ilp32--
@end smallexample
Example 2: Add multi-lib suppport for rv32i with ilp32 and rv32imafd with ilp32.
@smallexample
rv32i-ilp32--;rv32imafd-ilp32--
@end smallexample
Example 3: Add multi-lib suppport for rv32i with ilp32; rv32im with ilp32 and
rv32ic with ilp32 will reuse this multi-lib set.
@smallexample
rv32i-ilp32-rv32im-c
@end smallexample
Example 4: Add multi-lib suppport for rv64ima with lp64; rv64imaf with lp64,
rv64imac with lp64 and rv64imafc with lp64 will reuse this multi-lib set.
@smallexample
rv64ima-lp64--f,c,fc
@end smallexample
@item --with-endian=@var{endians} @item --with-endian=@var{endians}
Specify what endians to use. Specify what endians to use.
Currently only implemented for sh*-*-*. Currently only implemented for sh*-*-*.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment