From 17d683d4d3dc95d13096ec52ad9937a2b011f9a4 Mon Sep 17 00:00:00 2001 From: Kito Cheng Date: Thu, 4 May 2023 15:12:27 +0800 Subject: 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. --- gcc/config/riscv/riscv-opts.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gcc/config/riscv/riscv-opts.h') 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) -- cgit v1.1