aboutsummaryrefslogtreecommitdiff
path: root/gcc/config
diff options
context:
space:
mode:
authorKito Cheng <kito.cheng@sifive.com>2023-05-04 15:12:27 +0800
committerKito Cheng <kito.cheng@sifive.com>2023-05-08 15:00:51 +0800
commit17d683d4d3dc95d13096ec52ad9937a2b011f9a4 (patch)
tree7658f50831d89d8f711701eb1a7bac219e178765 /gcc/config
parent31c70a7daa368767f0f58e0389deb2c69d9e14fd (diff)
downloadgcc-17d683d4d3dc95d13096ec52ad9937a2b011f9a4.zip
gcc-17d683d4d3dc95d13096ec52ad9937a2b011f9a4.tar.gz
gcc-17d683d4d3dc95d13096ec52ad9937a2b011f9a4.tar.bz2
RISC-V: Handle multi-lib path correclty for linux
RISC-V Linux encodes the ABI into the path, so in theory, we can only use that to select multi-lib paths, and no way to use different multi-lib paths between `rv32i/ilp32` and `rv32ima/ilp32`, we'll mapping both to `/lib/ilp32`. It's hard to do that with GCC's builtin multi-lib selection mechanism; builtin mechanism did the option string compare and then enumerate all possible reuse rules during the build time. However, it's impossible to RISC-V; we have a huge number of combinations of `-march`, so implementing a customized multi-lib selection becomes the only solution. Multi-lib configuration is only used for determines which ISA should be used when compiling the corresponding ABI variant after this patch. During the multi-lib selection stage, only consider -mabi as the only key to select the multi-lib path. gcc/ChangeLog: * common/config/riscv/riscv-common.cc (riscv_select_multilib_by_abi): New. (riscv_select_multilib): New. (riscv_compute_multilib): Extract logic to riscv_select_multilib and also handle select_by_abi. * config/riscv/elf.h (RISCV_USE_CUSTOMISED_MULTI_LIB): Change it to select_by_abi_arch_cmodel from 1. * config/riscv/linux.h (RISCV_USE_CUSTOMISED_MULTI_LIB): Define. * config/riscv/riscv-opts.h (enum riscv_multilib_select_kind): New.
Diffstat (limited to 'gcc/config')
-rw-r--r--gcc/config/riscv/elf.h2
-rw-r--r--gcc/config/riscv/linux.h2
-rw-r--r--gcc/config/riscv/riscv-opts.h9
3 files changed, 12 insertions, 1 deletions
diff --git a/gcc/config/riscv/elf.h b/gcc/config/riscv/elf.h
index a725c00..4b7e5c9 100644
--- a/gcc/config/riscv/elf.h
+++ b/gcc/config/riscv/elf.h
@@ -37,4 +37,4 @@ along with GCC; see the file COPYING3. If not see
#undef ENDFILE_SPEC
#define ENDFILE_SPEC "crtend%O%s"
-#define RISCV_USE_CUSTOMISED_MULTI_LIB 1
+#define RISCV_USE_CUSTOMISED_MULTI_LIB select_by_abi_arch_cmodel
diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h
index 2fdfd93..3e625e0 100644
--- a/gcc/config/riscv/linux.h
+++ b/gcc/config/riscv/linux.h
@@ -66,3 +66,5 @@ along with GCC; see the file COPYING3. If not see
"/usr/lib" XLEN_SPEC "/" ABI_SPEC "/ " \
"/lib/ " \
"/usr/lib/ "
+
+#define RISCV_USE_CUSTOMISED_MULTI_LIB select_by_abi
diff --git a/gcc/config/riscv/riscv-opts.h b/gcc/config/riscv/riscv-opts.h
index 4207db2..1b2e6de 100644
--- a/gcc/config/riscv/riscv-opts.h
+++ b/gcc/config/riscv/riscv-opts.h
@@ -82,6 +82,15 @@ enum riscv_autovec_lmul_enum {
RVV_M8 = 8
};
+enum riscv_multilib_select_kind {
+ /* Select multilib by builtin way. */
+ select_by_builtin,
+ /* Select multilib by ABI, arch and code model. */
+ select_by_abi_arch_cmodel,
+ /* Select multilib by ABI only. */
+ select_by_abi,
+};
+
#define MASK_ZICSR (1 << 0)
#define MASK_ZIFENCEI (1 << 1)