git: eb90239d0886 - main - lib{c,thr}: add DT_RUNPATH for gcc -m32

From: Brooks Davis <brooks_at_FreeBSD.org>
Date: Mon, 19 Feb 2024 22:44:37 UTC
The branch main has been updated by brooks:

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

commit eb90239d08863bcff3cf82a556ad9d89776cdf3f
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2024-02-19 22:44:08 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2024-02-19 22:44:08 +0000

    lib{c,thr}: add DT_RUNPATH for gcc -m32
    
    To allow gcc -m32 to work, link libc and libthr with --rpath-/usr/lib32.
    When called with -m32, gcc is currently unable to communicate to
    the bfd linker that it should look in /usr/lib32 to resolve needed (as
    opposed to explicitly linked) libraries so we need to provide a hint.
    
    See also: https://sourceware.org/bugzilla/show_bug.cgi?id=31395
    
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D43910
---
 lib/libc/Makefile   | 5 +++++
 lib/libthr/Makefile | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/lib/libc/Makefile b/lib/libc/Makefile
index 41cf0f6de72a..aa6a737002c4 100644
--- a/lib/libc/Makefile
+++ b/lib/libc/Makefile
@@ -63,6 +63,11 @@ CFLAGS+= -ftls-model=initial-exec
 LDFLAGS+= -nodefaultlibs
 LIBADD+=	compiler_rt
 LIBADD+=	sys
+.if defined(COMPAT_libcompat)
+# XXX: work around gcc -m32 + bfd ld path issue for DT_NEEDED symbols.
+# https://sourceware.org/bugzilla/show_bug.cgi?id=31395
+LDFLAGS+=	-Wl,--rpath=/usr/lib${COMPAT_libcompat}
+.endif
 
 LDFLAGS+=-Wl,--auxiliary,libsys.so.7
 
diff --git a/lib/libthr/Makefile b/lib/libthr/Makefile
index 325a320d55ec..46b547e8da85 100644
--- a/lib/libthr/Makefile
+++ b/lib/libthr/Makefile
@@ -8,6 +8,11 @@ PACKAGE=	clibs
 SHLIBDIR?= /lib
 
 LIBADD=	c sys
+.if defined(COMPAT_libcompat)
+# XXX: work around gcc -m32 + bfd ld path issue for DT_NEEDED symbols.
+# https://sourceware.org/bugzilla/show_bug.cgi?id=31395
+LDFLAGS+=	-Wl,--rpath=/usr/lib${COMPAT_libcompat}
+.endif
 
 .include <src.opts.mk>
 MK_SSP=	no