]> git.ipfire.org Git - thirdparty/glibc.git/blame - stdlib/Makefile
Add a test for setjmp/longjmp within user context
[thirdparty/glibc.git] / stdlib / Makefile
CommitLineData
6d7e8eda 1# Copyright (C) 1991-2023 Free Software Foundation, Inc.
28f540f4
RM
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
41bdb6e2
AJ
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.
28f540f4
RM
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
41bdb6e2 12# Lesser General Public License for more details.
28f540f4 13
41bdb6e2 14# You should have received a copy of the GNU Lesser General Public
59ba27a6 15# License along with the GNU C Library; if not, see
5a82c748 16# <https://www.gnu.org/licenses/>.
28f540f4
RM
17
18#
19# Makefile for stdlib routines
20#
21subdir := stdlib
22
a5f891ac
JM
23include ../Makeconfig
24
d275970a
AZ
25headers := \
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 \
d275970a 34 bits/stdlib-ldbl.h \
91f33a30 35 bits/stdlib.h \
d275970a
AZ
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
51
52routines := \
53 a64l \
54 abort \
55 abs \
6f4e0fcf
AZN
56 arc4random \
57 arc4random_uniform \
d275970a
AZ
58 at_quick_exit \
59 atof \
60 atoi \
61 atol\
91f33a30 62 atoll \
d275970a
AZ
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 \
d275970a
AZ
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
146
20c894d2
FB
147# Exclude fortified routines from being built with _FORTIFY_SOURCE
148routines_no_fortify += \
149 mbstowcs \
150 wcstombs \
151 wctomb \
152 # routines_no_fortify
153
d275970a
AZ
154aux = \
155 grouping \
156 groupingwc \
157 tens_in_limb \
158 # aux
28f540f4 159
c08bc50a
UD
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.
d275970a 163static-only-routines = \
d275970a 164 at_quick_exit \
91f33a30 165 atexit \
d275970a
AZ
166 # static-only-routines
167
168test-srcs := \
169 tst-fmtmsg \
170 #test-srcs
c08bc50a 171
f9dab1b5
SP
172tests := \
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 \
fd78cfa7 180 test-atexit-recursive \
f9dab1b5
SP
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 \
0d21b378 193 tst-abs \
8dd890d9
AZN
194 tst-arc4random-fork \
195 tst-arc4random-stats \
196 tst-arc4random-thread \
f9dab1b5
SP
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 \
b11db301 207 tst-labs \
f9dab1b5 208 tst-limits \
d877b52d 209 tst-llabs \
f9dab1b5
SP
210 tst-makecontext \
211 tst-makecontext-align \
212 tst-makecontext2 \
213 tst-makecontext3 \
214 tst-on_exit \
215 tst-qsort \
216 tst-qsort2 \
bc888a39 217 tst-qsort3 \
64e4acf2 218 tst-qsort5 \
b9390ba9 219 tst-qsort6 \
f9dab1b5
SP
220 tst-quick_exit \
221 tst-rand48 \
222 tst-rand48-2 \
223 tst-random \
224 tst-random2 \
225 tst-realpath \
ee8d5e33 226 tst-realpath-toolong \
f9dab1b5
SP
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 \
08bc191f 237 tst-setcontext10 \
49b4de21 238 tst-setcontext11 \
f9dab1b5
SP
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 \
64924422
JM
252 tst-strtol-binary-c11 \
253 tst-strtol-binary-c2x \
254 tst-strtol-binary-gnu11 \
255 tst-strtol-binary-gnu2x \
f9dab1b5
SP
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 \
d275970a
AZ
265 # tests
266
267tests-internal := \
55364e1f 268 tst-qsort4 \
d275970a
AZ
269 tst-strtod1i \
270 tst-strtod3 \
271 tst-strtod4 \
272 tst-strtod5i \
273 tst-tls-atexit \
274 tst-tls-atexit-nodelete \
275 # tests-internal
5f3b183d 276
d275970a
AZ
277tests-static := \
278 tst-secure-getenv \
279 # tests-static
280
281tests-container := \
282 tst-system \
283 #tests-container
7c3018f9 284
41389c40 285ifeq ($(build-hardcoded-path-in-tests),yes)
d275970a
AZ
286tests += \
287 tst-empty-env \
288 # tests
41389c40 289endif
7c3018f9 290
26e70aec
PP
291LDLIBS-test-atexit-race = $(shared-thread-library)
292LDLIBS-test-at_quick_exit-race = $(shared-thread-library)
293LDLIBS-test-cxa_atexit-race = $(shared-thread-library)
16adc58e 294LDLIBS-test-cxa_atexit-race2 = $(shared-thread-library)
26e70aec 295LDLIBS-test-on_exit-race = $(shared-thread-library)
961d7cff 296LDLIBS-tst-canon-bz26341 = $(shared-thread-library)
8dd890d9
AZN
297LDLIBS-tst-arc4random-fork = $(shared-thread-library)
298LDLIBS-tst-arc4random-thread = $(shared-thread-library)
d0309464 299LDLIBS-tst-system = $(shared-thread-library)
26e70aec 300
6f1c7010 301LDLIBS-test-dlclose-exit-race = $(shared-thread-library)
e5e4d7cc
PP
302LDFLAGS-test-dlclose-exit-race = $(LDFLAGS-rdynamic)
303LDLIBS-test-dlclose-exit-race-helper.so = $(libsupport) $(shared-thread-library)
304
0d21b378 305CFLAGS-tst-abs.c += -fno-builtin
b11db301 306CFLAGS-tst-labs.c += -fno-builtin
d877b52d 307CFLAGS-tst-llabs.c += -fno-builtin
0d21b378 308
47dd3543
CD
309ifeq ($(have-cxx-thread_local),yes)
310CFLAGS-tst-quick_exit.o = -std=c++11
311LDLIBS-tst-quick_exit = -lstdc++
312CFLAGS-tst-thread-quick_exit.o = -std=c++11
313LDLIBS-tst-thread-quick_exit = -lstdc++
314$(objpfx)tst-thread-quick_exit: $(shared-thread-library)
315else
d275970a
AZ
316tests-unsupported += \
317 tst-quick_exit \
318 tst-thread-quick_exit \
319 # tests-unsupported
47dd3543 320endif
28f540f4 321
d275970a
AZ
322modules-names = \
323 test-dlclose-exit-race-helper \
324 tst-tls-atexit-lib \
325 # modules-names
b4bcb3ae 326extra-test-objs += $(addsuffix .os, $(modules-names))
ba384f6e 327
574b268e 328ifeq ($(build-shared),yes)
d275970a
AZ
329tests += \
330 tst-putenv \
331 # tests
574b268e 332endif
3ef21326
RM
333
334# Several mpn functions from GNU MP are used by the strtod function.
d275970a
AZ
335mpn-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
352mpn-headers = \
353 asm-syntax.h \
354 gmp-impl.h \
355 gmp-mparam.h \
356 gmp.h \
357 longlong.h \
358 # mpn-headers
3ef21326 359
d275970a
AZ
360routines := \
361 $(strip $(routines) $(mpn-routines)) \
362 dbl2mpn \
363 ldbl2mpn \
364 mpn2dbl \
365 mpn2flt \
366 mpn2ldbl \
367 # routines
368aux += \
369 fpioconst \
370 mp_clz_tab \
371 # aux
574b268e 372
d275970a
AZ
373tests-extras += \
374 tst-putenvmod \
375 # tests-extras
dd06af4f 376
d275970a
AZ
377extra-test-objs += \
378 tst-putenvmod.os \
379 # extra-test-objs
3ef21326 380
d275970a
AZ
381generated += \
382 isomac \
383 isomac.out \
384 tst-putenvmod.so \
385 # generated
3ef21326 386
36975e8e 387CFLAGS-bsearch.c += $(uses-callbacks)
36975e8e
L
388CFLAGS-qsort.c += $(uses-callbacks)
389CFLAGS-system.c += -fexceptions
6bbc689e 390CFLAGS-system.os = -fomit-frame-pointer
36975e8e 391CFLAGS-fmtmsg.c += -fexceptions
dff14448 392
36975e8e
L
393CFLAGS-strfmon.c += $(libio-mtsafe)
394CFLAGS-strfmon_l.c += $(libio-mtsafe)
917e27b8 395
6962682f
GG
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.
36975e8e
L
398CFLAGS-strfromd.c += $(libio-mtsafe)
399CFLAGS-strfromf.c += $(libio-mtsafe)
400CFLAGS-strfroml.c += $(libio-mtsafe)
6962682f 401
8d98c7c0
AZ
402CFLAGS-strtol.c += $(config-cflags-wno-ignored-attributes)
403CFLAGS-strtoul.c += $(config-cflags-wno-ignored-attributes)
404CFLAGS-strtoll.c += $(config-cflags-wno-ignored-attributes)
405CFLAGS-strtoull.c += $(config-cflags-wno-ignored-attributes)
406CFLAGS-strtof.c += $(config-cflags-wno-ignored-attributes)
407CFLAGS-strtof_l.c += $(config-cflags-wno-ignored-attributes)
408CFLAGS-strtod.c += $(config-cflags-wno-ignored-attributes)
409CFLAGS-strtod_l.c += $(config-cflags-wno-ignored-attributes)
410CFLAGS-strtold.c += $(config-cflags-wno-ignored-attributes)
411CFLAGS-strtold_l.c += $(config-cflags-wno-ignored-attributes)
412CFLAGS-secure-getenv.c += $(config-cflags-wno-ignored-attributes)
413
36975e8e
L
414CFLAGS-tst-bsearch.c += $(stack-align-test-flags)
415CFLAGS-tst-qsort.c += $(stack-align-test-flags)
e535ce25 416CFLAGS-tst-makecontext.c += -funwind-tables
36975e8e 417CFLAGS-tst-makecontext2.c += $(stack-align-test-flags)
a4db3439 418
35bcb08e 419CFLAGS-testmb.c += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Wall -Werror
464d189b 420
64924422
JM
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.
424CFLAGS-tst-strtol-binary-c11.c += -std=c11
425CFLAGS-tst-strtol-binary-c2x.c += -std=c11
426CFLAGS-tst-strtol-binary-gnu11.c += -std=gnu11
427CFLAGS-tst-strtol-binary-gnu2x.c += -std=gnu11
428
464d189b 429
f214606a
JM
430# Run a test on the header files we use.
431tests-special += $(objpfx)isomac.out
432
433ifeq ($(run-built-tests),yes)
434tests-special += $(objpfx)tst-fmtmsg.out
435endif
436
28f540f4 437include ../Rules
3ef21326 438
f881f6ff 439ifeq ($(run-built-tests),yes)
d275970a
AZ
440LOCALES := \
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
f881f6ff
AS
451include ../gen-locales.mk
452
453$(objpfx)bug-strtod2.out: $(gen-locales)
454$(objpfx)testmb2.out: $(gen-locales)
455$(objpfx)tst-strtod.out: $(gen-locales)
e4890300 456$(objpfx)tst-strtod1i.out: $(gen-locales)
f881f6ff
AS
457$(objpfx)tst-strtod3.out: $(gen-locales)
458$(objpfx)tst-strtod4.out: $(gen-locales)
459$(objpfx)tst-strtod5.out: $(gen-locales)
e4890300 460$(objpfx)tst-strtod5i.out: $(gen-locales)
f5eee5c7 461$(objpfx)tst-strtol-locale.out: $(gen-locales)
a7f0c5ae 462$(objpfx)tst-strtod-nan-locale.out: $(gen-locales)
985fc132 463$(objpfx)tst-strfmon_l.out: $(gen-locales)
cd74aa4d
RS
464$(objpfx)tst-strfrom.out: $(gen-locales)
465$(objpfx)tst-strfrom-locale.out: $(gen-locales)
e5e4d7cc 466$(objpfx)test-dlclose-exit-race.out: $(objpfx)test-dlclose-exit-race-helper.so
f881f6ff
AS
467endif
468
e25054c4 469# Testdir has to be named stdlib and needs to be writable
9f835f5f 470test-canon-ARGS = --test-dir=${common-objpfx}stdlib
e25054c4 471
400aa020 472bug-fmtmsg1-ENV = SEV_LEVEL=foo,11,newsev
98d3e993 473
ca41028b 474$(objpfx)isomac.out: $(objpfx)isomac
7eff7a05 475 $(dir $<)$(notdir $<) '$(CC)' \
d5afb385 476 '-I../include $(+sysdep-includes) $(sysincludes) -I..' > $@; \
f0881698 477 $(evaluate-test)
1eb687d0 478
e69924e3 479isomac-CFLAGS = -O
1eb687d0
UD
480$(objpfx)isomac: isomac.c
481 $(native-compile)
9f6c1fc4
UD
482
483$(objpfx)tst-fmtmsg.out: tst-fmtmsg.sh $(objpfx)tst-fmtmsg
8540f6d2
JM
484 $(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \
485 '$(run-program-env)' '$(test-program-prefix-after-env)' \
8f8052c2 486 $(common-objpfx)stdlib/; \
f0881698 487 $(evaluate-test)
574b268e
UD
488
489$(objpfx)tst-putenv: $(objpfx)tst-putenvmod.so
8b196ac4 490LDFLAGS-tst-putenv = -Wl,--no-as-needed
574b268e 491
fab7ce3f 492$(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os $(link-libc-deps)
574b268e 493 $(build-module)
9cd47470 494libof-tst-putenvmod = extramodules
75ea32ab 495
79520f4b 496$(objpfx)bug-getcontext: $(libm)
45f39d45 497$(objpfx)bug-strtod2: $(libm)
79520f4b
JM
498$(objpfx)tst-strtod-round: $(libm)
499$(objpfx)tst-tininess: $(libm)
500$(objpfx)tst-strtod-underflow: $(libm)
501$(objpfx)tst-strtod6: $(libm)
a7f0c5ae 502$(objpfx)tst-strtod-nan-locale: $(libm)
b12c1e79 503$(objpfx)tst-strtod-nan-sign: $(libm)
ba384f6e
SP
504
505tst-tls-atexit-lib.so-no-z-defs = yes
e5e4d7cc 506test-dlclose-exit-race-helper.so-no-z-defs = yes
ba384f6e 507
6f1c7010 508$(objpfx)tst-tls-atexit: $(shared-thread-library)
ba384f6e 509$(objpfx)tst-tls-atexit.out: $(objpfx)tst-tls-atexit-lib.so
c92d40c0 510
6f1c7010 511$(objpfx)tst-tls-atexit-nodelete: $(shared-thread-library)
90b37cac
SP
512$(objpfx)tst-tls-atexit-nodelete.out: $(objpfx)tst-tls-atexit-lib.so
513
c92d40c0
CD
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)' \
8f8052c2 517 $(common-objpfx)stdlib/; \
c92d40c0 518 $(evaluate-test)
64e4acf2
FW
519
520$(objpfx)tst-qsort5: $(libm)