pmaports/cross/gcc-aarch64/0029-riscv-disable-multilib-support.patch
2022-02-21 17:53:32 +01:00

74 lines
3.2 KiB
Diff

From 18bcf23cae4069ffe9d9f64e851193d29dd4814f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
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 | 6 ------
gcc/config/riscv/t-linux | 7 +++++--
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h
index ee29979dd34..fe8a82d6702 100644
--- a/gcc/config/riscv/linux.h
+++ b/gcc/config/riscv/linux.h
@@ -71,9 +71,3 @@ along with GCC; see the file COPYING3. If not see
%{static:-static}}"
#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
-
-#define STARTFILE_PREFIX_SPEC \
- "/lib" XLEN_SPEC "/" ABI_SPEC "/ " \
- "/usr/lib" XLEN_SPEC "/" ABI_SPEC "/ " \
- "/lib/ " \
- "/usr/lib/ "
diff --git a/gcc/config/riscv/t-linux b/gcc/config/riscv/t-linux
index 216d2776a18..1a8a863853e 100644
--- a/gcc/config/riscv/t-linux
+++ b/gcc/config/riscv/t-linux
@@ -1,3 +1,6 @@
-# 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
--
2.35.1