linux: Add pidfd_getpid
[glibc.git] / sysdeps / unix / sysv / linux / Makefile
blob063719bae645b24a4474729640453fa4b5a63056
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 signalfd \
101 splice \
102 sysctl \
103 tee \
104 timerfd_gettime \
105 timerfd_settime \
106 umount \
107 umount2 \
108 vmsplice \
109 xmknod \
110 xmknodat \
111 xstat \
112 xstat64 \
113 # sysdep_routines
115 CFLAGS-gethostid.c = -fexceptions
116 CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables
117 CFLAGS-vmsplice.c = -fexceptions -fasynchronous-unwind-tables
118 CFLAGS-splice.c = -fexceptions -fasynchronous-unwind-tables
119 CFLAGS-open_by_handle_at.c = -fexceptions -fasynchronous-unwind-tables
120 CFLAGS-sync_file_range.c = -fexceptions -fasynchronous-unwind-tables
121 CFLAGS-pselect32.c = -fexceptions -fasynchronous-unwind-tables
122 CFLAGS-tst-writev.c += "-DARTIFICIAL_LIMIT=(0x80000000-sysconf(_SC_PAGESIZE))"
124 # The test triggers FORTIFY abortion due to purposely wrong parameters
125 CFLAGS-test-errno-linux.c += $(no-fortify-source)
127 sysdep_headers += \
128 bits/a.out.h \
129 bits/epoll.h \
130 bits/eventfd.h \
131 bits/inotify.h \
132 bits/mman-linux.h \
133 bits/mman-map-flags-generic.h \
134 bits/mman-shared.h \
135 bits/procfs-extra.h \
136 bits/procfs-id.h \
137 bits/procfs-prregset.h \
138 bits/procfs.h \
139 bits/pthread_stack_min-dynamic.h \
140 bits/pthread_stack_min.h \
141 bits/ptrace-shared.h \
142 bits/rseq.h \
143 bits/shmlba.h \
144 bits/siginfo-arch.h \
145 bits/siginfo-consts-arch.h \
146 bits/signalfd.h \
147 bits/socket_type.h \
148 bits/struct_stat.h \
149 bits/struct_stat_time64_helper.h \
150 bits/syscall.h \
151 bits/termios-baud.h \
152 bits/termios-c_cc.h \
153 bits/termios-c_cflag.h \
154 bits/termios-c_iflag.h \
155 bits/termios-c_lflag.h \
156 bits/termios-c_oflag.h \
157 bits/termios-misc.h \
158 bits/termios-struct.h \
159 bits/termios-tcflow.h \
160 bits/timerfd.h \
161 bits/types/struct_msqid64_ds.h \
162 bits/types/struct_msqid64_ds_helper.h \
163 bits/types/struct_semid64_ds.h \
164 bits/types/struct_semid64_ds_helper.h \
165 bits/types/struct_semid_ds.h \
166 bits/types/struct_shmid64_ds.h \
167 bits/types/struct_shmid64_ds_helper.h \
168 scsi/scsi.h \
169 scsi/scsi_ioctl.h \
170 scsi/sg.h \
171 sys/acct.h \
172 sys/epoll.h \
173 sys/eventfd.h \
174 sys/fanotify.h \
175 sys/fsuid.h \
176 sys/inotify.h \
177 sys/kd.h \
178 sys/klog.h \
179 sys/mount.h \
180 sys/pci.h \
181 sys/personality.h \
182 sys/pidfd.h \
183 sys/prctl.h \
184 sys/quota.h \
185 sys/raw.h \
186 sys/rseq.h \
187 sys/signalfd.h \
188 sys/soundcard.h \
189 sys/timerfd.h \
190 sys/user.h \
191 sys/vt.h \
192 # sysdep_headers
194 tests += \
195 test-errno-linux \
196 tst-adjtimex \
197 tst-clock_adjtime \
198 tst-clone \
199 tst-clone2 \
200 tst-clone3 \
201 tst-epoll \
202 tst-fanotify \
203 tst-getauxval \
204 tst-gettid \
205 tst-gettid-kill \
206 tst-memfd_create \
207 tst-misalign-clone \
208 tst-mlock2 \
209 tst-mount \
210 tst-ntp_adjtime \
211 tst-ntp_gettime \
212 tst-ntp_gettimex \
213 tst-ofdlocks \
214 tst-personality \
215 tst-pidfd \
216 tst-pidfd_getpid \
217 tst-pkey \
218 tst-ppoll \
219 tst-prctl \
220 tst-process_mrelease \
221 tst-quota \
222 tst-rlimit-infinity \
223 tst-scm_rights \
224 tst-sigtimedwait \
225 tst-sync_file_range \
226 tst-sysconf-iov_max \
227 tst-sysvmsg-linux \
228 tst-sysvsem-linux \
229 tst-sysvshm-linux \
230 tst-tgkill \
231 tst-timerfd \
232 tst-ttyname-direct \
233 tst-ttyname-namespace \
234 # tests
236 # process_madvise requires CAP_SYS_ADMIN.
237 xtests += \
238 tst-process_madvise \
239 # xtests
241 # For +depfiles in Makerules.
242 extra-test-objs += \
243 tst-sysconf-iov_max-uapi.o \
244 # extra-test-objs
246 # Test for the symbol version of fcntl that was replaced in glibc 2.28.
247 ifeq ($(have-GLIBC_2.27)$(build-shared),yesyes)
248 tests += \
249 tst-ofdlocks-compat \
250 # tests
251 endif
253 tests-internal += \
254 tst-rseq \
255 tst-sigcontext-get_pc \
256 # tests-internal
258 tests-internal += \
259 tst-rseq-disable \
260 # tests-internal
262 tests-time64 += \
263 tst-adjtimex-time64 \
264 tst-clock_adjtime-time64 \
265 tst-epoll-time64 \
266 tst-ntp_adjtime-time64 \
267 tst-ntp_gettime-time64 \
268 tst-ntp_gettimex-time64 \
269 tst-ppoll-time64 \
270 tst-prctl-time64 \
271 tst-scm_rights-time64 \
272 tst-sigtimedwait-time64 \
273 tst-timerfd-time64 \
274 # tests-time64
276 tests-clone-internal = \
277 tst-align-clone-internal \
278 tst-clone2-internal \
279 tst-clone3-internal \
280 tst-getpid1-internal
281 # tests-clone-internal
282 tests-internal += \
283 $(tests-clone-internal) \
284 # tests-internal
285 tests-static += \
286 $(tests-clone-internal) \
287 # tests-static
289 CFLAGS-tst-sigcontext-get_pc.c = -fasynchronous-unwind-tables
291 # Generate the list of SYS_* macros for the system calls (__NR_*
292 # macros). The file syscall-names.list contains all possible system
293 # call names, and the generated header file produces SYS_* macros for
294 # the __NR_* macros which are actually defined.
296 generated += bits/syscall.h
297 $(objpfx)bits/syscall.h: \
298 ../sysdeps/unix/sysv/linux/gen-syscall-h.awk \
299 ../sysdeps/unix/sysv/linux/syscall-names.list
300 $(make-target-directory)
301 LC_ALL=C $(AWK) -f $^ > $@-tmp
302 $(move-if-change) $@-tmp $@
303 before-compile += $(objpfx)bits/syscall.h
305 # All macros defined by <sys/syscall.h>. Include <bits/syscall.h>
306 # explicitly because <sys/sycall.h> skips it if _LIBC is defined.
307 $(objpfx)tst-syscall-list-macros.list: \
308 $(objpfx)bits/syscall.h ../sysdeps/unix/sysv/linux/sys/syscall.h
309 printf '#include <linux/version.h>\n\
310 #include <sys/syscall.h>\n#include <bits/syscall.h>\n' | \
311 $(CC) -E -o $@-tmp $(CFLAGS) $(CPPFLAGS) -x c - -dM
312 $(move-if-change) $@-tmp $@
314 # __NR_* system call names. Used by the test below.
315 $(objpfx)tst-syscall-list-nr.list: \
316 ../sysdeps/unix/sysv/linux/filter-nr-syscalls.awk \
317 $(objpfx)tst-syscall-list-macros.list
318 LC_ALL=C $(AWK) -f $^ > $@-tmp
319 $(move-if-change) $@-tmp $@
321 # SYS_* system call names. Used by the test below.
322 $(objpfx)tst-syscall-list-sys.list: $(objpfx)tst-syscall-list-macros.list
323 LC_ALL=C $(AWK) '/^#define SYS_/ { print substr($$2, 5) }' $< > $@-tmp
324 $(move-if-change) $@-tmp $@
326 tests-special += \
327 $(objpfx)tst-syscall-list.out
328 # tests-special
329 $(objpfx)tst-syscall-list.out: \
330 ../sysdeps/unix/sysv/linux/tst-syscall-list.sh \
331 $(objpfx)tst-syscall-list-macros.list \
332 $(objpfx)tst-syscall-list-nr.list \
333 $(objpfx)tst-syscall-list-sys.list
334 $(BASH) $^ $(AWK) > $@; $(evaluate-test)
336 tests-special += \
337 $(objpfx)tst-glibcsyscalls.out
338 # tests-special
339 # arch-syscall.h is located via the sysdeps override search path.
340 $(objpfx)tst-glibcsyscalls.out: arch-syscall.h \
341 ../sysdeps/unix/sysv/linux/syscall-names.list
342 $(sysdeps-linux-python) \
343 ../sysdeps/unix/sysv/linux/tst-glibcsyscalls.py \
344 $(sysdeps-linux-python-cc) $< \
345 ../sysdeps/unix/sysv/linux/syscall-names.list \
346 < /dev/null > $@ 2>&1; $(evaluate-test)
347 $(objpfx)tst-glibcsyscalls.out: \
348 ../sysdeps/unix/sysv/linux/tst-glibcsyscalls.py \
349 $(sysdeps-linux-python-deps)
351 # Separate object file for access to the constant from the UAPI header.
352 $(objpfx)tst-sysconf-iov_max: $(objpfx)tst-sysconf-iov_max-uapi.o
354 tests-special += \
355 $(objpfx)tst-mman-consts.out \
356 # tests-special
357 $(objpfx)tst-mman-consts.out: ../sysdeps/unix/sysv/linux/tst-mman-consts.py
358 $(sysdeps-linux-python) \
359 ../sysdeps/unix/sysv/linux/tst-mman-consts.py \
360 $(sysdeps-linux-python-cc) \
361 < /dev/null > $@ 2>&1; $(evaluate-test)
362 $(objpfx)tst-mman-consts.out: $(sysdeps-linux-python-deps)
364 tests-special += \
365 $(objpfx)tst-pidfd-consts.out \
366 # tests-special
367 $(objpfx)tst-pidfd-consts.out: ../sysdeps/unix/sysv/linux/tst-pidfd-consts.py
368 $(sysdeps-linux-python) \
369 ../sysdeps/unix/sysv/linux/tst-pidfd-consts.py \
370 $(sysdeps-linux-python-cc) \
371 < /dev/null > $@ 2>&1; $(evaluate-test)
372 $(objpfx)tst-pidfd-consts.out: $(sysdeps-linux-python-deps)
374 tests-special += \
375 $(objpfx)tst-mount-consts.out \
376 # tests-special
377 $(objpfx)tst-mount-consts.out: ../sysdeps/unix/sysv/linux/tst-mount-consts.py
378 $(sysdeps-linux-python) \
379 ../sysdeps/unix/sysv/linux/tst-mount-consts.py \
380 $(sysdeps-linux-python-cc) \
381 < /dev/null > $@ 2>&1; $(evaluate-test)
382 $(objpfx)tst-mount-consts.out: $(sysdeps-linux-python-deps)
384 tests-special += \
385 $(objpfx)tst-mount-compile.out \
386 # tests-special
387 $(objpfx)tst-mount-compile.out: ../sysdeps/unix/sysv/linux/tst-mount-compile.py
388 $(sysdeps-linux-python) \
389 ../sysdeps/unix/sysv/linux/tst-mount-compile.py \
390 $(sysdeps-linux-python-cc) \
391 < /dev/null > $@ 2>&1; $(evaluate-test)
392 $(objpfx)tst-mount-compile.out: $(sysdeps-linux-python-deps)
394 tst-rseq-disable-ENV = GLIBC_TUNABLES=glibc.pthread.rseq=0
396 endif # $(subdir) == misc
398 ifeq ($(subdir),time)
399 sysdep_headers += \
400 bits/timex.h \
401 sys/timex.h \
402 # sysdep_headers
404 sysdep_routines += \
405 ntp_gettime \
406 ntp_gettimex \
407 # sysdep_routines
409 tests += \
410 tst-clock_gettime-clobber \
411 tst-gettimeofday-clobber \
412 tst-time-clobber \
413 # tests
414 endif
416 ifeq ($(subdir),signal)
417 tests-special += \
418 $(objpfx)tst-signal-numbers.out \
419 # tests-special
421 # Depending on signal.o* is a hack. What we actually want is a dependency
422 # on signal.h and everything it includes. That's impractical to write
423 # in this context, but signal.c includes signal.h and not much else so it'll
424 # be conservatively correct.
425 $(objpfx)tst-signal-numbers.out: \
426 ../sysdeps/unix/sysv/linux/tst-signal-numbers.py \
427 $(objpfx)signal.o*
428 $(sysdeps-linux-python) \
429 ../sysdeps/unix/sysv/linux/tst-signal-numbers.py \
430 $(sysdeps-linux-python-cc) \
431 < /dev/null > $@ 2>&1; $(evaluate-test)
432 $(objpfx)tst-signal-numbers.out: $(sysdeps-linux-python-deps)
433 endif
435 ifeq ($(subdir),socket)
436 sysdep_headers += \
437 bits/socket-constants.h \
438 net/ethernet.h \
439 net/if_arp.h \
440 net/if_packet.h \
441 net/if_ppp.h \
442 net/if_shaper.h \
443 net/if_slip.h \
444 net/ppp-comp.h \
445 net/ppp_defs.h \
446 net/route.h \
447 # sysdep_headers
449 sysdep_routines += \
450 cmsg_nxthdr \
451 # sysdep_routines
453 CFLAGS-recvmmsg.c = -fexceptions -fasynchronous-unwind-tables
454 CFLAGS-sendmmsg.c = -fexceptions -fasynchronous-unwind-tables
456 tests += \
457 tst-socket-timestamp \
458 tst-socket-timestamp-compat \
459 # tests
460 tests-time64 += \
461 tst-socket-timestamp-compat-time64 \
462 tst-socket-timestamp-time64 \
463 # tests-time64
465 tests-special += \
466 $(objpfx)tst-socket-consts.out \
467 # tests-special
468 $(objpfx)tst-socket-consts.out: ../sysdeps/unix/sysv/linux/tst-socket-consts.py
469 PYTHONPATH=../scripts \
470 $(PYTHON) ../sysdeps/unix/sysv/linux/tst-socket-consts.py \
471 --cc="$(CC) $(patsubst -DMODULE_NAME=%, \
472 -DMODULE_NAME=testsuite, \
473 $(CPPFLAGS)) -D_ISOMAC" \
474 < /dev/null > $@ 2>&1; $(evaluate-test)
475 endif # $(subdir) == socket
477 ifeq ($(subdir),sunrpc)
478 sysdep_headers += \
479 nfs/nfs.h \
480 # sysdep_headers
481 endif
483 ifeq ($(subdir),termios)
484 sysdep_headers += \
485 termio.h \
486 # sysdep_headers
487 endif
489 ifeq ($(subdir),posix)
490 sysdep_headers += \
491 bits/initspin.h \
492 # sysdep_headers
494 sysdep_routines += \
495 getcpu \
496 oldglob \
497 pidfd_getpid \
498 pidfd_spawn \
499 pidfd_spawnp \
500 procutils \
501 sched_getcpu \
502 spawnattr_getcgroup_np \
503 spawnattr_setcgroup_np \
504 # sysdep_routines
506 tests += \
507 tst-affinity \
508 tst-affinity-pid \
509 tst-posix_spawn-setsid-pidfd \
510 tst-spawn-cgroup \
511 tst-spawn-chdir-pidfd \
512 tst-spawn-pidfd \
513 tst-spawn2-pidfd \
514 tst-spawn3-pidfd \
515 tst-spawn4-pidfd \
516 tst-spawn5-pidfd \
517 tst-spawn6-pidfd \
518 tst-spawn7-pidfd \
519 # tests
521 tests-static += \
522 tst-affinity-static \
523 # tests-static
525 tests += \
526 $(tests-static) \
527 # tests
529 CFLAGS-fork.c = $(libio-mtsafe)
530 CFLAGS-getpid.o = -fomit-frame-pointer
531 CFLAGS-getpid.os = -fomit-frame-pointer
532 CFLAGS-tst-spawn3-pidfd.c += -DOBJPFX=\"$(objpfx)\"
534 tst-spawn-cgroup-ARGS = -- $(host-test-program-cmd)
535 tst-spawn-pidfd-ARGS = -- $(host-test-program-cmd)
536 tst-spawn5-pidfd-ARGS = -- $(host-test-program-cmd)
537 tst-spawn6-pidfd-ARGS = -- $(host-test-program-cmd)
538 tst-spawn7-pidfd-ARGS = -- $(host-test-program-cmd)
539 tst-posix_spawn-setsid-pidfd-ARGS = -- $(host-test-program-cmd)
540 endif
542 ifeq ($(subdir),inet)
543 sysdep_headers += \
544 netash/ash.h \
545 netatalk/at.h \
546 netax25/ax25.h \
547 neteconet/ec.h \
548 netinet/if_fddi.h \
549 netinet/if_tr.h \
550 netipx/ipx.h \
551 netiucv/iucv.h \
552 netpacket/packet.h \
553 netrom/netrom.h \
554 netrose/rose.h \
555 # sysdep_headers
557 sysdep_routines += \
558 netlink_assert_response \
559 # sysdep_routines
561 CFLAGS-check_pf.c += -fexceptions
562 endif
564 # Don't compile the ctype glue code, since there is no old non-GNU C library.
565 inhibit-glue = yes
567 ifeq ($(subdir),dirent)
568 sysdep_routines += \
569 getdirentries \
570 getdirentries64 \
571 # sysdep_routines
573 tests += \
574 tst-getdents64 \
575 tst-readdir64-compat \
576 # tests
577 endif # $(subdir) == dirent
579 ifeq ($(subdir),nis)
580 CFLAGS-ypclnt.c = -DUSE_BINDINGDIR=1
581 endif
583 ifeq ($(subdir),io)
584 sysdep_routines += \
585 close_nocancel \
586 fallocate \
587 fallocate64 \
588 fcntl_nocancel \
589 internal_statvfs \
590 open64_nocancel \
591 open_nocancel \
592 openat64_nocancel \
593 openat_nocancel \
594 pread64_nocancel \
595 read_nocancel \
596 stat_t64_cp \
597 statx_cp \
598 sync_file_range \
599 write_nocancel \
600 xstatconv \
601 # sysdep_routines
603 sysdep_headers += \
604 bits/fcntl-linux.h \
605 # sysdep_headers
607 tests += \
608 tst-fallocate \
609 tst-fallocate64 \
610 tst-getcwd-smallbuff \
611 tst-o_path-locks \
612 # tests
613 endif
615 ifeq ($(subdir),elf)
616 sysdep-rtld-routines += \
617 dl-brk \
618 dl-getcwd \
619 dl-openat64 \
620 dl-opendir \
621 dl-sbrk \
622 # sysdep-rtld-routines
624 others += \
625 pldd \
626 # others
628 install-bin += \
629 pldd \
630 # install-bin
632 $(objpfx)pldd: $(objpfx)xmalloc.o
633 endif
635 ifeq ($(subdir),rt)
636 CFLAGS-mq_send.c += -fexceptions
637 CFLAGS-mq_receive.c += -fexceptions
638 endif
640 ifeq ($(subdir),nscd)
641 sysdep-CFLAGS += -DHAVE_EPOLL -DHAVE_INOTIFY -DHAVE_NETLINK
642 CFLAGS-gai.c += -DNEED_NETLINK
643 endif
645 ifeq ($(subdir),nptl)
646 tests += \
647 tst-align-clone \
648 tst-getpid1 \
649 # tests
651 # tst-rseq-nptl is an internal test because it requires a definition of
652 # __NR_rseq from the internal system call list.
653 tests-internal += \
654 tst-rseq-nptl \
655 # tests-internal
656 endif