xref: /freebsd/lib/libthr/Makefile (revision 3750ccefb8629a08890bfbae894dd6bc6a7483b4)
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,--auxiliary,libsys.so.7
57
58VERSION_DEF=${SRCTOP}/lib/libc/Versions.def
59SYMBOL_MAPS=${.CURDIR}/pthread.map
60
61MAN=	libthr.3
62
63.if ${MK_PTHREADS_ASSERTIONS} != "no"
64# enable extra internal consistency checks
65CFLAGS+=-D_PTHREADS_INVARIANTS
66.endif
67
68PRECIOUSLIB=
69
70.PATH: ${.CURDIR}/arch/${MACHINE_CPUARCH}/${MACHINE_CPUARCH}
71.PATH: ${SRCTOP}/libexec/rtld-elf
72
73.if exists(${.CURDIR}/arch/${MACHINE_CPUARCH}/Makefile.inc)
74.include "${.CURDIR}/arch/${MACHINE_CPUARCH}/Makefile.inc"
75.endif
76.include "${.CURDIR}/sys/Makefile.inc"
77.include "${.CURDIR}/thread/Makefile.inc"
78SRCS+= rtld_malloc.c
79
80LIBSYS_SRCTOP=	${.CURDIR:H}/libsys
81.if exists(${LIBSYS_SRCTOP}/${MACHINE_CPUARCH}/_umtx_op_err.S)
82.PATH: ${LIBSYS_SRCTOP}/${MACHINE_CPUARCH}
83.else
84.PATH: ${LIBSYS_SRCTOP}
85.endif
86OBJS+=	_umtx_op_err.o
87
88.if ${MK_INSTALLLIB} != "no"
89SYMLINKS+=lib${LIB}.a ${LIBDIR}/libpthread.a
90.endif
91.if !defined(NO_PIC)
92SYMLINKS+=lib${LIB}.so ${LIBDIR}/libpthread.so
93.endif
94
95HAS_TESTS=
96SUBDIR.${MK_TESTS}+= tests
97
98.include <bsd.lib.mk>
99