d3704401fbccda0ff74ff101713662bdbc15cf3e
[platform/upstream/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   elision-conf \
34   elision-lock \
35   elision-timed \
36   elision-trylock \
37   elision-unlock \
38   forward \
39   futex-internal \
40   libc-cancellation \
41   libc-cleanup \
42   libc_multiple_threads \
43   libc_pthread_init \
44   lowlevellock \
45   old_pthread_cond_destroy \
46   old_pthread_cond_init \
47   pthread_atfork \
48   pthread_attr_copy \
49   pthread_attr_destroy \
50   pthread_attr_extension \
51   pthread_attr_getdetachstate \
52   pthread_attr_getinheritsched \
53   pthread_attr_getschedparam \
54   pthread_attr_getschedpolicy \
55   pthread_attr_getscope \
56   pthread_attr_getsigmask \
57   pthread_attr_init \
58   pthread_attr_setaffinity \
59   pthread_attr_setdetachstate \
60   pthread_attr_setinheritsched \
61   pthread_attr_setschedparam \
62   pthread_attr_setschedpolicy \
63   pthread_attr_setscope \
64   pthread_attr_setsigmask \
65   pthread_attr_setsigmask_internal \
66   pthread_cond_destroy \
67   pthread_cond_init \
68   pthread_condattr_destroy \
69   pthread_condattr_init \
70   pthread_equal \
71   pthread_getaffinity \
72   pthread_getattr_np \
73   pthread_getschedparam \
74   pthread_self \
75   pthread_setschedparam \
76   pthread_sigmask \
77
78 shared-only-routines = forward
79 static-only-routines = pthread_atfork
80
81 # We need to provide certain routines for compatibility with existing
82 # binaries.
83 pthread-compat-wrappers = \
84                       send \
85                       lseek lseek64 \
86                       open open64 \
87                       pread pread64 pwrite pwrite64 \
88                       msgrcv msgsnd \
89                       sigsuspend \
90
91 libpthread-routines = \
92   $(pthread-compat-wrappers) \
93   cancellation \
94   cleanup \
95   cleanup_compat \
96   cleanup_defer \
97   cleanup_defer_compat \
98   cleanup_routine \
99   events \
100   flockfile \
101   ftrylockfile \
102   funlockfile \
103   herrno \
104   libpthread-compat \
105   nptl-init \
106   nptlfreeres \
107   old_pthread_atfork \
108   old_pthread_cond_broadcast \
109   old_pthread_cond_signal \
110   old_pthread_cond_timedwait \
111   old_pthread_cond_wait \
112   pt-allocrtsig \
113   pt-cleanup \
114   pt-interp \
115   pt-longjmp \
116   pt-raise \
117   pthread_attr_getaffinity \
118   pthread_attr_getguardsize \
119   pthread_attr_getstack \
120   pthread_attr_getstackaddr \
121   pthread_attr_getstacksize \
122   pthread_attr_setguardsize \
123   pthread_attr_setstack \
124   pthread_attr_setstackaddr \
125   pthread_attr_setstacksize \
126   pthread_barrier_destroy \
127   pthread_barrier_init \
128   pthread_barrier_wait \
129   pthread_barrierattr_destroy \
130   pthread_barrierattr_getpshared \
131   pthread_barrierattr_init \
132   pthread_barrierattr_setpshared \
133   pthread_cancel \
134   pthread_clockjoin \
135   pthread_cond_broadcast \
136   pthread_cond_signal \
137   pthread_cond_wait \
138   pthread_condattr_getclock \
139   pthread_condattr_getpshared \
140   pthread_condattr_setclock \
141   pthread_condattr_setpshared \
142   pthread_create \
143   pthread_detach \
144   pthread_exit \
145   pthread_getattr_default_np \
146   pthread_getconcurrency \
147   pthread_getcpuclockid \
148   pthread_getname \
149   pthread_getspecific \
150   pthread_join \
151   pthread_join_common \
152   pthread_key_create \
153   pthread_key_delete \
154   pthread_kill \
155   pthread_kill_other_threads \
156   pthread_mutex_cond_lock \
157   pthread_mutex_conf \
158   pthread_mutex_consistent \
159   pthread_mutex_destroy \
160   pthread_mutex_getprioceiling \
161   pthread_mutex_init \
162   pthread_mutex_lock \
163   pthread_mutex_setprioceiling \
164   pthread_mutex_timedlock \
165   pthread_mutex_trylock \
166   pthread_mutex_unlock \
167   pthread_mutexattr_destroy \
168   pthread_mutexattr_getprioceiling \
169   pthread_mutexattr_getprotocol \
170   pthread_mutexattr_getpshared \
171   pthread_mutexattr_getrobust \
172   pthread_mutexattr_gettype \
173   pthread_mutexattr_init \
174   pthread_mutexattr_setprioceiling \
175   pthread_mutexattr_setprotocol \
176   pthread_mutexattr_setpshared \
177   pthread_mutexattr_setrobust \
178   pthread_mutexattr_settype \
179   pthread_once \
180   pthread_rwlock_clockrdlock \
181   pthread_rwlock_clockwrlock \
182   pthread_rwlock_destroy \
183   pthread_rwlock_init \
184   pthread_rwlock_rdlock \
185   pthread_rwlock_timedrdlock \
186   pthread_rwlock_timedwrlock \
187   pthread_rwlock_tryrdlock \
188   pthread_rwlock_trywrlock \
189   pthread_rwlock_unlock \
190   pthread_rwlock_wrlock \
191   pthread_rwlockattr_destroy \
192   pthread_rwlockattr_getkind_np \
193   pthread_rwlockattr_getpshared \
194   pthread_rwlockattr_init \
195   pthread_rwlockattr_setkind_np \
196   pthread_rwlockattr_setpshared \
197   pthread_setaffinity \
198   pthread_setattr_default_np \
199   pthread_setcancelstate \
200   pthread_setcanceltype \
201   pthread_setconcurrency \
202   pthread_setname \
203   pthread_setschedprio \
204   pthread_setspecific \
205   pthread_sigqueue \
206   pthread_spin_destroy \
207   pthread_spin_init \
208   pthread_spin_lock \
209   pthread_spin_trylock \
210   pthread_spin_unlock \
211   pthread_testcancel \
212   pthread_timedjoin \
213   pthread_tryjoin \
214   pthread_yield \
215   res \
216   sem_clockwait \
217   sem_close \
218   sem_destroy \
219   sem_getvalue \
220   sem_init \
221   sem_open \
222   sem_post \
223   sem_routines \
224   sem_timedwait \
225   sem_unlink \
226   sem_wait \
227   sigaction \
228   tpp \
229   unwind \
230   unwind-forcedunwind \
231   vars \
232   version \
233
234 libpthread-shared-only-routines = \
235   pt-allocrtsig \
236   pt-interp \
237   unwind-forcedunwind \
238   version \
239
240 # Since cancellation handling is in large parts handled using exceptions
241 # we have to compile some files with exception handling enabled, some
242 # even with asynchronous unwind tables.
243
244 # nptl-init.c contains sigcancel_handler().
245 CFLAGS-nptl-init.c += -fexceptions -fasynchronous-unwind-tables
246 # The unwind code itself,
247 CFLAGS-unwind.c += -fexceptions
248 CFLAGS-unwind-forcedunwind.c += -fexceptions -fasynchronous-unwind-tables
249
250 # The following three functions must be async-cancel safe.
251 CFLAGS-pthread_cancel.c += -fexceptions -fasynchronous-unwind-tables
252 CFLAGS-pthread_setcancelstate.c += -fexceptions -fasynchronous-unwind-tables
253 CFLAGS-pthread_setcanceltype.c += -fexceptions -fasynchronous-unwind-tables
254
255 # These are internal functions which similar functionality as setcancelstate
256 # and setcanceltype.
257 CFLAGS-cancellation.c += -fasynchronous-unwind-tables
258 CFLAGS-libc-cancellation.c += -fasynchronous-unwind-tables
259
260 # Calling pthread_exit() must cause the registered cancel handlers to
261 # be executed.  Therefore exceptions have to be thrown through this
262 # function.
263 CFLAGS-pthread_exit.c += -fexceptions
264
265 # Among others, __pthread_unwind is forwarded.  This function must handle
266 # exceptions.
267 CFLAGS-forward.c += -fexceptions
268
269 # The following are cancellation points.  Some of the functions can
270 # block and therefore temporarily enable asynchronous cancellation.
271 # Those must be compiled asynchronous unwind tables.
272 CFLAGS-pthread_testcancel.c += -fexceptions
273 CFLAGS-pthread_join.c += -fexceptions -fasynchronous-unwind-tables
274 CFLAGS-pthread_timedjoin.c += -fexceptions -fasynchronous-unwind-tables
275 CFLAGS-pthread_clockjoin.c += -fexceptions -fasynchronous-unwind-tables
276 CFLAGS-pthread_once.c += $(uses-callbacks) -fexceptions \
277                         -fasynchronous-unwind-tables
278 CFLAGS-pthread_cond_wait.c += -fexceptions -fasynchronous-unwind-tables
279 CFLAGS-sem_wait.c += -fexceptions -fasynchronous-unwind-tables
280 CFLAGS-sem_timedwait.c += -fexceptions -fasynchronous-unwind-tables
281 CFLAGS-sem_clockwait.c = -fexceptions -fasynchronous-unwind-tables
282
283 # These are the function wrappers we have to duplicate here.
284 CFLAGS-lockf.c += -fexceptions
285 CFLAGS-pread.c += -fexceptions -fasynchronous-unwind-tables
286 CFLAGS-pread64.c += -fexceptions -fasynchronous-unwind-tables
287 CFLAGS-pwrite.c += -fexceptions -fasynchronous-unwind-tables
288 CFLAGS-pwrite64.c += -fexceptions -fasynchronous-unwind-tables
289 CFLAGS-sigwait.c += -fexceptions -fasynchronous-unwind-tables
290 CFLAGS-msgrcv.c += -fexceptions -fasynchronous-unwind-tables
291 CFLAGS-msgsnd.c += -fexceptions -fasynchronous-unwind-tables
292 CFLAGS-open.c += -fexceptions -fasynchronous-unwind-tables
293 CFLAGS-open64.c += -fexceptions -fasynchronous-unwind-tables
294 CFLAGS-send.c += -fexceptions -fasynchronous-unwind-tables
295 CFLAGS-sigsuspend.c += -fexceptions -fasynchronous-unwind-tables
296 CFLAGS-fdatasync.c += -fexceptions -fasynchronous-unwind-tables
297
298 CFLAGS-futex-internal.c += -fexceptions -fasynchronous-unwind-tables
299
300 LDLIBS-tst-once5 = -lstdc++
301 CFLAGS-tst-thread_local1.o = -std=gnu++11
302 LDLIBS-tst-thread_local1 = -lstdc++
303 CFLAGS-tst-thread-exit-clobber.o = -std=gnu++11
304 LDLIBS-tst-thread-exit-clobber = -lstdc++
305 CFLAGS-tst-minstack-throw.o = -std=gnu++11
306 LDLIBS-tst-minstack-throw = -lstdc++
307
308 tests = tst-attr2 tst-attr3 tst-default-attr \
309         tst-mutex5a tst-mutex7a \
310         tst-mutexpi1 tst-mutexpi2 tst-mutexpi3 tst-mutexpi4 \
311         tst-mutexpi5 tst-mutexpi5a tst-mutexpi6 tst-mutexpi7 tst-mutexpi7a \
312         tst-mutexpi9 tst-mutexpi10 \
313         tst-cond22 tst-cond26 \
314         tst-robustpi1 tst-robustpi2 tst-robustpi3 tst-robustpi4 tst-robustpi5 \
315         tst-robustpi6 tst-robustpi7 tst-robustpi9 \
316         tst-rwlock2 tst-rwlock2a tst-rwlock2b tst-rwlock3 \
317         tst-rwlock6 tst-rwlock7 tst-rwlock8 \
318         tst-rwlock9 tst-rwlock10 tst-rwlock11 \
319         tst-rwlock15 tst-rwlock17 tst-rwlock18 \
320         tst-once5 \
321         tst-sem17 \
322         tst-tsd3 tst-tsd4 \
323         tst-cancel4_1 tst-cancel4_2 \
324         tst-cancel7 tst-cancel17 tst-cancel24 \
325         tst-cleanup4 \
326         tst-signal3 \
327         tst-exec4 tst-exec5 \
328         tst-stack2 tst-stack3 tst-stack4 \
329         tst-pthread-attr-affinity \
330         tst-dlsym1 \
331         tst-context1 \
332         tst-sched1 \
333         tst-initializers1 $(addprefix tst-initializers1-,\
334                             c89 gnu89 c99 gnu99 c11 gnu11) \
335         tst-thread_local1 \
336         tst-robust-fork \
337         tst-thread-exit-clobber tst-minstack-cancel tst-minstack-exit \
338         tst-minstack-throw \
339         tst-rwlock-pwn \
340         tst-thread-affinity-pthread \
341         tst-thread-affinity-pthread2 \
342         tst-thread-affinity-sched \
343         tst-pthread-defaultattr-free \
344         tst-pthread-attr-sigmask \
345         tst-pthread-timedlock-lockloop
346
347 tests-container =  tst-pthread-getattr
348
349 tests-internal := tst-robustpi8 tst-rwlock19 tst-rwlock20 \
350                   tst-sem11 tst-sem12 tst-sem13 \
351                   tst-barrier5 tst-signal7 tst-mutex8 tst-mutex8-static \
352                   tst-mutexpi8 tst-mutexpi8-static \
353                   tst-setgetname \
354
355 xtests = tst-setuid1 tst-setuid1-static tst-setuid2 \
356         tst-mutexpp1 tst-mutexpp6 tst-mutexpp10 tst-setgroups \
357         tst-mutexpp5 tst-mutexpp9
358
359 # This test can run into task limits because of a linux kernel bug
360 # and then cause the make process to fail too, see bug 24537.
361 xtests += tst-eintr1
362
363 test-srcs = tst-oddstacklimit
364
365 gen-as-const-headers = unwindbuf.sym \
366                        pthread-pi-defines.sym
367
368 gen-py-const-headers := nptl_lock_constants.pysym
369 pretty-printers := nptl-printers.py
370 tests-printers := test-mutexattr-printers test-mutex-printers \
371                   test-condattr-printers test-cond-printers \
372                   test-rwlockattr-printers test-rwlock-printers
373
374 # We must specify both CFLAGS and CPPFLAGS to override any
375 # compiler options the user might have provided that conflict
376 # with what we need e.g. user specifies CPPFLAGS with -O2 and
377 # we need -O0.
378 CFLAGS-test-mutexattr-printers.c := $(CFLAGS-printers-tests)
379 CFLAGS-test-mutex-printers.c := $(CFLAGS-printers-tests)
380 CFLAGS-test-condattr-printers.c := $(CFLAGS-printers-tests)
381 CFLAGS-test-cond-printers.c := $(CFLAGS-printers-tests)
382 CFLAGS-test-rwlockattr-printers.c := $(CFLAGS-printers-tests)
383 CFLAGS-test-rwlock-printers.c := $(CFLAGS-printers-tests)
384 CPPFLAGS-test-mutexattr-printers.c := $(CFLAGS-printers-tests)
385 CPPFLAGS-test-mutex-printers.c := $(CFLAGS-printers-tests)
386 CPPFLAGS-test-condattr-printers.c := $(CFLAGS-printers-tests)
387 CPPFLAGS-test-cond-printers.c := $(CFLAGS-printers-tests)
388 CPPFLAGS-test-rwlockattr-printers.c := $(CFLAGS-printers-tests)
389 CPPFLAGS-test-rwlock-printers.c := $(CFLAGS-printers-tests)
390
391 ifeq ($(build-shared),yes)
392 tests-printers-libs := $(shared-thread-library)
393 else
394 tests-printers-libs := $(static-thread-library)
395 endif
396
397 LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst
398
399 tests += tst-cancelx7 tst-cancelx17 tst-cleanupx4
400
401 ifeq ($(build-shared),yes)
402 tests += tst-compat-forwarder tst-audit-threads
403 tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1
404 ifeq ($(have-z-execstack),yes)
405 tests += tst-execstack
406 endif
407 endif
408
409 modules-names = tst-tls3mod \
410                 tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \
411                 tst-tls5modd tst-tls5mode tst-tls5modf tst-stack4mod \
412                 tst-execstack-mod \
413                 tst-compat-forwarder-mod tst-audit-threads-mod1 \
414                 tst-audit-threads-mod2
415 extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \
416                    tst-cleanup4aux.o tst-cleanupx4aux.o
417 test-extras += tst-cleanup4aux tst-cleanupx4aux
418
419 tst-tls3mod.so-no-z-defs = yes
420 tst-tls5mod.so-no-z-defs = yes
421 tst-tls5moda.so-no-z-defs = yes
422 tst-tls5modb.so-no-z-defs = yes
423 tst-tls5modc.so-no-z-defs = yes
424 tst-tls5modd.so-no-z-defs = yes
425 tst-tls5mode.so-no-z-defs = yes
426 tst-tls5modf.so-no-z-defs = yes
427
428 ifeq ($(build-shared),yes)
429
430 # Set the `multidir' variable by grabbing the variable from the compiler.
431 # We do it once and save the result in a generated makefile.
432 -include $(objpfx)multidir.mk
433 $(objpfx)multidir.mk: $(common-objpfx)config.make
434         $(make-target-directory)
435         dir=`$(CC) $(CFLAGS) $(CPPFLAGS) -print-multi-directory`; \
436         echo "multidir := $$dir" > $@T
437         mv -f $@T $@
438
439 crti-objs := crti.o
440 crtn-objs := crtn.o
441 ifneq (,$(patsubst .,,$(multidir)))
442 generated-dirs += $(firstword $(subst /, , $(multidir)))
443 crti-objs += $(multidir)/crti.o
444 crtn-objs += $(multidir)/crtn.o
445 $(objpfx)$(multidir):
446         mkdir -p $@
447 endif
448 extra-objs += $(crti-objs) $(crtn-objs)
449 extra-objs += pt-crti.o
450 endif
451
452 CFLAGS-flockfile.c += $(libio-mtsafe)
453 CFLAGS-ftrylockfile.c += $(libio-mtsafe)
454 CFLAGS-funlockfile.c += $(libio-mtsafe)
455
456 link-libc-static := $(common-objpfx)libc.a $(static-gnulib) \
457                     $(common-objpfx)libc.a
458
459 tests-static += tst-stackguard1-static \
460                 tst-cancel24-static \
461                 tst-mutex8-static tst-mutexpi8-static tst-sem11-static \
462                 tst-sem12-static tst-cond11-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