]> git.ipfire.org Git - thirdparty/glibc.git/blob - stdlib/Makefile
Refer to C23 in place of C2X in glibc
[thirdparty/glibc.git] / stdlib / Makefile
1 # Copyright (C) 1991-2024 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
3
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.
8
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.
13
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/>.
17
18 #
19 # Makefile for stdlib routines
20 #
21 subdir := stdlib
22
23 include ../Makeconfig
24
25 headers := \
26 alloca.h \
27 bits/errno.h \
28 bits/indirect-return.h \
29 bits/monetary-ldbl.h \
30 bits/stdint-intn.h \
31 bits/stdint-least.h \
32 bits/stdint-uintn.h \
33 bits/stdlib-bsearch.h \
34 bits/stdlib-float.h \
35 bits/stdlib-ldbl.h \
36 bits/stdlib.h \
37 bits/time64.h \
38 bits/timesize.h \
39 bits/types/error_t.h \
40 bits/wordsize.h \
41 errno.h \
42 fmtmsg.h \
43 inttypes.h \
44 monetary.h \
45 stdbit.h \
46 stdint.h \
47 stdlib.h \
48 sys/errno.h \
49 sys/random.h \
50 sys/ucontext.h \
51 ucontext.h \
52 # headers
53
54 routines := \
55 a64l \
56 abort \
57 abs \
58 arc4random \
59 arc4random_uniform \
60 at_quick_exit \
61 atof \
62 atoi \
63 atol\
64 atoll \
65 bsearch \
66 canonicalize \
67 cxa_at_quick_exit \
68 cxa_atexit \
69 cxa_finalize \
70 cxa_thread_atexit_impl \
71 div \
72 drand48 \
73 drand48-iter \
74 drand48_r \
75 erand48 \
76 erand48_r \
77 exit \
78 fmtmsg \
79 getcontext \
80 getentropy \
81 getenv \
82 getrandom \
83 getsubopt \
84 jrand48 \
85 jrand48_r \
86 l64a \
87 labs \
88 lcong48 \
89 lcong48_r \
90 ldiv \
91 llabs \
92 lldiv \
93 lrand48 \
94 lrand48_r \
95 makecontext \
96 mblen \
97 mbstowcs \
98 mbtowc \
99 mrand48 \
100 mrand48_r \
101 nrand48 \
102 nrand48_r \
103 old_atexit \
104 on_exit atexit \
105 putenv \
106 qsort \
107 quick_exit \
108 rand \
109 rand_r \
110 random \
111 random_r \
112 rpmatch \
113 secure-getenv \
114 seed48 \
115 seed48_r \
116 setcontext \
117 setenv \
118 srand48 \
119 srand48_r \
120 stdc_bit_ceil_uc \
121 stdc_bit_ceil_ui \
122 stdc_bit_ceil_ul \
123 stdc_bit_ceil_ull \
124 stdc_bit_ceil_us \
125 stdc_bit_floor_uc \
126 stdc_bit_floor_ui \
127 stdc_bit_floor_ul \
128 stdc_bit_floor_ull \
129 stdc_bit_floor_us \
130 stdc_bit_width_uc \
131 stdc_bit_width_ui \
132 stdc_bit_width_ul \
133 stdc_bit_width_ull \
134 stdc_bit_width_us \
135 stdc_count_ones_uc \
136 stdc_count_ones_ui \
137 stdc_count_ones_ul \
138 stdc_count_ones_ull \
139 stdc_count_ones_us \
140 stdc_count_zeros_uc \
141 stdc_count_zeros_ui \
142 stdc_count_zeros_ul \
143 stdc_count_zeros_ull \
144 stdc_count_zeros_us \
145 stdc_first_leading_one_uc \
146 stdc_first_leading_one_ui \
147 stdc_first_leading_one_ul \
148 stdc_first_leading_one_ull \
149 stdc_first_leading_one_us \
150 stdc_first_leading_zero_uc \
151 stdc_first_leading_zero_ui \
152 stdc_first_leading_zero_ul \
153 stdc_first_leading_zero_ull \
154 stdc_first_leading_zero_us \
155 stdc_first_trailing_one_uc \
156 stdc_first_trailing_one_ui \
157 stdc_first_trailing_one_ul \
158 stdc_first_trailing_one_ull \
159 stdc_first_trailing_one_us \
160 stdc_first_trailing_zero_uc \
161 stdc_first_trailing_zero_ui \
162 stdc_first_trailing_zero_ul \
163 stdc_first_trailing_zero_ull \
164 stdc_first_trailing_zero_us \
165 stdc_has_single_bit_uc \
166 stdc_has_single_bit_ui \
167 stdc_has_single_bit_ul \
168 stdc_has_single_bit_ull \
169 stdc_has_single_bit_us \
170 stdc_leading_ones_uc \
171 stdc_leading_ones_ui \
172 stdc_leading_ones_ul \
173 stdc_leading_ones_ull \
174 stdc_leading_ones_us \
175 stdc_leading_zeros_uc \
176 stdc_leading_zeros_ui \
177 stdc_leading_zeros_ul \
178 stdc_leading_zeros_ull \
179 stdc_leading_zeros_us \
180 stdc_trailing_ones_uc \
181 stdc_trailing_ones_ui \
182 stdc_trailing_ones_ul \
183 stdc_trailing_ones_ull \
184 stdc_trailing_ones_us \
185 stdc_trailing_zeros_uc \
186 stdc_trailing_zeros_ui \
187 stdc_trailing_zeros_ul \
188 stdc_trailing_zeros_ull \
189 stdc_trailing_zeros_us \
190 strfmon \
191 strfmon_l \
192 strfromd \
193 strfromf \
194 strfroml \
195 strtod \
196 strtod_l \
197 strtod_nan \
198 strtof \
199 strtof_l \
200 strtof_nan \
201 strtol \
202 strtol_l \
203 strtold \
204 strtold_l \
205 strtold_nan \
206 strtoll \
207 strtoll_l \
208 strtoul \
209 strtoul_l \
210 strtoull \
211 strtoull_l \
212 swapcontext \
213 system \
214 wcstombs \
215 wctomb \
216 xpg_basename \
217 # routines
218
219 # Exclude fortified routines from being built with _FORTIFY_SOURCE
220 routines_no_fortify += \
221 mbstowcs \
222 wcstombs \
223 wctomb \
224 # routines_no_fortify
225
226 aux = \
227 grouping \
228 groupingwc \
229 tens_in_limb \
230 # aux
231
232 # These routines will be omitted from the libc shared object.
233 # Instead the static object files will be included in a special archive
234 # linked against when the shared library will be used.
235 static-only-routines = \
236 at_quick_exit \
237 atexit \
238 # static-only-routines
239
240 test-srcs := \
241 tst-fmtmsg \
242 #test-srcs
243
244 tests := \
245 bug-fmtmsg1 \
246 bug-getcontext \
247 bug-strtod \
248 bug-strtod2 \
249 test-a64l \
250 test-at_quick_exit-race \
251 test-atexit-race \
252 test-atexit-recursive \
253 test-bz22786 \
254 test-canon \
255 test-canon2 \
256 test-cxa_atexit-race \
257 test-cxa_atexit-race2 \
258 test-dlclose-exit-race \
259 test-on_exit-race \
260 testdiv \
261 testmb \
262 testmb2 \
263 testrand \
264 testsort \
265 tst-abs \
266 tst-arc4random-fork \
267 tst-arc4random-stats \
268 tst-arc4random-thread \
269 tst-at_quick_exit \
270 tst-atexit \
271 tst-atof1 \
272 tst-atof2 \
273 tst-bsearch \
274 tst-bz20544 \
275 tst-canon-bz26341 \
276 tst-cxa_atexit \
277 tst-environ \
278 tst-getrandom \
279 tst-labs \
280 tst-limits \
281 tst-llabs \
282 tst-makecontext \
283 tst-makecontext-align \
284 tst-makecontext2 \
285 tst-makecontext3 \
286 tst-on_exit \
287 tst-qsort \
288 tst-qsort2 \
289 tst-qsort3 \
290 tst-qsort6 \
291 tst-quick_exit \
292 tst-rand48 \
293 tst-rand48-2 \
294 tst-random \
295 tst-random2 \
296 tst-realpath \
297 tst-realpath-toolong \
298 tst-secure-getenv \
299 tst-setcontext \
300 tst-setcontext2 \
301 tst-setcontext3 \
302 tst-setcontext4 \
303 tst-setcontext5 \
304 tst-setcontext6 \
305 tst-setcontext7 \
306 tst-setcontext8 \
307 tst-setcontext9 \
308 tst-setcontext10 \
309 tst-setcontext11 \
310 tst-stdbit-Wconversion \
311 tst-stdbit-builtins \
312 tst-stdc_bit_ceil \
313 tst-stdc_bit_floor \
314 tst-stdc_bit_width \
315 tst-stdc_count_ones \
316 tst-stdc_count_zeros \
317 tst-stdc_first_leading_one \
318 tst-stdc_first_leading_zero \
319 tst-stdc_first_trailing_one \
320 tst-stdc_first_trailing_zero \
321 tst-stdc_has_single_bit \
322 tst-stdc_leading_ones \
323 tst-stdc_leading_zeros \
324 tst-stdc_trailing_ones \
325 tst-stdc_trailing_zeros \
326 tst-strfmon_l \
327 tst-strfrom \
328 tst-strfrom-locale \
329 tst-strtod \
330 tst-strtod-nan-locale \
331 tst-strtod-nan-sign \
332 tst-strtod-overflow \
333 tst-strtod-round \
334 tst-strtod-underflow \
335 tst-strtod2 \
336 tst-strtod5 \
337 tst-strtod6 \
338 tst-strtol \
339 tst-strtol-binary-c11 \
340 tst-strtol-binary-c2x \
341 tst-strtol-binary-gnu11 \
342 tst-strtol-binary-gnu2x \
343 tst-strtol-locale \
344 tst-strtoll \
345 tst-swapcontext1 \
346 tst-swapcontext2 \
347 tst-thread-quick_exit \
348 tst-tininess \
349 tst-unsetenv1 \
350 tst-width \
351 tst-width-stdint \
352 tst-xpg-basename \
353 # tests
354
355 tests-internal := \
356 tst-qsort4 \
357 tst-strtod1i \
358 tst-strtod3 \
359 tst-strtod4 \
360 tst-strtod5i \
361 tst-tls-atexit \
362 tst-tls-atexit-nodelete \
363 # tests-internal
364
365 tests-static := \
366 tst-secure-getenv \
367 # tests-static
368
369 tests-container := \
370 tst-system \
371 #tests-container
372
373 ifeq ($(build-hardcoded-path-in-tests),yes)
374 tests += \
375 tst-empty-env \
376 # tests
377 endif
378
379 LDLIBS-test-atexit-race = $(shared-thread-library)
380 LDLIBS-test-at_quick_exit-race = $(shared-thread-library)
381 LDLIBS-test-cxa_atexit-race = $(shared-thread-library)
382 LDLIBS-test-cxa_atexit-race2 = $(shared-thread-library)
383 LDLIBS-test-on_exit-race = $(shared-thread-library)
384 LDLIBS-tst-canon-bz26341 = $(shared-thread-library)
385 LDLIBS-tst-arc4random-fork = $(shared-thread-library)
386 LDLIBS-tst-arc4random-thread = $(shared-thread-library)
387 LDLIBS-tst-system = $(shared-thread-library)
388
389 LDLIBS-test-dlclose-exit-race = $(shared-thread-library)
390 LDFLAGS-test-dlclose-exit-race = $(LDFLAGS-rdynamic)
391 LDLIBS-test-dlclose-exit-race-helper.so = $(libsupport) $(shared-thread-library)
392
393 CFLAGS-tst-abs.c += -fno-builtin
394 CFLAGS-tst-labs.c += -fno-builtin
395 CFLAGS-tst-llabs.c += -fno-builtin
396
397 CFLAGS-tst-stdbit-Wconversion.c += -Wconversion -Werror
398 CFLAGS-tst-stdc_trailing_zeros.c += -fno-builtin
399 CFLAGS-tst-stdc_trailing_ones.c += -fno-builtin
400 CFLAGS-tst-stdc_leading_zeros.c += -fno-builtin
401 CFLAGS-tst-stdc_leading_ones.c += -fno-builtin
402 CFLAGS-tst-stdc_has_single_bit.c += -fno-builtin
403 CFLAGS-tst-stdc_first_trailing_zero.c += -fno-builtin
404 CFLAGS-tst-stdc_first_trailing_one.c += -fno-builtin
405 CFLAGS-tst-stdc_first_leading_zero.c += -fno-builtin
406 CFLAGS-tst-stdc_first_leading_one.c += -fno-builtin
407 CFLAGS-tst-stdc_count_zeros.c += -fno-builtin
408 CFLAGS-tst-stdc_count_ones.c += -fno-builtin
409 CFLAGS-tst-stdc_bit_width.c += -fno-builtin
410 CFLAGS-tst-stdc_bit_floor.c += -fno-builtin
411 CFLAGS-tst-stdc_bit_ceil.c += -fno-builtin
412
413 ifeq ($(have-cxx-thread_local),yes)
414 CFLAGS-tst-quick_exit.o = -std=c++11
415 LDLIBS-tst-quick_exit = -lstdc++
416 CFLAGS-tst-thread-quick_exit.o = -std=c++11
417 LDLIBS-tst-thread-quick_exit = -lstdc++
418 $(objpfx)tst-thread-quick_exit: $(shared-thread-library)
419 else
420 tests-unsupported += \
421 tst-quick_exit \
422 tst-thread-quick_exit \
423 # tests-unsupported
424 endif
425
426 modules-names = \
427 test-dlclose-exit-race-helper \
428 tst-tls-atexit-lib \
429 # modules-names
430 extra-test-objs += $(addsuffix .os, $(modules-names))
431
432 ifeq ($(build-shared),yes)
433 tests += \
434 tst-putenv \
435 # tests
436 endif
437
438 # Several mpn functions from GNU MP are used by the strtod function.
439 mpn-routines := \
440 add_n \
441 addmul_1 \
442 cmp \
443 divmod_1 \
444 divrem \
445 inlines \
446 lshift \
447 mod_1 \
448 mul \
449 mul_1 \
450 mul_n \
451 rshift \
452 sub_n \
453 submul_1 \
454 udiv_qrnnd \
455 # mpn-routines
456 mpn-headers = \
457 asm-syntax.h \
458 gmp-impl.h \
459 gmp-mparam.h \
460 gmp.h \
461 longlong.h \
462 # mpn-headers
463
464 routines := \
465 $(strip $(routines) $(mpn-routines)) \
466 dbl2mpn \
467 ldbl2mpn \
468 mpn2dbl \
469 mpn2flt \
470 mpn2ldbl \
471 # routines
472 aux += \
473 fpioconst \
474 mp_clz_tab \
475 # aux
476
477 tests-extras += \
478 tst-putenvmod \
479 # tests-extras
480
481 extra-test-objs += \
482 tst-putenvmod.os \
483 # extra-test-objs
484
485 generated += \
486 isomac \
487 isomac.out \
488 tst-putenvmod.so \
489 # generated
490
491 CFLAGS-bsearch.c += $(uses-callbacks)
492 CFLAGS-qsort.c += $(uses-callbacks)
493 CFLAGS-system.c += -fexceptions
494 CFLAGS-system.os = -fomit-frame-pointer
495 CFLAGS-fmtmsg.c += -fexceptions
496
497 CFLAGS-strfmon.c += $(libio-mtsafe)
498 CFLAGS-strfmon_l.c += $(libio-mtsafe)
499
500 # The strfrom class of functions call __printf_fp in order to convert the
501 # floating-point value to characters. This requires the value of IO_MTSAFE_IO.
502 CFLAGS-strfromd.c += $(libio-mtsafe)
503 CFLAGS-strfromf.c += $(libio-mtsafe)
504 CFLAGS-strfroml.c += $(libio-mtsafe)
505
506 CFLAGS-strtol.c += $(config-cflags-wno-ignored-attributes)
507 CFLAGS-strtoul.c += $(config-cflags-wno-ignored-attributes)
508 CFLAGS-strtoll.c += $(config-cflags-wno-ignored-attributes)
509 CFLAGS-strtoull.c += $(config-cflags-wno-ignored-attributes)
510 CFLAGS-strtof.c += $(config-cflags-wno-ignored-attributes)
511 CFLAGS-strtof_l.c += $(config-cflags-wno-ignored-attributes)
512 CFLAGS-strtod.c += $(config-cflags-wno-ignored-attributes)
513 CFLAGS-strtod_l.c += $(config-cflags-wno-ignored-attributes)
514 CFLAGS-strtold.c += $(config-cflags-wno-ignored-attributes)
515 CFLAGS-strtold_l.c += $(config-cflags-wno-ignored-attributes)
516 CFLAGS-secure-getenv.c += $(config-cflags-wno-ignored-attributes)
517
518 CFLAGS-tst-bsearch.c += $(stack-align-test-flags)
519 CFLAGS-tst-qsort.c += $(stack-align-test-flags)
520 CFLAGS-tst-makecontext.c += -funwind-tables
521 CFLAGS-tst-makecontext2.c += $(stack-align-test-flags)
522
523 CFLAGS-testmb.c += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Wall -Werror
524
525 # Some versions of GCC supported for building glibc do not support -std=c23
526 # or -std=gnu23 (added in GCC 14), or the older names -std=c2x or -std=gnu2x
527 # (added in GCC 9), so the tests for those versions use -std=c11 and -std=gnu11
528 # and then _ISOC23_SOURCE is defined in the test as needed.
529 CFLAGS-tst-strtol-binary-c11.c += -std=c11
530 CFLAGS-tst-strtol-binary-c2x.c += -std=c11
531 CFLAGS-tst-strtol-binary-gnu11.c += -std=gnu11
532 CFLAGS-tst-strtol-binary-gnu2x.c += -std=gnu11
533
534
535 # Run a test on the header files we use.
536 tests-special += $(objpfx)isomac.out
537
538 ifeq ($(run-built-tests),yes)
539 tests-special += $(objpfx)tst-fmtmsg.out
540 endif
541
542 include ../Rules
543
544 ifeq ($(run-built-tests),yes)
545 LOCALES := \
546 cs_CZ.UTF-8 \
547 de_DE.UTF-8 \
548 el_GR.UTF-8 \
549 en_US.ISO-8859-1 \
550 hi_IN.UTF-8 \
551 hr_HR.UTF-8 \
552 tg_TJ.UTF-8 \
553 tr_TR.ISO-8859-9 \
554 tr_TR.UTF-8 \
555 # LOCALES
556 include ../gen-locales.mk
557
558 $(objpfx)bug-strtod2.out: $(gen-locales)
559 $(objpfx)testmb2.out: $(gen-locales)
560 $(objpfx)tst-strtod.out: $(gen-locales)
561 $(objpfx)tst-strtod1i.out: $(gen-locales)
562 $(objpfx)tst-strtod3.out: $(gen-locales)
563 $(objpfx)tst-strtod4.out: $(gen-locales)
564 $(objpfx)tst-strtod5.out: $(gen-locales)
565 $(objpfx)tst-strtod5i.out: $(gen-locales)
566 $(objpfx)tst-strtol-locale.out: $(gen-locales)
567 $(objpfx)tst-strtod-nan-locale.out: $(gen-locales)
568 $(objpfx)tst-strfmon_l.out: $(gen-locales)
569 $(objpfx)tst-strfrom.out: $(gen-locales)
570 $(objpfx)tst-strfrom-locale.out: $(gen-locales)
571 $(objpfx)test-dlclose-exit-race.out: $(objpfx)test-dlclose-exit-race-helper.so
572 endif
573
574 # Testdir has to be named stdlib and needs to be writable
575 test-canon-ARGS = --test-dir=${common-objpfx}stdlib
576
577 bug-fmtmsg1-ENV = SEV_LEVEL=foo,11,newsev
578
579 $(objpfx)isomac.out: $(objpfx)isomac
580 $(dir $<)$(notdir $<) '$(CC)' \
581 '-I../include $(+sysdep-includes) $(sysincludes) -I..' > $@; \
582 $(evaluate-test)
583
584 isomac-CFLAGS = -O
585 $(objpfx)isomac: isomac.c
586 $(native-compile)
587
588 $(objpfx)tst-fmtmsg.out: tst-fmtmsg.sh $(objpfx)tst-fmtmsg
589 $(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \
590 '$(run-program-env)' '$(test-program-prefix-after-env)' \
591 $(common-objpfx)stdlib/; \
592 $(evaluate-test)
593
594 $(objpfx)tst-putenv: $(objpfx)tst-putenvmod.so
595 LDFLAGS-tst-putenv = -Wl,--no-as-needed
596
597 $(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os $(link-libc-deps)
598 $(build-module)
599 libof-tst-putenvmod = extramodules
600
601 $(objpfx)bug-getcontext: $(libm)
602 $(objpfx)bug-strtod2: $(libm)
603 $(objpfx)tst-strtod-round: $(libm)
604 $(objpfx)tst-tininess: $(libm)
605 $(objpfx)tst-strtod-underflow: $(libm)
606 $(objpfx)tst-strtod6: $(libm)
607 $(objpfx)tst-strtod-nan-locale: $(libm)
608 $(objpfx)tst-strtod-nan-sign: $(libm)
609
610 tst-tls-atexit-lib.so-no-z-defs = yes
611 test-dlclose-exit-race-helper.so-no-z-defs = yes
612
613 $(objpfx)tst-tls-atexit: $(shared-thread-library)
614 $(objpfx)tst-tls-atexit.out: $(objpfx)tst-tls-atexit-lib.so
615
616 $(objpfx)tst-tls-atexit-nodelete: $(shared-thread-library)
617 $(objpfx)tst-tls-atexit-nodelete.out: $(objpfx)tst-tls-atexit-lib.so
618
619 $(objpfx)tst-setcontext3.out: tst-setcontext3.sh $(objpfx)tst-setcontext3
620 $(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \
621 '$(run-program-env)' '$(test-program-prefix-after-env)' \
622 $(common-objpfx)stdlib/; \
623 $(evaluate-test)
624
625 $(objpfx)tst-qsort5: $(libm)