]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
malloc: Fix tst-tcfree3 build csky-linux-gnuabiv2 with fortify source
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 23 Oct 2023 16:33:47 +0000 (13:33 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 23 Oct 2023 16:34:04 +0000 (13:34 -0300)
With gcc 13.1 with --enable-fortify-source=2, tst-tcfree3 fails to
build on csky-linux-gnuabiv2 with:

../string/bits/string_fortified.h: In function ‘do_test’:
../string/bits/string_fortified.h:26:8: error: inlining failed in call
to ‘always_inline’ ‘memcpy’: target specific option mismatch
   26 | __NTH (memcpy (void *__restrict __dest, const void *__restrict
      __src,
      |        ^~~~~~
../misc/sys/cdefs.h:81:62: note: in definition of macro ‘__NTH’
   81 | #  define __NTH(fct)    __attribute__ ((__nothrow__ __LEAF)) fct
      |                                                              ^~~
tst-tcfree3.c:45:3: note: called from here
   45 |   memcpy (c, a, 32);
      |   ^~~~~~~~~~~~~~~~~

Instead of relying on -O0 to avoid malloc/free to be optimized away,
disable the builtin.

Reviewed-by: DJ Delorie <dj@redhat.com>
malloc/Makefile
malloc/tst-tcfree3.c

index c1db3347d88e112fcdfd78c90564c6d5d95abb33..f6cdf7bf0be2ee2c02788bc40169fdeb9f81a98d 100644 (file)
@@ -298,6 +298,8 @@ CPPFLAGS-malloc.c += -DUSE_TCACHE=1
 # Uncomment this for test releases.  For public releases it is too expensive.
 #CPPFLAGS-malloc.o += -DMALLOC_DEBUG=1
 
+CFLAGS-tst-tcfree3.c += -fno-builtin-malloc -fno-builtin-free
+
 sLIBdir := $(shell echo $(slibdir) | sed 's,lib\(\|64\)$$,\\\\$$LIB,')
 
 $(objpfx)mtrace: mtrace.pl
index ce6d958f8a9541bbc138a27ef7eaf37d6c04c4d2..30886b6f499a10c8637f0572945aa872791f5375 100644 (file)
@@ -19,9 +19,6 @@
 #include <malloc.h>
 #include <string.h>
 
-/* Prevent GCC from optimizing away any malloc/free pairs.  */
-#pragma GCC optimize ("O0")
-
 static int
 do_test (void)
 {