nptl: fix potential merge of __rseq_* relro symbols
[glibc.git] / sysdeps / unix / sysv / linux / Makefile
blobae66590e9135bca4419423e7cf69ebecba53cdb6
1 # Option to pass to Python scripts to set the C compiler. Rewriting
2 # MODULE_NAME is required to enable the _ISOMAC verbatim header
3 # environment.
4 sysdeps-linux-python-cc = \
5 --cc="$(CC) $(patsubst -DMODULE_NAME=%,-DMODULE_NAME=testsuite,$(CPPFLAGS))"
7 # Additional dependencies for Python scripts.
8 sysdeps-linux-python-deps = \
9 $(..)scripts/glibcextract.py \
10 $(..)sysdeps/unix/sysv/linux/glibcsyscalls.py \
11 # sysdeps-linux-python-deps
13 # Invocation of the Python interpreter with the Python search path.
14 sysdeps-linux-python = \
15 PYTHONPATH=$(..)scripts:$(..)sysdeps/unix/sysv/linux $(PYTHON)
17 ifndef subdir
18 # This target performs two actions:
20 # Replace <arch-syscall.h> with a file generated from kernel headers
21 # and <fixup-asm-unistd.h>. Both files are located via the sysdeps
22 # override search path.
24 # Update sysdeps/unix/sysv/linux/syscall-names.list with additional
25 # names found in the generated <arch-syscall.h> file, so that the
26 # global system call names list is a superset of the
27 # architecture-specific system call names.
29 # To bootstrap a new architecture, create an empty file in the right
30 # place and run `make update-syscall-lists' from the top-level of a
31 # configured, but not-yet-built glibc tree.
33 # --lock points to a file not replaced during the update operation, so
34 # that mutual exclusion is achieved.
35 .PHONY: update-syscall-lists
36 update-syscall-lists: arch-syscall.h
37 $(sysdeps-linux-python) \
38 sysdeps/unix/sysv/linux/update-syscall-lists.py \
39 $(sysdeps-linux-python-cc) \
40 --lock=sysdeps/unix/sysv/linux/update-syscall-lists.py $< \
41 sysdeps/unix/sysv/linux/syscall-names.list
42 endif
44 ifeq ($(subdir),csu)
45 sysdep_routines += \
46 errno-loc \
47 # sysdep_routines
48 endif
50 ifeq ($(subdir),assert)
51 CFLAGS-assert.c += -DFATAL_PREPARE_INCLUDE='<fatal-prepare.h>'
52 CFLAGS-assert-perr.c += -DFATAL_PREPARE_INCLUDE='<fatal-prepare.h>'
53 endif
55 ifeq ($(subdir),malloc)
56 CFLAGS-malloc.c += -DMORECORE_CLEARS=2
57 endif
59 ifeq ($(subdir),misc)
60 sysdep_routines += \
61 adjtimex \
62 clock_adjtime \
63 clone \
64 clone-internal \
65 clone-pidfd-support \
66 clone3 \
67 closefrom_fallback \
68 convert_scm_timestamps \
69 epoll_create \
70 epoll_pwait \
71 epoll_pwait2 \
72 epoll_wait \
73 eventfd \
74 eventfd_read \
75 eventfd_write \
76 fanotify_mark \
77 fxstat \
78 fxstat64 \
79 fxstatat \
80 fxstatat64 \
81 inotify_init \
82 lxstat \
83 lxstat64 \
84 mlock2 \
85 mremap \
86 open_by_handle_at \
87 personality \
88 pkey_get \
89 pkey_mprotect \
90 pkey_set \
91 prctl \
92 prlimit \
93 prlimit64 \
94 process_vm_readv \
95 process_vm_writev \
96 pselect32 \
97 readahead \
98 setfsgid \
99 setfsuid \
100 setvmaname \
101 signalfd \
102 splice \
103 sysctl \
104 tee \
105 timerfd_gettime \
106 timerfd_settime \
107 umount \
108 umount2 \
109 vmsplice \
110 xmknod \
111 xmknodat \
112 xstat \
113 xstat64 \
114 # sysdep_routines
116 CFLAGS-gethostid.c = -fexceptions
117 CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables
118 CFLAGS-vmsplice.c = -fexceptions -fasynchronous-unwind-tables
119 CFLAGS-splice.c = -fexceptions -fasynchronous-unwind-tables
120 CFLAGS-open_by_handle_at.c = -fexceptions -fasynchronous-unwind-tables
121 CFLAGS-sync_file_range.c = -fexceptions -fasynchronous-unwind-tables
122 CFLAGS-pselect32.c = -fexceptions -fasynchronous-unwind-tables
123 CFLAGS-tst-writev.c += "-DARTIFICIAL_LIMIT=(0x80000000-sysconf(_SC_PAGESIZE))"
125 # The test triggers FORTIFY abortion due to purposely wrong parameters
126 CFLAGS-test-errno-linux.c += $(no-fortify-source)
128 sysdep_headers += \
129 bits/a.out.h \
130 bits/epoll.h \
131 bits/eventfd.h \
132 bits/inotify.h \
133 bits/mman-linux.h \
134 bits/mman-map-flags-generic.h \
135 bits/mman-shared.h \
136 bits/procfs-extra.h \
137 bits/procfs-id.h \
138 bits/procfs-prregset.h \
139 bits/procfs.h \
140 bits/pthread_stack_min-dynamic.h \
141 bits/pthread_stack_min.h \
142 bits/ptrace-shared.h \
143 bits/rseq.h \
144 bits/shmlba.h \
145 bits/siginfo-arch.h \
146 bits/siginfo-consts-arch.h \
147 bits/signalfd.h \
148 bits/socket_type.h \
149 bits/struct_stat.h \
150 bits/struct_stat_time64_helper.h \
151 bits/syscall.h \
152 bits/termios-baud.h \
153 bits/termios-c_cc.h \
154 bits/termios-c_cflag.h \
155 bits/termios-c_iflag.h \
156 bits/termios-c_lflag.h \
157 bits/termios-c_oflag.h \
158 bits/termios-misc.h \
159 bits/termios-struct.h \
160 bits/termios-tcflow.h \
161 bits/timerfd.h \
162 bits/types/struct_msqid64_ds.h \
163 bits/types/struct_msqid64_ds_helper.h \
164 bits/types/struct_semid64_ds.h \
165 bits/types/struct_semid64_ds_helper.h \
166 bits/types/struct_semid_ds.h \
167 bits/types/struct_shmid64_ds.h \
168 bits/types/struct_shmid64_ds_helper.h \
169 scsi/scsi.h \
170 scsi/scsi_ioctl.h \
171 scsi/sg.h \
172 sys/acct.h \
173 sys/epoll.h \
174 sys/eventfd.h \
175 sys/fanotify.h \
176 sys/fsuid.h \
177 sys/inotify.h \
178 sys/kd.h \
179 sys/klog.h \
180 sys/mount.h \
181 sys/pci.h \
182 sys/personality.h \
183 sys/pidfd.h \
184 sys/prctl.h \
185 sys/quota.h \
186 sys/raw.h \
187 sys/rseq.h \
188 sys/signalfd.h \
189 sys/soundcard.h \
190 sys/timerfd.h \
191 sys/user.h \
192 sys/vt.h \
193 # sysdep_headers
195 tests += \
196 test-errno-linux \
197 tst-adjtimex \
198 tst-clock_adjtime \
199 tst-clone \
200 tst-clone2 \
201 tst-clone3 \
202 tst-epoll \
203 tst-epoll-ioctls \
204 tst-fanotify \
205 tst-fdopendir-o_path \
206 tst-getauxval \
207 tst-gettid \
208 tst-gettid-kill \
209 tst-memfd_create \
210 tst-misalign-clone \
211 tst-mlock2 \
212 tst-mount \
213 tst-ntp_adjtime \
214 tst-ntp_gettime \
215 tst-ntp_gettimex \
216 tst-ofdlocks \
217 tst-personality \
218 tst-pidfd \
219 tst-pidfd_getpid \
220 tst-pkey \
221 tst-ppoll \
222 tst-prctl \
223 tst-process_mrelease \
224 tst-quota \
225 tst-rlimit-infinity \
226 tst-scm_rights \
227 tst-sigtimedwait \
228 tst-sync_file_range \
229 tst-sysconf-iov_max \
230 tst-sysvmsg-linux \
231 tst-sysvsem-linux \
232 tst-sysvshm-linux \
233 tst-tgkill \
234 tst-timerfd \
235 tst-ttyname-direct \
236 tst-ttyname-namespace \
237 # tests
239 # process_madvise requires CAP_SYS_ADMIN.
240 xtests += \
241 tst-process_madvise \
242 # xtests
244 # For +depfiles in Makerules.
245 extra-test-objs += \
246 tst-sysconf-iov_max-uapi.o \
247 # extra-test-objs
249 # Test for the symbol version of fcntl that was replaced in glibc 2.28.
250 ifeq ($(have-GLIBC_2.27)$(build-shared),yesyes)
251 tests += \
252 tst-ofdlocks-compat \
253 # tests
254 endif
256 tests-internal += \
257 tst-rseq \
258 tst-sigcontext-get_pc \
259 # tests-internal
261 tests-internal += \
262 tst-rseq-disable \
263 # tests-internal
265 tests-time64 += \
266 tst-adjtimex-time64 \
267 tst-clock_adjtime-time64 \
268 tst-epoll-time64 \
269 tst-ntp_adjtime-time64 \
270 tst-ntp_gettime-time64 \
271 tst-ntp_gettimex-time64 \
272 tst-ppoll-time64 \
273 tst-prctl-time64 \
274 tst-scm_rights-time64 \
275 tst-sigtimedwait-time64 \
276 tst-timerfd-time64 \
277 # tests-time64
279 tests-clone-internal = \
280 tst-align-clone-internal \
281 tst-clone2-internal \
282 tst-clone3-internal \
283 tst-getpid1-internal
284 # tests-clone-internal
285 tests-internal += \
286 $(tests-clone-internal) \
287 # tests-internal
288 tests-static += \
289 $(tests-clone-internal) \
290 # tests-static
292 CFLAGS-tst-sigcontext-get_pc.c = -fasynchronous-unwind-tables
294 # Generate the list of SYS_* macros for the system calls (__NR_*
295 # macros). The file syscall-names.list contains all possible system
296 # call names, and the generated header file produces SYS_* macros for
297 # the __NR_* macros which are actually defined.
299 generated += bits/syscall.h
300 $(objpfx)bits/syscall.h: \
301 ../sysdeps/unix/sysv/linux/gen-syscall-h.awk \
302 ../sysdeps/unix/sysv/linux/syscall-names.list
303 $(make-target-directory)
304 LC_ALL=C $(AWK) -f $^ > $@-tmp
305 $(move-if-change) $@-tmp $@
306 before-compile += $(objpfx)bits/syscall.h
308 # All macros defined by <sys/syscall.h>. Include <bits/syscall.h>
309 # explicitly because <sys/sycall.h> skips it if _LIBC is defined.
310 $(objpfx)tst-syscall-list-macros.list: \
311 $(objpfx)bits/syscall.h ../sysdeps/unix/sysv/linux/sys/syscall.h
312 printf '#include <linux/version.h>\n\
313 #include <sys/syscall.h>\n#include <bits/syscall.h>\n' | \
314 $(CC) -E -o $@-tmp $(CFLAGS) $(CPPFLAGS) -x c - -dM
315 $(move-if-change) $@-tmp $@
317 # __NR_* system call names. Used by the test below.
318 $(objpfx)tst-syscall-list-nr.list: \
319 ../sysdeps/unix/sysv/linux/filter-nr-syscalls.awk \
320 $(objpfx)tst-syscall-list-macros.list
321 LC_ALL=C $(AWK) -f $^ > $@-tmp
322 $(move-if-change) $@-tmp $@
324 # SYS_* system call names. Used by the test below.
325 $(objpfx)tst-syscall-list-sys.list: $(objpfx)tst-syscall-list-macros.list
326 LC_ALL=C $(AWK) '/^#define SYS_/ { print substr($$2, 5) }' $< > $@-tmp
327 $(move-if-change) $@-tmp $@
329 tests-special += \
330 $(objpfx)tst-syscall-list.out
331 # tests-special
332 $(objpfx)tst-syscall-list.out: \
333 ../sysdeps/unix/sysv/linux/tst-syscall-list.sh \
334 $(objpfx)tst-syscall-list-macros.list \
335 $(objpfx)tst-syscall-list-nr.list \
336 $(objpfx)tst-syscall-list-sys.list
337 $(BASH) $^ $(AWK) > $@; $(evaluate-test)
339 tests-special += \
340 $(objpfx)tst-glibcsyscalls.out
341 # tests-special
342 # arch-syscall.h is located via the sysdeps override search path.
343 $(objpfx)tst-glibcsyscalls.out: arch-syscall.h \
344 ../sysdeps/unix/sysv/linux/syscall-names.list
345 $(sysdeps-linux-python) \
346 ../sysdeps/unix/sysv/linux/tst-glibcsyscalls.py \
347 $(sysdeps-linux-python-cc) $< \
348 ../sysdeps/unix/sysv/linux/syscall-names.list \
349 < /dev/null > $@ 2>&1; $(evaluate-test)
350 $(objpfx)tst-glibcsyscalls.out: \
351 ../sysdeps/unix/sysv/linux/tst-glibcsyscalls.py \
352 $(sysdeps-linux-python-deps)
354 # Separate object file for access to the constant from the UAPI header.
355 $(objpfx)tst-sysconf-iov_max: $(objpfx)tst-sysconf-iov_max-uapi.o
357 tests-special += \
358 $(objpfx)tst-mman-consts.out \
359 # tests-special
360 $(objpfx)tst-mman-consts.out: ../sysdeps/unix/sysv/linux/tst-mman-consts.py
361 $(sysdeps-linux-python) \
362 ../sysdeps/unix/sysv/linux/tst-mman-consts.py \
363 $(sysdeps-linux-python-cc) \
364 < /dev/null > $@ 2>&1; $(evaluate-test)
365 $(objpfx)tst-mman-consts.out: $(sysdeps-linux-python-deps)
367 tests-special += \
368 $(objpfx)tst-pidfd-consts.out \
369 # tests-special
370 $(objpfx)tst-pidfd-consts.out: ../sysdeps/unix/sysv/linux/tst-pidfd-consts.py
371 $(sysdeps-linux-python) \
372 ../sysdeps/unix/sysv/linux/tst-pidfd-consts.py \
373 $(sysdeps-linux-python-cc) \
374 < /dev/null > $@ 2>&1; $(evaluate-test)
375 $(objpfx)tst-pidfd-consts.out: $(sysdeps-linux-python-deps)
377 tests-special += \
378 $(objpfx)tst-mount-consts.out \
379 # tests-special
380 $(objpfx)tst-mount-consts.out: ../sysdeps/unix/sysv/linux/tst-mount-consts.py
381 $(sysdeps-linux-python) \
382 ../sysdeps/unix/sysv/linux/tst-mount-consts.py \
383 $(sysdeps-linux-python-cc) \
384 < /dev/null > $@ 2>&1; $(evaluate-test)
385 $(objpfx)tst-mount-consts.out: $(sysdeps-linux-python-deps)
387 tests-special += \
388 $(objpfx)tst-mount-compile.out \
389 # tests-special
390 $(objpfx)tst-mount-compile.out: ../sysdeps/unix/sysv/linux/tst-mount-compile.py
391 $(sysdeps-linux-python) \
392 ../sysdeps/unix/sysv/linux/tst-mount-compile.py \
393 $(sysdeps-linux-python-cc) \
394 < /dev/null > $@ 2>&1; $(evaluate-test)
395 $(objpfx)tst-mount-compile.out: $(sysdeps-linux-python-deps)
397 tst-rseq-disable-ENV = GLIBC_TUNABLES=glibc.pthread.rseq=0
399 endif # $(subdir) == misc
401 ifeq ($(subdir),time)
402 sysdep_headers += \
403 bits/timex.h \
404 sys/timex.h \
405 # sysdep_headers
407 sysdep_routines += \
408 ntp_gettime \
409 ntp_gettimex \
410 # sysdep_routines
412 tests += \
413 tst-clock_gettime-clobber \
414 tst-gettimeofday-clobber \
415 tst-time-clobber \
416 # tests
417 endif
419 ifeq ($(subdir),signal)
420 tests-special += \
421 $(objpfx)tst-signal-numbers.out \
422 # tests-special
424 # Depending on signal.o* is a hack. What we actually want is a dependency
425 # on signal.h and everything it includes. That's impractical to write
426 # in this context, but signal.c includes signal.h and not much else so it'll
427 # be conservatively correct.
428 $(objpfx)tst-signal-numbers.out: \
429 ../sysdeps/unix/sysv/linux/tst-signal-numbers.py \
430 $(objpfx)signal.o*
431 $(sysdeps-linux-python) \
432 ../sysdeps/unix/sysv/linux/tst-signal-numbers.py \
433 $(sysdeps-linux-python-cc) \
434 < /dev/null > $@ 2>&1; $(evaluate-test)
435 $(objpfx)tst-signal-numbers.out: $(sysdeps-linux-python-deps)
436 endif
438 ifeq ($(subdir),socket)
439 sysdep_headers += \
440 bits/socket-constants.h \
441 net/ethernet.h \
442 net/if_arp.h \
443 net/if_packet.h \
444 net/if_ppp.h \
445 net/if_shaper.h \
446 net/if_slip.h \
447 net/ppp-comp.h \
448 net/ppp_defs.h \
449 net/route.h \
450 # sysdep_headers
452 sysdep_routines += \
453 cmsg_nxthdr \
454 # sysdep_routines
456 CFLAGS-recvmmsg.c = -fexceptions -fasynchronous-unwind-tables
457 CFLAGS-sendmmsg.c = -fexceptions -fasynchronous-unwind-tables
459 tests += \
460 tst-socket-timestamp \
461 tst-socket-timestamp-compat \
462 # tests
463 tests-time64 += \
464 tst-socket-timestamp-compat-time64 \
465 tst-socket-timestamp-time64 \
466 # tests-time64
468 tests-special += \
469 $(objpfx)tst-socket-consts.out \
470 # tests-special
471 $(objpfx)tst-socket-consts.out: ../sysdeps/unix/sysv/linux/tst-socket-consts.py
472 PYTHONPATH=../scripts \
473 $(PYTHON) ../sysdeps/unix/sysv/linux/tst-socket-consts.py \
474 --cc="$(CC) $(patsubst -DMODULE_NAME=%, \
475 -DMODULE_NAME=testsuite, \
476 $(CPPFLAGS)) -D_ISOMAC" \
477 < /dev/null > $@ 2>&1; $(evaluate-test)
478 endif # $(subdir) == socket
480 ifeq ($(subdir),sunrpc)
481 sysdep_headers += \
482 nfs/nfs.h \
483 # sysdep_headers
484 endif
486 ifeq ($(subdir),termios)
487 sysdep_headers += \
488 termio.h \
489 # sysdep_headers
490 endif
492 ifeq ($(subdir),posix)
493 sysdep_headers += \
494 bits/initspin.h \
495 # sysdep_headers
497 sysdep_routines += \
498 getcpu \
499 oldglob \
500 pidfd_getpid \
501 pidfd_spawn \
502 pidfd_spawnp \
503 procutils \
504 sched_getcpu \
505 spawnattr_getcgroup_np \
506 spawnattr_setcgroup_np \
507 # sysdep_routines
509 tests += \
510 tst-affinity \
511 tst-affinity-pid \
512 tst-posix_spawn-setsid-pidfd \
513 tst-spawn-cgroup \
514 tst-spawn-chdir-pidfd \
515 tst-spawn-pidfd \
516 tst-spawn2-pidfd \
517 tst-spawn3-pidfd \
518 tst-spawn4-pidfd \
519 tst-spawn5-pidfd \
520 tst-spawn6-pidfd \
521 tst-spawn7-pidfd \
522 # tests
524 tests-static += \
525 tst-affinity-static \
526 # tests-static
528 tests += \
529 $(tests-static) \
530 # tests
532 CFLAGS-fork.c = $(libio-mtsafe)
533 CFLAGS-getpid.o = -fomit-frame-pointer
534 CFLAGS-getpid.os = -fomit-frame-pointer
535 CFLAGS-tst-spawn3-pidfd.c += -DOBJPFX=\"$(objpfx)\"
537 tst-spawn-cgroup-ARGS = -- $(host-test-program-cmd)
538 tst-spawn-pidfd-ARGS = -- $(host-test-program-cmd)
539 tst-spawn5-pidfd-ARGS = -- $(host-test-program-cmd)
540 tst-spawn6-pidfd-ARGS = -- $(host-test-program-cmd)
541 tst-spawn7-pidfd-ARGS = -- $(host-test-program-cmd)
542 tst-posix_spawn-setsid-pidfd-ARGS = -- $(host-test-program-cmd)
543 endif
545 ifeq ($(subdir),inet)
546 sysdep_headers += \
547 netash/ash.h \
548 netatalk/at.h \
549 netax25/ax25.h \
550 neteconet/ec.h \
551 netinet/if_fddi.h \
552 netinet/if_tr.h \
553 netipx/ipx.h \
554 netiucv/iucv.h \
555 netpacket/packet.h \
556 netrom/netrom.h \
557 netrose/rose.h \
558 # sysdep_headers
560 sysdep_routines += \
561 netlink_assert_response \
562 # sysdep_routines
564 CFLAGS-check_pf.c += -fexceptions
565 endif
567 # Don't compile the ctype glue code, since there is no old non-GNU C library.
568 inhibit-glue = yes
570 ifeq ($(subdir),dirent)
571 sysdep_routines += \
572 getdirentries \
573 getdirentries64 \
574 # sysdep_routines
576 tests += \
577 tst-getdents64 \
578 tst-readdir64-compat \
579 # tests
580 endif # $(subdir) == dirent
582 ifeq ($(subdir),nis)
583 CFLAGS-ypclnt.c = -DUSE_BINDINGDIR=1
584 endif
586 ifeq ($(subdir),io)
587 sysdep_routines += \
588 close_nocancel \
589 fallocate \
590 fallocate64 \
591 fcntl_nocancel \
592 internal_statvfs \
593 open64_nocancel \
594 open_nocancel \
595 openat64_nocancel \
596 openat_nocancel \
597 pread64_nocancel \
598 read_nocancel \
599 stat_t64_cp \
600 statx_cp \
601 sync_file_range \
602 write_nocancel \
603 xstatconv \
604 # sysdep_routines
606 sysdep_headers += \
607 bits/fcntl-linux.h \
608 # sysdep_headers
610 tests += \
611 tst-fallocate \
612 tst-fallocate64 \
613 tst-getcwd-smallbuff \
614 tst-o_path-locks \
615 # tests
616 endif
618 ifeq ($(subdir),elf)
619 sysdep-rtld-routines += \
620 dl-brk \
621 dl-getcwd \
622 dl-openat64 \
623 dl-opendir \
624 dl-sbrk \
625 # sysdep-rtld-routines
627 others += \
628 pldd \
629 # others
631 install-bin += \
632 pldd \
633 # install-bin
635 $(objpfx)pldd: $(objpfx)xmalloc.o
636 endif
638 ifeq ($(subdir),rt)
639 CFLAGS-mq_send.c += -fexceptions
640 CFLAGS-mq_receive.c += -fexceptions
641 endif
643 ifeq ($(subdir),nscd)
644 sysdep-CFLAGS += -DHAVE_EPOLL -DHAVE_INOTIFY -DHAVE_NETLINK
645 CFLAGS-gai.c += -DNEED_NETLINK
646 endif
648 ifeq ($(subdir),nptl)
649 tests += \
650 tst-align-clone \
651 tst-getpid1 \
652 # tests
654 # tst-rseq-nptl is an internal test because it requires a definition of
655 # __NR_rseq from the internal system call list.
656 tests-internal += \
657 tst-rseq-nptl \
658 # tests-internal
659 endif