Add a test for setjmp/longjmp within user context
[glibc.git] / stdlib / Makefile
blob0b5ef699a2592fb8b36ce471cc54226d9862d2e2
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
21 subdir := stdlib
23 include ../Makeconfig
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-uintn.h \
32 bits/stdlib-bsearch.h \
33 bits/stdlib-float.h \
34 bits/stdlib-ldbl.h \
35 bits/stdlib.h \
36 bits/time64.h \
37 bits/timesize.h \
38 bits/types/error_t.h \
39 bits/wordsize.h \
40 errno.h \
41 fmtmsg.h \
42 inttypes.h \
43 monetary.h \
44 stdint.h \
45 stdlib.h \
46 sys/errno.h \
47 sys/random.h \
48 sys/ucontext.h \
49 ucontext.h \
50 # headers
52 routines := \
53 a64l \
54 abort \
55 abs \
56 arc4random \
57 arc4random_uniform \
58 at_quick_exit \
59 atof \
60 atoi \
61 atol\
62 atoll \
63 bsearch \
64 canonicalize \
65 cxa_at_quick_exit \
66 cxa_atexit \
67 cxa_finalize \
68 cxa_thread_atexit_impl \
69 div \
70 drand48 \
71 drand48-iter \
72 drand48_r \
73 erand48 \
74 erand48_r \
75 exit \
76 fmtmsg \
77 getcontext \
78 getentropy \
79 getenv \
80 getrandom \
81 getsubopt \
82 jrand48 \
83 jrand48_r \
84 l64a \
85 labs \
86 lcong48 \
87 lcong48_r \
88 ldiv \
89 llabs \
90 lldiv \
91 lrand48 \
92 lrand48_r \
93 makecontext \
94 mblen \
95 mbstowcs \
96 mbtowc \
97 mrand48 \
98 mrand48_r \
99 nrand48 \
100 nrand48_r \
101 old_atexit \
102 on_exit atexit \
103 putenv \
104 qsort \
105 quick_exit \
106 rand \
107 rand_r \
108 random \
109 random_r \
110 rpmatch \
111 secure-getenv \
112 seed48 \
113 seed48_r \
114 setcontext \
115 setenv \
116 srand48 \
117 srand48_r \
118 strfmon \
119 strfmon_l \
120 strfromd \
121 strfromf \
122 strfroml \
123 strtod \
124 strtod_l \
125 strtod_nan \
126 strtof \
127 strtof_l \
128 strtof_nan \
129 strtol \
130 strtol_l \
131 strtold \
132 strtold_l \
133 strtold_nan \
134 strtoll \
135 strtoll_l \
136 strtoul \
137 strtoul_l \
138 strtoull \
139 strtoull_l \
140 swapcontext \
141 system \
142 wcstombs \
143 wctomb \
144 xpg_basename \
145 # routines
147 # Exclude fortified routines from being built with _FORTIFY_SOURCE
148 routines_no_fortify += \
149 mbstowcs \
150 wcstombs \
151 wctomb \
152 # routines_no_fortify
154 aux = \
155 grouping \
156 groupingwc \
157 tens_in_limb \
158 # aux
160 # These routines will be omitted from the libc shared object.
161 # Instead the static object files will be included in a special archive
162 # linked against when the shared library will be used.
163 static-only-routines = \
164 at_quick_exit \
165 atexit \
166 # static-only-routines
168 test-srcs := \
169 tst-fmtmsg \
170 #test-srcs
172 tests := \
173 bug-fmtmsg1 \
174 bug-getcontext \
175 bug-strtod \
176 bug-strtod2 \
177 test-a64l \
178 test-at_quick_exit-race \
179 test-atexit-race \
180 test-atexit-recursive \
181 test-bz22786 \
182 test-canon \
183 test-canon2 \
184 test-cxa_atexit-race \
185 test-cxa_atexit-race2 \
186 test-dlclose-exit-race \
187 test-on_exit-race \
188 testdiv \
189 testmb \
190 testmb2 \
191 testrand \
192 testsort \
193 tst-abs \
194 tst-arc4random-fork \
195 tst-arc4random-stats \
196 tst-arc4random-thread \
197 tst-at_quick_exit \
198 tst-atexit \
199 tst-atof1 \
200 tst-atof2 \
201 tst-bsearch \
202 tst-bz20544 \
203 tst-canon-bz26341 \
204 tst-cxa_atexit \
205 tst-environ \
206 tst-getrandom \
207 tst-labs \
208 tst-limits \
209 tst-llabs \
210 tst-makecontext \
211 tst-makecontext-align \
212 tst-makecontext2 \
213 tst-makecontext3 \
214 tst-on_exit \
215 tst-qsort \
216 tst-qsort2 \
217 tst-qsort3 \
218 tst-qsort5 \
219 tst-qsort6 \
220 tst-quick_exit \
221 tst-rand48 \
222 tst-rand48-2 \
223 tst-random \
224 tst-random2 \
225 tst-realpath \
226 tst-realpath-toolong \
227 tst-secure-getenv \
228 tst-setcontext \
229 tst-setcontext2 \
230 tst-setcontext3 \
231 tst-setcontext4 \
232 tst-setcontext5 \
233 tst-setcontext6 \
234 tst-setcontext7 \
235 tst-setcontext8 \
236 tst-setcontext9 \
237 tst-setcontext10 \
238 tst-setcontext11 \
239 tst-strfmon_l \
240 tst-strfrom \
241 tst-strfrom-locale \
242 tst-strtod \
243 tst-strtod-nan-locale \
244 tst-strtod-nan-sign \
245 tst-strtod-overflow \
246 tst-strtod-round \
247 tst-strtod-underflow \
248 tst-strtod2 \
249 tst-strtod5 \
250 tst-strtod6 \
251 tst-strtol \
252 tst-strtol-binary-c11 \
253 tst-strtol-binary-c2x \
254 tst-strtol-binary-gnu11 \
255 tst-strtol-binary-gnu2x \
256 tst-strtol-locale \
257 tst-strtoll \
258 tst-swapcontext1 \
259 tst-thread-quick_exit \
260 tst-tininess \
261 tst-unsetenv1 \
262 tst-width \
263 tst-width-stdint \
264 tst-xpg-basename \
265 # tests
267 tests-internal := \
268 tst-qsort4 \
269 tst-strtod1i \
270 tst-strtod3 \
271 tst-strtod4 \
272 tst-strtod5i \
273 tst-tls-atexit \
274 tst-tls-atexit-nodelete \
275 # tests-internal
277 tests-static := \
278 tst-secure-getenv \
279 # tests-static
281 tests-container := \
282 tst-system \
283 #tests-container
285 ifeq ($(build-hardcoded-path-in-tests),yes)
286 tests += \
287 tst-empty-env \
288 # tests
289 endif
291 LDLIBS-test-atexit-race = $(shared-thread-library)
292 LDLIBS-test-at_quick_exit-race = $(shared-thread-library)
293 LDLIBS-test-cxa_atexit-race = $(shared-thread-library)
294 LDLIBS-test-cxa_atexit-race2 = $(shared-thread-library)
295 LDLIBS-test-on_exit-race = $(shared-thread-library)
296 LDLIBS-tst-canon-bz26341 = $(shared-thread-library)
297 LDLIBS-tst-arc4random-fork = $(shared-thread-library)
298 LDLIBS-tst-arc4random-thread = $(shared-thread-library)
299 LDLIBS-tst-system = $(shared-thread-library)
301 LDLIBS-test-dlclose-exit-race = $(shared-thread-library)
302 LDFLAGS-test-dlclose-exit-race = $(LDFLAGS-rdynamic)
303 LDLIBS-test-dlclose-exit-race-helper.so = $(libsupport) $(shared-thread-library)
305 CFLAGS-tst-abs.c += -fno-builtin
306 CFLAGS-tst-labs.c += -fno-builtin
307 CFLAGS-tst-llabs.c += -fno-builtin
309 ifeq ($(have-cxx-thread_local),yes)
310 CFLAGS-tst-quick_exit.o = -std=c++11
311 LDLIBS-tst-quick_exit = -lstdc++
312 CFLAGS-tst-thread-quick_exit.o = -std=c++11
313 LDLIBS-tst-thread-quick_exit = -lstdc++
314 $(objpfx)tst-thread-quick_exit: $(shared-thread-library)
315 else
316 tests-unsupported += \
317 tst-quick_exit \
318 tst-thread-quick_exit \
319 # tests-unsupported
320 endif
322 modules-names = \
323 test-dlclose-exit-race-helper \
324 tst-tls-atexit-lib \
325 # modules-names
326 extra-test-objs += $(addsuffix .os, $(modules-names))
328 ifeq ($(build-shared),yes)
329 tests += \
330 tst-putenv \
331 # tests
332 endif
334 # Several mpn functions from GNU MP are used by the strtod function.
335 mpn-routines := \
336 add_n \
337 addmul_1 \
338 cmp \
339 divmod_1 \
340 divrem \
341 inlines \
342 lshift \
343 mod_1 \
344 mul \
345 mul_1 \
346 mul_n \
347 rshift \
348 sub_n \
349 submul_1 \
350 udiv_qrnnd \
351 # mpn-routines
352 mpn-headers = \
353 asm-syntax.h \
354 gmp-impl.h \
355 gmp-mparam.h \
356 gmp.h \
357 longlong.h \
358 # mpn-headers
360 routines := \
361 $(strip $(routines) $(mpn-routines)) \
362 dbl2mpn \
363 ldbl2mpn \
364 mpn2dbl \
365 mpn2flt \
366 mpn2ldbl \
367 # routines
368 aux += \
369 fpioconst \
370 mp_clz_tab \
371 # aux
373 tests-extras += \
374 tst-putenvmod \
375 # tests-extras
377 extra-test-objs += \
378 tst-putenvmod.os \
379 # extra-test-objs
381 generated += \
382 isomac \
383 isomac.out \
384 tst-putenvmod.so \
385 # generated
387 CFLAGS-bsearch.c += $(uses-callbacks)
388 CFLAGS-qsort.c += $(uses-callbacks)
389 CFLAGS-system.c += -fexceptions
390 CFLAGS-system.os = -fomit-frame-pointer
391 CFLAGS-fmtmsg.c += -fexceptions
393 CFLAGS-strfmon.c += $(libio-mtsafe)
394 CFLAGS-strfmon_l.c += $(libio-mtsafe)
396 # The strfrom class of functions call __printf_fp in order to convert the
397 # floating-point value to characters. This requires the value of IO_MTSAFE_IO.
398 CFLAGS-strfromd.c += $(libio-mtsafe)
399 CFLAGS-strfromf.c += $(libio-mtsafe)
400 CFLAGS-strfroml.c += $(libio-mtsafe)
402 CFLAGS-strtol.c += $(config-cflags-wno-ignored-attributes)
403 CFLAGS-strtoul.c += $(config-cflags-wno-ignored-attributes)
404 CFLAGS-strtoll.c += $(config-cflags-wno-ignored-attributes)
405 CFLAGS-strtoull.c += $(config-cflags-wno-ignored-attributes)
406 CFLAGS-strtof.c += $(config-cflags-wno-ignored-attributes)
407 CFLAGS-strtof_l.c += $(config-cflags-wno-ignored-attributes)
408 CFLAGS-strtod.c += $(config-cflags-wno-ignored-attributes)
409 CFLAGS-strtod_l.c += $(config-cflags-wno-ignored-attributes)
410 CFLAGS-strtold.c += $(config-cflags-wno-ignored-attributes)
411 CFLAGS-strtold_l.c += $(config-cflags-wno-ignored-attributes)
412 CFLAGS-secure-getenv.c += $(config-cflags-wno-ignored-attributes)
414 CFLAGS-tst-bsearch.c += $(stack-align-test-flags)
415 CFLAGS-tst-qsort.c += $(stack-align-test-flags)
416 CFLAGS-tst-makecontext.c += -funwind-tables
417 CFLAGS-tst-makecontext2.c += $(stack-align-test-flags)
419 CFLAGS-testmb.c += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Wall -Werror
421 # Some versions of GCC supported for building glibc do not support -std=c2x
422 # or -std=gnu2x, so the tests for those versions use -std=c11 and -std=gnu11
423 # and then _ISOC2X_SOURCE is defined in the test as needed.
424 CFLAGS-tst-strtol-binary-c11.c += -std=c11
425 CFLAGS-tst-strtol-binary-c2x.c += -std=c11
426 CFLAGS-tst-strtol-binary-gnu11.c += -std=gnu11
427 CFLAGS-tst-strtol-binary-gnu2x.c += -std=gnu11
430 # Run a test on the header files we use.
431 tests-special += $(objpfx)isomac.out
433 ifeq ($(run-built-tests),yes)
434 tests-special += $(objpfx)tst-fmtmsg.out
435 endif
437 include ../Rules
439 ifeq ($(run-built-tests),yes)
440 LOCALES := \
441 cs_CZ.UTF-8 \
442 de_DE.UTF-8 \
443 el_GR.UTF-8 \
444 en_US.ISO-8859-1 \
445 hi_IN.UTF-8 \
446 hr_HR.UTF-8 \
447 tg_TJ.UTF-8 \
448 tr_TR.ISO-8859-9 \
449 tr_TR.UTF-8 \
450 # LOCALES
451 include ../gen-locales.mk
453 $(objpfx)bug-strtod2.out: $(gen-locales)
454 $(objpfx)testmb2.out: $(gen-locales)
455 $(objpfx)tst-strtod.out: $(gen-locales)
456 $(objpfx)tst-strtod1i.out: $(gen-locales)
457 $(objpfx)tst-strtod3.out: $(gen-locales)
458 $(objpfx)tst-strtod4.out: $(gen-locales)
459 $(objpfx)tst-strtod5.out: $(gen-locales)
460 $(objpfx)tst-strtod5i.out: $(gen-locales)
461 $(objpfx)tst-strtol-locale.out: $(gen-locales)
462 $(objpfx)tst-strtod-nan-locale.out: $(gen-locales)
463 $(objpfx)tst-strfmon_l.out: $(gen-locales)
464 $(objpfx)tst-strfrom.out: $(gen-locales)
465 $(objpfx)tst-strfrom-locale.out: $(gen-locales)
466 $(objpfx)test-dlclose-exit-race.out: $(objpfx)test-dlclose-exit-race-helper.so
467 endif
469 # Testdir has to be named stdlib and needs to be writable
470 test-canon-ARGS = --test-dir=${common-objpfx}stdlib
472 bug-fmtmsg1-ENV = SEV_LEVEL=foo,11,newsev
474 $(objpfx)isomac.out: $(objpfx)isomac
475 $(dir $<)$(notdir $<) '$(CC)' \
476 '-I../include $(+sysdep-includes) $(sysincludes) -I..' > $@; \
477 $(evaluate-test)
479 isomac-CFLAGS = -O
480 $(objpfx)isomac: isomac.c
481 $(native-compile)
483 $(objpfx)tst-fmtmsg.out: tst-fmtmsg.sh $(objpfx)tst-fmtmsg
484 $(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \
485 '$(run-program-env)' '$(test-program-prefix-after-env)' \
486 $(common-objpfx)stdlib/; \
487 $(evaluate-test)
489 $(objpfx)tst-putenv: $(objpfx)tst-putenvmod.so
490 LDFLAGS-tst-putenv = -Wl,--no-as-needed
492 $(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os $(link-libc-deps)
493 $(build-module)
494 libof-tst-putenvmod = extramodules
496 $(objpfx)bug-getcontext: $(libm)
497 $(objpfx)bug-strtod2: $(libm)
498 $(objpfx)tst-strtod-round: $(libm)
499 $(objpfx)tst-tininess: $(libm)
500 $(objpfx)tst-strtod-underflow: $(libm)
501 $(objpfx)tst-strtod6: $(libm)
502 $(objpfx)tst-strtod-nan-locale: $(libm)
503 $(objpfx)tst-strtod-nan-sign: $(libm)
505 tst-tls-atexit-lib.so-no-z-defs = yes
506 test-dlclose-exit-race-helper.so-no-z-defs = yes
508 $(objpfx)tst-tls-atexit: $(shared-thread-library)
509 $(objpfx)tst-tls-atexit.out: $(objpfx)tst-tls-atexit-lib.so
511 $(objpfx)tst-tls-atexit-nodelete: $(shared-thread-library)
512 $(objpfx)tst-tls-atexit-nodelete.out: $(objpfx)tst-tls-atexit-lib.so
514 $(objpfx)tst-setcontext3.out: tst-setcontext3.sh $(objpfx)tst-setcontext3
515 $(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \
516 '$(run-program-env)' '$(test-program-prefix-after-env)' \
517 $(common-objpfx)stdlib/; \
518 $(evaluate-test)
520 $(objpfx)tst-qsort5: $(libm)