Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Dec 2025 17:00:10 +0000
Message-ID:  <69403e9a.c6f4.14cd4b50@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/14 has been updated by jrtc27:

URL: https://cgit.FreeBSD.org/src/commit/?id=6559b303a34b60b2cc2836bc376bec27f3df5b8a

commit 6559b303a34b60b2cc2836bc376bec27f3df5b8a
Author:     Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2024-10-18 12:59:48 +0000
Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2025-12-15 16:58:43 +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
    
    (cherry picked from commit 7aa6667623bef7306009d50a571e5e8c7766a174)
---
 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


help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69403e9a.c6f4.14cd4b50>