native-comp 已经合并到主干了

Commit: https://git.savannah.gnu.org/gitweb/?p=emacs.git;a=commit;h=289000eee729689b0cf362a21baa40ac7f9506f6

Reddit 网友讨论: https://www.reddit.com/r/emacs/comments/myej3z/the_nativecompilation_branch_was_just_merged_into/

编译&参数:

./autogen.sh && ./configure --with-native-compilation

不知现在编译速度有没有改善。

我已经很久没用 native-comp 了,主要是因为电脑太旧,扛不住每次更新包都要花长时间的编译,宁愿 Emacs 反应慢一点。听起来是不是有点讽刺,一个旨在加速的特性,却让需要加速的用户却步。

3 个赞

普通台式办公电脑估计15分钟吧?

(defcustom comp-async-jobs-number 0
  "Default number of subprocesses used for async native compilation.
Value of zero means to use half the number of the CPU's execution units,
or one if there's just one execution unit."
  :type 'integer
  :risky t
  :version "28.1")

那种2c4t的老平台确实不太舒服,但调调这个参数应该还可以,

实际上的大头是更新emacs版本重新编译的大量自带包

压低包更新频率和少用大体量的包会更好


  (setq comp-async-jobs-number 7 
		comp-deferred-compilation t
		;; comp-deferred-compilation-black-list '()
		;; or it will be too annoying
		comp-async-report-warnings-errors nil) 

反正这几个参数调一调体验总能改进一点

默认异步编译,随时退出不影响使用,我没啥感觉

机器不好的话,编译安装很慢很慢

折腾了一下午,gcc-9不行,重新编译了个gcc-11才搞掂。

像guix这种编译Emacs包发布编译后文件的发行版挺好。

我是自己本地编译的 Emacs,然后从 Nix 安装了 emacs-telega 包:

(defun nixpkgs/emacs-package-load-path (name)
  "Return the load path of emacs package NAME."
  (with-temp-buffer
    (when (zerop (call-process-shell-command
                  (concat "nix-env -q --out-path --installed " name) nil t))
      (let ((ss (split-string (buffer-substring (point-min) (1- (point-max))))))
        (expand-file-name
         (concat "share/emacs/site-lisp/elpa/" (car ss)) (cadr ss))))))

(defun telega/ensure-telega-server ()
  (interactive)
  (if (executable-find "telega-server")
      (let ((pkg-path (nixpkgs/emacs-package-load-path "emacs-telega")))
        (add-to-list 'load-path pkg-path)
        (add-to-list 'load-path (expand-file-name "contrib" pkg-path))
        (setq telega--lib-directory pkg-path)
        (setq telega-proxies (list dot-telega-proxy))
        (setq telega-chat-fill-column 70)
        (setq telega-root-fill-column 70)
        (use-package! rainbow-identifiers)
        (use-package! visual-fill-column)
        (require 'telega))
    (when (yes-or-no-p "Install ‘telega-server’ now? ")
      (with-temp-buffer
        (if (zerop (call-process-shell-command
                    (concat "nix-env"
                            " -f '<nixpkgs>'"
                            " -iA emacsPackages.melpaPackages.telega")
                    nil t))
            (telega/ensure-telega-server)
          (user-error (buffer-string)))))))

Nix 把相关依赖&补丁都打包好了并且提供二进制:

如果从 homebrew 编译安装 telega-server,不仅费时,还可能跟 telega.el 不匹配。

2 个赞

刚刚在 Windows 10 (msys2)下编译完成,make -j$(nproc) nproc = 12, 花了30分钟,跟以前差不多。

据说28会默认开启nativecomp,挺好奇Windows到时候咋打包