1 # Copyright (C) 1991-2023 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 \
32 bits/stdlib-bsearch.h \
38 bits/types/error_t.h \
68 cxa_thread_atexit_impl \
148 # Exclude fortified routines from being built with _FORTIFY_SOURCE
149 routines_no_fortify += \
153 # routines_no_fortify
161 # These routines will be omitted from the libc shared object.
162 # Instead the static object files will be included in a special archive
163 # linked against when the shared library will be used.
164 static-only-routines = \
167 # static-only-routines
179 test-at_quick_exit-race \
181 test-atexit-recursive \
185 test-cxa_atexit-race \
186 test-cxa_atexit-race2 \
187 test-dlclose-exit-race \
195 tst-arc4random-fork \
196 tst-arc4random-stats \
197 tst-arc4random-thread \
212 tst-makecontext-align \
224 tst-realpath-toolong \
239 tst-strtod-nan-locale \
240 tst-strtod-nan-sign \
241 tst-strtod-overflow \
243 tst-strtod-underflow \
248 tst-strtol-binary-c11 \
249 tst-strtol-binary-c2x \
250 tst-strtol-binary-gnu11 \
251 tst-strtol-binary-gnu2x \
255 tst-thread-quick_exit \
269 tst-tls-atexit-nodelete \
280 ifeq ($(build-hardcoded-path-in-tests),yes)
286 LDLIBS-test-atexit-race = $(shared-thread-library)
287 LDLIBS-test-at_quick_exit-race = $(shared-thread-library)
288 LDLIBS-test-cxa_atexit-race = $(shared-thread-library)
289 LDLIBS-test-cxa_atexit-race2 = $(shared-thread-library)
290 LDLIBS-test-on_exit-race = $(shared-thread-library)
291 LDLIBS-tst-canon-bz26341 = $(shared-thread-library)
292 LDLIBS-tst-arc4random-fork = $(shared-thread-library)
293 LDLIBS-tst-arc4random-thread = $(shared-thread-library)
294 LDLIBS-tst-system = $(shared-thread-library)
296 LDLIBS-test-dlclose-exit-race = $(shared-thread-library)
297 LDFLAGS-test-dlclose-exit-race = $(LDFLAGS-rdynamic)
298 LDLIBS-test-dlclose-exit-race-helper.so = $(libsupport) $(shared-thread-library)
300 CFLAGS-tst-abs.c += -fno-builtin
301 CFLAGS-tst-labs.c += -fno-builtin
302 CFLAGS-tst-llabs.c += -fno-builtin
304 ifeq ($(have-cxx-thread_local),yes)
305 CFLAGS-tst-quick_exit.o = -std=c++11
306 LDLIBS-tst-quick_exit = -lstdc++
307 CFLAGS-tst-thread-quick_exit.o = -std=c++11
308 LDLIBS-tst-thread-quick_exit = -lstdc++
309 $(objpfx)tst-thread-quick_exit: $(shared-thread-library)
311 tests-unsupported += \
313 tst-thread-quick_exit \
318 test-dlclose-exit-race-helper \
321 extra-test-objs += $(addsuffix .os, $(modules-names))
323 ifeq ($(build-shared),yes)
329 # Several mpn functions from GNU MP are used by the strtod function.
356 $(strip $(routines) $(mpn-routines)) \
382 CFLAGS-bsearch.c += $(uses-callbacks)
383 CFLAGS-msort.c += $(uses-callbacks)
384 CFLAGS-qsort.c += $(uses-callbacks)
385 CFLAGS-system.c += -fexceptions
386 CFLAGS-system.os = -fomit-frame-pointer
387 CFLAGS-fmtmsg.c += -fexceptions
389 CFLAGS-strfmon.c += $(libio-mtsafe)
390 CFLAGS-strfmon_l.c += $(libio-mtsafe)
392 # The strfrom class of functions call __printf_fp in order to convert the
393 # floating-point value to characters. This requires the value of IO_MTSAFE_IO.
394 CFLAGS-strfromd.c += $(libio-mtsafe)
395 CFLAGS-strfromf.c += $(libio-mtsafe)
396 CFLAGS-strfroml.c += $(libio-mtsafe)
398 CFLAGS-strtol.c += $(config-cflags-wno-ignored-attributes)
399 CFLAGS-strtoul.c += $(config-cflags-wno-ignored-attributes)
400 CFLAGS-strtoll.c += $(config-cflags-wno-ignored-attributes)
401 CFLAGS-strtoull.c += $(config-cflags-wno-ignored-attributes)
402 CFLAGS-strtof.c += $(config-cflags-wno-ignored-attributes)
403 CFLAGS-strtof_l.c += $(config-cflags-wno-ignored-attributes)
404 CFLAGS-strtod.c += $(config-cflags-wno-ignored-attributes)
405 CFLAGS-strtod_l.c += $(config-cflags-wno-ignored-attributes)
406 CFLAGS-strtold.c += $(config-cflags-wno-ignored-attributes)
407 CFLAGS-strtold_l.c += $(config-cflags-wno-ignored-attributes)
408 CFLAGS-secure-getenv.c += $(config-cflags-wno-ignored-attributes)
410 CFLAGS-tst-bsearch.c += $(stack-align-test-flags)
411 CFLAGS-tst-qsort.c += $(stack-align-test-flags)
412 CFLAGS-tst-makecontext.c += -funwind-tables
413 CFLAGS-tst-makecontext2.c += $(stack-align-test-flags)
415 CFLAGS-testmb.c += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Wall -Werror
417 # Some versions of GCC supported for building glibc do not support -std=c2x
418 # or -std=gnu2x, so the tests for those versions use -std=c11 and -std=gnu11
419 # and then _ISOC2X_SOURCE is defined in the test as needed.
420 CFLAGS-tst-strtol-binary-c11.c += -std=c11
421 CFLAGS-tst-strtol-binary-c2x.c += -std=c11
422 CFLAGS-tst-strtol-binary-gnu11.c += -std=gnu11
423 CFLAGS-tst-strtol-binary-gnu2x.c += -std=gnu11
426 # Run a test on the header files we use.
427 tests-special += $(objpfx)isomac.out
429 ifeq ($(run-built-tests),yes)
430 tests-special += $(objpfx)tst-fmtmsg.out
435 ifeq ($(run-built-tests),yes)
447 include ../gen-locales.mk
449 $(objpfx)bug-strtod2.out: $(gen-locales)
450 $(objpfx)testmb2.out: $(gen-locales)
451 $(objpfx)tst-strtod.out: $(gen-locales)
452 $(objpfx)tst-strtod1i.out: $(gen-locales)
453 $(objpfx)tst-strtod3.out: $(gen-locales)
454 $(objpfx)tst-strtod4.out: $(gen-locales)
455 $(objpfx)tst-strtod5.out: $(gen-locales)
456 $(objpfx)tst-strtod5i.out: $(gen-locales)
457 $(objpfx)tst-strtol-locale.out: $(gen-locales)
458 $(objpfx)tst-strtod-nan-locale.out: $(gen-locales)
459 $(objpfx)tst-strfmon_l.out: $(gen-locales)
460 $(objpfx)tst-strfrom.out: $(gen-locales)
461 $(objpfx)tst-strfrom-locale.out: $(gen-locales)
462 $(objpfx)test-dlclose-exit-race.out: $(objpfx)test-dlclose-exit-race-helper.so
465 # Testdir has to be named stdlib and needs to be writable
466 test-canon-ARGS = --test-dir=${common-objpfx}stdlib
468 bug-fmtmsg1-ENV = SEV_LEVEL=foo,11,newsev
470 $(objpfx)isomac.out: $(objpfx)isomac
471 $(dir $<)$(notdir $<) '$(CC)' \
472 '-I../include $(+sysdep-includes) $(sysincludes) -I..' > $@; \
476 $(objpfx)isomac: isomac.c
479 $(objpfx)tst-fmtmsg.out: tst-fmtmsg.sh $(objpfx)tst-fmtmsg
480 $(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \
481 '$(run-program-env)' '$(test-program-prefix-after-env)' \
482 $(common-objpfx)stdlib/; \
485 $(objpfx)tst-putenv: $(objpfx)tst-putenvmod.so
486 LDFLAGS-tst-putenv = -Wl,--no-as-needed
488 $(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os $(link-libc-deps)
490 libof-tst-putenvmod = extramodules
492 $(objpfx)bug-getcontext: $(libm)
493 $(objpfx)bug-strtod2: $(libm)
494 $(objpfx)tst-strtod-round: $(libm)
495 $(objpfx)tst-tininess: $(libm)
496 $(objpfx)tst-strtod-underflow: $(libm)
497 $(objpfx)tst-strtod6: $(libm)
498 $(objpfx)tst-strtod-nan-locale: $(libm)
499 $(objpfx)tst-strtod-nan-sign: $(libm)
501 tst-tls-atexit-lib.so-no-z-defs = yes
502 test-dlclose-exit-race-helper.so-no-z-defs = yes
504 $(objpfx)tst-tls-atexit: $(shared-thread-library)
505 $(objpfx)tst-tls-atexit.out: $(objpfx)tst-tls-atexit-lib.so
507 $(objpfx)tst-tls-atexit-nodelete: $(shared-thread-library)
508 $(objpfx)tst-tls-atexit-nodelete.out: $(objpfx)tst-tls-atexit-lib.so
510 $(objpfx)tst-setcontext3.out: tst-setcontext3.sh $(objpfx)tst-setcontext3
511 $(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \
512 '$(run-program-env)' '$(test-program-prefix-after-env)' \
513 $(common-objpfx)stdlib/; \