]> git.ipfire.org Git - thirdparty/glibc.git/blob - stdlib/Makefile
stdlib: Add testcases for abs(). (BZ #30263)
[thirdparty/glibc.git] / stdlib / Makefile
1 # Copyright (C) 1991-2023 Free Software Foundation, Inc.
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
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.
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
12 # Lesser General Public License for more details.
13
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/>.
17
18 #
19 # Makefile for stdlib routines
20 #
21 subdir := stdlib
22
23 include ../Makeconfig
24
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
51
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 msort \
100 nrand48 \
101 nrand48_r \
102 old_atexit \
103 on_exit atexit \
104 putenv \
105 qsort \
106 quick_exit \
107 rand \
108 rand_r \
109 random \
110 random_r \
111 rpmatch \
112 secure-getenv \
113 seed48 \
114 seed48_r \
115 setcontext \
116 setenv \
117 srand48 \
118 srand48_r \
119 strfmon \
120 strfmon_l \
121 strfromd \
122 strfromf \
123 strfroml \
124 strtod \
125 strtod_l \
126 strtod_nan \
127 strtof \
128 strtof_l \
129 strtof_nan \
130 strtol \
131 strtol_l \
132 strtold \
133 strtold_l \
134 strtold_nan \
135 strtoll \
136 strtoll_l \
137 strtoul \
138 strtoul_l \
139 strtoull \
140 strtoull_l \
141 swapcontext \
142 system \
143 wcstombs \
144 wctomb \
145 xpg_basename \
146 # routines
147
148 aux = \
149 grouping \
150 groupingwc \
151 tens_in_limb \
152 # aux
153
154 # These routines will be omitted from the libc shared object.
155 # Instead the static object files will be included in a special archive
156 # linked against when the shared library will be used.
157 static-only-routines = \
158 at_quick_exit \
159 atexit \
160 # static-only-routines
161
162 test-srcs := \
163 tst-fmtmsg \
164 #test-srcs
165
166 tests := \
167 bug-fmtmsg1 \
168 bug-getcontext \
169 bug-strtod \
170 bug-strtod2 \
171 test-a64l \
172 test-at_quick_exit-race \
173 test-atexit-race \
174 test-atexit-recursive \
175 test-bz22786 \
176 test-canon \
177 test-canon2 \
178 test-cxa_atexit-race \
179 test-cxa_atexit-race2 \
180 test-dlclose-exit-race \
181 test-on_exit-race \
182 testdiv \
183 testmb \
184 testmb2 \
185 testrand \
186 testsort \
187 tst-abs \
188 tst-arc4random-fork \
189 tst-arc4random-stats \
190 tst-arc4random-thread \
191 tst-at_quick_exit \
192 tst-atexit \
193 tst-atof1 \
194 tst-atof2 \
195 tst-bsearch \
196 tst-bz20544 \
197 tst-canon-bz26341 \
198 tst-cxa_atexit \
199 tst-environ \
200 tst-getrandom \
201 tst-limits \
202 tst-makecontext \
203 tst-makecontext-align \
204 tst-makecontext2 \
205 tst-makecontext3 \
206 tst-on_exit \
207 tst-qsort \
208 tst-qsort2 \
209 tst-quick_exit \
210 tst-rand48 \
211 tst-rand48-2 \
212 tst-random \
213 tst-random2 \
214 tst-realpath \
215 tst-realpath-toolong \
216 tst-secure-getenv \
217 tst-setcontext \
218 tst-setcontext2 \
219 tst-setcontext3 \
220 tst-setcontext4 \
221 tst-setcontext5 \
222 tst-setcontext6 \
223 tst-setcontext7 \
224 tst-setcontext8 \
225 tst-setcontext9 \
226 tst-strfmon_l \
227 tst-strfrom \
228 tst-strfrom-locale \
229 tst-strtod \
230 tst-strtod-nan-locale \
231 tst-strtod-nan-sign \
232 tst-strtod-overflow \
233 tst-strtod-round \
234 tst-strtod-underflow \
235 tst-strtod2 \
236 tst-strtod5 \
237 tst-strtod6 \
238 tst-strtol \
239 tst-strtol-binary-c11 \
240 tst-strtol-binary-c2x \
241 tst-strtol-binary-gnu11 \
242 tst-strtol-binary-gnu2x \
243 tst-strtol-locale \
244 tst-strtoll \
245 tst-swapcontext1 \
246 tst-thread-quick_exit \
247 tst-tininess \
248 tst-unsetenv1 \
249 tst-width \
250 tst-width-stdint \
251 tst-xpg-basename \
252 # tests
253
254 tests-internal := \
255 tst-strtod1i \
256 tst-strtod3 \
257 tst-strtod4 \
258 tst-strtod5i \
259 tst-tls-atexit \
260 tst-tls-atexit-nodelete \
261 # tests-internal
262
263 tests-static := \
264 tst-secure-getenv \
265 # tests-static
266
267 tests-container := \
268 tst-system \
269 #tests-container
270
271 ifeq ($(build-hardcoded-path-in-tests),yes)
272 tests += \
273 tst-empty-env \
274 # tests
275 endif
276
277 LDLIBS-test-atexit-race = $(shared-thread-library)
278 LDLIBS-test-at_quick_exit-race = $(shared-thread-library)
279 LDLIBS-test-cxa_atexit-race = $(shared-thread-library)
280 LDLIBS-test-cxa_atexit-race2 = $(shared-thread-library)
281 LDLIBS-test-on_exit-race = $(shared-thread-library)
282 LDLIBS-tst-canon-bz26341 = $(shared-thread-library)
283 LDLIBS-tst-arc4random-fork = $(shared-thread-library)
284 LDLIBS-tst-arc4random-thread = $(shared-thread-library)
285 LDLIBS-tst-system = $(shared-thread-library)
286
287 LDLIBS-test-dlclose-exit-race = $(shared-thread-library)
288 LDFLAGS-test-dlclose-exit-race = $(LDFLAGS-rdynamic)
289 LDLIBS-test-dlclose-exit-race-helper.so = $(libsupport) $(shared-thread-library)
290
291 CFLAGS-tst-abs.c += -fno-builtin
292
293 ifeq ($(have-cxx-thread_local),yes)
294 CFLAGS-tst-quick_exit.o = -std=c++11
295 LDLIBS-tst-quick_exit = -lstdc++
296 CFLAGS-tst-thread-quick_exit.o = -std=c++11
297 LDLIBS-tst-thread-quick_exit = -lstdc++
298 $(objpfx)tst-thread-quick_exit: $(shared-thread-library)
299 else
300 tests-unsupported += \
301 tst-quick_exit \
302 tst-thread-quick_exit \
303 # tests-unsupported
304 endif
305
306 modules-names = \
307 test-dlclose-exit-race-helper \
308 tst-tls-atexit-lib \
309 # modules-names
310 extra-test-objs += $(addsuffix .os, $(modules-names))
311
312 ifeq ($(build-shared),yes)
313 tests += \
314 tst-putenv \
315 # tests
316 endif
317
318 # Several mpn functions from GNU MP are used by the strtod function.
319 mpn-routines := \
320 add_n \
321 addmul_1 \
322 cmp \
323 divmod_1 \
324 divrem \
325 inlines \
326 lshift \
327 mod_1 \
328 mul \
329 mul_1 \
330 mul_n \
331 rshift \
332 sub_n \
333 submul_1 \
334 udiv_qrnnd \
335 # mpn-routines
336 mpn-headers = \
337 asm-syntax.h \
338 gmp-impl.h \
339 gmp-mparam.h \
340 gmp.h \
341 longlong.h \
342 # mpn-headers
343
344 routines := \
345 $(strip $(routines) $(mpn-routines)) \
346 dbl2mpn \
347 ldbl2mpn \
348 mpn2dbl \
349 mpn2flt \
350 mpn2ldbl \
351 # routines
352 aux += \
353 fpioconst \
354 mp_clz_tab \
355 # aux
356
357 tests-extras += \
358 tst-putenvmod \
359 # tests-extras
360
361 extra-test-objs += \
362 tst-putenvmod.os \
363 # extra-test-objs
364
365 generated += \
366 isomac \
367 isomac.out \
368 tst-putenvmod.so \
369 # generated
370
371 CFLAGS-bsearch.c += $(uses-callbacks)
372 CFLAGS-msort.c += $(uses-callbacks)
373 CFLAGS-qsort.c += $(uses-callbacks)
374 CFLAGS-system.c += -fexceptions
375 CFLAGS-system.os = -fomit-frame-pointer
376 CFLAGS-fmtmsg.c += -fexceptions
377
378 CFLAGS-strfmon.c += $(libio-mtsafe)
379 CFLAGS-strfmon_l.c += $(libio-mtsafe)
380
381 # The strfrom class of functions call __printf_fp in order to convert the
382 # floating-point value to characters. This requires the value of IO_MTSAFE_IO.
383 CFLAGS-strfromd.c += $(libio-mtsafe)
384 CFLAGS-strfromf.c += $(libio-mtsafe)
385 CFLAGS-strfroml.c += $(libio-mtsafe)
386
387 CFLAGS-strtol.c += $(config-cflags-wno-ignored-attributes)
388 CFLAGS-strtoul.c += $(config-cflags-wno-ignored-attributes)
389 CFLAGS-strtoll.c += $(config-cflags-wno-ignored-attributes)
390 CFLAGS-strtoull.c += $(config-cflags-wno-ignored-attributes)
391 CFLAGS-strtof.c += $(config-cflags-wno-ignored-attributes)
392 CFLAGS-strtof_l.c += $(config-cflags-wno-ignored-attributes)
393 CFLAGS-strtod.c += $(config-cflags-wno-ignored-attributes)
394 CFLAGS-strtod_l.c += $(config-cflags-wno-ignored-attributes)
395 CFLAGS-strtold.c += $(config-cflags-wno-ignored-attributes)
396 CFLAGS-strtold_l.c += $(config-cflags-wno-ignored-attributes)
397 CFLAGS-secure-getenv.c += $(config-cflags-wno-ignored-attributes)
398
399 CFLAGS-tst-bsearch.c += $(stack-align-test-flags)
400 CFLAGS-tst-qsort.c += $(stack-align-test-flags)
401 CFLAGS-tst-makecontext.c += -funwind-tables
402 CFLAGS-tst-makecontext2.c += $(stack-align-test-flags)
403
404 CFLAGS-testmb.c += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Wall -Werror
405
406 # Some versions of GCC supported for building glibc do not support -std=c2x
407 # or -std=gnu2x, so the tests for those versions use -std=c11 and -std=gnu11
408 # and then _ISOC2X_SOURCE is defined in the test as needed.
409 CFLAGS-tst-strtol-binary-c11.c += -std=c11
410 CFLAGS-tst-strtol-binary-c2x.c += -std=c11
411 CFLAGS-tst-strtol-binary-gnu11.c += -std=gnu11
412 CFLAGS-tst-strtol-binary-gnu2x.c += -std=gnu11
413
414
415 # Run a test on the header files we use.
416 tests-special += $(objpfx)isomac.out
417
418 ifeq ($(run-built-tests),yes)
419 tests-special += $(objpfx)tst-fmtmsg.out
420 endif
421
422 include ../Rules
423
424 ifeq ($(run-built-tests),yes)
425 LOCALES := \
426 cs_CZ.UTF-8 \
427 de_DE.UTF-8 \
428 el_GR.UTF-8 \
429 en_US.ISO-8859-1 \
430 hi_IN.UTF-8 \
431 hr_HR.UTF-8 \
432 tg_TJ.UTF-8 \
433 tr_TR.ISO-8859-9 \
434 tr_TR.UTF-8 \
435 # LOCALES
436 include ../gen-locales.mk
437
438 $(objpfx)bug-strtod2.out: $(gen-locales)
439 $(objpfx)testmb2.out: $(gen-locales)
440 $(objpfx)tst-strtod.out: $(gen-locales)
441 $(objpfx)tst-strtod1i.out: $(gen-locales)
442 $(objpfx)tst-strtod3.out: $(gen-locales)
443 $(objpfx)tst-strtod4.out: $(gen-locales)
444 $(objpfx)tst-strtod5.out: $(gen-locales)
445 $(objpfx)tst-strtod5i.out: $(gen-locales)
446 $(objpfx)tst-strtol-locale.out: $(gen-locales)
447 $(objpfx)tst-strtod-nan-locale.out: $(gen-locales)
448 $(objpfx)tst-strfmon_l.out: $(gen-locales)
449 $(objpfx)tst-strfrom.out: $(gen-locales)
450 $(objpfx)tst-strfrom-locale.out: $(gen-locales)
451 $(objpfx)test-dlclose-exit-race.out: $(objpfx)test-dlclose-exit-race-helper.so
452 endif
453
454 # Testdir has to be named stdlib and needs to be writable
455 test-canon-ARGS = --test-dir=${common-objpfx}stdlib
456
457 bug-fmtmsg1-ENV = SEV_LEVEL=foo,11,newsev
458
459 $(objpfx)isomac.out: $(objpfx)isomac
460 $(dir $<)$(notdir $<) '$(CC)' \
461 '-I../include $(+sysdep-includes) $(sysincludes) -I..' > $@; \
462 $(evaluate-test)
463
464 isomac-CFLAGS = -O
465 $(objpfx)isomac: isomac.c
466 $(native-compile)
467
468 $(objpfx)tst-fmtmsg.out: tst-fmtmsg.sh $(objpfx)tst-fmtmsg
469 $(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \
470 '$(run-program-env)' '$(test-program-prefix-after-env)' \
471 $(common-objpfx)stdlib/; \
472 $(evaluate-test)
473
474 $(objpfx)tst-putenv: $(objpfx)tst-putenvmod.so
475 LDFLAGS-tst-putenv = -Wl,--no-as-needed
476
477 $(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os $(link-libc-deps)
478 $(build-module)
479 libof-tst-putenvmod = extramodules
480
481 $(objpfx)bug-getcontext: $(libm)
482 $(objpfx)bug-strtod2: $(libm)
483 $(objpfx)tst-strtod-round: $(libm)
484 $(objpfx)tst-tininess: $(libm)
485 $(objpfx)tst-strtod-underflow: $(libm)
486 $(objpfx)tst-strtod6: $(libm)
487 $(objpfx)tst-strtod-nan-locale: $(libm)
488 $(objpfx)tst-strtod-nan-sign: $(libm)
489
490 tst-tls-atexit-lib.so-no-z-defs = yes
491 test-dlclose-exit-race-helper.so-no-z-defs = yes
492
493 $(objpfx)tst-tls-atexit: $(shared-thread-library)
494 $(objpfx)tst-tls-atexit.out: $(objpfx)tst-tls-atexit-lib.so
495
496 $(objpfx)tst-tls-atexit-nodelete: $(shared-thread-library)
497 $(objpfx)tst-tls-atexit-nodelete.out: $(objpfx)tst-tls-atexit-lib.so
498
499 $(objpfx)tst-setcontext3.out: tst-setcontext3.sh $(objpfx)tst-setcontext3
500 $(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \
501 '$(run-program-env)' '$(test-program-prefix-after-env)' \
502 $(common-objpfx)stdlib/; \
503 $(evaluate-test)