From b1ab523d6fa44aae8f3ec5f787a8f86f8686bf64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Mon, 3 Jan 2022 07:14:48 +0100 Subject: [PATCH] riscv: disable multilib support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From the musl wiki [1]: musl does not support sharing an include directory between archs […], and thus is not compatible with GCC-style multilib. It is recommended that distributions build GCC with multilib disabled, and use library directories named lib, not lib64 or lib32. For this reason, we patch existing GCC configuration files (gcc/config) to pin MULTILIB_OSDIRNAMES to lib, there is also a corresponding GCC upstream bug about this issue [2]. Avoiding the use of lib64 and lib32 directories is a bit more difficult on the RISC-V architecture. This is due to the fact that the default RISC-V configuration does not only use the lib64 and lib32 directories but also subdirectories within these directories for different RISC-V ABIs (e.g. lp64d, lp64, …) [3]. This patch aligns the RISC-V configuration with other architectures by pinning MULTILIB_OSDIRNAMES to lib for rv64gc (our default RISC-V -march). Furthermore, this patch removes the ABI-specific startfile prefix spec. Since both of these impact the default LIBRARY_PATH [4] this patch thereby aligns the default RISC-V LIBRARY_PATH with that from other Alpine architectures and thereby fixes #13369 [5]. Incidentally, this also fixes gccgo on riscv64, as without this patch gccgo is otherwise not able to find the *.gox files for the Go standard library. [1]: https://wiki.musl-libc.org/guidelines-for-distributions.html#Multilib/multi_arch [2]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90077 [3]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103889#c14 [4]: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/gcc.c;h=d4c8746b0aa322286decf92aa72a12f0a393b655;hb=HEAD#l9122 [5]: https://gitlab.alpinelinux.org/alpine/aports/-/issues/13369 --- gcc/config/riscv/linux.h | 8 -------- gcc/config/riscv/t-linux | 7 +++++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h index 282c77b6a7b..07adae3d59c 100644 --- a/gcc/config/riscv/linux.h +++ b/gcc/config/riscv/linux.h @@ -61,11 +61,3 @@ along with GCC; see the file COPYING3. If not see %{rdynamic:-export-dynamic} \ -dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \ %{static:-static} %{static-pie:-static -pie --no-dynamic-linker -z text}}" - -#define STARTFILE_PREFIX_SPEC \ - "/lib" XLEN_SPEC "/" ABI_SPEC "/ " \ - "/usr/lib" XLEN_SPEC "/" ABI_SPEC "/ " \ - "/lib/ " \ - "/usr/lib/ " - -#define RISCV_USE_CUSTOMISED_MULTI_LIB select_by_abi diff --git a/gcc/config/riscv/t-linux b/gcc/config/riscv/t-linux index a6f64f88d25..f88776ec520 100644 --- a/gcc/config/riscv/t-linux +++ b/gcc/config/riscv/t-linux @@ -1,5 +1,8 @@ -# Only XLEN and ABI affect Linux multilib dir names, e.g. /lib32/ilp32d/ -MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES))) +MULTILIB_OPTIONS := march=rv64gc +MULTILIB_DIRNAMES := rv64gc + +MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib,$(MULTILIB_DIRNAMES))) MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES)) +MULTILIB_MATCHES := march?rv64gc=march?rv64imafdc MULTIARCH_DIRNAME := $(call if_multiarch,$(firstword $(subst -, ,$(target)))-linux-gnu) -- 2.50.1