xref: /freebsd/lib/libthr/Makefile (revision 3750ccefb8629a08890bfbae894dd6bc6a7483b4)
1c389411cSGlen BarberPACKAGE=	clibs
2241715e7SRuslan ErmilovSHLIBDIR?= /lib
3241715e7SRuslan Ermilov
499ea6757SBrooks DavisLIBADD=	c sys
5eb90239dSBrooks Davis.if defined(COMPAT_libcompat)
6eb90239dSBrooks Davis# XXX: work around gcc -m32 + bfd ld path issue for DT_NEEDED symbols.
7eb90239dSBrooks Davis# https://sourceware.org/bugzilla/show_bug.cgi?id=31395
8eb90239dSBrooks DavisLDFLAGS+=	-Wl,--rpath=/usr/lib${COMPAT_libcompat}
9eb90239dSBrooks Davis.endif
1099ea6757SBrooks Davis
11c6063d0dSWarner Losh.include <src.opts.mk>
12d9ca85fcSRuslan ErmilovMK_SSP=	no
139bfd3b40SKyle Evans# SSP forced off already implies FORTIFY_SOURCE=0, but we must make sure that
149bfd3b40SKyle Evans# one cannot turn it back on.
159bfd3b40SKyle EvansFORTIFY_SOURCE=	0
1600fb440cSDaniel Eischen
17bb535300SJeff RobersonLIB=thr
18419ecd5dSDaniel EischenSHLIB_MAJOR= 3
19ef9871c6SBrooks Davis
206eccf6e3SEric van GyzenNO_WTHREAD_SAFETY=1
21afba14e2SEric van GyzenNO_WCAST_ALIGN.gcc=1    # for gcc 4.2
22a091d823SDavid XuCFLAGS+=-DPTHREAD_KERNEL
235d00c5a6SKonstantin BelousovCFLAGS+=-I${SRCTOP}/lib/libc/include
245d00c5a6SKonstantin BelousovCFLAGS+=-I${SRCTOP}/lib/libc/${MACHINE_CPUARCH}
255d00c5a6SKonstantin BelousovCFLAGS+=-I${.CURDIR}/thread
26f4fbf9c8SNathan WhitehornCFLAGS+=-I${.CURDIR}/arch/${MACHINE_CPUARCH}/include
27a091d823SDavid XuCFLAGS+=-I${.CURDIR}/sys
2858368ba9SEnji CooperCFLAGS+=-I${SRCTOP}/libexec/rtld-elf
2958368ba9SEnji CooperCFLAGS+=-I${SRCTOP}/libexec/rtld-elf/${MACHINE_CPUARCH}
3058368ba9SEnji CooperCFLAGS+=-I${SRCTOP}/lib/libthread_db
313832fd24SDavid Xu
320b2f3f20SEric van GyzenCFLAGS.thr_stack.c+=	-Wno-cast-align
33d49ca25dSKonstantin BelousovCFLAGS.rtld_malloc.c+=	-Wno-cast-align
34*39733922SRyan Libby# Disable compiler builtins so that the compiler does not optimize away rtld's
35*39733922SRyan Libby# attempts to force early PLT resolution for certain functions that may be
36*39733922SRyan Libby# replaced by builtins.
37*39733922SRyan LibbyCFLAGS.thr_rtld.c+=	-fno-builtin
380b2f3f20SEric van GyzenCFLAGS.thr_symbols.c+=	-Wno-missing-variable-declarations
399efbe526SAlex Richardson.if ${MK_ASAN} != "no"
409efbe526SAlex Richardson# False-positive ASAN error claiming the local "struct sigaction act;" is
419efbe526SAlex Richardson# overflowed by handle_signal() reading from the ucontext_t argument. This
429efbe526SAlex Richardson# could be caused by ASAN not treating this function as a signal handler.
439efbe526SAlex RichardsonCFLAGS.thr_sig.c+=	-fno-sanitize=address
449efbe526SAlex Richardson.endif
450b2f3f20SEric van Gyzen
46bbf4df17SJohn Baldwin.if ${MACHINE_CPUARCH} == "arm"
47bbf4df17SJohn BaldwinNO_THREAD_UNWIND_STACK= yes
48bbf4df17SJohn Baldwin.endif
49bbf4df17SJohn Baldwin
50f4213b90SDavid Xu.ifndef NO_THREAD_UNWIND_STACK
510935fc89SDavid XuCFLAGS+=-fexceptions
523832fd24SDavid XuCFLAGS+=-D_PTHREAD_FORCED_UNWIND
533832fd24SDavid Xu.endif
543832fd24SDavid Xu
556d772c3bSKonstantin BelousovLDFLAGS+=-Wl,-znodelete
5649d68436SBrooks DavisLDFLAGS+=-Wl,--auxiliary,libsys.so.7
57a091d823SDavid Xu
5858368ba9SEnji CooperVERSION_DEF=${SRCTOP}/lib/libc/Versions.def
59a9b9744fSDag-Erling SmørgravSYMBOL_MAPS=${.CURDIR}/pthread.map
60bb535300SJeff Roberson
615335c6bcSRobert WatsonMAN=	libthr.3
625335c6bcSRobert Watson
63642cd511SGreg Becker.if ${MK_PTHREADS_ASSERTIONS} != "no"
64e13c6045SKonstantin Belousov# enable extra internal consistency checks
6544a31c2dSDavid XuCFLAGS+=-D_PTHREADS_INVARIANTS
66642cd511SGreg Becker.endif
67bb535300SJeff Roberson
68a35d8893SRuslan ErmilovPRECIOUSLIB=
69bb535300SJeff Roberson
7010f3ae58SWarner Losh.PATH: ${.CURDIR}/arch/${MACHINE_CPUARCH}/${MACHINE_CPUARCH}
71381c2d2eSKonstantin Belousov.PATH: ${SRCTOP}/libexec/rtld-elf
7210f3ae58SWarner Losh
7320fe2c94SAndrew Turner.if exists(${.CURDIR}/arch/${MACHINE_CPUARCH}/Makefile.inc)
74f4fbf9c8SNathan Whitehorn.include "${.CURDIR}/arch/${MACHINE_CPUARCH}/Makefile.inc"
7520fe2c94SAndrew Turner.endif
76a091d823SDavid Xu.include "${.CURDIR}/sys/Makefile.inc"
77a091d823SDavid Xu.include "${.CURDIR}/thread/Makefile.inc"
78d49ca25dSKonstantin BelousovSRCS+= rtld_malloc.c
79bb535300SJeff Roberson
80ef9871c6SBrooks DavisLIBSYS_SRCTOP=	${.CURDIR:H}/libsys
81ef9871c6SBrooks Davis.if exists(${LIBSYS_SRCTOP}/${MACHINE_CPUARCH}/_umtx_op_err.S)
82ef9871c6SBrooks Davis.PATH: ${LIBSYS_SRCTOP}/${MACHINE_CPUARCH}
83ef9871c6SBrooks Davis.else
84ef9871c6SBrooks Davis.PATH: ${LIBSYS_SRCTOP}
85ef9871c6SBrooks Davis.endif
8649d68436SBrooks DavisOBJS+=	_umtx_op_err.o
87ef9871c6SBrooks Davis
88455cc6ecSJung-uk Kim.if ${MK_INSTALLLIB} != "no"
8955ac4c35SDavid XuSYMLINKS+=lib${LIB}.a ${LIBDIR}/libpthread.a
90455cc6ecSJung-uk Kim.endif
9155ac4c35SDavid Xu.if !defined(NO_PIC)
9284e709f1SRuslan ErmilovSYMLINKS+=lib${LIB}.so ${LIBDIR}/libpthread.so
9355ac4c35SDavid Xu.endif
9455ac4c35SDavid Xu
95d511b20aSEnji CooperHAS_TESTS=
964b330699SEnji CooperSUBDIR.${MK_TESTS}+= tests
973eee258dSEnji Cooper
98bb535300SJeff Roberson.include <bsd.lib.mk>
99