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