public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] malloc: Fix tst-tcfree3 build csky-linux-gnuabiv2 with fortify source
@ 2023-10-19 16:50 Adhemerval Zanella
  2023-10-19 17:59 ` DJ Delorie
  0 siblings, 1 reply; 3+ messages in thread
From: Adhemerval Zanella @ 2023-10-19 16:50 UTC (permalink / raw)
  To: libc-alpha

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.
---
 malloc/Makefile      | 2 ++
 malloc/tst-tcfree3.c | 3 ---
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/malloc/Makefile b/malloc/Makefile
index c1db3347d8..f6cdf7bf0b 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -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
diff --git a/malloc/tst-tcfree3.c b/malloc/tst-tcfree3.c
index ce6d958f8a..30886b6f49 100644
--- a/malloc/tst-tcfree3.c
+++ b/malloc/tst-tcfree3.c
@@ -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)
 {
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] malloc: Fix tst-tcfree3 build csky-linux-gnuabiv2 with fortify source
  2023-10-19 16:50 [PATCH] malloc: Fix tst-tcfree3 build csky-linux-gnuabiv2 with fortify source Adhemerval Zanella
@ 2023-10-19 17:59 ` DJ Delorie
  2023-10-19 18:03   ` Adhemerval Zanella Netto
  0 siblings, 1 reply; 3+ messages in thread
From: DJ Delorie @ 2023-10-19 17:59 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha


LGTM but would it make sense to have -fno-builtin-malloc for *all* the
malloc tests?

Reviewed-by: DJ Delorie <dj@redhat.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] malloc: Fix tst-tcfree3 build csky-linux-gnuabiv2 with fortify source
  2023-10-19 17:59 ` DJ Delorie
@ 2023-10-19 18:03   ` Adhemerval Zanella Netto
  0 siblings, 0 replies; 3+ messages in thread
From: Adhemerval Zanella Netto @ 2023-10-19 18:03 UTC (permalink / raw)
  To: DJ Delorie; +Cc: libc-alpha



On 19/10/23 14:59, DJ Delorie wrote:
> 
> LGTM but would it make sense to have -fno-builtin-malloc for *all* the
> malloc tests?
> 
> Reviewed-by: DJ Delorie <dj@redhat.com>
> 

I think it would be valuable, this is what I did in azanella/clang [1] to 
avoid clang optimize ways most of the calls.


[1] https://sourceware.org/git/?p=glibc.git;a=blobdiff;f=malloc/Makefile;h=0e47b8446f59fab9d05364543aff8d988f640a3e;hp=c1db3347d88e112fcdfd78c90564c6d5d95abb33;hb=ca27004e1096ab2942dc770acccf835e52bc9d74;hpb=9fd866d9a7ac9b55b6a796df207aa3cd0899e451

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-19 18:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-19 16:50 [PATCH] malloc: Fix tst-tcfree3 build csky-linux-gnuabiv2 with fortify source Adhemerval Zanella
2023-10-19 17:59 ` DJ Delorie
2023-10-19 18:03   ` Adhemerval Zanella Netto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).