public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx@kernel.org>
To: libc-alpha@sourceware.org
Cc: Alejandro Colomar <alx@kernel.org>,
	Florian Weimer <fweimer@redhat.com>,
	Xi Ruoyao <xry111@xry111.site>, Sam James <sam@gentoo.org>,
	Richard Biener <rguenth@gcc.gnu.org>,
	Andrew Pinski <apinski@marvell.com>
Subject: [RFC v1 2/2] Makeconfig: Compile glibc with -fno-delete-null-pointer-checks
Date: Tue, 11 Jul 2023 15:11:06 +0200	[thread overview]
Message-ID: <20230711131105.19203-3-alx@kernel.org> (raw)
In-Reply-To: <20230711131105.19203-1-alx@kernel.org>

Don't undefine __nonnull to prevent compiler optimizations.  Instead,
tell the compiler to not optimize based on the attribute, via the
appropriate flag.

Link: <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110617>
Reported-by: Florian Weimer <fweimer@redhat.com>
Cc: Xi Ruoyao <xry111@xry111.site>
Cc: Sam James <sam@gentoo.org>
Cc: Richard Biener <rguenth@gcc.gnu.org>
Cc: Andrew Pinski <apinski@marvell.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
---
 Makeconfig          | 1 +
 include/sys/cdefs.h | 6 ------
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/Makeconfig b/Makeconfig
index 369a596e79..ecbe30e53f 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -1045,6 +1045,7 @@ CPPFLAGS = $(config-extra-cppflags) $(CPPFLAGS-config) \
 
 override CFLAGS	= -std=gnu11 \
 		  -fgnu89-inline \
+		  -fno-delete-null-pointer-checks \
 		  $(config-extra-cflags) \
 		  $(filter-out %frame-pointer,$(+cflags)) \
 		  $(+gccwarn-c) \
diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h
index b84ad34a70..e4a8dd7844 100644
--- a/include/sys/cdefs.h
+++ b/include/sys/cdefs.h
@@ -10,12 +10,6 @@
 #include <misc/sys/cdefs.h>
 
 #ifndef _ISOMAC
-/* The compiler will optimize based on the knowledge the parameter is
-   not NULL.  This will omit tests.  A robust implementation cannot allow
-   this so when compiling glibc itself we ignore this attribute.  */
-# undef __nonnull
-# define __nonnull(params)
-
 extern void __chk_fail (void) __attribute__ ((__noreturn__));
 libc_hidden_proto (__chk_fail)
 rtld_hidden_proto (__chk_fail)
-- 
2.40.1


  parent reply	other threads:[~2023-07-11 13:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-11 13:11 [RFC v1 0/2] Use -fno-delete-null-pointer-checks to build glibc Alejandro Colomar
2023-07-11 13:11 ` [RFC v1 1/2] Makeconfig: Use one line per token Alejandro Colomar
2023-07-11 18:05   ` Adhemerval Zanella Netto
2023-07-11 13:11 ` Alejandro Colomar [this message]
2023-07-11 13:41   ` [RFC v1 2/2] Makeconfig: Compile glibc with -fno-delete-null-pointer-checks Florian Weimer
2023-07-11 13:53     ` Siddhesh Poyarekar
2023-07-12 10:56   ` Richard Biener
2023-07-12 12:22     ` Cristian Rodríguez
2023-07-12 12:43     ` Florian Weimer
2023-07-11 13:18 ` [RFC v1 0/2] Use -fno-delete-null-pointer-checks to build glibc Florian Weimer
2023-07-11 13:19   ` Alejandro Colomar
2023-07-11 13:22 ` Xi Ruoyao
2023-07-11 13:24   ` Alejandro Colomar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230711131105.19203-3-alx@kernel.org \
    --to=alx@kernel.org \
    --cc=apinski@marvell.com \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=rguenth@gcc.gnu.org \
    --cc=sam@gentoo.org \
    --cc=xry111@xry111.site \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).