Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1jZPb7-0000F0-LQ for mharc-grub-devel@gnu.org; Thu, 14 May 2020 21:57:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jZPb6-0000DN-75 for grub-devel@gnu.org; Thu, 14 May 2020 21:57:12 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:42196) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jZPb2-0005I1-5D for grub-devel@gnu.org; Thu, 14 May 2020 21:57:11 -0400 Received: by mail-pg1-x543.google.com with SMTP id n11so242578pgl.9 for ; Thu, 14 May 2020 18:57:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-transfer-encoding; bh=WvCLTrrAfkUAK8yZFTDpzy9IMSTahzEJDA+Qb3XSG1g=; b=puNpDly3AFcpKIgjp/NCNN6BoAwKv/j/Eg8r/GN2Pc1uMy0pXfpP++Cd2r0Zxj5Dzq 8KBRTFmtSI6AM2PFYrt4HtsgMKt2/+mPYt7i3C65BHE6d7swXquW7XFtJGKyvaZUauen EYtO0lP+5/+sX0MIk5E2FQqoYOXFrRE6oktoQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=WvCLTrrAfkUAK8yZFTDpzy9IMSTahzEJDA+Qb3XSG1g=; b=bL0mKg6OjphvbjjkJGEt0DAx4Q7VfI6JfeDkn3zmgd72HgQATqLv9MFiSEpq2lUbiz B67TUbTnZkH2LEVsa7MDh7kU//K+bcLeYzwpbQRXnXYG2+SYGgCiw3z4Q/MRQtusUaci r1xQXgEIObK3l8SQ/caWV2FFnVBxjMv+p/mTcWE4SuG8Z/9iHFyM4Tupx5D5Oh/pzBF6 jBfA/7s5qUWGed+j4HNwbXOpdV0j2SmDENx7Q70DHYsnzdxRidTrq51IK9dGpywcPKrv wSMHGc1gxlQ1HZVqhp4jOA24U0BJDy/BEEPAkR8v5UH7C7irTlikqQF3xEPCIasem9qx Ji5Q== X-Gm-Message-State: AOAM531z8OwqEWkrGC2ovP4II+eM45+8Fn8q/SVRTDX6G+ajFDMMhAWb Kx/73TLtZ3xZFkKBIFNGd46tug== X-Google-Smtp-Source: ABdhPJzDeTWE8e1z2sBgzynoXXk91PrcRHOq/KNBTXcZjaQp2w5kz5I1hlxHeBCipCmGa/RnAnnF2w== X-Received: by 2002:a63:f157:: with SMTP id o23mr963330pgk.15.1589507826103; Thu, 14 May 2020 18:57:06 -0700 (PDT) Received: from localhost (2001-44b8-111e-5c00-44b9-3a8c-24cb-2345.static.ipv6.internode.on.net. [2001:44b8:111e:5c00:44b9:3a8c:24cb:2345]) by smtp.gmail.com with ESMTPSA id g1sm250362pjt.25.2020.05.14.18.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 May 2020 18:56:59 -0700 (PDT) From: Daniel Axtens To: Daniel Kiper , grub-devel@gnu.org Cc: eschwartz@archlinux.org, floppym@gentoo.org, glaubitz@physik.fu-berlin.de, javierm@redhat.com, leif@nuviainc.com, olaf@aepfle.de, phcoder@gmail.com, pjones@redhat.com Subject: Re: [PATCH v3 2/5] configure: Set gnu99 C language standard by default In-Reply-To: <20200513120251.9861-3-daniel.kiper@oracle.com> References: <20200513120251.9861-1-daniel.kiper@oracle.com> <20200513120251.9861-3-daniel.kiper@oracle.com> Date: Fri, 15 May 2020 11:56:56 +1000 Message-ID: <87v9kyq7tj.fsf@dja-thinkpad.axtens.net> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2607:f8b0:4864:20::543; envelope-from=dja@axtens.net; helo=mail-pg1-x543.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 May 2020 01:57:12 -0000 Hi Daniel, > Commit d5a32255d (misc: Make grub_strtol() "end" pointers have safer > const qualifiers) introduced "restrict" keyword into some functions > definitions. This keyword was introduced in C99 standard. However, some > compilers by default may use C89 or something different. This behavior > leads to the breakage during builds when c89 or gnu89 is in force. So, > let's set gnu99 C language standard for all compilers by default. This > way a bit random build issue will be fixed and the GRUB source will be > build consistently regardless of type and version of the compiler. > > It was decided to use gnu99 C language standard because it fixes the > issue mentioned above and also provides some useful extensions which are > used here and there in the GRUB source. Potentially we can use gnu11 > too. However, this may reduce pool of older compilers which can be used > to build the GRUB. So, let's live with gnu99 until we discover that we > strongly require a feature from newer C standard. I tried building this with CC=3Dclang just to see if it didn't like gnu99 for some reason. It does not, but for different reasons to what I expected: clang -DHAVE_CONFIG_H -I. -Wall -W -DGRUB_UTIL=3D1 -D_FILE_OFFSET_BITS=3D6= 4 -I./include -DGRUB_FILE=3D\"grub-core/lib/json/json.c\" -I. -I. -I. -I. -= I./include -I./include -I./grub-core/lib/libgcrypt-grub/src/ -I./grub-core= /lib/gnulib -I./grub-core/lib/gnulib -I./grub-core/lib/json -D_FILE_OFFSET_= BITS=3D64 -std=3Dgnu99 -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-su= bscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-= by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -W= implicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-br= aces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Ws= equence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragma= s -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-val= ue -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes = -Wcast-align -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-poin= ter-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -W= vla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-re= gister-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmis= sing-declarations -Wformat=3D2 -Werror -Wno-undef -Wno-sign-compare -Wno-u= nused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno= -conversion -MT grub-core/lib/json/libgrubkern_a-json.o -MD -MP -MF grub-c= ore/lib/json/.deps-util/libgrubkern_a-json.Tpo -c -o grub-core/lib/json/lib= grubkern_a-json.o `test -f 'grub-core/lib/json/json.c' || echo './'`grub-co= re/lib/json/json.c In file included from grub-core/lib/json/json.c:24: ./grub-core/lib/json/json.h:39:24: error: redefinition of typedef 'jsmntok_= t' is a C11 feature [-Werror,-Wtypedef-redefinition] typedef struct jsmntok jsmntok_t; ^ ./grub-core/lib/json/jsmn.h:77:3: note: previous definition is here } jsmntok_t; ^ 1 error generated. clang --version clang version 9.0.0-2 (tags/RELEASE_900/final) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin Without this patch, clang-9 fails on the use of nested functions in commit cb2f15c54489 ("normal/main: Search for specific config files for netboot") - I'll send a fix for that shortly. If I revert that as a temporary measure, clang will build. I notice from ./configure that it already does some form of testing for restrict: checking for C/C++ restrict keyword... __restrict I'm not sure what brings that test in to configure (gnulib?), and accessing it is a little bit tricky because we use AC_CONFIG_FILES for config.h rather than AC_CONFIG_HEADER, but that could be a general purpose solution. Regards, Daniel > The user is still able to override C language standard using relevant > *_CFLAGS variables. > > Signed-off-by: Daniel Kiper > --- > v3 - suggestions/fixes: > - add a comment before the change in configure.ac > (suggested by Javier Martinez Canillas and Leif Lindholm), > - improve commit message > (suggested by Javier Martinez Canillas and Leif Lindholm). > > v2 - suggestions/fixes: > - unconditionally enforce gnu99 C language standard > (suggested by Leif Lindholm). > --- > configure.ac | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/configure.ac b/configure.ac > index b2576b013..3eda9a5a2 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -80,6 +80,12 @@ if test "x$TARGET_CFLAGS" =3D x; then > TARGET_CFLAGS=3D-Os > fi >=20=20 > +# Enable support for "restrict" keyword and other > +# features from gnu99 C language standard. > +BUILD_CFLAGS=3D"-std=3Dgnu99 $BUILD_CFLAGS" > +HOST_CFLAGS=3D"-std=3Dgnu99 $HOST_CFLAGS" > +TARGET_CFLAGS=3D"-std=3Dgnu99 $TARGET_CFLAGS" > + > # Default HOST_CPPFLAGS > HOST_CPPFLAGS=3D"$HOST_CPPFLAGS -Wall -W" > HOST_CPPFLAGS=3D"$HOST_CPPFLAGS -DGRUB_UTIL=3D1" > --=20 > 2.11.0 > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel