From 4d60e14ad247a134822b05b0bce29f5641d1ee6f Mon Sep 17 00:00:00 2001 From: Mauricio Collares Date: Fri, 19 Feb 2021 17:15:59 -0300 Subject: [PATCH] emacs: precompile trampolines in parallel --- pkgs/applications/editors/emacs/generic.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkgs/applications/editors/emacs/generic.nix b/pkgs/applications/editors/emacs/generic.nix index 619bde59874c..70e253dd6dfb 100644 --- a/pkgs/applications/editors/emacs/generic.nix +++ b/pkgs/applications/editors/emacs/generic.nix @@ -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\")" \