From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.org 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689081100; bh=TXw7DciWKB3A9wDYexsWIdP+W0zra+HxKTY2LFsM+Ns=; h=From:To:Cc:Subject:Date:From; b=fN56yhC+9koTf0IG7//XX4A+GJkRHNphGL1tlRrGu4I0mvrmk5uxJVpD+VomyRKlJ uumB0AN3vGod/37oJp1aelggbb/KEiG/y/iZGPBD31VD84YpJn8MfXDoIJYnhlQxYp CpuetSzHT9y6wM9ok8T/ie+TTFvl7WPc57LSdrSzCKpK3IzZ2eDc5XeSHZOqftZxUk UUTkw3LS6PDAoRQ1nez9+HqgeeK/TbwXUtLajoixu/aHmNKD8UBkwG2d1pdsC2ycrL 7Oj/S5hflUQPA+D8HzlCWyUhZYluY9khGYrDiFaUSxylBU1QorOoUM2cUrgJN8AF/+ Ov898j8CCPVEQ== From: Alejandro Colomar 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 List-Id: 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=3D"" -C ../nonnull objdir=3D`pwd` all make[1]: Entering directory '/home/alx/src/gnu/glibc/nonnull' type "make help" for help with common glibc makefile targets make subdir=3Dcsu -C csu ..=3D../ subdir_lib make subdir=3Diconv -C iconv ..=3D../ subdir_lib make[2]: Entering directory '/home/alx/src/gnu/glibc/nonnull/iconv' gcc gconv_conf.c -c -std=3Dgnu11 -fgnu89-inline -fno-delete-null-pointer-ch= ecks -g -O2 -Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -f= rounding-math -fno-stack-protector -fno-common -Wp,-U_FORTIFY_SOURCE -Wstri= ct-prototypes -Wold-style-definition -fmath-errno -fPIE -DGCONV_PATH= =3D'"/opt/gnu/glibc/nonnull/lib/gconv"' -ftls-model=3Dinitial-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/x= 86_64 -I../sysdeps/unix/sysv/linux/x86/include -I../sysdeps/unix/sysv/linu= x/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/un= ix/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/x= 86_64/fpu/multiarch -I../sysdeps/x86_64/fpu -I../sysdeps/x86/fpu -I../sy= sdeps/x86_64/multiarch -I../sysdeps/x86_64 -I../sysdeps/x86/include -I../= sysdeps/x86 -I../sysdeps/ieee754/float128 -I../sysdeps/ieee754/ldbl-96/in= clude -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysde= ps/ieee754/flt-32 -I../sysdeps/wordsize-64 -I../sysdeps/ieee754 -I../sys= deps/generic -I.. -I../libio -I. -D_LIBC_REENTRANT -include /home/alx/src= /gnu/glibc/.tmp/libc-modules.h -DMODULE_NAME=3Dlibc -include ../include/lib= c-symbols.h -DPIC -DTOP_NAMESPACE=3Dglibc -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 =E2=80=98)=E2=80=99 before numer= ic constant 53 | __nonnull (4) attribute_hidden; | ^ ../misc/sys/cdefs.h:401:69: note: in definition of macro =E2=80=98__attribu= te_nonnull__=E2=80=99 401 | # define __attribute_nonnull__(params) __attribute__ ((__nonnull__= params)) | = ^~~~~~ ../include/dirent.h:53:6: note: in expansion of macro =E2=80=98__nonnull=E2= =80=99 53 | __nonnull (4) attribute_hidden; | ^~~~~~~~~ ../misc/sys/cdefs.h:401:76: error: expected =E2=80=98,=E2=80=99 or =E2=80= =98;=E2=80=99 before =E2=80=98)=E2=80=99 token 401 | # define __attribute_nonnull__(params) __attribute__ ((__nonnull__= params)) | = ^ ../misc/sys/cdefs.h:407:28: note: in expansion of macro =E2=80=98__attribut= e_nonnull__=E2=80=99 407 | # define __nonnull(params) __attribute_nonnull__ (params) | ^~~~~~~~~~~~~~~~~~~~~ ../include/dirent.h:53:6: note: in expansion of macro =E2=80=98__nonnull=E2= =80=99 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 --=20 2.40.1