git: a689dd9f2b17 - stable/15 - libgcc_s: add libgcc_s_asneeded.so wrapper for gcc 16
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 07 Oct 2026 23:58:19 UTC
The branch stable/15 has been updated by siva:
URL: https://cgit.FreeBSD.org/src/commit/?id=a689dd9f2b1798c7152b08019f7826935c04e9e0
commit a689dd9f2b1798c7152b08019f7826935c04e9e0
Author: Siva Mahadevan <siva@FreeBSD.org>
AuthorDate: 2026-09-28 15:07:56 +0000
Commit: Siva Mahadevan <siva@FreeBSD.org>
CommitDate: 2026-10-07 23:56:48 +0000
libgcc_s: add libgcc_s_asneeded.so wrapper for gcc 16
GCC 16[0][1] now requires a wrapper lib to handle
`--push-state --as-needed -lgcc_s --pop-state` logic[1]
for `gcc` invocations. `g++` will still unconditionally
use `-lgcc_s`.
This fixes buildworld with gcc16.
[0] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=8a99fdb70493df1294b53406913e5ea1fc971c13
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123396
Reviewed by: jhb
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D59511
Squashed commits including fixups:
(cherry picked from commit fdd3f6f78888b02a1bfa69a0572317413dc14a45)
(cherry picked from commit b45d14d3d665e0253391924e5c0595c259b8a773)
(cherry picked from commit 222210c6a82282de78aa863c550da21471630316)
---
Makefile.inc1 | 7 ++++---
lib/Makefile | 1 +
lib/libgcc_s_asneeded/Makefile | 11 +++++++++++
lib/libgcc_s_asneeded/libgcc_s_asneeded.ldscript | 1 +
share/mk/bsd.lib.mk | 2 +-
5 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/Makefile.inc1 b/Makefile.inc1
index fb2a5e2ce527..162951157c2d 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -3304,13 +3304,14 @@ _startup_libs+= lib/libc_nonshared
_startup_libs+= lib/libcxxrt
_startup_libs+= lib/libsys
-_prereq_libs+= lib/libgcc_eh lib/libgcc_s
-_startup_libs+= lib/libgcc_eh lib/libgcc_s
+_prereq_libs+= lib/libgcc_eh lib/libgcc_s lib/libgcc_s_asneeded
+_startup_libs+= lib/libgcc_eh lib/libgcc_s lib/libgcc_s_asneeded
lib/libc__L: lib/libsys__L
lib/libgcc_s__L: lib/libc__L
lib/libgcc_s__L: lib/libc_nonshared__L
-lib/libcxxrt__L: lib/libgcc_s__L
+lib/libgcc_s_asneeded__L: lib/libgcc_s__L
+lib/libcxxrt__L: lib/libgcc_s_asneeded__L
lib/libcrypt__L: lib/libmd__L
_prebuild_libs= ${_kerberos5_lib_libasn1} \
diff --git a/lib/Makefile b/lib/Makefile
index 6e2ff634c963..f1d72e025c81 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -61,6 +61,7 @@ SUBDIR= ${SUBDIR_BOOTSTRAP} \
libfetch \
libgcc_eh \
libgcc_s \
+ libgcc_s_asneeded \
libgeom \
libifconfig \
libipsec \
diff --git a/lib/libgcc_s_asneeded/Makefile b/lib/libgcc_s_asneeded/Makefile
new file mode 100644
index 000000000000..eb59daac50f8
--- /dev/null
+++ b/lib/libgcc_s_asneeded/Makefile
@@ -0,0 +1,11 @@
+PACKAGE= clibs
+SHLIB_NAME= libgcc_s_asneeded.so.1
+SHLIBDIR?= /lib
+
+SHLIB_LDSCRIPT= libgcc_s_asneeded.ldscript
+
+.include <bsd.opts.mk>
+
+LDFLAGS+= -nodefaultlibs
+
+.include <bsd.lib.mk>
diff --git a/lib/libgcc_s_asneeded/libgcc_s_asneeded.ldscript b/lib/libgcc_s_asneeded/libgcc_s_asneeded.ldscript
new file mode 100644
index 000000000000..3461e92fa7ca
--- /dev/null
+++ b/lib/libgcc_s_asneeded/libgcc_s_asneeded.ldscript
@@ -0,0 +1 @@
+INPUT (AS_NEEDED(-lgcc_s))
diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
index e3b3d760ff28..5b7bed041b8f 100644
--- a/share/mk/bsd.lib.mk
+++ b/share/mk/bsd.lib.mk
@@ -291,7 +291,7 @@ ${SHLIB_NAME_FULL}: ${SOBJS}
.endif
${_LD:N${CCACHE_BIN}} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \
-o ${.TARGET} -Wl,-soname,${SONAME} ${SOBJS} ${LDADD}
-.if ${MK_CTF} != "no"
+.if ${MK_CTF} != "no" && defined(SOBJS) && !empty(SOBJS)
${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS}
.endif