debug: Improve fcntl.h fortify warnings with clang
[glibc.git] / conform / Makefile
blob73a3cb6da2e99d8018c52263a1aa90f070056a77
1 # Copyright (C) 1999-2024 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
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.
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.
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/>.
19 # Sub-makefile for conform portion of the library.
21 subdir := conform
23 include ../Makeconfig
25 conformtest-headers-data := $(wildcard data/*.h-data) \
26 $(wildcard data/*/*.h-data)
28 conformtest-standards := \
29 ISO \
30 ISO11 \
31 ISO99 \
32 POSIX \
33 POSIX2008 \
34 UNIX98 \
35 XOPEN2K \
36 XOPEN2K8 \
37 XPG4 \
38 XPG42 \
39 # conformtest-standards
40 conformtest-headers-ISO := \
41 assert.h \
42 ctype.h \
43 errno.h \
44 float.h \
45 limits.h \
46 locale.h \
47 math.h \
48 setjmp.h \
49 signal.h \
50 stdarg.h \
51 stddef.h \
52 stdio.h \
53 stdlib.h \
54 string.h \
55 time.h \
56 # conformtest-headers-ISO
57 conformtest-headers-ISO99 := \
58 $(conformtest-headers-ISO) \
59 complex.h \
60 fenv.h \
61 inttypes.h \
62 iso646.h \
63 stdbool.h \
64 stdint.h \
65 tgmath.h \
66 wchar.h \
67 wctype.h \
68 # conformtest-headers-ISO99
69 # Missing ISO11 expectations for: stdatomic.h
70 conformtest-headers-ISO11 := \
71 $(conformtest-headers-ISO99) \
72 stdalign.h \
73 stdnoreturn.h \
74 threads.h \
75 uchar.h \
76 # conformtest-headers-ISO11
77 conformtest-headers-POSIX := \
78 $(conformtest-headers-ISO) \
79 aio.h \
80 dirent.h \
81 fcntl.h \
82 fnmatch.h \
83 glob.h \
84 grp.h \
85 mqueue.h \
86 pthread.h \
87 pwd.h \
88 regex.h \
89 sched.h \
90 semaphore.h \
91 sys/mman.h \
92 sys/stat.h \
93 sys/times.h \
94 sys/types.h \
95 sys/utsname.h \
96 sys/wait.h \
97 tar.h \
98 termios.h \
99 unistd.h \
100 utime.h \
101 wordexp.h \
102 # conformtest-headers-POSIX
103 # Missing XPG4 expectations for: regexp.h wchar.h.
104 conformtest-headers-XPG4 := \
105 $(conformtest-headers-ISO) \
106 cpio.h \
107 dirent.h \
108 fcntl.h \
109 fnmatch.h \
110 ftw.h \
111 glob.h \
112 grp.h \
113 iconv.h \
114 langinfo.h \
115 monetary.h \
116 nl_types.h \
117 pwd.h \
118 regex.h \
119 search.h \
120 sys/ipc.h \
121 sys/msg.h \
122 sys/sem.h \
123 sys/shm.h \
124 sys/stat.h \
125 sys/times.h \
126 sys/types.h \
127 sys/utsname.h \
128 sys/wait.h \
129 tar.h \
130 termios.h \
131 ulimit.h \
132 unistd.h \
133 utime.h \
134 varargs.h \
135 wordexp.h \
136 # conformtest-headers-XPG4
137 # Missing XPG42 expectations for:
138 # re_comp.h
139 # regexp.h
140 # wchar.h
141 # XPG42 includes XTI and STREAMS, but those are not implemented by glibc.
142 conformtest-headers-XPG42 := \
143 $(conformtest-headers-XPG4) \
144 arpa/inet.h \
145 fmtmsg.h \
146 libgen.h \
147 ndbm.h \
148 netdb.h \
149 netinet/in.h \
150 poll.h \
151 strings.h \
152 sys/mman.h \
153 sys/resource.h \
154 sys/socket.h \
155 sys/statvfs.h \
156 sys/time.h \
157 sys/timeb.h \
158 sys/uio.h \
159 sys/un.h \
160 syslog.h \
161 ucontext.h \
162 utmpx.h \
163 # conformtest-headers-XPG42
164 # Missing UNIX98 expectations for:
165 # inttypes.h
166 # re_comp.h
167 # regexp.h
168 # The online UNIX98 includes XCURSES, but curses.h, term.h and
169 # unctrl.h are outside the scope of these tests. It also includes
170 # XTI and STREAMS, but those are not implemented by glibc.
171 conformtest-headers-UNIX98 := \
172 $(conformtest-headers-POSIX) \
173 arpa/inet.h \
174 cpio.h \
175 dlfcn.h \
176 fmtmsg.h \
177 ftw.h \
178 iconv.h \
179 iso646.h \
180 langinfo.h \
181 libgen.h \
182 monetary.h \
183 ndbm.h \
184 netdb.h \
185 netinet/in.h \
186 nl_types.h \
187 poll.h \
188 search.h \
189 strings.h \
190 sys/ipc.h \
191 sys/msg.h \
192 sys/resource.h \
193 sys/sem.h \
194 sys/shm.h \
195 sys/socket.h \
196 sys/statvfs.h \
197 sys/time.h \
198 sys/timeb.h \
199 sys/uio.h \
200 sys/un.h \
201 syslog.h \
202 ucontext.h \
203 ulimit.h \
204 utmpx.h \
205 varargs.h \
206 wchar.h \
207 wctype.h \
208 # conformtest-headers-UNIX98
209 # Missing XOPEN2K expectations for:
210 # trace.h
211 # stropts.h
212 conformtest-headers-XOPEN2K := \
213 $(conformtest-headers-POSIX) \
214 arpa/inet.h \
215 complex.h \
216 cpio.h \
217 dlfcn.h \
218 fenv.h \
219 fmtmsg.h \
220 ftw.h \
221 iconv.h \
222 inttypes.h \
223 iso646.h \
224 langinfo.h \
225 libgen.h \
226 monetary.h \
227 ndbm.h \
228 net/if.h \
229 netdb.h \
230 netinet/in.h \
231 netinet/tcp.h \
232 nl_types.h \
233 poll.h \
234 search.h \
235 spawn.h \
236 stdbool.h \
237 stdint.h \
238 strings.h \
239 sys/ipc.h \
240 sys/msg.h \
241 sys/resource.h \
242 sys/select.h \
243 sys/sem.h \
244 sys/shm.h \
245 sys/socket.h \
246 sys/statvfs.h \
247 sys/time.h \
248 sys/timeb.h \
249 sys/uio.h \
250 sys/un.h \
251 syslog.h \
252 tgmath.h \
253 ucontext.h \
254 ulimit.h \
255 utmpx.h \
256 wchar.h \
257 wctype.h \
258 # conformtest-headers-XOPEN2K
259 # Missing POSIX2008 expectations for:
260 # trace.h
261 # stropts.h
262 conformtest-headers-POSIX2008 := \
263 $(conformtest-headers-POSIX) \
264 arpa/inet.h \
265 complex.h \
266 cpio.h \
267 dlfcn.h \
268 fenv.h \
269 iconv.h \
270 inttypes.h \
271 iso646.h \
272 langinfo.h \
273 monetary.h \
274 net/if.h \
275 netdb.h \
276 netinet/in.h \
277 netinet/tcp.h \
278 nl_types.h \
279 poll.h \
280 spawn.h \
281 stdbool.h \
282 stdint.h \
283 strings.h \
284 sys/select.h \
285 sys/socket.h \
286 sys/statvfs.h \
287 sys/un.h \
288 tgmath.h \
289 wchar.h \
290 wctype.h \
291 # conformtest-headers-POSIX2008
292 # Missing XOPEN2K8 expectations for:
293 # trace.h
294 conformtest-headers-XOPEN2K8 := \
295 $(conformtest-headers-POSIX2008) \
296 fmtmsg.h \
297 ftw.h \
298 libgen.h \
299 ndbm.h \
300 search.h \
301 sys/ipc.h \
302 sys/msg.h \
303 sys/resource.h \
304 sys/sem.h \
305 sys/shm.h \
306 sys/time.h \
307 sys/uio.h \
308 syslog.h \
309 ulimit.h \
310 utmpx.h \
311 # conformtest-headers-XOPEN2K8
313 conformtest-header-list-base := $(foreach std,$(conformtest-standards),\
314 header-list-$(std).out)
315 conformtest-header-list-tests := $(addprefix $(objpfx),\
316 $(conformtest-header-list-base))
317 tests-special += $(conformtest-header-list-tests)
318 generated += $(conformtest-header-list-base)
320 conformtest-header-base := $(foreach std,\
321 $(conformtest-standards),\
322 $(foreach h,\
323 $(conformtest-headers-$(std)),\
324 $(std)/$(h)/conform.out))
325 conformtest-header-tests := $(addprefix $(objpfx),$(conformtest-header-base))
326 ifneq (yes,$(fast-check))
327 tests-special += $(conformtest-header-tests)
328 generated += $(conformtest-header-base)
329 endif
331 linknamespace-symlists-base := $(foreach std,$(conformtest-standards),\
332 symlist-$(std))
333 linknamespace-symlists-tests := $(addprefix $(objpfx),\
334 $(linknamespace-symlists-base))
335 tests-special += $(linknamespace-symlists-tests)
337 linknamespace-symlist-stdlibs-base := $(foreach std,$(conformtest-standards),\
338 symlist-stdlibs-$(std))
339 linknamespace-symlist-stdlibs-tests := \
340 $(addprefix $(objpfx),\
341 $(linknamespace-symlist-stdlibs-base))
343 tests-special += $(linknamespace-symlist-stdlibs-tests)
345 linknamespace-header-base := $(foreach std,\
346 $(conformtest-standards),\
347 $(foreach h,\
348 $(conformtest-headers-$(std)),\
349 $(std)/$(h)/linknamespace.out))
350 linknamespace-header-tests := $(addprefix $(objpfx),\
351 $(linknamespace-header-base))
352 tests-special += $(linknamespace-header-tests)
354 include ../Rules
356 $(conformtest-header-list-tests): $(objpfx)header-list-%.out: \
357 check-header-lists.sh \
358 $(conformtest-headers-data)
359 $(SHELL) $< "$*" "$(CC)" "$(strip $(conformtest-headers-$*))" \
360 "$(conformtest-headers-data)" > $@; \
361 $(evaluate-test)
363 # Pre-standard C feature no longer supported by GCC (obsoleted in
364 # newer POSIX standards).
365 test-xfail-XPG4/varargs.h/conform = yes
366 test-xfail-XPG42/varargs.h/conform = yes
367 test-xfail-UNIX98/varargs.h/conform = yes
369 # Header not provided by glibc.
370 test-xfail-XPG42/ndbm.h/conform = yes
371 test-xfail-UNIX98/ndbm.h/conform = yes
372 test-xfail-XOPEN2K/ndbm.h/conform = yes
373 test-xfail-XOPEN2K8/ndbm.h/conform = yes
375 conformtest-cc-flags = -I../include $(+sysdep-includes) $(sysincludes) -I..
376 # conformtest-xfail-conds may be set by a sysdeps Makefile fragment to
377 # a list of conditions that are considered to be true when encountered
378 # in xfail[cond]- lines in test expectations.
379 conformtest-xfail = $(if $(conformtest-xfail-conds),\
380 --xfail='$(conformtest-xfail-conds)')
381 ifeq (no,$(cross-compiling))
382 conformtest-cross =
383 else
384 conformtest-cross = --cross
385 endif
386 $(conformtest-header-tests): $(objpfx)%/conform.out: \
387 conformtest.py $(conformtest-headers-data)
388 (set -e; std_hdr=$*; std=$${std_hdr%%/*}; hdr=$${std_hdr#*/}; \
389 mkdir -p $(@D); \
390 $(PYTHON) $< --cc='$(CC) $(pie-default)' \
391 --flags='$(conformtest-cc-flags)' \
392 --ldflags='$(+link-tests-before-inputs)' \
393 --libs='$(+link-tests-after-inputs)' \
394 --run-program-prefix='$(run-program-prefix)' \
395 --standard=$$std --header=$$hdr $(conformtest-xfail) \
396 $(conformtest-cross) \
397 > $@ 2>&1); \
398 $(evaluate-test)
400 $(linknamespace-symlists-tests): $(objpfx)symlist-%: list-header-symbols.py
401 $(PYTHON) $< --cc='$(CC)' --flags='$(conformtest-cc-flags)' \
402 --standard=$* --headers="$(strip $(conformtest-headers-$*))" \
403 > $@ 2> $@.err; \
404 $(evaluate-test)
406 linknamespace-libs-isoc = $(common-objpfx)libc.a $(common-objpfx)math/libm.a
407 linknamespace-libs-thr = $(linknamespace-libs-isoc) \
408 $(common-objpfx)rt/librt.a \
409 $(filter-out %_syms.a,$(static-thread-library))
410 linknamespace-libs-posix = $(linknamespace-libs-thr) \
411 $(common-objpfx)dlfcn/libdl.a
412 linknamespace-libs-xsi = $(linknamespace-libs-posix)
413 linknamespace-libs-ISO = $(linknamespace-libs-isoc)
414 linknamespace-libs-ISO99 = $(linknamespace-libs-isoc)
415 linknamespace-libs-ISO11 = $(linknamespace-libs-isoc) \
416 $(filter-out %_syms.a,$(static-thread-library))
417 linknamespace-libs-XPG4 = $(linknamespace-libs-isoc)
418 linknamespace-libs-XPG42 = $(linknamespace-libs-XPG4)
419 linknamespace-libs-POSIX = $(linknamespace-libs-thr)
420 linknamespace-libs-UNIX98 = $(linknamespace-libs-xsi)
421 linknamespace-libs-XOPEN2K = $(linknamespace-libs-xsi)
422 linknamespace-libs-POSIX2008 = $(linknamespace-libs-posix)
423 linknamespace-libs-XOPEN2K8 = $(linknamespace-libs-xsi)
424 linknamespace-libs = $(foreach std,$(conformtest-standards),\
425 $(linknamespace-libs-$(std)))
427 $(linknamespace-symlist-stdlibs-tests): $(objpfx)symlist-stdlibs-%: \
428 $(linknamespace-libs)
429 LC_ALL=C $(READELF) -W -s $(linknamespace-libs-$*) > $@; \
430 $(evaluate-test)
432 $(linknamespace-header-tests): $(objpfx)%/linknamespace.out: \
433 linknamespace.py \
434 $(linknamespace-symlists-tests) \
435 $(linknamespace-symlist-stdlibs-tests)
436 (set -e; std_hdr=$*; std=$${std_hdr%%/*}; hdr=$${std_hdr#*/}; \
437 mkdir -p $(@D); \
438 $(PYTHON) $< --cc='$(CC)' --flags='$(conformtest-cc-flags)' \
439 --standard=$$std --stdsyms=$(objpfx)symlist-$$std \
440 --header=$$hdr --libsyms=$(objpfx)symlist-stdlibs-$$std \
441 --readelf='$(READELF)' \
442 > $@ 2>&1); \
443 $(evaluate-test)
445 # Pre-standard C feature no longer supported by GCC (obsoleted in
446 # newer POSIX standards).
447 test-xfail-XPG4/varargs.h/linknamespace = yes
448 test-xfail-XPG42/varargs.h/linknamespace = yes
449 test-xfail-UNIX98/varargs.h/linknamespace = yes
451 # Header not provided by glibc.
452 test-xfail-XPG42/ndbm.h/linknamespace = yes
453 test-xfail-UNIX98/ndbm.h/linknamespace = yes
454 test-xfail-XOPEN2K/ndbm.h/linknamespace = yes
455 test-xfail-XOPEN2K8/ndbm.h/linknamespace = yes