1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-13 03:09:51 +03:00
aports/main/gcc/0023-riscv-disable-multilib-support.patch
2025-05-30 12:41:30 +00:00

71 lines
3.2 KiB
Diff

From b26224acf342eacb33491f6ea0da1faf73d35715 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 23/35] 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(-)
--- 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
--- 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)