Subject: [BUG] Error: void-function (rx) during generating autoloads for python.el when building from source

From: Lin Sun <[email-masked]>
Date: Wed, 13 Nov 2024 00:31:07 +0000

I met a compile issue while generating the autoloads.el from
python.el, it seems the `python--auto-mode-alist-regexp` is defined
with 'rx' but the 'rx' wasn't loaded.
Should relate to the commit `2f485e68ff96cc66a17df2c0a58e272bbfc24765`
    Add Python "*.pth" files to auto-mode-alist
    * lisp/progmodes/python.el (python--auto-mode-alist-regexp): New
    variable.

Here is the errors:

Loading ~/dev-env/work-dev/emacs31.build/lisp/theme-loaddefs.el (source)...
Error: void-function (rx)
  (rx (or (seq "." (or "py" "pth" "pyi" "pyw")) (seq "/" (or
"SConstruct" "SConscript"))) eos)
  (defconst python--auto-mode-alist-regexp (rx (or (seq "." (or "py"
"pth" "pyi" "pyw")) (seq "/" (or "SConstruct" "SConscript"))) eos))
  eval-buffer(#<buffer  *load*> nil
"~/dev-env/work-dev/emacs31.build/lisp/loaddefs.el" nil t)
  (if eval-function (funcall eval-function buffer (if dump-mode file
fullname)) (eval-buffer buffer nil (if dump-mode file fullname) nil
t))
  (let ((read-symbol-shorthands shorthands)) (if eval-function
(funcall eval-function buffer (if dump-mode file fullname))
(eval-buffer buffer nil (if dump-mode file fullname) nil t)))
  (let ((load-true-file-name fullname) (load-file-name fullname)
(set-auto-coding-for-load t) (inhibit-file-name-operation nil)
shorthands) (with-current-buffer buffer (set-buffer-multibyte t) (let
(deactivate-mark) (insert-file-contents fullname)) (setq shorthands
(and hack-read-symbol-shorthands-function (funcall
hack-read-symbol-shorthands-function))) (if (and
enable-multibyte-characters (or (eq (coding-system-type
last-coding-system-used) 'raw-text))) (set-buffer-multibyte nil))
(set-buffer-modified-p nil)) (let ((read-symbol-shorthands
shorthands)) (if eval-function (funcall eval-function buffer (if
dump-mode file fullname)) (eval-buffer buffer nil (if dump-mode file
fullname) nil t))))
  (unwind-protect (let ((load-true-file-name fullname) (load-file-name
fullname) (set-auto-coding-for-load t) (inhibit-file-name-operation
nil) shorthands) (with-current-buffer buffer (set-buffer-multibyte t)
(let (deactivate-mark) (insert-file-contents fullname)) (setq
shorthands (and hack-read-symbol-shorthands-function (funcall
hack-read-symbol-shorthands-function))) (if (and
enable-multibyte-characters (or (eq (coding-system-type
last-coding-system-used) 'raw-text))) (set-buffer-multibyte nil))
(set-buffer-modified-p nil)) (let ((read-symbol-shorthands
shorthands)) (if eval-function (funcall eval-function buffer (if
dump-mode file fullname)) (eval-buffer buffer nil (if dump-mode file
fullname) nil t)))) (let (kill-buffer-hook
kill-buffer-query-functions) (kill-buffer buffer)))
  (let ((buffer (generate-new-buffer " *load*")) (load-in-progress t)
(source (string-suffix-p ".el" fullname))) (unless nomessage (if
source (message "Loading %s (source)..." file) (message "Loading
%s..." file))) (when purify-flag (push (purecopy file)
preloaded-file-list)) (unwind-protect (let ((load-true-file-name
fullname) (load-file-name fullname) (set-auto-coding-for-load t)
(inhibit-file-name-operation nil) shorthands) (with-current-buffer
buffer (set-buffer-multibyte t) (let (deactivate-mark)
(insert-file-contents fullname)) (setq shorthands (and
hack-read-symbol-shorthands-function (funcall
hack-read-symbol-shorthands-function))) (if (and
enable-multibyte-characters (or (eq (coding-system-type
last-coding-system-used) 'raw-text))) (set-buffer-multibyte nil))
(set-buffer-modified-p nil)) (let ((read-symbol-shorthands
shorthands)) (if eval-function (funcall eval-function buffer (if
dump-mode file fullname)) (eval-buffer buffer nil (if dump-mode file
fullname) nil t)))) (let (kill-buffer-hook
kill-buffer-query-functions) (kill-buffer buffer)))
(do-after-load-evaluation fullname) (unless (or nomessage
noninteractive) (if source (message "Loading %s (source)...done" file)
(message "Loading %s...done" file))) t)
  (if (null (file-readable-p fullname)) (and (null noerror) (signal
'file-error (list "Cannot open load file" file))) (let ((buffer
(generate-new-buffer " *load*")) (load-in-progress t) (source
(string-suffix-p ".el" fullname))) (unless nomessage (if source
(message "Loading %s (source)..." file) (message "Loading %s..."
file))) (when purify-flag (push (purecopy file) preloaded-file-list))
(unwind-protect (let ((load-true-file-name fullname) (load-file-name
fullname) (set-auto-coding-for-load t) (inhibit-file-name-operation
nil) shorthands) (with-current-buffer buffer (set-buffer-multibyte t)
(let (deactivate-mark) (insert-file-contents fullname)) (setq
shorthands (and hack-read-symbol-shorthands-function (funcall
hack-read-symbol-shorthands-function))) (if (and
enable-multibyte-characters (or (eq (coding-system-type
last-coding-system-used) 'raw-text))) (set-buffer-multibyte nil))
(set-buffer-modified-p nil)) (let ((read-symbol-shorthands
shorthands)) (if eval-function (funcall eval-function buffer (if
dump-mode file fullname)) (eval-buffer buffer nil (if dump-mode file
fullname) nil t)))) (let (kill-buffer-hook
kill-buffer-query-functions) (kill-buffer buffer)))
(do-after-load-evaluation fullname) (unless (or nomessage
noninteractive) (if source (message "Loading %s (source)...done" file)
(message "Loading %s...done" file))) t))
  load-with-code-conversion("~/dev-env/work-dev/emacs31.build/lisp/loaddefs.el"
"~/dev-env/work-dev/emacs31.build/lisp/loaddefs.el" nil nil)
  load("loaddefs")
  (condition-case nil (load "loaddefs") (file-error (load "ldefs-boot.el")))
  load("loadup.el")
Symbol's function definition is void: rx
make[2]: *** [Makefile:1016: bootstrap-emacs.pdmp] Error 255
make[2]: Leaving directory '~/dev-env/work-dev/emacs31.build/src'
make[1]: *** [Makefile:554: src] Error 2
make[1]: Leaving directory '~/dev-env/work-dev/emacs31.build'
make[1]: Entering directory '~/dev-env/work-dev/emacs31.build'
***
*** "make all" failed with exit status 2.