Subject: Re: bug#75451: scratch/igc: Enable CHECK_STRUCTS

From: Stefan Kangas <[email-masked]>
Date: Fri, 10 Jan 2025 18:42:56 +0000

Pip Cet <[email-masked]> writes:

> 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=all could include
> -Werror=cpp.  (So the warnings would still abort a build with
> --enable-checking=all, but they'd *also* show up in regular builds.)

As I was continuing to work on CHECK_STRUCTS, I stumbled into this and
re-read parts of the old discussion linked below:

commit 9994bf17cf532f2e1d4310341da7180342202191
Author: Paul Eggert <[email-masked]>
Date:   Wed Apr 10 19:42:37 2019 -0700

    Bring back dmpstruct.h

    Bring back the dmpstruct.h checking, and use it when
    --enable-checking=structs is specified.  The checking can be helpful
    to some developers, although it gets in the way of others and is
    not needed for ordinary tarball builds.
    * src/dmpstruct.awk: Restore this file, with mode 644 not 755.
    * configure.ac: New option-arg --enable-checking=structs,
    implied by --enable-checking.
    (CHECK_STRUCTS): New macro and var.
    * src/Makefile.in (CHECK_STRUCTS): New macro.
    (dmpstruct_headers, dmpstruct.h, dmpstruct.h):
    Restore these macros and rules.
    (pdumper.o): Restore this dependency if $(CHECK_STRUCTS) is true.
    (mostlyclean): Remove dmpstruct.h.
    * src/pdumper.c [CHECK_STRUCTS]: Include dmpstruct.h,
    and restore checks against hashes.

commit 44a39e3e761c0774cd1bb9360db7f49e1d66ec06
Author: Paul Eggert <[email-masked]>
Date:   Tue Apr 9 15:42:10 2019 -0700

    Remove dmpstruct.h

    The hassles of updating the dmpstruct.h-using code bit me again.
    These updates are more trouble than they’re worth.  See:
    https://lists.gnu.org/r/emacs-devel/2019-03/msg00122.html
    As I’m the main person who’s made changes in this area since
    dmpstruct.h was introduced, I’m the most motivated to clean up
    the situation.

I'm curios to know what is the experience while developing scratch/igc:
have these checks been very helpful?

Meanwhile, for enums, I'm wondering if something like this wouldn't make
more sense?  (Or perhaps in addition to CHECK_STRUCTS.  Hmm.)

diff --git a/src/igc.c b/src/igc.c
index 37929765522..6c8ad55878c 100644
--- a/src/igc.c
+++ b/src/igc.c
@@ -2770,6 +2776,8 @@ fix_vector (mps_ss_t ss, struct Lisp_Vector *v)
 #endif
 	IGC_FIX_CALL_FN (ss, struct Lisp_Vector, v, fix_vectorlike);
 	break;
+      default:
+	emacs_abort ();
       }
   }
   MPS_SCAN_END (ss);