Skip to content

Commit

Permalink
libthr: filter rather than link with libsys
Browse files Browse the repository at this point in the history
The allows gcc + GNU ld to link programs with -m32 -pthread without
erroring out due to _umtx_op_err being undefined (unless -lsys is added
to the link command.

We now always link _umtx_op_err into libthr (not just when it's static)
and filter it with libsys so we call that implementation.  The dynamic
implementations (at least the assembly ones) should likely become stubs
as a further refinement.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D43783
  • Loading branch information
brooksdavis committed Feb 7, 2024
1 parent 49076f3 commit 49d6843
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/libthr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ MK_SSP= no
LIB=thr
SHLIB_MAJOR= 3

LIBADD= sys

NO_WTHREAD_SAFETY=1
NO_WCAST_ALIGN.gcc=1 # for gcc 4.2
CFLAGS+=-DPTHREAD_KERNEL
Expand Down Expand Up @@ -47,6 +45,7 @@ CFLAGS+=-D_PTHREAD_FORCED_UNWIND
.endif

LDFLAGS+=-Wl,-znodelete
LDFLAGS+=-Wl,--auxiliary,libsys.so.7

VERSION_DEF=${SRCTOP}/lib/libc/Versions.def
SYMBOL_MAPS=${.CURDIR}/pthread.map
Expand Down Expand Up @@ -76,7 +75,7 @@ LIBSYS_SRCTOP= ${.CURDIR:H}/libsys
.else
.PATH: ${LIBSYS_SRCTOP}
.endif
STATICOBJS+= _umtx_op_err.o
OBJS+= _umtx_op_err.o

.if ${MK_INSTALLLIB} != "no"
SYMLINKS+=lib${LIB}.a ${LIBDIR}/libpthread.a
Expand Down
3 changes: 3 additions & 0 deletions lib/libthr/pthread.map
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ FBSDprivate_1.0 {

/* ABI bug workaround, indicate that pli->rtli_version is valid */
_pli_rtli_version;

/* Expose stub for libsys filter */
_umtx_op_err;
};

FBSD_1.1 {
Expand Down

0 comments on commit 49d6843

Please sign in to comment.