homebrew-emacs-plus: warning - libgccjit.so: error: error invoking gcc driver

What you were trying to do

I have installed Emacs on macOS Big Sur using following command

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

What happened (include command output)

$ brew install emacs-plus [OPTIONS]
Command output
Warning (comp): libgccjit.so: error: error invoking gcc driver Disable showing Disable logging
Warning (comp): /usr/local/Cellar/emacs-plus@28/28.0.50/share/emacs/28.0.50/lisp/emacs-lisp/cl-lib.el.gz: Error: Internal native compiler error failed to compile Disable showing Disable logging
  

Output of brew config

$ brew config
HOMEBREW_VERSION: 3.0.8-32-g9a355b0
ORIGIN: https://github.com/Homebrew/brew
HEAD: 9a355b07c3706d9c0477827009ae817c8749261d
Last commit: 21 minutes ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 5f905845a19ef0d32641a3e0db131cd5a991b1ff
Core tap last commit: 34 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_DISPLAY: 192.168.59.3:0
HOMEBREW_GITHUB_API_TOKEN: set
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 kabylake
Clang: 12.0 build 1200
Git: 2.31.0 => /usr/local/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.2.3-x86_64
CLT: 12.4.0.0.1.1610135815
Xcode: 12.4

Output of brew doctor

$ brew doctor

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Some installed formulae are deprecated or disabled.
You should find replacements for the following formulae:
  guile@2

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
  /usr/local/lib/libwkhtmltox.0.12.6.dylib

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
  /usr/local/include/wkhtmltox/image.h
  /usr/local/include/wkhtmltox/pdf.h

Warning: You have uncommitted modifications to Homebrew/homebrew-core.
If this is a surprise to you, then you should stash these modifications.
Stashing returns Homebrew to a pristine state but can be undone
should you later need to do so for some reason.
  cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core && git stash && git clean -d -f

Uncommitted files:
   M Formula/wxmac.rb

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 24 (6 by maintainers)

Most upvoted comments

for anyone else running into this, i also fixed this by simply running xcode-select --install.

Putting following in early-init.el fixed the issue

(setenv "LIBRARY_PATH" "/usr/local/opt/gcc/lib/gcc/10:/usr/local/opt/libgccjit/lib/gcc/10:/usr/local/opt/gcc/lib/gcc/10/gcc/x86_64-apple-darwin20/10.2.0")

Please note, I have installed gcc and libgccjit without flag --force --build-from-source with homebrew. I didn’t try building from source as it was taking a lot of time (More than 20 mins)

I still see this warning though

Warning (comp): seq.el.gz:396:16: Warning: ‘seq-contains’ is an obsolete generic function (as of 27.1); use ‘seq-contains-p’ instead. Disable showing Disable logging

Here are some more warnings captured https://gist.github.com/8aa802fa01c6adee206cf1a6d64f711e

Is there any function or way which tells that gccemacs is perfectly working fine? As Emacs seems working fine from usability perspective.

@anildigital You can use M-x describe-function [RET] <func-name> to see if a specific function is natively compiled or not. For example doing so with ibuffer should yield this:

ibuffer is an interactive native compiled Lisp function in
‘ibuffer.el’.

However, if it’s a auto-loaded function that hasn’t been loaded yet, it will not mention native comp, for example, this is the output for M-x describe-function [RET] tramp-version for me before tramp is loaded:

tramp-version is an autoloaded interactive compiled Lisp function in
‘tramp-cmds.el’.

And this is after tramp is loaded:

tramp-version is an interactive native compiled Lisp function in
‘tramp-cmds.el’.

And sure enough the workaround broke with gcc going to version 12, new line:

(setenv "LIBRARY_PATH" "/opt/homebrew/opt/gcc/lib/gcc/12:/opt/homebrew/opt/libgccjit/lib/gcc/12:/opt/homebrew/opt/gcc/lib/gcc/12/gcc/aarch64-apple-darwin21/12")

I just had this issue as well and followed this suggestion you linked earlier in the thread @d12frosted to get it working, though I have no idea why that worked.

Worked for me on MacOs Sur with below entry in early-init.el as metioned above:

(setenv "LIBRARY_PATH" "/usr/local/Cellar/gcc/12.2.0:/usr/local/Cellar/libgccjit/12.2.0/lib/gcc/current:\
/usr/local/Cellar/gcc/12.2.0/lib/gcc/current/gcc/x86_64-apple-darwin20/12")

I had encountered the same issue and fixed by the following steps (not needed setenv):

  1. sudo rm -rf /Library/Developer/CommandLineTools
  2. Manually download and install latest Xcode CommandLineTools from https://developer.apple.com/download/all/
  3. sudo xcode-select -s /Library/Developer/CommandLineTools
  4. Optional (I think): brew uninstall and install emacs-plus

@anildigital in that case everything should be fine. I imagine it wasn’t showing before you hadn’t run magit-status since you launched Emacs. If you had, then ¯\_(ツ)_/¯

Well, modifying LIBRARY_PATH is a workaround, dirty one, not future-proof, but still a workaround. Not sure what’s wrong with your env though and why it doesn’t work for you. I will clean install soon to see the process from the beginning (I’ve been medling with my env so much during my attempts to introduce --with-native-comp option) 😸

AFAIK, there is no tool to check this. If it works, it works 😸 Those warnings are totally fine to see.

That’s because when you start applications from finder (or spotlight), environment is very different. There are many ways of dealing with this (one of the viable solutions is to use exec-path-from-shell). But in this particular case I would avoid messing with LIBRARY_PATH and rather reinstall libgccjit and try again (afaik, no need to build from sources):

$ brew uninstall gcc libgccjit
$ brew install gcc libgccjit

Hope that helps.