]> git.ipfire.org Git - thirdparty/glibc.git/blob - nptl/Makefile
nptl: Move pthread_setcancelstate into libc
[thirdparty/glibc.git] / nptl / Makefile
1 # Copyright (C) 2002-2021 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
3
4 # The GNU C Library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8
9 # The GNU C Library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
13
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with the GNU C Library; if not, see
16 # <https://www.gnu.org/licenses/>.
17
18 #
19 # Sub-makefile for NPTL portion of the library.
20 #
21 subdir := nptl
22
23 include ../Makeconfig
24
25 headers := pthread.h semaphore.h bits/semaphore.h \
26 bits/struct_mutex.h bits/struct_rwlock.h
27
28 extra-libs := libpthread
29 extra-libs-others := $(extra-libs)
30
31 routines = \
32 alloca_cutoff \
33 cleanup_compat \
34 cleanup_defer_compat \
35 cleanup_routine \
36 elision-conf \
37 elision-lock \
38 elision-timed \
39 elision-trylock \
40 elision-unlock \
41 forward \
42 futex-internal \
43 libc-cancellation \
44 libc-cleanup \
45 libc_multiple_threads \
46 libc_pthread_init \
47 lowlevellock \
48 nptl_deallocate_tsd \
49 nptl_nthreads \
50 old_pthread_cond_destroy \
51 old_pthread_cond_init \
52 pthread_atfork \
53 pthread_attr_copy \
54 pthread_attr_destroy \
55 pthread_attr_extension \
56 pthread_attr_getdetachstate \
57 pthread_attr_getinheritsched \
58 pthread_attr_getschedparam \
59 pthread_attr_getschedpolicy \
60 pthread_attr_getscope \
61 pthread_attr_getsigmask \
62 pthread_attr_init \
63 pthread_attr_setaffinity \
64 pthread_attr_setdetachstate \
65 pthread_attr_setinheritsched \
66 pthread_attr_setschedparam \
67 pthread_attr_setschedpolicy \
68 pthread_attr_setscope \
69 pthread_attr_setsigmask \
70 pthread_attr_setsigmask_internal \
71 pthread_cleanup_upto \
72 pthread_cond_destroy \
73 pthread_cond_init \
74 pthread_condattr_destroy \
75 pthread_condattr_init \
76 pthread_equal \
77 pthread_exit \
78 pthread_getaffinity \
79 pthread_getattr_np \
80 pthread_getschedparam \
81 pthread_keys \
82 pthread_kill \
83 pthread_mutex_consistent \
84 pthread_once \
85 pthread_self \
86 pthread_setcancelstate \
87 pthread_setschedparam \
88 pthread_sigmask \
89 unwind \
90
91 shared-only-routines = forward
92 static-only-routines = pthread_atfork
93
94 libpthread-routines = \
95 cancellation \
96 cleanup \
97 cleanup_defer \
98 events \
99 flockfile \
100 ftrylockfile \
101 funlockfile \
102 herrno \
103 libpthread-compat \
104 nptl-init \
105 nptlfreeres \
106 old_pthread_atfork \
107 old_pthread_cond_broadcast \
108 old_pthread_cond_signal \
109 old_pthread_cond_timedwait \
110 old_pthread_cond_wait \
111 pt-interp \
112 pthread_attr_getaffinity \
113 pthread_attr_getguardsize \
114 pthread_attr_getstack \
115 pthread_attr_getstackaddr \
116 pthread_attr_getstacksize \
117 pthread_attr_setguardsize \
118 pthread_attr_setstack \
119 pthread_attr_setstackaddr \
120 pthread_attr_setstacksize \
121 pthread_barrier_destroy \
122 pthread_barrier_init \
123 pthread_barrier_wait \
124 pthread_barrierattr_destroy \
125 pthread_barrierattr_getpshared \
126 pthread_barrierattr_init \
127 pthread_barrierattr_setpshared \
128 pthread_cancel \
129 pthread_clockjoin \
130 pthread_cond_broadcast \
131 pthread_cond_signal \
132 pthread_cond_wait \
133 pthread_condattr_getclock \
134 pthread_condattr_getpshared \
135 pthread_condattr_setclock \
136 pthread_condattr_setpshared \
137 pthread_create \
138 pthread_detach \
139 pthread_getattr_default_np \
140 pthread_getconcurrency \
141 pthread_getcpuclockid \
142 pthread_getname \
143 pthread_getspecific \
144 pthread_join \
145 pthread_join_common \
146 pthread_key_create \
147 pthread_key_delete \
148 pthread_kill_other_threads \
149 pthread_mutex_cond_lock \
150 pthread_mutex_conf \
151 pthread_mutex_destroy \
152 pthread_mutex_getprioceiling \
153 pthread_mutex_init \
154 pthread_mutex_lock \
155 pthread_mutex_setprioceiling \
156 pthread_mutex_timedlock \
157 pthread_mutex_trylock \
158 pthread_mutex_unlock \
159 pthread_mutexattr_destroy \
160 pthread_mutexattr_getprioceiling \
161 pthread_mutexattr_getprotocol \
162 pthread_mutexattr_getpshared \
163 pthread_mutexattr_getrobust \
164 pthread_mutexattr_gettype \
165 pthread_mutexattr_init \
166 pthread_mutexattr_setprioceiling \
167 pthread_mutexattr_setprotocol \
168 pthread_mutexattr_setpshared \
169 pthread_mutexattr_setrobust \
170 pthread_mutexattr_settype \
171 pthread_rwlock_clockrdlock \
172 pthread_rwlock_clockwrlock \
173 pthread_rwlock_destroy \
174 pthread_rwlock_init \
175 pthread_rwlock_rdlock \
176 pthread_rwlock_timedrdlock \
177 pthread_rwlock_timedwrlock \
178 pthread_rwlock_tryrdlock \
179 pthread_rwlock_trywrlock \
180 pthread_rwlock_unlock \
181 pthread_rwlock_wrlock \
182 pthread_rwlockattr_destroy \
183 pthread_rwlockattr_getkind_np \
184 pthread_rwlockattr_getpshared \
185 pthread_rwlockattr_init \
186 pthread_rwlockattr_setkind_np \
187 pthread_rwlockattr_setpshared \
188 pthread_setaffinity \
189 pthread_setattr_default_np \
190 pthread_setcanceltype \
191 pthread_setconcurrency \
192 pthread_setname \
193 pthread_setschedprio \
194 pthread_setspecific \
195 pthread_sigqueue \
196 pthread_spin_destroy \
197 pthread_spin_init \
198 pthread_spin_lock \
199 pthread_spin_trylock \
200 pthread_spin_unlock \
201 pthread_testcancel \
202 pthread_timedjoin \
203 pthread_tryjoin \
204 pthread_yield \
205 res \
206 sem_clockwait \
207 sem_close \
208 sem_destroy \
209 sem_getvalue \
210 sem_init \
211 sem_open \
212 sem_post \
213 sem_routines \
214 sem_timedwait \
215 sem_unlink \
216 sem_wait \
217 tpp \
218 vars \
219 version \
220
221 libpthread-shared-only-routines = \
222 pt-allocrtsig \
223 pt-interp \
224 version \
225
226 # Since cancellation handling is in large parts handled using exceptions
227 # we have to compile some files with exception handling enabled, some
228 # even with asynchronous unwind tables.
229
230 # nptl-init.c contains sigcancel_handler().
231 CFLAGS-nptl-init.c += -fexceptions -fasynchronous-unwind-tables
232 # The unwind code itself,
233 CFLAGS-unwind.c += -fexceptions
234 CFLAGS-unwind-forcedunwind.c += -fexceptions -fasynchronous-unwind-tables
235
236 # The following three functions must be async-cancel safe.
237 CFLAGS-pthread_cancel.c += -fexceptions -fasynchronous-unwind-tables
238 CFLAGS-pthread_setcancelstate.c += -fexceptions -fasynchronous-unwind-tables
239 CFLAGS-pthread_setcanceltype.c += -fexceptions -fasynchronous-unwind-tables
240
241 # These are internal functions which similar functionality as setcancelstate
242 # and setcanceltype.
243 CFLAGS-cancellation.c += -fasynchronous-unwind-tables
244 CFLAGS-libc-cancellation.c += -fasynchronous-unwind-tables
245
246 # Calling pthread_exit() must cause the registered cancel handlers to
247 # be executed. Therefore exceptions have to be thrown through this
248 # function.
249 CFLAGS-pthread_exit.c += -fexceptions
250
251 # Among others, __pthread_unwind is forwarded. This function must handle
252 # exceptions.
253 CFLAGS-forward.c += -fexceptions
254
255 # The following are cancellation points. Some of the functions can
256 # block and therefore temporarily enable asynchronous cancellation.
257 # Those must be compiled asynchronous unwind tables.
258 CFLAGS-pthread_testcancel.c += -fexceptions
259 CFLAGS-pthread_join.c += -fexceptions -fasynchronous-unwind-tables
260 CFLAGS-pthread_timedjoin.c += -fexceptions -fasynchronous-unwind-tables
261 CFLAGS-pthread_clockjoin.c += -fexceptions -fasynchronous-unwind-tables
262 CFLAGS-pthread_once.c += $(uses-callbacks) -fexceptions \
263 -fasynchronous-unwind-tables
264 CFLAGS-pthread_cond_wait.c += -fexceptions -fasynchronous-unwind-tables
265 CFLAGS-sem_wait.c += -fexceptions -fasynchronous-unwind-tables
266 CFLAGS-sem_timedwait.c += -fexceptions -fasynchronous-unwind-tables
267 CFLAGS-sem_clockwait.c = -fexceptions -fasynchronous-unwind-tables
268
269 CFLAGS-futex-internal.c += -fexceptions -fasynchronous-unwind-tables
270
271 LDLIBS-tst-once5 = -lstdc++
272 CFLAGS-tst-thread_local1.o = -std=gnu++11
273 LDLIBS-tst-thread_local1 = -lstdc++
274 CFLAGS-tst-thread-exit-clobber.o = -std=gnu++11
275 LDLIBS-tst-thread-exit-clobber = -lstdc++
276 CFLAGS-tst-minstack-throw.o = -std=gnu++11
277 LDLIBS-tst-minstack-throw = -lstdc++
278
279 tests = tst-attr2 tst-attr3 tst-default-attr \
280 tst-mutex5a tst-mutex7a \
281 tst-mutexpi1 tst-mutexpi2 tst-mutexpi3 tst-mutexpi4 \
282 tst-mutexpi5 tst-mutexpi5a tst-mutexpi6 tst-mutexpi7 tst-mutexpi7a \
283 tst-mutexpi9 tst-mutexpi10 \
284 tst-cond22 tst-cond26 \
285 tst-robustpi1 tst-robustpi2 tst-robustpi3 tst-robustpi4 tst-robustpi5 \
286 tst-robustpi6 tst-robustpi7 tst-robustpi9 \
287 tst-rwlock2 tst-rwlock2a tst-rwlock2b tst-rwlock3 \
288 tst-rwlock6 tst-rwlock7 tst-rwlock8 \
289 tst-rwlock9 tst-rwlock10 tst-rwlock11 \
290 tst-rwlock15 tst-rwlock17 tst-rwlock18 \
291 tst-once5 \
292 tst-sem17 \
293 tst-tsd3 tst-tsd4 \
294 tst-cancel4_1 tst-cancel4_2 \
295 tst-cancel7 tst-cancel17 tst-cancel24 \
296 tst-signal3 \
297 tst-exec4 tst-exec5 \
298 tst-stack2 tst-stack3 tst-stack4 \
299 tst-pthread-attr-affinity \
300 tst-dlsym1 \
301 tst-context1 \
302 tst-sched1 \
303 tst-initializers1 $(addprefix tst-initializers1-,\
304 c89 gnu89 c99 gnu99 c11 gnu11) \
305 tst-thread_local1 \
306 tst-robust-fork \
307 tst-thread-exit-clobber tst-minstack-cancel tst-minstack-exit \
308 tst-minstack-throw \
309 tst-rwlock-pwn \
310 tst-thread-affinity-pthread \
311 tst-thread-affinity-pthread2 \
312 tst-thread-affinity-sched \
313 tst-pthread-defaultattr-free \
314 tst-pthread-attr-sigmask \
315 tst-pthread-timedlock-lockloop \
316 tst-pthread-gdb-attach tst-pthread-gdb-attach-static \
317 tst-pthread_exit-nothreads \
318 tst-pthread_exit-nothreads-static \
319
320 tests-nolibpthread = \
321 tst-pthread_exit-nothreads \
322 tst-pthread_exit-nothreads-static \
323
324 tests-container = tst-pthread-getattr
325
326 tests-internal := tst-robustpi8 tst-rwlock19 tst-rwlock20 \
327 tst-sem11 tst-sem12 tst-sem13 \
328 tst-barrier5 tst-signal7 tst-mutex8 tst-mutex8-static \
329 tst-mutexpi8 tst-mutexpi8-static \
330 tst-setgetname \
331
332 xtests = tst-setuid1 tst-setuid1-static tst-setuid2 \
333 tst-mutexpp1 tst-mutexpp6 tst-mutexpp10 tst-setgroups \
334 tst-mutexpp5 tst-mutexpp9
335
336 # This test can run into task limits because of a linux kernel bug
337 # and then cause the make process to fail too, see bug 24537.
338 xtests += tst-eintr1
339
340 test-srcs = tst-oddstacklimit
341
342 gen-as-const-headers = unwindbuf.sym \
343 pthread-pi-defines.sym
344
345 gen-py-const-headers := nptl_lock_constants.pysym
346 pretty-printers := nptl-printers.py
347 tests-printers := test-mutexattr-printers test-mutex-printers \
348 test-condattr-printers test-cond-printers \
349 test-rwlockattr-printers test-rwlock-printers
350
351 # We must specify both CFLAGS and CPPFLAGS to override any
352 # compiler options the user might have provided that conflict
353 # with what we need e.g. user specifies CPPFLAGS with -O2 and
354 # we need -O0.
355 CFLAGS-test-mutexattr-printers.c := $(CFLAGS-printers-tests)
356 CFLAGS-test-mutex-printers.c := $(CFLAGS-printers-tests)
357 CFLAGS-test-condattr-printers.c := $(CFLAGS-printers-tests)
358 CFLAGS-test-cond-printers.c := $(CFLAGS-printers-tests)
359 CFLAGS-test-rwlockattr-printers.c := $(CFLAGS-printers-tests)
360 CFLAGS-test-rwlock-printers.c := $(CFLAGS-printers-tests)
361 CPPFLAGS-test-mutexattr-printers.c := $(CFLAGS-printers-tests)
362 CPPFLAGS-test-mutex-printers.c := $(CFLAGS-printers-tests)
363 CPPFLAGS-test-condattr-printers.c := $(CFLAGS-printers-tests)
364 CPPFLAGS-test-cond-printers.c := $(CFLAGS-printers-tests)
365 CPPFLAGS-test-rwlockattr-printers.c := $(CFLAGS-printers-tests)
366 CPPFLAGS-test-rwlock-printers.c := $(CFLAGS-printers-tests)
367
368 # Reuse the CFLAGS setting for the GDB attaching test. It needs
369 # debugging information.
370 CFLAGS-tst-pthread-gdb-attach.c := $(CFLAGS-printers-tests)
371 CPPFLAGS-tst-pthread-gdb-attach.c := $(CFLAGS-printers-tests)
372 ifeq ($(build-shared)$(build-hardcoded-path-in-tests),yesno)
373 CPPFLAGS-tst-pthread-gdb-attach.c += -DDO_ADD_SYMBOL_FILE=1
374 else
375 CPPFLAGS-tst-pthread-gdb-attach.c += -DDO_ADD_SYMBOL_FILE=0
376 endif
377 CFLAGS-tst-pthread-gdb-attach-static.c := $(CFLAGS-printers-tests)
378 CPPFLAGS-tst-pthread-gdb-attach-static.c := \
379 $(CFLAGS-printers-tests) -DDO_ADD_SYMBOL_FILE=0
380
381 ifeq ($(build-shared),yes)
382 tests-printers-libs := $(shared-thread-library)
383 else
384 tests-printers-libs := $(static-thread-library)
385 endif
386
387 LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst
388
389 tests += tst-cancelx7 tst-cancelx17
390
391 ifeq ($(build-shared),yes)
392 tests += tst-compat-forwarder tst-audit-threads
393 tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1
394 ifeq ($(have-z-execstack),yes)
395 tests += tst-execstack
396 endif
397 endif
398
399 modules-names = tst-tls3mod \
400 tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \
401 tst-tls5modd tst-tls5mode tst-tls5modf tst-stack4mod \
402 tst-execstack-mod \
403 tst-compat-forwarder-mod tst-audit-threads-mod1 \
404 tst-audit-threads-mod2
405 extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \
406 tst-cleanup4aux.o tst-cleanupx4aux.o
407 test-extras += tst-cleanup4aux tst-cleanupx4aux
408
409 # This test exercises compat symbols removed in glibc 2.34.
410 ifdef have-GLIBC_2.33
411 tests += tst-cleanup4
412 ifeq ($(build-shared),yes)
413 tests += tst-cleanupx4
414 endif
415 endif
416
417 tst-tls3mod.so-no-z-defs = yes
418 tst-tls5mod.so-no-z-defs = yes
419 tst-tls5moda.so-no-z-defs = yes
420 tst-tls5modb.so-no-z-defs = yes
421 tst-tls5modc.so-no-z-defs = yes
422 tst-tls5modd.so-no-z-defs = yes
423 tst-tls5mode.so-no-z-defs = yes
424 tst-tls5modf.so-no-z-defs = yes
425
426 ifeq ($(build-shared),yes)
427
428 # Set the `multidir' variable by grabbing the variable from the compiler.
429 # We do it once and save the result in a generated makefile.
430 -include $(objpfx)multidir.mk
431 $(objpfx)multidir.mk: $(common-objpfx)config.make
432 $(make-target-directory)
433 dir=`$(CC) $(CFLAGS) $(CPPFLAGS) -print-multi-directory`; \
434 echo "multidir := $$dir" > $@T
435 mv -f $@T $@
436
437 crti-objs := crti.o
438 crtn-objs := crtn.o
439 ifneq (,$(patsubst .,,$(multidir)))
440 generated-dirs += $(firstword $(subst /, , $(multidir)))
441 crti-objs += $(multidir)/crti.o
442 crtn-objs += $(multidir)/crtn.o
443 $(objpfx)$(multidir):
444 mkdir -p $@
445 endif
446 extra-objs += $(crti-objs) $(crtn-objs)
447 extra-objs += pt-crti.o
448 endif
449
450 CFLAGS-flockfile.c += $(libio-mtsafe)
451 CFLAGS-ftrylockfile.c += $(libio-mtsafe)
452 CFLAGS-funlockfile.c += $(libio-mtsafe)
453
454 link-libc-static := $(common-objpfx)libc.a $(static-gnulib) \
455 $(common-objpfx)libc.a
456
457 tests-static += tst-stackguard1-static \
458 tst-cancel24-static \
459 tst-mutex8-static tst-mutexpi8-static tst-sem11-static \
460 tst-sem12-static tst-cond11-static \
461 tst-pthread-gdb-attach-static \
462 tst-pthread_exit-nothreads-static
463
464 tests += tst-cancel24-static
465
466 tests-internal += tst-sem11-static tst-sem12-static tst-stackguard1-static
467 xtests-static += tst-setuid1-static
468
469 ifeq ($(run-built-tests),yes)
470 tests-special += $(objpfx)tst-stack3-mem.out $(objpfx)tst-oddstacklimit.out
471 ifeq ($(build-shared),yes)
472 tests-special += $(objpfx)tst-tls6.out
473 endif
474 endif
475
476 ifeq (,$(CXX))
477 # These tests require a C++ compiler and runtime.
478 tests-unsupported += tst-cancel24 tst-cancel24-static tst-once5 \
479 tst-thread-exit-clobber tst-minstack-throw
480 endif
481 # These tests require a C++ compiler and runtime with thread_local support.
482 ifneq ($(have-cxx-thread_local),yes)
483 tests-unsupported += tst-thread_local1
484 endif
485
486 include ../Rules
487
488 ifeq (yes,$(build-shared))
489 # Make sure these things are built in the `make lib' pass so they can be used
490 # to run programs during the `make others' pass.
491 lib-noranlib: $(addprefix $(objpfx),$(extra-objs))
492 endif
493
494
495 # 'pthread_self' is a simple memory or register load. Setting up the
496 # stack frame is more work than the actual operation. Disable the
497 # frame creation entirely. This will help applications which call the
498 # function frequently to get a thread-specific handle.
499 CFLAGS-pthread_self.os += -fomit-frame-pointer
500
501 # Run the cancellation and cleanup tests also for the modern, exception-based
502 # implementation. For this we have to pass the -fexceptions parameter.
503 CFLAGS-tst-cancelx7.c += -fexceptions
504 CFLAGS-tst-cancelx17.c += -fexceptions
505 CFLAGS-tst-cleanupx4.c += -fexceptions
506 CFLAGS-tst-cleanupx4aux.c += -fexceptions
507 CFLAGS-tst-initializers1.c += -W -Wall -Werror
508 CFLAGS-tst-initializers1-< = $(CFLAGS-tst-initializers1.c) \
509 $(patsubst tst-initializers1-%.c,-std=%,$<)
510 CFLAGS-tst-initializers1-c89.c += $(CFLAGS-tst-initializers1-<)
511 CFLAGS-tst-initializers1-c99.c += $(CFLAGS-tst-initializers1-<)
512 CFLAGS-tst-initializers1-c11.c += $(CFLAGS-tst-initializers1-<)
513 CFLAGS-tst-initializers1-gnu89.c += $(CFLAGS-tst-initializers1-<)
514 CFLAGS-tst-initializers1-gnu99.c += $(CFLAGS-tst-initializers1-<)
515 CFLAGS-tst-initializers1-gnu11.c += $(CFLAGS-tst-initializers1-<)
516
517 tst-cancel7-ARGS = --command "exec $(host-test-program-cmd)"
518 tst-cancelx7-ARGS = $(tst-cancel7-ARGS)
519
520 tst-stack3-ENV = MALLOC_TRACE=$(objpfx)tst-stack3.mtrace
521 $(objpfx)tst-stack3-mem.out: $(objpfx)tst-stack3.out
522 $(common-objpfx)malloc/mtrace $(objpfx)tst-stack3.mtrace > $@; \
523 $(evaluate-test)
524 generated += tst-stack3-mem.out tst-stack3.mtrace
525
526 $(objpfx)tst-stack4: $(libdl) $(shared-thread-library)
527 tst-stack4mod.sos=$(shell for i in 0 1 2 3 4 5 6 7 8 9 10 \
528 11 12 13 14 15 16 17 18 19; do \
529 for j in 0 1 2 3 4 5 6 7 8 9 10 \
530 11 12 13 14 15 16 17 18 19; do \
531 echo $(objpfx)tst-stack4mod-$$i-$$j.so; \
532 done; done)
533 $(objpfx)tst-stack4.out: $(tst-stack4mod.sos)
534 $(tst-stack4mod.sos): $(objpfx)tst-stack4mod.so
535 cp -f $< $@
536 clean:
537 rm -f $(tst-stack4mod.sos)
538
539 $(objpfx)tst-cleanup4: $(objpfx)tst-cleanup4aux.o $(shared-thread-library)
540 $(objpfx)tst-cleanupx4: $(objpfx)tst-cleanupx4aux.o $(shared-thread-library)
541
542 $(objpfx)tst-tls3: $(libdl) $(shared-thread-library)
543 LDFLAGS-tst-tls3 = -rdynamic
544 $(objpfx)tst-tls3.out: $(objpfx)tst-tls3mod.so
545 $(objpfx)tst-tls3mod.so: $(shared-thread-library)
546
547 $(objpfx)tst-tls3-malloc: $(libdl) $(shared-thread-library)
548 LDFLAGS-tst-tls3-malloc = -rdynamic
549 $(objpfx)tst-tls3-malloc.out: $(objpfx)tst-tls3mod.so
550
551 $(objpfx)tst-tls5: $(objpfx)tst-tls5mod.so $(shared-thread-library)
552 LDFLAGS-tst-tls5 = -Wl,--no-as-needed
553 LDFLAGS-tst-tls5mod.so = -Wl,-soname,tst-tls5mod.so
554
555 ifeq ($(build-shared),yes)
556 $(objpfx)tst-tls6.out: tst-tls6.sh $(objpfx)tst-tls5 \
557 $(objpfx)tst-tls5moda.so $(objpfx)tst-tls5modb.so \
558 $(objpfx)tst-tls5modc.so $(objpfx)tst-tls5modd.so \
559 $(objpfx)tst-tls5mode.so $(objpfx)tst-tls5modf.so
560 $(BASH) $< $(common-objpfx) '$(test-via-rtld-prefix)' \
561 '$(test-wrapper-env)' '$(run-program-env)'; \
562 $(evaluate-test)
563 endif
564
565 $(objpfx)tst-dlsym1: $(libdl) $(shared-thread-library)
566
567 ifeq (yes,$(build-shared))
568 librt = $(common-objpfx)rt/librt.so
569 else
570 librt = $(common-objpfx)rt/librt.a
571 endif
572
573 # `make check' sometimes triggers a rebuild of librt.so using this Makefile,
574 # which ignores librt's dependence on libpthread
575 $(common-objpfx)rt/librt.so: $(shared-thread-library)
576
577 $(objpfx)tst-cancel17: $(librt)
578 $(objpfx)tst-cancelx17: $(librt)
579
580 LDLIBS-tst-cancel24 = -Wl,--no-as-needed -lstdc++
581 LDLIBS-tst-cancel24-static = $(LDLIBS-tst-cancel24)
582
583 extra-B-pthread.so = -B$(common-objpfx)nptl/
584 $(objpfx)libpthread.so: $(addprefix $(objpfx),$(crti-objs) $(crtn-objs))
585 $(objpfx)libpthread.so: +preinit += $(addprefix $(objpfx),$(crti-objs))
586 $(objpfx)libpthread.so: +postinit += $(addprefix $(objpfx),$(crtn-objs))
587
588 # Make sure we link with the thread library.
589 ifeq ($(build-shared),yes)
590 $(addprefix $(objpfx), \
591 $(filter-out $(tests-static) $(xtests-static) $(tests-reverse) \
592 $(tests-nolibpthread), \
593 $(tests) $(tests-internal) $(xtests) $(test-srcs) $(tests-container))): \
594 $(objpfx)libpthread.so
595 $(objpfx)tst-unload: $(libdl)
596 # $(objpfx)../libc.so is used instead of $(common-objpfx)libc.so,
597 # since otherwise libpthread.so comes before libc.so when linking.
598 $(addprefix $(objpfx), $(tests-reverse)): \
599 $(objpfx)../libc.so $(objpfx)libpthread.so
600 $(objpfx)../libc.so: $(common-objpfx)libc.so ;
601 $(addprefix $(objpfx),$(tests-static) $(xtests-static)): $(objpfx)libpthread.a
602 else
603 $(addprefix $(objpfx),$(tests) $(test-srcs)): $(objpfx)libpthread.a
604 endif
605
606 ifeq ($(build-shared),yes)
607 $(objpfx)crti.o: $(objpfx)pt-crti.o
608 ln -f $< $@
609
610 ifneq ($(multidir),.)
611 $(objpfx)$(multidir)/crti.o: $(objpfx)crti.o $(objpfx)$(multidir)/
612 ln -f $< $@
613
614 $(objpfx)$(multidir)/crtn.o: $(objpfx)crtn.o $(objpfx)$(multidir)/
615 ln -f $< $@
616 endif
617
618 generated += multidir.mk tst-tls6.out
619
620 # Give libpthread.so an entry point and make it directly runnable itself.
621 LDFLAGS-pthread.so += -e __nptl_main
622 # pt-interp.c exists just to get the runtime linker path into libpthread.so.
623 $(objpfx)pt-interp.os: $(common-objpfx)runtime-linker.h
624 endif
625
626 tst-exec4-ARGS = $(host-test-program-cmd)
627
628 $(objpfx)tst-execstack: $(libdl)
629 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
630 LDFLAGS-tst-execstack = -Wl,-z,noexecstack
631 CFLAGS-tst-execstack-mod.c += -Wno-trampolines
632
633 tst-stackguard1-ARGS = --command "$(host-test-program-cmd) --child"
634 tst-stackguard1-static-ARGS = --command "$(objpfx)tst-stackguard1-static --child"
635
636 ifeq ($(run-built-tests),yes)
637 $(objpfx)tst-oddstacklimit.out: $(objpfx)tst-oddstacklimit $(objpfx)tst-basic1
638 $(test-program-prefix) $< --command '$(host-test-program-cmd)' > $@; \
639 $(evaluate-test)
640 endif
641
642 $(objpfx)tst-compat-forwarder: $(objpfx)tst-compat-forwarder-mod.so
643
644 tst-mutex10-ENV = GLIBC_TUNABLES=glibc.elision.enable=1
645
646 # Protect against a build using -Wl,-z,now.
647 LDFLAGS-tst-audit-threads-mod1.so = -Wl,-z,lazy
648 LDFLAGS-tst-audit-threads-mod2.so = -Wl,-z,lazy
649 LDFLAGS-tst-audit-threads = -Wl,-z,lazy
650 $(objpfx)tst-audit-threads: $(objpfx)tst-audit-threads-mod2.so
651 $(objpfx)tst-audit-threads.out: $(objpfx)tst-audit-threads-mod1.so
652 tst-audit-threads-ENV = LD_AUDIT=$(objpfx)tst-audit-threads-mod1.so
653
654 # The test uses dlopen indirectly and would otherwise load system
655 # objects.
656 tst-setuid1-static-ENV = \
657 LD_LIBRARY_PATH=$(ld-library-path):$(common-objpfx)elf:$(common-objpfx)nss
658
659 # The tests here better do not run in parallel.
660 ifeq ($(run-built-tests),yes)
661 ifneq ($(filter %tests,$(MAKECMDGOALS)),)
662 .NOTPARALLEL:
663 endif
664 endif