xref: /freebsd/lib/libthr/Makefile (revision 7c6a5272f1ded20e91b63fe3d1a016243641a37d)
1PACKAGE=	clibs
2SHLIBDIR?= /lib
3
4LIBADD=	c sys
5.if defined(COMPAT_libcompat)
6# XXX: work around gcc -m32 + bfd ld path issue for DT_NEEDED symbols.
7# https://sourceware.org/bugzilla/show_bug.cgi?id=31395
8LDFLAGS+=	-Wl,--rpath=/usr/lib${COMPAT_libcompat}
9.endif
10
11.include <src.opts.mk>
12MK_SSP=	no
13# SSP forced off already implies FORTIFY_SOURCE=0, but we must make sure that
14# one cannot turn it back on.
15FORTIFY_SOURCE=	0
16
17LIB=thr
18SHLIB_MAJOR= 3
19
20NO_WTHREAD_SAFETY=1
21NO_WCAST_ALIGN.gcc=1    # for gcc 4.2
22CFLAGS+=-DPTHREAD_KERNEL
23CFLAGS+=-I${SRCTOP}/lib/libc/include
24CFLAGS+=-I${SRCTOP}/lib/libc/${MACHINE_CPUARCH}
25CFLAGS+=-I${.CURDIR}/thread
26CFLAGS+=-I${.CURDIR}/arch/${MACHINE_CPUARCH}/include
27CFLAGS+=-I${.CURDIR}/sys
28CFLAGS+=-I${SRCTOP}/libexec/rtld-elf
29CFLAGS+=-I${SRCTOP}/libexec/rtld-elf/${MACHINE_CPUARCH}
30CFLAGS+=-I${SRCTOP}/lib/libthread_db
31
32CFLAGS.thr_stack.c+=	-Wno-cast-align
33CFLAGS.rtld_malloc.c+=	-Wno-cast-align
34# Disable compiler builtins so that the compiler does not optimize away rtld's
35# attempts to force early PLT resolution for certain functions that may be
36# replaced by builtins.
37CFLAGS.thr_rtld.c+=	-fno-builtin
38CFLAGS.thr_symbols.c+=	-Wno-missing-variable-declarations
39.if ${MK_ASAN} != "no"
40# False-positive ASAN error claiming the local "struct sigaction act;" is
41# overflowed by handle_signal() reading from the ucontext_t argument. This
42# could be caused by ASAN not treating this function as a signal handler.
43CFLAGS.thr_sig.c+=	-fno-sanitize=address
44.endif
45
46.if ${MACHINE_CPUARCH} == "arm"
47NO_THREAD_UNWIND_STACK= yes
48.endif
49
50.ifndef NO_THREAD_UNWIND_STACK
51CFLAGS+=-fexceptions
52CFLAGS+=-D_PTHREAD_FORCED_UNWIND
53.endif
54
55LDFLAGS+=-Wl,-znodelete
56LDFLAGS+=-Wl,-zinitfirst
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
96HAS_TESTS=
97SUBDIR.${MK_TESTS}+= tests
98
99.include <bsd.lib.mk>
100