homebrew-emacs-plus: Could not install with @28 --with-native-comp - libgccjit not supported on M1

Please make sure to follow these steps (and mark the checkboxes):

  • run brew update and try to reproduce the issue again
  • run brew doctor, fix all issues and try to reproduce your issue again
  • run brew config and brew doctor and include their output

What you were trying to do

brew install emacs-plus@28 --with-native-comp

What happened (include command output)

$ brew install emacs-plus@28 --with-native-comp
Command output

==> Installing emacs-plus@28 from d12frosted/emacs-plus ==> Downloading https://homebrew.bintray.com/bottles/sqlite-3.35.4.arm64_big_sur.bottle.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/ecb945b9df98160dd9c935fc128e862fbc7d4593ff50 ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/python%403.9-3.9.4.arm64_big_sur.bottle.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/9d38ac550179a6b6004a30eb063ce659ba5d14c2412d ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/ghostscript-9.53.3_1.arm64_big_sur.bottle.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/e1a01add6b5692ebfd462591db21dd029d081529fbe4 ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/libde265-1.0.8.arm64_big_sur.bottle.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/856e3db9a951f15fc2e3c416ddf64c8336d405fc1e40 ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/docbook-5.1_1.arm64_big_sur.bottle.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/53a9dc79db8b2d06dc75009d5d09fc797ddcd5eb4ca0 ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/docbook-xsl-1.79.2_1.arm64_big_sur.bottle.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/9604b8989c3cc180c641b00f595e59d887aa85fbd410 ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/gnu-getopt-2.36.2.arm64_big_sur.bottle.tar.gz ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/xmlto-0.0.28.arm64_big_sur.bottle.2.tar.gz ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/shared-mime-info-2.1.arm64_big_sur.bottle.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/c2c98a7a02e1b23f5c7f7baafe0e4b04f22a7b1a6df7 ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/libheif-1.11.0_2.arm64_big_sur.bottle.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/6fb1565de0cf3f02dacaf0c1ca8631132900ecd2fb65 ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/liblqr-0.4.2_1.arm64_big_sur.bottle.1.tar.gz ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/libomp-11.1.0.arm64_big_sur.bottle.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/f87f7841eb8b72650fa771af39642361aec371ea1a1f ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/ilmbase-2.5.5.arm64_big_sur.bottle.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/f465c8e3f824777ab727d17e11c018eff8d8afc12ffe ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/openexr-2.5.5.arm64_big_sur.bottle.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/b484c97399b2317707c2685fceeb4e8ba26b9eea3d03 ######################################################################## 100.0% ==> Downloading https://homebrew.bintray.com/bottles/imagemagick-7.0.11-6.arm64_big_sur.bottle.tar.gz ==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/87fd9f93911df4e835c4fa834156dfcb44e566f174cb ######################################################################## 100.0% Error: libgccjit: no bottle available! You can try to install from source with: brew install --build-from-source libgccjit Please note building from source is unsupported. You will encounter build failures with some formulae. If you experience any issues please create pull requests instead of asking for help on Homebrew’s GitHub, Twitter or any other official channels.

Output of brew config

$ brew config
HOMEBREW_VERSION: 3.0.11
ORIGIN: https://github.com/Homebrew/brew
HEAD: 8e11f03fa93b148e26044a331654241a2c307039
Last commit: 4 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: efa89684e992ed605e9faa975677174c42be70a8
Core tap last commit: 16 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_DISPLAY: :0
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit arm_firestorm_icestorm
Clang: 12.0 build 1200
Git: 2.24.3 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.2.3-arm64
CLT: 12.4.0.0.1.1610135815
Xcode: 12.4
Rosetta 2: false

Output of brew doctor

$ brew doctor
Your system is ready to brew.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 23 (5 by maintainers)

Most upvoted comments

@hexagonal-sun this sounds great! thanks for fixing libgccjit for M1 💯

@DanMossa and @cacology it’s time to some native compilation 😉

Eli fixed the nativecomp segfault a bit later yesterday!

commit b5e6dba05fcb4fa1c716dc759f8c4b2561bacaa7
Author: Eli Zaretskii <eliz@gnu.org>
Date:   Sat May 15 20:44:40 2021 +0300

    Fix segfaults when byte-compiling with native-compilation

    * src/emacs.c (main): Call 'set_initial_minibuffer_mode' before
    entering recursive-exit.
    * src/minibuf.c (init_minibuf_once_for_pdumper): Don't call
    'set_minibuffer_mode' here...
    (set_initial_minibuffer_mode): ... set it in this new function.
    (Bug#48446)
    * src/lisp.h: Add prototype for 'set_initial_minibuffer_mode'.

@hexagonal-sun Over here on vanilla Emacs with my own home-grown config everything seems to be fine. I’ve tried different kinds of ways of opening files, and also orgmode, org-roam, mu4e, magit and everything runs great. Whenever I use a new mode for the first time, I can see the compiler doing its thing in *Async-native-compile-log*.

For now I’ve addressed the path problem by adding this to the start of my init.el:

(when (memq window-system '(mac ns))
  (setenv "PATH" (concat "/opt/homebrew/bin/:" (getenv "PATH"))))

(this only works because the basic stuff has already been native compiled during the first startup from the terminal, and that path gets added early enough for a normal gui startup to work perfectly.)

@hexagonal-sun I modified the emacs-plus formula to use the commit right before that one, and then it builds!

  1. clone the homebrew-emacs-plus repo
  2. edit emacs@28.rb changing the url line to read as follows:
url "https://github.com/emacs-mirror/emacs.git", revision: "248ec838aa8b1a720a05b422be760f6ab32aa630"
  1. rebuild with:
brew install --verbose --formula /your/dir/homebrew-emacs-plus/Formula/emacs-plus@28.rb --with-no-titlebar --with-native-comp

I wonder if that last Emacs commit will break the nativecomp compilation on more systems than just homebrew on M1.

segfaults while building emacs, goodness!

I did brew reinstall emacs-plus@28 --verbose --with-no-titlebar --with-native-comp

In my case, an explicit brew link libgccjit beforehand was necessary, else the emacs configure did not find gccjit.

Thanks for the links @cacology 💯 It’s sad that it’s still not there.

P. S. pinned for visibility.

Re: Apple Silicon

Not me. brew install --build-from-source libgccjit fails with:

[... omitting dependencies that install just fine]
==> Installing libgccjit
==> ../configure --build=x86_64-apple-darwin20 --prefix=/opt/homebrew/Cellar/libgccjit/10.2.0_1 --libdir=/opt/homebrew/Cellar/libgccjit/
==> make BOOT_LDFLAGS=-Wl,-headerpad_max_install_names
Last 15 lines from /Users/grumpy/Library/Logs/Homebrew/libgccjit/02.make:
echo timestamp > stmp-int-hdrs
/private/tmp/libgccjit-20210411-85488-22vlnh/gcc-10.2.0/build-jit/./gcc/xgcc -B/private/tmp/libgccjit-20210411-85488-22vlnh/gcc-10.2.0/build-jit/./gcc/ -xc -nostdinc /dev/null -S -o /dev/null -fself-test=../../gcc/testsuite/selftests
/private/tmp/libgccjit-20210411-85488-22vlnh/gcc-10.2.0/build-jit/./gcc/xgcc -B/private/tmp/libgccjit-20210411-85488-22vlnh/gcc-10.2.0/build-jit/./gcc/ -xc++ -nostdinc /dev/null -S -o /dev/null -fself-test=../../gcc/testsuite/selftests
cc1: note: self-tests are not enabled in this build
echo timestamp > s-selftest-c
/dev/null:1: internal compiler error: in darwin_gt_pch_use_address, at config/host-darwin.c:51
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://github.com/Homebrew/homebrew-core/issues> for instructions.
make[3]: *** [s-selftest-c++] Error 1
rm gcc.pod
make[2]: *** [all-stage1-gcc] Error 2
make[1]: *** [stage1-bubble] Error 2
make: *** [all] Error 2

Do not report this issue to Homebrew/brew or Homebrew/core!

The absence of an arm bottle, noted above, https://formulae.brew.sh/formula/libgccjit suggests this hasn’t come to the attention of someone who knows how to fix it.

brew install --build-from-source libgccjit --HEAD fares differently but no better.

==> ../configure --build=x86_64-apple-darwin20 --prefix=/opt/homebrew/Cellar/libgccjit/HEAD-ac20079_1 --libdir=/opt/homebrew/Cellar/libg
==> make BOOT_LDFLAGS=-Wl,-headerpad_max_install_names
Last 15 lines from /Users/grumpy/Library/Logs/Homebrew/libgccjit/02.make:
      __ZL13do_mpc_ckconvP10real_valueS0_PK12__mpc_structbPK11real_format in libbackend.a(fold-const-call.o)
      __ZL14do_mpfr_ckconvP10real_valuePK13__mpfr_structbPK11real_format in libbackend.a(fold-const-call.o)
  "_mpfr_y0", referenced from:
      __ZL17fold_const_call_111combined_fnP9tree_nodeS1_ in libbackend.a(fold-const-call.o)
  "_mpfr_y1", referenced from:
      __ZL17fold_const_call_111combined_fnP9tree_nodeS1_ in libbackend.a(fold-const-call.o)
  "_mpfr_yn", referenced from:
      __ZL17fold_const_call_111combined_fnP9tree_nodeS1_S1_ in libbackend.a(fold-const-call.o)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[3]: *** [cc1plus] Error 1
rm gcov.pod fsf-funding.pod lto-dump.pod gpl.pod cpp.pod gfdl.pod gcc.pod gcov-dump.pod gcov-tool.pod
make[2]: *** [all-stage2-gcc] Error 2
make[1]: *** [stage2-bubble] Error 2
make: *** [all] Error 2

Furthermore, brew install --build-from-source libgccjit -i and handholding:

  • ./configure --prefix=/opt/homebrew/Cellar/libgccjit/10.2.0_1 --libdir=/opt/homebrew/Cellar/libgccjit/
  • make BOOT_LDFLAGS=-Wl,-headerpad_max_install_names

Gives what I think is the real problem:

[... lots omitted]
*** Configuration arm-apple-darwin20.3.0 not supported
make[2]: *** [configure-stage1-gcc] Error 1
make[1]: *** [stage1-bubble] Error 2
make: *** [all] Error 2

Mutatis mutandis for handholding HEAD:

[... lots omitted]
*** Configuration aarch64-apple-darwin20.3.0 not supported
make[2]: *** [configure-stage1-gcc] Error 1
make[1]: *** [stage1-bubble] Error 2
make: *** [all] Error 2

EDIT:

A quick follow-up, the issue seems to be that GCC isn’t ported yet:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96168 and https://github.com/iains/gcc-darwin-arm64

That’s strange, there is a bottle (formula) for Big Sur. Though maybe it’s just not provided for arm. So maybe just use the suggestion provided by brew itself:

Error: libgccjit: no bottle available!

You can try to install from source with:

brew install --build-from-source libgccjit

Please note building from source is unsupported. You will encounter build
failures with some formulae. If you experience any issues please create pull
requests instead of asking for help on Homebrew's GitHub, Twitter or any other
official channels.

Though I love this controversity in their message. Sigh. But it’s really not related to emacs-plus.