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

Created on 23 Mar 2021  Â·  15Comments  Â·  Source: d12frosted/homebrew-emacs-plus

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
install error

Most helpful comment

@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’.

All 15 comments

Hard to tell what's wrong. I would love to hear all the steps you did prior to getting this error (including any modifications to LD_LIBRARY_PATH, LIBRARY_PATH or alike).

You may try this and this.

@d12frosted So I tried this from terminal

env LIBRARY_PATH="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib"
...
...
LIBRARY_PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
anil@mbp ~> /Applications/Emacs.app/Contents/MacOS/Emacs

The below 2 warnings I wanted to go are gone.

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

And only show this warning.

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

But when I start Emacs (clicking or from Finder) after putting following at the top of init.el or even early-init.el doesn't help, warnings come back again.

(setenv "LIBRARY_PATH" "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib")

I am not sure how to fix this now.

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.

@d12frosted I did try above uninstall, install for gcc and libgccjit. But it seems not helping. Still getting following warnings when I start Emacs from Spotlight/Finder.

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

Also I do use exec-path-from-shell, but that seems not helping either.

@d12frosted Emacs is working fine irrespective of above warnings. Does that mean I can ignore these warnings and there is no impact in performance of Emacs?

Also I do use exec-path-from-shell, but that seems not helping either.

I believe that in the case of gccemacs, exec-path-from-shell happens too late.

Does that mean I can ignore these warnings and there is no impact in performance of Emacs?

AFAIU, it means that gccemacs is not working for you :) And you will run into these warnings quite often and you will not get any performance gain.

Can you please share output of your env? :) But before blindly sharing it, please make sure to remove any lines containing any sensitive information. I am mostly interested in various gcc-related values.

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.

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.

@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’.

@jimeh I see following for ibuffer

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

but for magit-status, I see

magit-status is an interactive compiled Lisp function in
‘magit-status.el’.

@anildigital Try ibuffer again after opening it with M-x ibuffer, cause it looks like ibuffer has not been loaded.

As for magit, it looks like it has been loaded, but not been native compiled. This would suggest either something is wrong with native compilation for externally installed packages, or it's just not working in general. If ibuffer is native compiled after using it, it's related to external packages.

Do you have a *Async-native-compile-log* buffer? It should hopefully give some hints as to whats going on.

@jimeh Yep it shows now for ibuffer

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

for magit

I now see

magit-log is an interactive native compiled Lisp function in
‘magit-log.el’.
...
magit-mode is an interactive native compiled Lisp function in
‘magit-mode.el’.
...
magit-status is an interactive native compiled Lisp function in
‘magit-status.el’.
...
magit-diff is an interactive native compiled Lisp function in
‘magit-diff.el’.

I wonder why it was not showing native compiled before. *Async-native-compile-log* seems fine and shows compiling various packages.

@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 ¯\_(ツ)_/¯

Thanks @jimeh for your help!

Closing the issue as it seems that everything is working now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

agzam picture agzam  Â·  6Comments

thomasheartman picture thomasheartman  Â·  5Comments

d12frosted picture d12frosted  Â·  8Comments

d12frosted picture d12frosted  Â·  6Comments

smallzhan picture smallzhan  Â·  7Comments