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