RISC-V: Handle multi-lib path correclty for linux
commit17d683d4d3dc95d13096ec52ad9937a2b011f9a4
authorKito Cheng <kito.cheng@sifive.com>
Thu, 4 May 2023 07:12:27 +0000 (4 15:12 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Mon, 8 May 2023 07:00:51 +0000 (8 15:00 +0800)
tree7658f50831d89d8f711701eb1a7bac219e178765
parent31c70a7daa368767f0f58e0389deb2c69d9e14fd
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/common/config/riscv/riscv-common.cc
gcc/config/riscv/elf.h
gcc/config/riscv/linux.h
gcc/config/riscv/riscv-opts.h