diff options
author | Aurelien Jarno <aurelien@aurel32.net> | 2019-01-03 15:51:37 +0100 |
---|---|---|
committer | Aurelien Jarno <aurelien@aurel32.net> | 2019-01-07 14:59:07 +0100 |
commit | 2ef427168818ce04b03cecb7b739f9db0156e3e4 (patch) | |
tree | 6d3787d195256667929dc2a10c206c0374966256 /string/Makefile | |
parent | 7395f3a0efad9fc51bb54fa383ef6524702e0c49 (diff) | |
download | glibc-2ef427168818ce04b03cecb7b739f9db0156e3e4.zip glibc-2ef427168818ce04b03cecb7b739f9db0156e3e4.tar.gz glibc-2ef427168818ce04b03cecb7b739f9db0156e3e4.tar.bz2 |
Only build libm with -fno-math-errno (bug 24024)
Commit 1294b1892e ("Add support for sqrt asm redirects") added the
-fno-math-errno flag to build most of the glibc in order to enable GCC
to inline math functions. Due to GCC bug #88576, saving and restoring
errno around calls to malloc are optimized-out. In turn this causes
strerror to set errno to ENOMEM if it get passed an invalid error number
and if malloc sets errno to ENOMEM (which might happen even if it
succeeds). This is not allowed by POSIX.
This patch changes the build flags, building only libm with
-fno-math-errno and all the remaining code with -fno-math-errno. This
should be safe as libm doesn't contain any code saving and restoring
errno around malloc. This patch can probably be reverted once the GCC
bug is fixed and available in stable releases.
Tested on x86-64, no regression in the testsuite.
Changelog:
[BZ #24024]
* Makeconfig: Build libm with -fno-math-errno but build the remaining
code with -fmath-errno.
* string/Makefile [$(build-shared)] (tests): Add test-strerror-errno.
[$(build-shared)] (LDLIBS-test-strerror-errno): New variable.
* string/test-strerror-errno.c: New file.
Diffstat (limited to 'string/Makefile')
-rw-r--r-- | string/Makefile | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/string/Makefile b/string/Makefile index bf4fb89..38b26a0 100644 --- a/string/Makefile +++ b/string/Makefile @@ -64,6 +64,12 @@ tests := tester inl-tester noinl-tester testcopy test-ffs \ # This test allocates a lot of memory and can run for a long time. xtests = tst-strcoll-overflow +# This test needs libdl. +ifeq (yes,$(build-shared)) +tests += test-strerror-errno +LDLIBS-test-strerror-errno = $(libdl) +endif + ifeq ($(run-built-tests),yes) tests-special += $(objpfx)tst-svc-cmp.out endif |