xref: /freebsd/lib/libthr/Makefile (revision 4719366192d306a76e8e86bf926387f1c4122fd3)
1
2PACKAGE=	clibs
3SHLIBDIR?= /lib
4
5LIBADD=	c sys
6.if defined(COMPAT_libcompat)
7# XXX: work around gcc -m32 + bfd ld path issue for DT_NEEDED symbols.
8# https://sourceware.org/bugzilla/show_bug.cgi?id=31395
9LDFLAGS+=	-Wl,--rpath=/usr/lib${COMPAT_libcompat}
10.endif
11
12.include <src.opts.mk>
13MK_SSP=	no
14# SSP forced off already implies FORTIFY_SOURCE=0, but we must make sure that
15# one cannot turn it back on.
16FORTIFY_SOURCE=	0
17
18LIB=thr
19SHLIB_MAJOR= 3
20
21NO_WTHREAD_SAFETY=1
22NO_WCAST_ALIGN.gcc=1    # for gcc 4.2
23CFLAGS+=-DPTHREAD_KERNEL
24CFLAGS+=-I${SRCTOP}/lib/libc/include
25CFLAGS+=-I${SRCTOP}/lib/libc/${MACHINE_CPUARCH}
26CFLAGS+=-I${.CURDIR}/thread
27CFLAGS+=-I${.CURDIR}/arch/${MACHINE_CPUARCH}/include
28CFLAGS+=-I${.CURDIR}/sys
29CFLAGS+=-I${SRCTOP}/libexec/rtld-elf
30CFLAGS+=-I${SRCTOP}/libexec/rtld-elf/${MACHINE_CPUARCH}
31CFLAGS+=-I${SRCTOP}/lib/libthread_db
32
33CFLAGS.thr_stack.c+=	-Wno-cast-align
34CFLAGS.rtld_malloc.c+=	-Wno-cast-align
35# Disable compiler builtins so that the compiler does not optimize away rtld's
36# attempts to force early PLT resolution for certain functions that may be
37# replaced by builtins.
38CFLAGS.thr_rtld.c+=	-fno-builtin
39CFLAGS.thr_symbols.c+=	-Wno-missing-variable-declarations
40.if ${MK_ASAN} != "no"
41# False-positive ASAN error claiming the local "struct sigaction act;" is
42# overflowed by handle_signal() reading from the ucontext_t argument. This
43# could be caused by ASAN not treating this function as a signal handler.
44CFLAGS.thr_sig.c+=	-fno-sanitize=address
45.endif
46
47.if ${MACHINE_CPUARCH} == "arm"
48NO_THREAD_UNWIND_STACK= yes
49.endif
50
51.ifndef NO_THREAD_UNWIND_STACK
52CFLAGS+=-fexceptions
53CFLAGS+=-D_PTHREAD_FORCED_UNWIND
54.endif
55
56LDFLAGS+=-Wl,-znodelete
57LDFLAGS+=-Wl,--auxiliary,libsys.so.7
58
59VERSION_DEF=${SRCTOP}/lib/libc/Versions.def
60SYMBOL_MAPS=${.CURDIR}/pthread.map
61
62MAN=	libthr.3
63
64.if ${MK_PTHREADS_ASSERTIONS} != "no"
65# enable extra internal consistency checks
66CFLAGS+=-D_PTHREADS_INVARIANTS
67.endif
68
69PRECIOUSLIB=
70
71.PATH: ${.CURDIR}/arch/${MACHINE_CPUARCH}/${MACHINE_CPUARCH}
72.PATH: ${SRCTOP}/libexec/rtld-elf
73
74.if exists(${.CURDIR}/arch/${MACHINE_CPUARCH}/Makefile.inc)
75.include "${.CURDIR}/arch/${MACHINE_CPUARCH}/Makefile.inc"
76.endif
77.include "${.CURDIR}/sys/Makefile.inc"
78.include "${.CURDIR}/thread/Makefile.inc"
79SRCS+= rtld_malloc.c
80
81LIBSYS_SRCTOP=	${.CURDIR:H}/libsys
82.if exists(${LIBSYS_SRCTOP}/${MACHINE_CPUARCH}/_umtx_op_err.S)
83.PATH: ${LIBSYS_SRCTOP}/${MACHINE_CPUARCH}
84.else
85.PATH: ${LIBSYS_SRCTOP}
86.endif
87OBJS+=	_umtx_op_err.o
88
89.if ${MK_INSTALLLIB} != "no"
90SYMLINKS+=lib${LIB}.a ${LIBDIR}/libpthread.a
91.endif
92.if !defined(NO_PIC)
93SYMLINKS+=lib${LIB}.so ${LIBDIR}/libpthread.so
94.endif
95.if ${MK_PROFILE} != "no"
96SYMLINKS+=lib${LIB}_p.a ${LIBDIR}/libpthread_p.a
97.endif
98
99HAS_TESTS=
100SUBDIR.${MK_TESTS}+= tests
101
102.include <bsd.lib.mk>
103