Merge pull request #113730 from collares/parallel-trampolines

emacs: precompile trampolines in parallel
This commit is contained in:
adisbladis 2021-02-20 12:48:01 +01:00 committed by GitHub
commit e59a33db58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -159,10 +159,14 @@ let emacs = stdenv.mkDerivation (lib.optionalAttrs nativeComp {
'' + lib.optionalString (nativeComp && withNS) ''
ln -snf $out/lib/emacs/*/native-lisp $out/Applications/Emacs.app/Contents/native-lisp
'' + lib.optionalString nativeComp ''
$out/bin/emacs --batch \
-l comp --eval "(mapatoms (lambda (s) \
(when (subr-primitive-p (symbol-function s)) \
(comp-trampoline-compile s))))"
echo "Generating native-compiled trampolines..."
# precompile trampolines in parallel, but avoid spawning one process per trampoline.
# 1000 is a rough lower bound on the number of trampolines compiled.
$out/bin/emacs --batch --eval "(mapatoms (lambda (s) \
(when (subr-primitive-p (symbol-function s)) (print s))))" \
| 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 'comp-eln-load-path \"$out/share/emacs/native-lisp\")" \