git: fd153a0a4cfc - stable/12 - rtld-elf: link libcompiler_rt on all architectures

From: John Baldwin <>
Date: Wed, 22 Mar 2023 22:28:39 UTC
The branch stable/12 has been updated by jhb:


commit fd153a0a4cfc180241a8a43e19fbe135cef4868c
Author:     Ryan Libby <>
AuthorDate: 2020-12-28 08:44:25 +0000
Commit:     John Baldwin <>
CommitDate: 2023-03-22 19:22:25 +0000

    rtld-elf: link libcompiler_rt on all architectures
    Statically link rtld-elf with libcompiler_rt on all architectures so
    that we don't need to try to pick and choose the bits we need from it
    for each architecture (we now leave that to the linker).  Compilers may
    emit calls to support functions in this library, but because of the use
    of the linker flag -nostdlib for rtld's special needs, the library is
    not linked as normal.
    Previously we had two different solutions.  On some architectures, we
    were able to extract reimplementations of the necessary builtin
    functions from our special build of libc.  On ARM, we just linked
    This is motivated by the same issue as D26199 and D27665, but should be
    a simpler solution that will apply to all architectures.
    Reviewed by:    arichardson, kib
    Sponsored by:   Dell EMC Isilon
    Differential Revision:
    (cherry picked from commit 63f93c7e11e33149429ddc2831cd1683b2e7f3e1)
 libexec/rtld-elf/Makefile | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/libexec/rtld-elf/Makefile b/libexec/rtld-elf/Makefile
index a51acf68068a..dfa6d4e6b85e 100644
--- a/libexec/rtld-elf/Makefile
+++ b/libexec/rtld-elf/Makefile
@@ -68,14 +68,6 @@ LIBADD=		c_nossp_pic
-.if ${MACHINE_CPUARCH} == "arm"
-# Some of the required math functions (div & mod) are implemented in
-# libcompiler_rt on ARM. The library also needs to be placed first to be
-# correctly linked. As some of the functions are used before we have
-# shared libraries.
-LIBADD+=	compiler_rt
 .if ${MK_SYMVER} == "yes"
@@ -103,6 +95,10 @@ beforeinstall:
 SUBDIR.${MK_TESTS}+= tests
+# Some of the required math functions (div & mod) are implemented in
+# libcompiler_rt on some architectures.
+LIBADD+=	compiler_rt
 .include <>
 .include <>