emacs: fix site-start.el native compilation destination

Previously, natively compiled site-start.el was put into a wrong place
and Emacs could not find it at runtime.  As a result, starting Emacs
with an empty .emacs.d (--init-directory) created
an *Async-native-compile-log* buffer showing:

> Compiling /nix/store/jplfqmm84dmrfdlbq1qn4lz259av9lm7-emacs-30.2/share/emacs/site-lisp/site-start.el...

The compiled start-start.el file was at
.emacs.d/eln-cache/30.2-d829fb48/site-start-6352488c-77e47a63.eln.

With this patch, Emacs can find the natively compiled site-start.el at
runtime.  So starting Emacs with an empty .emacs.d will not create
an *Async-native-compile-log* buffer and .emacs.d/ remains empty.

The correct destination is found from INSTALL of Emacs source code:

> '/usr/local/lib/emacs/VERSION/native-lisp' holds the natively compiled
>		pre-loaded Emacs Lisp files.  If the build used the
>		'configure' option '--with-native-compilation=aot', then
> 		this directory holds all natively compiled Lisp files.

Also, the last item of native-comp-eln-load-path aligns with that.
This commit is contained in:
Lin Jian
2026-07-06 21:26:18 +08:00
parent d407951447
commit df361a5b5f
@@ -466,9 +466,8 @@ stdenv.mkDerivation (finalAttrs: {
| xargs -n $((1000/NIX_BUILD_CORES + 1)) -P $NIX_BUILD_CORES \
$out/bin/emacs --batch -l comp --eval "(while argv \
(comp-trampoline-compile (intern (pop argv))))"
mkdir -p $out/share/emacs/native-lisp
$out/bin/emacs --batch \
--eval "(add-to-list 'native-comp-eln-load-path \"$out/share/emacs/native-lisp\")" \
--eval "(add-to-list 'native-comp-eln-load-path \"$out/lib/emacs/$siteVersionDir/native-lisp\")" \
-f batch-native-compile $out/share/emacs/site-lisp/site-start.el
'';