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 \
314 tst-stdc_count_ones \
315 tst-stdc_count_zeros \
316 tst-stdc_first_leading_one \
317 tst-stdc_first_leading_zero \
318 tst-stdc_first_trailing_one \
319 tst-stdc_first_trailing_zero \
320 tst-stdc_has_single_bit \
321 tst-stdc_leading_ones \
322 tst-stdc_leading_zeros \
323 tst-stdc_trailing_ones \
324 tst-stdc_trailing_zeros \
329 tst-strtod-nan-locale \
330 tst-strtod-nan-sign \
331 tst-strtod-overflow \
333 tst-strtod-underflow \
338 tst-strtol-binary-c11 \
339 tst-strtol-binary-c2x \
340 tst-strtol-binary-gnu11 \
341 tst-strtol-binary-gnu2x \
346 tst-thread-quick_exit \
361 tst-tls-atexit-nodelete \
372 ifeq ($(build-hardcoded-path-in-tests
),yes
)
378 LDLIBS-test-atexit-race
= $(shared-thread-library
)
379 LDLIBS-test-at_quick_exit-race
= $(shared-thread-library
)
380 LDLIBS-test-cxa_atexit-race
= $(shared-thread-library
)
381 LDLIBS-test-cxa_atexit-race2
= $(shared-thread-library
)
382 LDLIBS-test-on_exit-race
= $(shared-thread-library
)
383 LDLIBS-tst-canon-bz26341
= $(shared-thread-library
)
384 LDLIBS-tst-arc4random-fork
= $(shared-thread-library
)
385 LDLIBS-tst-arc4random-thread
= $(shared-thread-library
)
386 LDLIBS-tst-system
= $(shared-thread-library
)
388 LDLIBS-test-dlclose-exit-race
= $(shared-thread-library
)
389 LDFLAGS-test-dlclose-exit-race
= $(LDFLAGS-rdynamic
)
390 LDLIBS-test-dlclose-exit-race-helper.so
= $(libsupport
) $(shared-thread-library
)
392 CFLAGS-tst-abs.c
+= -fno-builtin
393 CFLAGS-tst-labs.c
+= -fno-builtin
394 CFLAGS-tst-llabs.c
+= -fno-builtin
396 CFLAGS-tst-stdbit-Wconversion.c
+= -Wconversion
-Werror
397 CFLAGS-tst-stdc_trailing_zeros.c
+= -fno-builtin
398 CFLAGS-tst-stdc_trailing_ones.c
+= -fno-builtin
399 CFLAGS-tst-stdc_leading_zeros.c
+= -fno-builtin
400 CFLAGS-tst-stdc_leading_ones.c
+= -fno-builtin
401 CFLAGS-tst-stdc_has_single_bit.c
+= -fno-builtin
402 CFLAGS-tst-stdc_first_trailing_zero.c
+= -fno-builtin
403 CFLAGS-tst-stdc_first_trailing_one.c
+= -fno-builtin
404 CFLAGS-tst-stdc_first_leading_zero.c
+= -fno-builtin
405 CFLAGS-tst-stdc_first_leading_one.c
+= -fno-builtin
406 CFLAGS-tst-stdc_count_zeros.c
+= -fno-builtin
407 CFLAGS-tst-stdc_count_ones.c
+= -fno-builtin
408 CFLAGS-tst-stdc_bit_width.c
+= -fno-builtin
409 CFLAGS-tst-stdc_bit_floor.c
+= -fno-builtin
410 CFLAGS-tst-stdc_bit_ceil.c
+= -fno-builtin
412 ifeq ($(have-cxx-thread_local
),yes
)
413 CFLAGS-tst-quick_exit.o
= -std
=c
++11
414 LDLIBS-tst-quick_exit
= -lstdc
++
415 CFLAGS-tst-thread-quick_exit.o
= -std
=c
++11
416 LDLIBS-tst-thread-quick_exit
= -lstdc
++
417 $(objpfx
)tst-thread-quick_exit
: $(shared-thread-library
)
419 tests-unsupported
+= \
421 tst-thread-quick_exit \
426 test-dlclose-exit-race-helper \
429 extra-test-objs
+= $(addsuffix .os
, $(modules-names
))
431 ifeq ($(build-shared
),yes
)
437 # Several mpn functions from GNU MP are used by the strtod function.
464 $(strip $(routines
) $(mpn-routines
)) \
490 CFLAGS-bsearch.c
+= $(uses-callbacks
)
491 CFLAGS-qsort.c
+= $(uses-callbacks
)
492 CFLAGS-system.c
+= -fexceptions
493 CFLAGS-system.os
= -fomit-frame-pointer
494 CFLAGS-fmtmsg.c
+= -fexceptions
496 CFLAGS-strfmon.c
+= $(libio-mtsafe
)
497 CFLAGS-strfmon_l.c
+= $(libio-mtsafe
)
499 # The strfrom class of functions call __printf_fp in order to convert the
500 # floating-point value to characters. This requires the value of IO_MTSAFE_IO.
501 CFLAGS-strfromd.c
+= $(libio-mtsafe
)
502 CFLAGS-strfromf.c
+= $(libio-mtsafe
)
503 CFLAGS-strfroml.c
+= $(libio-mtsafe
)
505 CFLAGS-strtol.c
+= $(config-cflags-wno-ignored-attributes
)
506 CFLAGS-strtoul.c
+= $(config-cflags-wno-ignored-attributes
)
507 CFLAGS-strtoll.c
+= $(config-cflags-wno-ignored-attributes
)
508 CFLAGS-strtoull.c
+= $(config-cflags-wno-ignored-attributes
)
509 CFLAGS-strtof.c
+= $(config-cflags-wno-ignored-attributes
)
510 CFLAGS-strtof_l.c
+= $(config-cflags-wno-ignored-attributes
)
511 CFLAGS-strtod.c
+= $(config-cflags-wno-ignored-attributes
)
512 CFLAGS-strtod_l.c
+= $(config-cflags-wno-ignored-attributes
)
513 CFLAGS-strtold.c
+= $(config-cflags-wno-ignored-attributes
)
514 CFLAGS-strtold_l.c
+= $(config-cflags-wno-ignored-attributes
)
515 CFLAGS-secure-getenv.c
+= $(config-cflags-wno-ignored-attributes
)
517 CFLAGS-tst-bsearch.c
+= $(stack-align-test-flags
)
518 CFLAGS-tst-qsort.c
+= $(stack-align-test-flags
)
519 CFLAGS-tst-makecontext.c
+= -funwind-tables
520 CFLAGS-tst-makecontext2.c
+= $(stack-align-test-flags
)
522 CFLAGS-testmb.c
+= -U_FORTIFY_SOURCE
-D_FORTIFY_SOURCE
=2 -Wall
-Werror
524 # Some versions of GCC supported for building glibc do not support -std=c2x
525 # or -std=gnu2x, so the tests for those versions use -std=c11 and -std=gnu11
526 # and then _ISOC2X_SOURCE is defined in the test as needed.
527 CFLAGS-tst-strtol-binary-c11.c
+= -std
=c11
528 CFLAGS-tst-strtol-binary-c2x.c
+= -std
=c11
529 CFLAGS-tst-strtol-binary-gnu11.c
+= -std
=gnu11
530 CFLAGS-tst-strtol-binary-gnu2x.c
+= -std
=gnu11
533 # Run a test on the header files we use.
534 tests-special
+= $(objpfx
)isomac.out
536 ifeq ($(run-built-tests
),yes
)
537 tests-special
+= $(objpfx
)tst-fmtmsg.out
542 ifeq ($(run-built-tests
),yes
)
554 include ..
/gen-locales.mk
556 $(objpfx
)bug-strtod2.out
: $(gen-locales
)
557 $(objpfx
)testmb2.out
: $(gen-locales
)
558 $(objpfx
)tst-strtod.out
: $(gen-locales
)
559 $(objpfx
)tst-strtod1i.out
: $(gen-locales
)
560 $(objpfx
)tst-strtod3.out
: $(gen-locales
)
561 $(objpfx
)tst-strtod4.out
: $(gen-locales
)
562 $(objpfx
)tst-strtod5.out
: $(gen-locales
)
563 $(objpfx
)tst-strtod5i.out
: $(gen-locales
)
564 $(objpfx
)tst-strtol-locale.out
: $(gen-locales
)
565 $(objpfx
)tst-strtod-nan-locale.out
: $(gen-locales
)
566 $(objpfx
)tst-strfmon_l.out
: $(gen-locales
)
567 $(objpfx
)tst-strfrom.out
: $(gen-locales
)
568 $(objpfx
)tst-strfrom-locale.out
: $(gen-locales
)
569 $(objpfx
)test-dlclose-exit-race.out
: $(objpfx
)test-dlclose-exit-race-helper.so
572 # Testdir has to be named stdlib and needs to be writable
573 test-canon-ARGS
= --test-dir
=${common-objpfx
}stdlib
575 bug-fmtmsg1-ENV
= SEV_LEVEL
=foo
,11,newsev
577 $(objpfx
)isomac.out
: $(objpfx
)isomac
578 $(dir $<)$(notdir $<) '$(CC)' \
579 '-I../include $(+sysdep-includes) $(sysincludes) -I..' > $@
; \
583 $(objpfx
)isomac
: isomac.c
586 $(objpfx
)tst-fmtmsg.out
: tst-fmtmsg.sh
$(objpfx
)tst-fmtmsg
587 $(SHELL
) $< $(common-objpfx
) '$(test-program-prefix-before-env)' \
588 '$(run-program-env)' '$(test-program-prefix-after-env)' \
589 $(common-objpfx
)stdlib
/; \
592 $(objpfx
)tst-putenv
: $(objpfx
)tst-putenvmod.so
593 LDFLAGS-tst-putenv
= -Wl
,--no-as-needed
595 $(objpfx
)tst-putenvmod.so
: $(objpfx
)tst-putenvmod.os
$(link-libc-deps
)
597 libof-tst-putenvmod
= extramodules
599 $(objpfx
)bug-getcontext
: $(libm
)
600 $(objpfx
)bug-strtod2
: $(libm
)
601 $(objpfx
)tst-strtod-round
: $(libm
)
602 $(objpfx
)tst-tininess
: $(libm
)
603 $(objpfx
)tst-strtod-underflow
: $(libm
)
604 $(objpfx
)tst-strtod6
: $(libm
)
605 $(objpfx
)tst-strtod-nan-locale
: $(libm
)
606 $(objpfx
)tst-strtod-nan-sign
: $(libm
)
608 tst-tls-atexit-lib.so-no-z-defs
= yes
609 test-dlclose-exit-race-helper.so-no-z-defs
= yes
611 $(objpfx
)tst-tls-atexit
: $(shared-thread-library
)
612 $(objpfx
)tst-tls-atexit.out
: $(objpfx
)tst-tls-atexit-lib.so
614 $(objpfx
)tst-tls-atexit-nodelete
: $(shared-thread-library
)
615 $(objpfx
)tst-tls-atexit-nodelete.out
: $(objpfx
)tst-tls-atexit-lib.so
617 $(objpfx
)tst-setcontext3.out
: tst-setcontext3.sh
$(objpfx
)tst-setcontext3
618 $(SHELL
) $< $(common-objpfx
) '$(test-program-prefix-before-env)' \
619 '$(run-program-env)' '$(test-program-prefix-after-env)' \
620 $(common-objpfx
)stdlib
/; \
623 $(objpfx
)tst-qsort5
: $(libm
)