Makefile 11 KB

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