1# sysdeps makefile fragment for all pthread-supporting configurations.
2# Copyright (C) 2014-2022 Free Software Foundation, Inc.
3# This file is part of the GNU C Library.
4
5# The GNU C Library is free software; you can redistribute it and/or
6# modify it under the terms of the GNU Lesser General Public
7# License as published by the Free Software Foundation; either
8# version 2.1 of the License, or (at your option) any later version.
9
10# The GNU C Library is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13# Lesser General Public License for more details.
14
15# You should have received a copy of the GNU Lesser General Public
16# License along with the GNU C Library; if not, see
17# <https://www.gnu.org/licenses/>.
18
19ifeq ($(subdir),rt)
20$(objpfx)tst-timer: $(librt)
21endif
22
23ifneq (,$(filter $(subdir),htl nptl))
24headers += threads.h
25
26routines += thrd_current thrd_equal thrd_sleep thrd_yield pthread_atfork
27
28$(libpthread-routines-var) += \
29  call_once \
30  cnd_broadcast \
31  cnd_destroy \
32  cnd_init \
33  cnd_signal \
34  cnd_timedwait \
35  cnd_wait \
36  mtx_destroy \
37  mtx_init \
38  mtx_lock \
39  mtx_timedlock \
40  mtx_trylock \
41  mtx_unlock \
42  pthread_atfork_compat \
43  thrd_create \
44  thrd_detach \
45  thrd_exit \
46  thrd_join \
47  tss_create \
48  tss_delete \
49  tss_get \
50  tss_set \
51
52tests += tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \
53	 tst-cnd-timedwait tst-thrd-detach tst-mtx-basic tst-thrd-sleep \
54	 tst-mtx-recursive tst-tss-basic tst-call-once tst-mtx-timedlock \
55	 \
56	 tst-abstime \
57	 tst-pt-align tst-pt-align3 \
58	 tst-attr1 \
59	 tst-backtrace1 \
60	 tst-bad-schedattr \
61	 tst-barrier1 tst-barrier2 tst-barrier3 tst-barrier4 \
62	 tst-basic1 tst-basic2 tst-basic3 tst-basic4 tst-basic5 tst-basic6 \
63	 tst-basic7 \
64	 tst-cancel-self tst-cancel-self-cancelstate \
65	 tst-cancel-self-canceltype tst-cancel-self-testcancel \
66	 tst-cancel1 tst-cancel2 tst-cancel3 \
67	 tst-cancel4 tst-cancel5 \
68	 tst-cancel6 tst-cancel8 tst-cancel9 tst-cancel10 tst-cancel11 \
69	 tst-cancel12 tst-cancel13 tst-cancel14 tst-cancel15 tst-cancel16 \
70	 tst-cancel18 tst-cancel19 tst-cancel20 tst-cancel21 \
71	 tst-cancel22 tst-cancel23 tst-cancel26 tst-cancel27 tst-cancel28 \
72	 tst-cancel29 \
73	 tst-cleanup0 tst-cleanup1 tst-cleanup2 tst-cleanup3 \
74	 tst-clock1 \
75	 tst-cond-except \
76	 tst-cond1 tst-cond2 tst-cond3 tst-cond4 tst-cond5 tst-cond6 tst-cond7 \
77	 tst-cond8 tst-cond9 tst-cond10 tst-cond11 tst-cond12 tst-cond13 \
78	 tst-cond14 tst-cond15 tst-cond16 tst-cond17 tst-cond18 tst-cond19 \
79	 tst-cond20 tst-cond21 tst-cond23 tst-cond24 tst-cond25 tst-cond27 \
80	 tst-create-detached \
81	 tst-detach1 \
82	 tst-eintr2 tst-eintr3 tst-eintr4 tst-eintr5 \
83	 tst-exec1 tst-exec2 tst-exec3 \
84	 tst-exit1 tst-exit2 tst-exit3 \
85	 tst-flock1 tst-flock2 \
86	 tst-fork1 tst-fork2 tst-fork3 tst-fork4 \
87	 tst-atfork1 \
88	 tst-getpid3 \
89	 tst-join1 tst-join2 tst-join3 tst-join4 tst-join5 tst-join6 tst-join7 \
90	 tst-join8 tst-join9 tst-join10 tst-join11 tst-join12 tst-join13 \
91	 tst-join14 tst-join15 \
92	 tst-key1 tst-key2 tst-key3 tst-key4 \
93	 tst-kill1 tst-kill2 tst-kill3 tst-kill5 tst-kill6 \
94	 tst-locale1 tst-locale2 \
95	 tst-memstream \
96	 tst-mutex-errorcheck tst-mutex1 tst-mutex2 tst-mutex3 tst-mutex4 \
97	 tst-mutex5 tst-mutex6 tst-mutex7 tst-mutex7robust tst-mutex9 \
98	 tst-mutex10 tst-mutex11 tst-pthread-mutexattr \
99	 tst-once1 tst-once2 tst-once3 tst-once4 \
100	 tst-pt-popen1 \
101	 tst-raise1 \
102	 tst-robust1 tst-robust2 tst-robust3 tst-robust4 tst-robust5 \
103	 tst-robust6 tst-robust7 tst-robust9 tst-robust10 \
104	 tst-rwlock1 tst-rwlock4 tst-rwlock5 tst-rwlock12 \
105	 tst-rwlock13 tst-rwlock14 tst-rwlock16 \
106	 tst-rwlock-tryrdlock-stall tst-rwlock-trywrlock-stall \
107	 tst-sem1 tst-sem2 tst-sem3 tst-sem4 tst-sem5 tst-sem6 tst-sem7 \
108	 tst-sem8 tst-sem9 tst-sem10 tst-sem14 tst-sem15 tst-sem16 \
109	 tst-setuid3 \
110	 tst-signal1 tst-signal2 \
111	 tst-signal4 tst-signal5 tst-signal6 tst-signal8 \
112	 tst-spin1 tst-spin2 tst-spin3 tst-spin4 \
113	 tst-stack1 \
114	 tst-stdio1 tst-stdio2 \
115	 tst-pt-sysconf \
116	 tst-pt-tls1 tst-pt-tls2 \
117	 tst-tsd1 tst-tsd2 tst-tsd5 tst-tsd6 \
118	 tst-umask1 \
119	 tst-unload \
120	 tst-unwind-thread \
121	 tst-pt-vfork1 tst-pt-vfork2 tst-vfork1x tst-vfork2x \
122	 tst-pthread-exit-signal \
123	 tst-pthread-setuid-loop \
124	 tst-pthread_cancel-exited \
125	 tst-pthread_cancel-select-loop \
126	 tst-pthread-raise-blocked-self \
127	 tst-pthread_kill-exited \
128	 tst-pthread_kill-exiting \
129	 tst-cancel30 \
130	 # tests
131
132tests-time64 += \
133  tst-abstime-time64 \
134  tst-cnd-timedwait-time64 \
135  tst-cond11-time64 \
136  tst-join14-time64 \
137  tst-mtx-timedlock-time64 \
138  tst-rwlock14-time64 \
139  tst-sem5-time64 \
140  tst-thrd-sleep-time64 \
141
142static-only-routines = pthread_atfork
143
144# Files which must not be linked with libpthread.
145tests-nolibpthread += tst-unload
146
147# GCC-4.9 compiles 'sprintf(NULL, ...)' into UD2 on x86_64 without -fno-builtin
148CFLAGS-tst-cleanup2.c += -fno-builtin
149CFLAGS-tst-cleanupx2.c += -fno-builtin
150
151tests += tst-cancelx2 tst-cancelx3 tst-cancelx6 tst-cancelx8 tst-cancelx9 \
152	 tst-cancelx4 tst-cancelx5 \
153	 tst-cancelx10 tst-cancelx11 tst-cancelx12 tst-cancelx13 tst-cancelx14 \
154	 tst-cancelx15 tst-cancelx16 tst-cancelx18 tst-cancelx20 tst-cancelx21 \
155	 tst-cleanupx0 tst-cleanupx1 tst-cleanupx2 tst-cleanupx3
156
157ifeq ($(build-shared),yes)
158tests += \
159  tst-atfork2 \
160  tst-pt-tls4 \
161  tst-_res1 \
162  tst-fini1 \
163  tst-create1 \
164  tst-atfork3 \
165  tst-atfork4 \
166# tests
167
168tests-nolibpthread += tst-fini1
169endif
170
171modules-names += \
172  tst-atfork2mod \
173  tst-tls4moda \
174  tst-tls4modb \
175  tst-_res1mod1 \
176  tst-_res1mod2 \
177  tst-fini1mod \
178  tst-create1mod \
179  tst-atfork3mod \
180  tst-atfork4mod \
181# module-names
182
183test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(modules-names)))
184
185tst-atfork2mod.so-no-z-defs = yes
186tst-atfork3mod.so-no-z-defs = yes
187tst-atfork4mod.so-no-z-defs = yes
188tst-create1mod.so-no-z-defs = yes
189
190ifeq ($(build-shared),yes)
191# Build all the modules even when not actually running test programs.
192tests: $(test-modules)
193endif
194
195
196tests-static += tst-locale1 tst-locale2 tst-cancel21-static
197
198tests += tst-cancel21-static tst-cond11-static
199
200# These tests are linked with libc before libpthread
201tests-reverse += tst-cancel5 tst-cancel23 tst-vfork1x tst-vfork2x
202
203ifeq ($(run-built-tests),yes)
204ifeq ($(build-shared),yes)
205tests-special += $(objpfx)tst-cleanup0-cmp.out
206endif
207endif
208
209# The sigmask macro is deprecated and triggers are compiler warning
210# which cannot be suppressed (as of GCC 9).
211CFLAGS-tst-cancel4.c += -Wno-error
212CFLAGS-tst-cancel5.c += -Wno-error
213CFLAGS-tst-cancelx4.c += -Wno-error
214CFLAGS-tst-cancelx5.c += -Wno-error
215
216# Run the cancellation and cleanup tests also for the modern, exception-based
217# implementation.  For this we have to pass the -fexceptions parameter.
218CFLAGS-tst-cancelx2.c += -fexceptions
219CFLAGS-tst-cancelx3.c += -fexceptions
220CFLAGS-tst-cancelx4.c += -fexceptions
221CFLAGS-tst-cancelx5.c += -fexceptions
222CFLAGS-tst-cancelx6.c += -fexceptions
223CFLAGS-tst-cancelx8.c += -fexceptions
224CFLAGS-tst-cancelx9.c += -fexceptions
225CFLAGS-tst-cancelx10.c += -fexceptions
226CFLAGS-tst-cancelx11.c += -fexceptions
227CFLAGS-tst-cancelx12.c += -fexceptions
228CFLAGS-tst-cancelx13.c += -fexceptions
229CFLAGS-tst-cancelx14.c += -fexceptions
230CFLAGS-tst-cancelx15.c += -fexceptions
231CFLAGS-tst-cancelx16.c += -fexceptions
232CFLAGS-tst-cancelx18.c += -fexceptions
233CFLAGS-tst-cancelx20.c += -fexceptions -fasynchronous-unwind-tables
234CFLAGS-tst-cancelx21.c += -fexceptions -fasynchronous-unwind-tables
235CFLAGS-tst-cleanupx0.c += -fexceptions -fasynchronous-unwind-tables
236CFLAGS-tst-cleanupx1.c += -fexceptions -fasynchronous-unwind-tables
237CFLAGS-tst-cleanupx2.c += -fexceptions
238CFLAGS-tst-cleanupx3.c += -fexceptions
239CFLAGS-tst-pt-align.c += $(stack-align-test-flags)
240CFLAGS-tst-pt-align3.c += $(stack-align-test-flags)
241
242tst-umask1-ARGS = $(objpfx)tst-umask1.temp
243
244$(objpfx)tst-atfork2: $(shared-thread-library)
245LDFLAGS-tst-atfork2 = -rdynamic
246tst-atfork2-ENV = MALLOC_TRACE=$(objpfx)tst-atfork2.mtrace \
247		  LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
248$(objpfx)tst-atfork2mod.so: $(shared-thread-library)
249
250$(objpfx)tst-atfork3: $(shared-thread-library)
251LDFLAGS-tst-atfork3 = -rdynamic
252$(objpfx)tst-atfork3mod.so: $(shared-thread-library)
253
254$(objpfx)tst-atfork4: $(shared-thread-library)
255LDFLAGS-tst-atfork4 = -rdynamic
256$(objpfx)tst-atfork4mod.so: $(shared-thread-library)
257
258ifeq ($(build-shared),yes)
259$(objpfx)tst-atfork2.out: $(objpfx)tst-atfork2mod.so
260$(objpfx)tst-atfork3.out: $(objpfx)tst-atfork3mod.so
261$(objpfx)tst-atfork4.out: $(objpfx)tst-atfork4mod.so
262endif
263
264ifeq ($(build-shared),yes)
265$(objpfx)tst-cleanup0.out: /dev/null $(objpfx)tst-cleanup0
266	$(make-test-out) > $@ 2>&1; \
267	$(evaluate-test)
268
269$(objpfx)tst-cleanup0-cmp.out: $(..)sysdeps/pthread/tst-cleanup0.expect $(objpfx)tst-cleanup0.out
270	cmp $^ > $@; \
271	$(evaluate-test)
272endif
273
274$(objpfx)tst-cancel28: $(librt)
275
276$(objpfx)tst-fini1: $(shared-thread-library) $(objpfx)tst-fini1mod.so
277
278$(objpfx)tst-fini1mod.so: $(shared-thread-library)
279
280$(objpfx)tst-_res1mod2.so: $(objpfx)tst-_res1mod1.so
281LDFLAGS-tst-_res1mod1.so = -Wl,-soname,tst-_res1mod1.so
282LDFLAGS-tst-_res1mod2.so = -Wl,-soname,tst-_res1mod2.so
283$(objpfx)tst-_res1: $(objpfx)tst-_res1mod1.so $(objpfx)tst-_res1mod2.so \
284		    $(shared-thread-library)
285
286$(objpfx)tst-pt-tls4: $(shared-thread-library)
287$(objpfx)tst-pt-tls4.out: $(objpfx)tst-tls4moda.so $(objpfx)tst-tls4modb.so
288
289generated += tst-atfork2.mtrace
290
291generated += $(objpfx)tst-atfork2.mtrace \
292	     $(addsuffix .so,$(strip $(modules-names)))
293
294tests-internal += tst-cancel25 tst-robust8
295
296tests += tst-oncex3 tst-oncex4 tst-oncey3 tst-oncey4
297
298modules-names += tst-join7mod
299
300ifeq ($(build-shared),yes)
301tests-static += tst-cond8-static
302tests += tst-cond8-static
303endif
304
305CFLAGS-tst-oncex3.c += -fexceptions
306CFLAGS-tst-oncex4.c += -fexceptions
307CFLAGS-tst-oncey3.c += -fno-exceptions -fno-asynchronous-unwind-tables
308CFLAGS-tst-oncey4.c += -fno-exceptions -fno-asynchronous-unwind-tables
309
310$(objpfx)tst-join7: $(shared-thread-library)
311$(objpfx)tst-join7.out: $(objpfx)tst-join7mod.so
312$(objpfx)tst-join7mod.so: $(shared-thread-library)
313LDFLAGS-tst-join7mod.so = -Wl,-soname,tst-join7mod.so
314
315CFLAGS-tst-unwind-thread.c += -funwind-tables
316
317LDFLAGS-tst-create1 = -Wl,-export-dynamic
318$(objpfx)tst-create1: $(shared-thread-library)
319$(objpfx)tst-create1.out: $(objpfx)tst-create1mod.so
320
321endif
322