From eb90239d08863bcff3cf82a556ad9d89776cdf3f Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Mon, 19 Feb 2024 22:44:08 +0000 Subject: [PATCH] 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 41cf0f6de72..aa6a737002c 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 325a320d55e..46b547e8da8 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 MK_SSP= no