From patchwork Tue Jul 11 13:11:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alejandro Colomar X-Patchwork-Id: 1806333 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=HiOCXZN7; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R0h9G6dTcz20ZZ for ; Tue, 11 Jul 2023 23:12:02 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A499738555AB for ; Tue, 11 Jul 2023 13:12:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A499738555AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1689081120; bh=PKzLcaJIe8kqsd7LVoHznzt6iOrRvzKc5eMcX4a82AY=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=HiOCXZN7Gfa1d9LgIRyJW1kIGSaoX7rqe3P1tvxwhflR9yUgLflro63p43fisr1ba jTAbmvy/CalMlJbCdWIf8jS2yBNgHgYLU6tOqAlmRLS1XE4Ckzn+XgnCbI4YlZu/Mq eLFzKLpgGKJ+COdHNi3sEPi6s6vins0q5Myk1+eo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by sourceware.org (Postfix) with ESMTPS id 461E6385840A for ; Tue, 11 Jul 2023 13:11:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 461E6385840A Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8D4E1614AC; Tue, 11 Jul 2023 13:11:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 472CCC433C7; Tue, 11 Jul 2023 13:11:38 +0000 (UTC) To: libc-alpha@sourceware.org Cc: Alejandro Colomar , Florian Weimer , Xi Ruoyao , Sam James , Richard Biener , Andrew Pinski Subject: [RFC v1 0/2] Use -fno-delete-null-pointer-checks to build glibc Date: Tue, 11 Jul 2023 15:11:04 +0200 Message-Id: <20230711131105.19203-1-alx@kernel.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5328; i=alx@kernel.org; h=from:subject; bh=Pe5XH7Xq3abnaQqc7cOkZtnSYIDwBjMgUwQkfrn+npI=; b=owEBbQKS/ZANAwAKAZ6MGvu+/9syAcsmYgBkrVTZO9AfQ8NAFhTWfbn553ITmckgqu0NGiiVg h2CYuG76raJAjMEAAEKAB0WIQTqOofwpOugMORd8kCejBr7vv/bMgUCZK1U2QAKCRCejBr7vv/b MqFfD/4t3TBb5Kr2aaVoP+nqkEz+KuyUaMMyO4Ynrr52vKB5Qx5La0aHD5Iz71H3ORgdL6WDLcQ aPm/Aw4bi+MAYxPP86z+zo9HRsvXwICx1B04a5WwnoBxmWdJfcqQZLBBzkDQM+F08e7usIzqRs8 kbYMRWs+C2cJiqhIqj6DOE9GQqdgq9+OqAejK+RjfiaraovekvblIAquRTNFqDccdgSa34U6p7L T+nsxCQ0oG4ToawUcJB9MvdRUElWGz48ETDi7ClwDvg4VMTDvRc4+B53wgst3vylJU+1qkZnc1F aA/XZYisNDGEmDnh90biwtIooi+MVMcivPIXlBMbHh4iGHyrJPWmraRgQzYroQniDAsvRdPXrSd TvCAOZLIL8YU1KebjNQepYRZtpXklzBYV+XatkIDKkBCbOPXZszuJLzXMJZ10PdHS8PB/SihvNi CTtMTbmd47z5jsTllz57M+VNvn6EGO4ih4SzXBwnSyIljjv8i2eG5cuLVX9TDgMgiDH4lXdiL2P q+mkEAE8fve33eFuEfDIddlj2QLvT7+4MYCa/wgBeqpFnlvQL5Gn13fgf0GMfewDcydEFbFoYG7 Lxum89bfvy+926cuvYRHYEltIsjtP2Pe9c5cn0aHco9FWBx9HwffQVojHaVwRpocezAbNd3A8/J uB6zb6LTpLt82/w== X-Developer-Key: i=alx@kernel.org; a=openpgp; fpr=A9348594CE31283A826FBDD8D57633D441E25BB5 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alejandro Colomar via Libc-alpha From: Alejandro Colomar Reply-To: Alejandro Colomar Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Hi, Glibc currently undefines __nonnull internally, to avoid compiler optimizations that would make glibc unsafe. The attribute is only present in installed headers, but for internal code an #undef is used. Xi is trying to improve the consistency in uses of __nonnull in the installed headers, to avoid special cases in GCC's fanalyzer. That prompted the question of whether the attribute is safe, as the compiler is known to optimize too much based on it. Florian reported that there's -fno-delete-null-pointer-checks to tell the compiler to not optimize, and only warn about incorrect uses of null pointers. Another idea arised from that: it would be good if glibc used __nonnull internally to get more warnings. We only need to take care to prevent the compiler optimizations. While I was trying to do that change, which seemed trivial (see this patch set), I uncovered what seems some circular dependencies in the glibc header files (see the build log below). Could you please have a look at it? Thanks, Alex ---- (re)Build log ---- $ make make -r PARALLELMFLAGS="" -C ../nonnull objdir=`pwd` all make[1]: Entering directory '/home/alx/src/gnu/glibc/nonnull' type "make help" for help with common glibc makefile targets make subdir=csu -C csu ..=../ subdir_lib make subdir=iconv -C iconv ..=../ subdir_lib make[2]: Entering directory '/home/alx/src/gnu/glibc/nonnull/iconv' gcc gconv_conf.c -c -std=gnu11 -fgnu89-inline -fno-delete-null-pointer-checks -g -O2 -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math -fno-stack-protector -fno-common -Wp,-U_FORTIFY_SOURCE -Wstrict-prototypes -Wold-style-definition -fmath-errno -fPIE -DGCONV_PATH='"/opt/gnu/glibc/nonnull/lib/gconv"' -ftls-model=initial-exec -I../include -I/home/alx/src/gnu/glibc/.tmp/iconv -I/home/alx/src/gnu/glibc/.tmp -I../sysdeps/unix/sysv/linux/x86_64/64 -I../sysdeps/unix/sysv/linux/x86_64 -I../sysdeps/unix/sysv/linux/x86/include -I../sysdeps/unix/sysv/linux/x86 -I../sysdeps/x86/nptl -I../sysdeps/unix/sysv/linux/wordsize-64 -I../sysdeps/x86_64/nptl -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux -I../sysdeps/nptl -I../sysdeps/pthread -I../sysdeps/gnu -I../sysdeps/unix/inet -I../sysdeps/unix/sysv -I../sysdeps/unix/x86_64 -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/x86_64/64 -I../sysdeps/x86_64/fpu/multiarch -I../sysdeps/x86_64/fpu -I../sysdeps/x86/fpu -I../sysdeps/x86_64/multiarch -I../sysdeps/x86_64 -I../sysdeps/x86/include -I../sysdeps/x86 -I../sysdeps/ieee754/float128 -I../sysdeps/ieee754/ldbl-96/include -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/wordsize-64 -I../sysdeps/ieee754 -I../sysdeps/generic -I.. -I../libio -I. -D_LIBC_REENTRANT -include /home/alx/src/gnu/glibc/.tmp/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h -DPIC -DTOP_NAMESPACE=glibc -o /home/alx/src/gnu/glibc/.tmp/iconv/gconv_conf.o -MD -MP -MF /home/alx/src/gnu/glibc/.tmp/iconv/gconv_conf.o.dt -MT /home/alx/src/gnu/glibc/.tmp/iconv/gconv_conf.o In file included from ../include/sys/cdefs.h:10, from ../include/features.h:503, from ../assert/assert.h:35, from ../include/assert.h:1, from gconv_conf.c:19: ../include/dirent.h:53:17: error: expected ‘)’ before numeric constant 53 | __nonnull (4) attribute_hidden; | ^ ../misc/sys/cdefs.h:401:69: note: in definition of macro ‘__attribute_nonnull__’ 401 | # define __attribute_nonnull__(params) __attribute__ ((__nonnull__ params)) | ^~~~~~ ../include/dirent.h:53:6: note: in expansion of macro ‘__nonnull’ 53 | __nonnull (4) attribute_hidden; | ^~~~~~~~~ ../misc/sys/cdefs.h:401:76: error: expected ‘,’ or ‘;’ before ‘)’ token 401 | # define __attribute_nonnull__(params) __attribute__ ((__nonnull__ params)) | ^ ../misc/sys/cdefs.h:407:28: note: in expansion of macro ‘__attribute_nonnull__’ 407 | # define __nonnull(params) __attribute_nonnull__ (params) | ^~~~~~~~~~~~~~~~~~~~~ ../include/dirent.h:53:6: note: in expansion of macro ‘__nonnull’ 53 | __nonnull (4) attribute_hidden; | ^~~~~~~~~ make[2]: *** [../o-iterator.mk:9: /home/alx/src/gnu/glibc/.tmp/iconv/gconv_conf.o] Error 1 make[2]: Leaving directory '/home/alx/src/gnu/glibc/nonnull/iconv' make[1]: *** [Makefile:484: iconv/subdir_lib] Error 2 make[1]: Leaving directory '/home/alx/src/gnu/glibc/nonnull' make: *** [Makefile:9: all] Error 2 --- Build log end ---- Alejandro Colomar (2): Makeconfig: Use one line per token Makeconfig: Compile glibc with -fno-delete-null-pointer-checks Makeconfig | 18 +++++++++++++----- include/sys/cdefs.h | 6 ------ 2 files changed, 13 insertions(+), 11 deletions(-) Range-diff against v0: -: ---------- > 1: 55d7caa944 Makeconfig: Use one line per token -: ---------- > 2: efb21da36c Makeconfig: Compile glibc with -fno-delete-null-pointer-checks