1 # Copyright (C) 1991-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 # Makefile for stdlib routines
28 bits
/indirect-return.h \
29 bits
/monetary-ldbl.h \
33 bits
/stdlib-bsearch.h \
39 bits
/types
/error_t.h \
70 cxa_thread_atexit_impl \
138 stdc_count_ones_ull \
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 \
219 # Exclude fortified routines from being built with _FORTIFY_SOURCE
220 routines_no_fortify
+= \
224 # routines_no_fortify
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
= \
238 # static-only-routines
250 test-at_quick_exit-race \
252 test-atexit-recursive \
256 test-cxa_atexit-race \
257 test-cxa_atexit-race2 \
258 test-dlclose-exit-race \
266 tst-arc4random-fork \
267 tst-arc4random-stats \
268 tst-arc4random-thread \
283 tst-makecontext-align \
297 tst-realpath-toolong \
310 tst-stdbit-Wconversion \
311 tst-stdbit-builtins \
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 \
330 tst-strtod-nan-locale \
331 tst-strtod-nan-sign \
332 tst-strtod-overflow \
334 tst-strtod-underflow \
339 tst-strtol-binary-c11 \
340 tst-strtol-binary-c2x \
341 tst-strtol-binary-gnu11 \
342 tst-strtol-binary-gnu2x \
347 tst-thread-quick_exit \
362 tst-tls-atexit-nodelete \
373 ifeq ($(build-hardcoded-path-in-tests
),yes
)
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
)
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
)
393 CFLAGS-tst-abs.c
+= -fno-builtin
394 CFLAGS-tst-labs.c
+= -fno-builtin
395 CFLAGS-tst-llabs.c
+= -fno-builtin
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
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
)
420 tests-unsupported
+= \
422 tst-thread-quick_exit \
427 test-dlclose-exit-race-helper \
430 extra-test-objs
+= $(addsuffix .os
, $(modules-names
))
432 ifeq ($(build-shared
),yes
)
438 # Several mpn functions from GNU MP are used by the strtod function.
465 $(strip $(routines
) $(mpn-routines
)) \
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
497 CFLAGS-strfmon.c
+= $(libio-mtsafe
)
498 CFLAGS-strfmon_l.c
+= $(libio-mtsafe
)
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
)
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
)
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
)
523 CFLAGS-testmb.c
+= -U_FORTIFY_SOURCE
-D_FORTIFY_SOURCE
=2 -Wall
-Werror
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
535 # Run a test on the header files we use.
536 tests-special
+= $(objpfx
)isomac.out
538 ifeq ($(run-built-tests
),yes
)
539 tests-special
+= $(objpfx
)tst-fmtmsg.out
544 ifeq ($(run-built-tests
),yes
)
556 include ..
/gen-locales.mk
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
574 # Testdir has to be named stdlib and needs to be writable
575 test-canon-ARGS
= --test-dir
=${common-objpfx
}stdlib
577 bug-fmtmsg1-ENV
= SEV_LEVEL
=foo
,11,newsev
579 $(objpfx
)isomac.out
: $(objpfx
)isomac
580 $(dir $<)$(notdir $<) '$(CC)' \
581 '-I../include $(+sysdep-includes) $(sysincludes) -I..' > $@
; \
585 $(objpfx
)isomac
: isomac.c
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
/; \
594 $(objpfx
)tst-putenv
: $(objpfx
)tst-putenvmod.so
595 LDFLAGS-tst-putenv
= -Wl
,--no-as-needed
597 $(objpfx
)tst-putenvmod.so
: $(objpfx
)tst-putenvmod.os
$(link-libc-deps
)
599 libof-tst-putenvmod
= extramodules
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
)
610 tst-tls-atexit-lib.so-no-z-defs
= yes
611 test-dlclose-exit-race-helper.so-no-z-defs
= yes
613 $(objpfx
)tst-tls-atexit
: $(shared-thread-library
)
614 $(objpfx
)tst-tls-atexit.out
: $(objpfx
)tst-tls-atexit-lib.so
616 $(objpfx
)tst-tls-atexit-nodelete
: $(shared-thread-library
)
617 $(objpfx
)tst-tls-atexit-nodelete.out
: $(objpfx
)tst-tls-atexit-lib.so
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
/; \
625 $(objpfx
)tst-qsort5
: $(libm
)