public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Enable _FORTIFY_SOURCE=3 for gcc 12 and above
@ 2021-12-17  4:07 Siddhesh Poyarekar
  2021-12-17 13:17 ` Adhemerval Zanella
  0 siblings, 1 reply; 10+ messages in thread
From: Siddhesh Poyarekar @ 2021-12-17  4:07 UTC (permalink / raw)
  To: libc-alpha; +Cc: fweimer, carlos

gcc 12 now has support for the __builtin_dynamic_object_size builtin.
Adapt the macro checks to enable _FORTIFY_SOURCE=3 on gcc 12 and above.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
---
 include/features.h | 4 +++-
 misc/sys/cdefs.h   | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/features.h b/include/features.h
index d974eabfaf..933499bcff 100644
--- a/include/features.h
+++ b/include/features.h
@@ -412,7 +412,9 @@
 #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
 # elif !__GNUC_PREREQ (4, 1)
 #  warning _FORTIFY_SOURCE requires GCC 4.1 or later
-# elif _FORTIFY_SOURCE > 2 && __glibc_clang_prereq (9, 0)
+# elif _FORTIFY_SOURCE > 2 && (__glibc_clang_prereq (9, 0)		      \
+			       || __GNUC_PREREQ (12, 0))
+
 #  if _FORTIFY_SOURCE > 3
 #   warning _FORTIFY_SOURCE > 3 is treated like 3 on this platform
 #  endif
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index a05b538579..1875e5c6ed 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -143,7 +143,8 @@
 #define __bos0(ptr) __builtin_object_size (ptr, 0)
 
 /* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available.  */
-#if __USE_FORTIFY_LEVEL == 3 && __glibc_clang_prereq (9, 0)
+#if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0)		      \
+				 || __GNUC_PREREQ (12, 0))
 # define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)
 # define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)
 #else
-- 
2.31.1


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

end of thread, other threads:[~2022-01-12 12:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-17  4:07 [PATCH] Enable _FORTIFY_SOURCE=3 for gcc 12 and above Siddhesh Poyarekar
2021-12-17 13:17 ` Adhemerval Zanella
2021-12-17 13:54   ` Siddhesh Poyarekar
2021-12-17 15:24     ` Siddhesh Poyarekar
2021-12-17 19:04       ` Adhemerval Zanella
2021-12-17 19:30         ` Siddhesh Poyarekar
2021-12-17 19:48           ` Adhemerval Zanella
2021-12-17 19:50             ` Siddhesh Poyarekar
2022-01-12  4:14   ` Siddhesh Poyarekar
2022-01-12 12:52     ` Adhemerval Zanella

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).