Subject: 30.1.50; AOT-compiling site-lisp during the Emacs build doesn't work

From: Spencer Baugh <[email-masked]>
Date: Fri, 13 Jun 2025 09:34:10 -0400

Native compilation of site-lisp directories during the Emacs build
(e.g. --with-native-compilation=aot) produces .eln files which are
unused when installed.

The reason is that the absolute file name of the site-lisp directory
differs between build-time and install-time, and therefore
comp-el-to-eln-rel-filename computes a different path hash for the files
contained in site-lisp at build-time and at install-time.

The same issue would affect AOT native compilation of all Lisp in Emacs,
except that there's a workaround built into comp-el-to-eln-rel-filename,
as explained by this comment:

     As installing .eln files compiled during the build changes their
     absolute path we need an hashing mechanism that is not sensitive
     to that.  For this we replace if match PATH_DUMPLOADSEARCH or
     *PATH_REL_LOADSEARCH with '//' before computing the hash.

In other words, file names containing e.g. "30.1.50/lisp", like
"/usr/local/share/emacs/30.1.50/lisp/foo.el", are transformed to
"//foo.el" before the path hash is computed.

I suggest the same should be done for file names containing
"30.1.50/site-lisp".  That would resolve the problem and allow site-lisp
to actually be AOT-compiled.

In GNU Emacs 30.1.50 (build 19, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.15.12, Xaw scroll bars) of 2025-05-26 built on
 igm-qws-u22796a
Repository revision: 1743ab3d48bedae367ca6a1deb3faf8f902e7d5c
Repository branch: emacs-30
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Rocky Linux 8.10 (Green Obsidian)

Configured using:
 'configure --config-cache --with-x-toolkit=lucid --without-gpm
 --without-gconf --without-selinux --without-imagemagick --with-modules
 --with-gif=no --with-cairo --with-rsvg --without-compress-install
 --with-tree-sitter --with-native-compilation=aot
 PKG_CONFIG_PATH=/usr/local/home/garnish/libtree-sitter/0.22.6-1/lib/pkgconfig/'

Configured features:
CAIRO DBUS FREETYPE GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG LIBSYSTEMD
LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP
SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER X11 XDBE XIM
XINPUT2 XPM LUCID ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix