Subject: Re: bug#32352: 27.0.50; build error

From: Noam Postavsky <[email-masked]>
Date: Mon, 12 Nov 2018 20:37:09 -0500

Glenn Morris <[email-masked]> writes:

> I seem to be able to reproduce it at will with (after a bootstrap):
>
> touch lisp/files.el src/emacs.c 
> rm src/bootstrap-emacs
> make

Ah right, I missed removing bootstrap-emacs.

> which dies doing
>
> ./src/bootstrap-emacs -batch -f batch-byte-compile lisp/files.el
>
> at (alist-get class dir-locals-class-alist) when gv.elc loads.
> (It's fine if you load bytecomp.el instead of .elc.)

Not entirely sure about bytecomp.el vs elc, but the problem seems to be
that files.el binds read-circle over too much code, and gv.elc has some
circular structure in it.  The following patch fixes it:

--- c/lisp/files.el
+++ i/lisp/files.el
@@ -4099,7 +4099,6 @@ dir-locals-read-from-dir
 Return the new class name, which is a symbol named DIR."
   (let* ((class-name (intern dir))
          (files (dir-locals--all-files dir))
-         (read-circle nil)
 	 ;; If there was a problem, use the values we could get but
 	 ;; don't let the cache prevent future reads.
 	 (latest 0) (success 0)
@@ -4114,7 +4113,8 @@ dir-locals-read-from-dir
           (insert-file-contents file)
           (let ((newvars
                  (condition-case-unless-debug nil
-                     (read (current-buffer))
+                     (let ((read-circle nil))
+                       (read (current-buffer)))
                    (end-of-file nil))))
             (setq variables
                   ;; Try and avoid loading `map' since that also loads cl-lib

I guess this could go to emacs-26 (although I'm suddenly unable to build
it today, I get tons of "undefined reference to X" link errors
(including X=main!?)).