0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

macOS 27 (Golden Gate) でEmacsの動きがおかしい場合に確認すること

0
Last updated at Posted at 2026-09-23

はじめに

brewのemacs-appが31.1になっていたので、macOS27でアップグレードしたところ、拙作のmac-imeやivyなどが動作しなくなった原因を調査した内容になります。

TL;DR

Warningバッファに⛔ Warning (native-compiler): clang: error: invalid version number in '-mmacosx-version-min=18.0'みたいなエラーが表示されている場合、~/.emacs.d/early-init.el(または init.el の先頭)に以下を追記してみてください。

;; macOSでのlibgccjitによるバージョン誤計算を回避
(when (eq system-type 'darwin)
  (setenv "MACOSX_DEPLOYMENT_TARGET"
          (or (getenv "MACOSX_DEPLOYMENT_TARGET")
              (string-trim (shell-command-to-string "sw_vers -productVersion")))))

何が起きていたか

elispをネイティブコードにコンパイルする場合にコンパイルエラーが発生していました。

(native-compiler-error "Compiling /Users/ma0001/.emacs.d/eln-cache/31_1-032f33bc/subr--trampoline-726561642d737472696e67_read_string_0.eln...\nclang: error: invalid version number in '-mmacosx-version-min=18.0'\nlibgccjit.so: error: error invoking gcc driver\n\ndebug-early-backtrace...done\nInternal native compiler error: \"failed to compile\", \"/Users/ma0001/.emacs.d/eln-cache/31_1-032f33bc/subr--trampoline-726561642d737472696e67_read_string_0.eln\", \"error invoking gcc driver\"\n\nError: native-ice (\"failed to compile\" \"/Users/ma0001/.emacs.d/eln-cache/31_1-032f33bc/subr--trampoline-726561642d737472696e67_read_string_0.eln\" \"error invoking gcc driver\")\n  comp--compile-ctxt-to-file0(\"/Users/ma0001/.emacs.d/eln-cache/31_1-032f33bc/subr--trampoline-726561642d737472696e67_read_string_0.eln\")\n  comp--compile-ctxt-to-file(\"/Users/ma0001/.emacs.d/eln-cache/31_1-032f33bc/subr--trampoline-726561642d737472696e67_read_string_0.eln\")\n  comp--final1()\n  load-with-code-conversion(\"/private/var/folders/v2/8py1csgn45l9wm6p4bh_p50h0000gn/T/emacs-int-comp-subr--trampoline-726561642d737472696e67_read_string_0-FekenG.el\" \"/private/var/folders/v2/8py1csgn45l9wm6p4bh_p50h0000gn/T/emacs-int-comp-subr--trampoline-726561642d737472696e67_read_string_0-FekenG.el\" nil t)\n  command-line-1((\"-l\" \"/var/folders/v2/8py1csgn45l9wm6p4bh_p50h0000gn/T/emacs-int-comp-subr--trampoline-726561642d737472696e67_read_string_0-FekenG.el\"))\n  command-line()\n  normal-top-level()\n" (lambda (arg8 &optional arg9 arg10 arg11 arg12) (let ((f #'read-string)) (funcall f arg8 arg9 arg10 arg11 arg12))))

invalid version number in '-mmacosx-version-min=18.0'\nlibgccjit.so: error:
エラー内容の通り、OSのバージョン指定が間違っています。Golden Gateになって一挙にバージョン番号が上がってしまった弊害ですね。コンパイル時に使う libgccjitの問題のようです。

あまり詳しく調べていませんが、ネイティブコンパイルができないとpre-command-hookのようなC言語関数へhookがかからなくなるようです

最新版ではもちろん直っているようですが
https://github.com/gcc-mirror/gcc/blob/dc301f9b3da5d0a367a0a6be394eba318d3f5b92/gcc/config/darwin-driver.cc#L136

brewのemacs-appに入っているのは14.3

% strings /Applications/Emacs.app/Contents/MacOS/lib-arm64-11/libgccjit.0.dylib | grep -E "libgccjit-[0-9]"
/nix/store/4kbqns0y68ahfc9zjcx0s161q8yn9jgn-libgccjit-14.3.0/lib/gcc/arm64-apple-darwin/14.3.0/../../../../arm64-apple-darwin/include/finclude/
/nix/store/4kbqns0y68ahfc9zjcx0s161q8yn9jgn-libgccjit-14.3.0/libexec/gcc/
...

これは、カーネルバージョンからmacOSメジャー = Darwinメジャー - 9 = 18と計算しているみたいです
https://github.com/gcc-mirror/gcc/blob/c9cd41fba9ebd288c4f101e4b99da934bcb96a11/gcc/config/darwin-driver.cc#L169

MACOSX_DEPLOYMENT_TARGETを指定することにより、この計算を回避することができます。

参考リンク

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?