git: 7aa6667623be - main - lib/clang: Commit cleaned-up workaround for building on RISC-V
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 18 Oct 2024 13:01:13 UTC
The branch main has been updated by jrtc27:
URL: https://cgit.FreeBSD.org/src/commit/?id=7aa6667623bef7306009d50a571e5e8c7766a174
commit 7aa6667623bef7306009d50a571e5e8c7766a174
Author: Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2024-10-18 12:59:48 +0000
Commit: Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2024-10-18 12:59:48 +0000
lib/clang: Commit cleaned-up workaround for building on RISC-V
There is a long-standing issue on RISC-V around --gc-sections when
statically linking, which affects the bootstrap build of LLVM. Since
fixing this properly has remained a TODO for years, commit the
workaround with documentation so that building natively from source
works out of the box.
PR: 258358
MFC after: 1 week
---
lib/clang/llvm.build.mk | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lib/clang/llvm.build.mk b/lib/clang/llvm.build.mk
index 7b16f4485340..2520637e2d06 100644
--- a/lib/clang/llvm.build.mk
+++ b/lib/clang/llvm.build.mk
@@ -109,6 +109,14 @@ CFLAGS+= -fdata-sections
LDFLAGS+= -Wl,-dead_strip
.else
LDFLAGS+= -Wl,--gc-sections
+# XXX: --gc-sections strips the ELF brand note and on RISC-V the OS/ABI ends up
+# as NONE, so for statically-linked binaries, i.e. lacking an interpreter,
+# get_brandinfo finds nothing and (f)execve fails with ENOEXEC. Work around
+# this by manually setting the OS/ABI field via the emulation.
+.if ${MACHINE_ARCH:Mriscv64*} != "" && ${NO_SHARED:Uno:tl} != "no" && \
+ (${.MAKE.OS} == "FreeBSD" || !defined(BOOTSTRAPPING))
+LDFLAGS+= -Wl,-m,elf64lriscv_fbsd
+.endif
.endif
CXXSTD?= c++17