1# sysdeps makefile fragment for all pthread-supporting configurations. 2# Copyright (C) 2014-2021 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-cleanup0 tst-cleanup1 tst-cleanup2 tst-cleanup3 \ 73 tst-clock1 \ 74 tst-cond-except \ 75 tst-cond1 tst-cond2 tst-cond3 tst-cond4 tst-cond5 tst-cond6 tst-cond7 \ 76 tst-cond8 tst-cond9 tst-cond10 tst-cond11 tst-cond12 tst-cond13 \ 77 tst-cond14 tst-cond15 tst-cond16 tst-cond17 tst-cond18 tst-cond19 \ 78 tst-cond20 tst-cond21 tst-cond23 tst-cond24 tst-cond25 tst-cond27 \ 79 tst-create-detached \ 80 tst-detach1 \ 81 tst-eintr2 tst-eintr3 tst-eintr4 tst-eintr5 \ 82 tst-exec1 tst-exec2 tst-exec3 \ 83 tst-exit1 tst-exit2 tst-exit3 \ 84 tst-flock1 tst-flock2 \ 85 tst-fork1 tst-fork2 tst-fork3 tst-fork4 \ 86 tst-atfork1 \ 87 tst-getpid3 \ 88 tst-join1 tst-join2 tst-join3 tst-join4 tst-join5 tst-join6 tst-join7 \ 89 tst-join8 tst-join9 tst-join10 tst-join11 tst-join12 tst-join13 \ 90 tst-join14 tst-join15 \ 91 tst-key1 tst-key2 tst-key3 tst-key4 \ 92 tst-kill1 tst-kill2 tst-kill3 tst-kill5 tst-kill6 \ 93 tst-locale1 tst-locale2 \ 94 tst-memstream \ 95 tst-mutex-errorcheck tst-mutex1 tst-mutex2 tst-mutex3 tst-mutex4 \ 96 tst-mutex5 tst-mutex6 tst-mutex7 tst-mutex7robust tst-mutex9 \ 97 tst-mutex10 tst-mutex11 tst-pthread-mutexattr \ 98 tst-once1 tst-once2 tst-once3 tst-once4 \ 99 tst-pt-popen1 \ 100 tst-raise1 \ 101 tst-robust1 tst-robust2 tst-robust3 tst-robust4 tst-robust5 \ 102 tst-robust6 tst-robust7 tst-robust9 tst-robust10 \ 103 tst-rwlock1 tst-rwlock4 tst-rwlock5 tst-rwlock12 \ 104 tst-rwlock13 tst-rwlock14 tst-rwlock16 \ 105 tst-rwlock-tryrdlock-stall tst-rwlock-trywrlock-stall \ 106 tst-sem1 tst-sem2 tst-sem3 tst-sem4 tst-sem5 tst-sem6 tst-sem7 \ 107 tst-sem8 tst-sem9 tst-sem10 tst-sem14 tst-sem15 tst-sem16 \ 108 tst-setuid3 \ 109 tst-signal1 tst-signal2 \ 110 tst-signal4 tst-signal5 tst-signal6 tst-signal8 \ 111 tst-spin1 tst-spin2 tst-spin3 tst-spin4 \ 112 tst-stack1 \ 113 tst-stdio1 tst-stdio2 \ 114 tst-pt-sysconf \ 115 tst-pt-tls1 tst-pt-tls2 \ 116 tst-tsd1 tst-tsd2 tst-tsd5 tst-tsd6 \ 117 tst-umask1 \ 118 tst-unload \ 119 tst-unwind-thread \ 120 tst-pt-vfork1 tst-pt-vfork2 tst-vfork1x tst-vfork2x \ 121 tst-pthread-exit-signal \ 122 tst-pthread-setuid-loop \ 123 tst-pthread_cancel-exited \ 124 tst-pthread_cancel-select-loop \ 125 tst-pthread-raise-blocked-self \ 126 tst-pthread_kill-exited \ 127 tst-pthread_kill-exiting \ 128 # tests 129 130tests-time64 := \ 131 tst-abstime-time64 \ 132 tst-cnd-timedwait-time64 \ 133 tst-cond11-time64 \ 134 tst-join14-time64 \ 135 tst-mtx-timedlock-time64 \ 136 tst-rwlock14-time64 \ 137 tst-sem5-time64 \ 138 tst-thrd-sleep-time64 \ 139 140static-only-routines = pthread_atfork 141 142# Files which must not be linked with libpthread. 143tests-nolibpthread += tst-unload 144 145# GCC-4.9 compiles 'sprintf(NULL, ...)' into UD2 on x86_64 without -fno-builtin 146CFLAGS-tst-cleanup2.c += -fno-builtin 147CFLAGS-tst-cleanupx2.c += -fno-builtin 148 149tests += tst-cancelx2 tst-cancelx3 tst-cancelx6 tst-cancelx8 tst-cancelx9 \ 150 tst-cancelx4 tst-cancelx5 \ 151 tst-cancelx10 tst-cancelx11 tst-cancelx12 tst-cancelx13 tst-cancelx14 \ 152 tst-cancelx15 tst-cancelx16 tst-cancelx18 tst-cancelx20 tst-cancelx21 \ 153 tst-cleanupx0 tst-cleanupx1 tst-cleanupx2 tst-cleanupx3 154 155ifeq ($(build-shared),yes) 156tests += tst-atfork2 tst-pt-tls4 tst-_res1 tst-fini1 tst-create1 157tests-nolibpthread += tst-fini1 158endif 159 160modules-names += tst-atfork2mod tst-tls4moda tst-tls4modb \ 161 tst-_res1mod1 tst-_res1mod2 tst-fini1mod \ 162 tst-create1mod 163test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(modules-names))) 164 165tst-atfork2mod.so-no-z-defs = yes 166tst-create1mod.so-no-z-defs = yes 167 168ifeq ($(build-shared),yes) 169# Build all the modules even when not actually running test programs. 170tests: $(test-modules) 171endif 172 173 174tests-static += tst-locale1 tst-locale2 tst-cancel21-static 175 176tests += tst-cancel21-static tst-cond11-static 177 178# These tests are linked with libc before libpthread 179tests-reverse += tst-cancel5 tst-cancel23 tst-vfork1x tst-vfork2x 180 181ifeq ($(run-built-tests),yes) 182ifeq ($(build-shared),yes) 183tests-special += $(objpfx)tst-cleanup0-cmp.out 184endif 185endif 186 187# The sigmask macro is deprecated and triggers are compiler warning 188# which cannot be suppressed (as of GCC 9). 189CFLAGS-tst-cancel4.c += -Wno-error 190CFLAGS-tst-cancel5.c += -Wno-error 191CFLAGS-tst-cancelx4.c += -Wno-error 192CFLAGS-tst-cancelx5.c += -Wno-error 193 194# Run the cancellation and cleanup tests also for the modern, exception-based 195# implementation. For this we have to pass the -fexceptions parameter. 196CFLAGS-tst-cancelx2.c += -fexceptions 197CFLAGS-tst-cancelx3.c += -fexceptions 198CFLAGS-tst-cancelx4.c += -fexceptions 199CFLAGS-tst-cancelx5.c += -fexceptions 200CFLAGS-tst-cancelx6.c += -fexceptions 201CFLAGS-tst-cancelx8.c += -fexceptions 202CFLAGS-tst-cancelx9.c += -fexceptions 203CFLAGS-tst-cancelx10.c += -fexceptions 204CFLAGS-tst-cancelx11.c += -fexceptions 205CFLAGS-tst-cancelx12.c += -fexceptions 206CFLAGS-tst-cancelx13.c += -fexceptions 207CFLAGS-tst-cancelx14.c += -fexceptions 208CFLAGS-tst-cancelx15.c += -fexceptions 209CFLAGS-tst-cancelx16.c += -fexceptions 210CFLAGS-tst-cancelx18.c += -fexceptions 211CFLAGS-tst-cancelx20.c += -fexceptions -fasynchronous-unwind-tables 212CFLAGS-tst-cancelx21.c += -fexceptions -fasynchronous-unwind-tables 213CFLAGS-tst-cleanupx0.c += -fexceptions -fasynchronous-unwind-tables 214CFLAGS-tst-cleanupx1.c += -fexceptions -fasynchronous-unwind-tables 215CFLAGS-tst-cleanupx2.c += -fexceptions 216CFLAGS-tst-cleanupx3.c += -fexceptions 217CFLAGS-tst-pt-align.c += $(stack-align-test-flags) 218CFLAGS-tst-pt-align3.c += $(stack-align-test-flags) 219 220tst-umask1-ARGS = $(objpfx)tst-umask1.temp 221 222$(objpfx)tst-atfork2: $(shared-thread-library) 223LDFLAGS-tst-atfork2 = -rdynamic 224tst-atfork2-ENV = MALLOC_TRACE=$(objpfx)tst-atfork2.mtrace \ 225 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so 226$(objpfx)tst-atfork2mod.so: $(shared-thread-library) 227 228ifeq ($(build-shared),yes) 229$(objpfx)tst-atfork2.out: $(objpfx)tst-atfork2mod.so 230endif 231 232ifeq ($(build-shared),yes) 233$(objpfx)tst-cleanup0.out: /dev/null $(objpfx)tst-cleanup0 234 $(make-test-out) > $@ 2>&1; \ 235 $(evaluate-test) 236 237$(objpfx)tst-cleanup0-cmp.out: $(..)sysdeps/pthread/tst-cleanup0.expect $(objpfx)tst-cleanup0.out 238 cmp $^ > $@; \ 239 $(evaluate-test) 240endif 241 242$(objpfx)tst-cancel28: $(librt) 243 244$(objpfx)tst-fini1: $(shared-thread-library) $(objpfx)tst-fini1mod.so 245 246$(objpfx)tst-fini1mod.so: $(shared-thread-library) 247 248$(objpfx)tst-_res1mod2.so: $(objpfx)tst-_res1mod1.so 249LDFLAGS-tst-_res1mod1.so = -Wl,-soname,tst-_res1mod1.so 250LDFLAGS-tst-_res1mod2.so = -Wl,-soname,tst-_res1mod2.so 251$(objpfx)tst-_res1: $(objpfx)tst-_res1mod1.so $(objpfx)tst-_res1mod2.so \ 252 $(shared-thread-library) 253 254$(objpfx)tst-pt-tls4: $(shared-thread-library) 255$(objpfx)tst-pt-tls4.out: $(objpfx)tst-tls4moda.so $(objpfx)tst-tls4modb.so 256 257generated += tst-atfork2.mtrace 258 259generated += $(objpfx)tst-atfork2.mtrace \ 260 $(addsuffix .so,$(strip $(modules-names))) 261 262tests-internal += tst-cancel25 tst-robust8 263 264tests += tst-oncex3 tst-oncex4 tst-oncey3 tst-oncey4 265 266modules-names += tst-join7mod 267 268ifeq ($(build-shared),yes) 269tests-static += tst-cond8-static 270tests += tst-cond8-static 271endif 272 273CFLAGS-tst-oncex3.c += -fexceptions 274CFLAGS-tst-oncex4.c += -fexceptions 275CFLAGS-tst-oncey3.c += -fno-exceptions -fno-asynchronous-unwind-tables 276CFLAGS-tst-oncey4.c += -fno-exceptions -fno-asynchronous-unwind-tables 277 278$(objpfx)tst-join7: $(shared-thread-library) 279$(objpfx)tst-join7.out: $(objpfx)tst-join7mod.so 280$(objpfx)tst-join7mod.so: $(shared-thread-library) 281LDFLAGS-tst-join7mod.so = -Wl,-soname,tst-join7mod.so 282 283CFLAGS-tst-unwind-thread.c += -funwind-tables 284 285LDFLAGS-tst-create1 = -Wl,-export-dynamic 286$(objpfx)tst-create1: $(shared-thread-library) 287$(objpfx)tst-create1.out: $(objpfx)tst-create1mod.so 288 289endif 290