From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#75451: scratch/igc: Enable CHECK_STRUCTS Date: Thu, 09 Jan 2025 10:09:00 +0000 Message-ID: <87frls47uu.fsf@protonmail.com> References: Reply-To: Pip Cet Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32437"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Gerd Moellmann , Stefan Kangas , 75451-done@debbugs.gnu.org To: Gerd =?UTF-8?Q?M=C3=B6llmann?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 09 11:10:27 2025 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tVpUg-0008FG-ST for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 09 Jan 2025 11:10:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVpUN-0004d4-Lz; Thu, 09 Jan 2025 05:10:07 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tVpUI-0004cf-CH for bug-gnu-emacs@gnu.org; Thu, 09 Jan 2025 05:10:02 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tVpUI-0007xA-0z for bug-gnu-emacs@gnu.org; Thu, 09 Jan 2025 05:10:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:From:Date:To:Subject; bh=phfayQsACxWC8dVpiaEIhi6TkuCNC/DpPv7ZXutm2xE=; b=VlPSdWxrcVuAZNGPDFfMBSo9xPo+oMhBrbNdLNOeIvjW9i0Qnqz958LkuuOoASLJLR19ZMU4FjhUMlIZGjCjFt7Jc5RBL2myEUfGg4V3ahiod9hiL2/RjQeb3J6mAPjzz3lowNNlzUqGrSE828+crJvXOcgbf8BAKrTrHOfqUd0gA2bj6rAyT+ns/8cvV1lMjs14kZ9lY1H0BGZgUB19M0lBnncDr1LxHTFmpO0MqMvX8UsLEGOBctIn8np/nuKHKotfhZU2+U51jsZBxsisCVCJdVgseojpXNuKqggP4DDLy4/X8k3IK/PaB4ReeylSOd3YcfJpyRNhS25zDHHCmQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tVpUH-0006RA-Kr for bug-gnu-emacs@gnu.org; Thu, 09 Jan 2025 05:10:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Pip Cet Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 09 Jan 2025 10:10:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 75451 X-GNU-PR-Package: emacs Original-Received: via spool by 75451-done@debbugs.gnu.org id=D75451.173641735424672 (code D ref 75451); Thu, 09 Jan 2025 10:10:01 +0000 Original-Received: (at 75451-done) by debbugs.gnu.org; 9 Jan 2025 10:09:14 +0000 Original-Received: from localhost ([127.0.0.1]:50501 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tVpTW-0006Ps-B0 for submit@debbugs.gnu.org; Thu, 09 Jan 2025 05:09:14 -0500 Original-Received: from mail-40131.protonmail.ch ([185.70.40.131]:11717) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tVpTT-0006PZ-Di for 75451-done@debbugs.gnu.org; Thu, 09 Jan 2025 05:09:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1736417345; x=1736676545; bh=phfayQsACxWC8dVpiaEIhi6TkuCNC/DpPv7ZXutm2xE=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=EYdQ/q5NuGPUtLYlvab3k43qurnJlaqTjRHrri9xzZBea6CqWjFH2GGCF1n7eDDmz GBG6ommOgCQz1XUdLcAmP4CxsMptWkef0UHP5WJWoy+sdWwJuP7eLZ3gGseYhluRM/ 6NFPKuN8ZVi0D8fWYWSanl3TUzSz7DF4t2IBM/wLpwyuZAEVswsXOoAgGqfw+9mf/H 7bna908MZKXCI63wjemiT8Jfj/gc/FM2Excg5y8ZeAmar/yfKXC8X6vPrRRDCiB+ok 6AuMa4UvrvSFHtfzSjjNX8lZzZfKONfFGwep5f4OqvpE5eqax2UoTkOY+JwmSJWixc epLmK6PIrvPlA== In-Reply-To: Feedback-ID: 112775352:user:proton X-Pm-Message-ID: 8d1b070a1bc456d65b6654f5719149764cfb2aef X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:298827 Archived-At: Gerd M=C3=B6llmann writes: > Stefan Kangas writes: > >> >>> (BTW, the contents of the #if might be out of date, not sure if we >>> meanwhile fix/scan additional structs.) >> >> I've now added checks for all structs that we use in "fix_*" functions >> (commit 76a0d739024). I kept notes to make sure I didn't miss anything, >> but it's not impossible that I did. I'll double-check things later. >> >> I plan to do anything passed to the "finalize_*" ones next, which should >> cover most of the ones we currently depend on, I think. > > Very nice! Thanks for taking this on! Thanks! This isn't strictly about the scratch/igc branch, but I personally think struct hashes should be checked in all builds, mismatches should be downgraded to #warnings, and --enable-checking=3Dall could include -Werror=3Dcpp. (So the warnings would still abort a build with --enable-checking=3Dall, but they'd *also* show up in regular builds.) Also, we should include them in the nativecomp ABI hash, as nativecomp relies on struct layout and the tagging scheme in nontrivial ways (most-positive-fixnum, for example, is treated as a compile-time constant by comp.el, but I'm not sure all changes to it would automatically affect the comp abi hash). Changes required might include: * autodetection of gawk vs awk (I think this simply means using $(AWK) rather than "awk" in src/Makefile.in; this is important on some machines which provide a very different "awk") * igc.o and comp.o should depend explicitly on dmpstruct.h (this is important for re-builds; in theory, the current scratch/igc branch is broken for highly parallel builds because dmpstruct.h might be generated after igc.o, but that is not important). * a hash-of-hashes for nativecomp Proposed partial patch: diff --git a/src/Makefile.in b/src/Makefile.in index 3d249a1abdd..f0ff9203b9d 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -546,10 +546,13 @@ dmpstruct_headers=3D =09$(srcdir)/treesit.h $(srcdir)/window.h $(srcdir)/xwidget.h ifeq ($(CHECK_STRUCTS),true) pdumper.o: dmpstruct.h +igc.o: dmpstruct.h +comp.o: dmpstruct.h endif +AWK =3D @AWK@ dmpstruct.h: $(srcdir)/dmpstruct.awk dmpstruct.h: $(libsrc)/make-fingerprint$(EXEEXT) $(dmpstruct_headers) -=09$(AM_V_GEN)POSIXLY_CORRECT=3D1 awk -f $(srcdir)/dmpstruct.awk \ +=09$(AM_V_GEN)POSIXLY_CORRECT=3D1 $(AWK) -f $(srcdir)/dmpstruct.awk \ =09=09$(dmpstruct_headers) > $@ =20 AUTO_DEPEND =3D @AUTO_DEPEND@ diff --git a/src/comp.c b/src/comp.c index cf15817c2fc..c029572d612 100644 --- a/src/comp.c +++ b/src/comp.c @@ -24,6 +24,7 @@ #include "igc.h" #include "comp.h" #include "pdumper.h" +#include "dmpstruct.h" =20 #ifdef HAVE_NATIVE_COMP =20 @@ -821,9 +822,12 @@ hash_native_abi (void) =20 Vcomp_abi_hash =3D comp_hash_string ( - concat3 (build_string (ABI_VERSION), -=09 concat3 (Vemacs_version, Vsystem_configuration, -=09=09=09Vsystem_configuration_options), + CALLN (Fconcat, +=09 build_string (ABI_VERSION), +=09 Vemacs_version, +=09 Vsystem_configuration, +=09 Vsystem_configuration_options, +=09 build_string (HASH_DMPSTRUCT), =09 Fmapconcat (intern_c_string ("comp--subr-signature"), =09=09=09 Vcomp_subr_list, build_string ("")))); =20 diff --git a/src/dmpstruct.awk b/src/dmpstruct.awk index e5e359e10b7..ac639082719 100644 --- a/src/dmpstruct.awk +++ b/src/dmpstruct.awk @@ -21,6 +21,7 @@ BEGIN { print "#define EMACS_DMPSTRUCT_H" struct_name =3D "" tmpfile =3D "dmpstruct.tmp" + tmpfile2 =3D "dmpstruct2.tmp" } # Match a type followed by optional syntactic whitespace /^(enum|struct|union) [a-zA-Z0-9_]+([\t ]|\/\*.*\*\/)*$/ { @@ -29,6 +30,7 @@ BEGIN { } /^(enum|struct|union) [a-zA-Z0-9_]+([\t ]|\/\*.*\*\/)*$/, /^( )?};$/ { print $0 > tmpfile + print $0 > tmpfile2 } /^( )?} *(GCALIGNED_STRUCT)? *;$/ { if (struct_name !=3D "") { @@ -41,5 +43,11 @@ BEGIN { } } END { + fflush (tmpfile2) + cmd =3D "../lib-src/make-fingerprint -r " tmpfile2 + cmd | getline hash + close (cmd) + printf "#define HASH_%s_%.10s\n", "dmpstruct", hash + printf "#define HASH_DMPSTRUCT \"%.10s\"\n", hash print "#endif /* EMACS_DMPSTRUCT_H */" } Pip