homebrew-emacs-plus icon indicating copy to clipboard operation
homebrew-emacs-plus copied to clipboard

Installation fails with libgccjit (and possibly gcc) 14.1.0 recent release

Open wenzlawski opened this issue 1 year ago β€’ 17 comments

Version

emacs-plus@30

Make sure to follow these steps before submitting the issue

  • [x] run brew update and try to reproduce the issue again
  • [x] run brew doctor, fix all issues and try to reproduce your issue again
  • [x] try to reproduce your issue without any custom options to the formula

What happened?

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

(omitted dependency installs for brevity)

==> Installing d12frosted/emacs-plus/emacs-plus@30 --with-native-comp [34m==>[0m [1mPatching[0m [34m==>[0m [1mApplying fix-window-role.patch[0m patching file 'src/nsterm.m' [34m==>[0m [1mApplying system-appearance.patch[0m patching file 'src/frame.h' patching file 'src/nsfns.m' patching file 'src/nsterm.m' [34m==>[0m [1mApplying round-undecorated-frame.patch[0m patching file 'src/frame.c' patching file 'src/frame.h' patching file 'src/nsfns.m' patching file 'src/nsterm.h' patching file 'src/nsterm.m' [34m==>[0m [1m./autogen.sh[0m [34m==>[0m [1m./configure --disable-silent-rules --enable-locallisppath=/usr/local/share/e[0m Last 15 lines from /Users/mw/Library/Logs/Homebrew/emacs-plus@30/02.configure: checking for library containing inflateEnd... -lz checking for dladdr... yes checking for dlfunc... no checking for gcc_jit_context_acquire in -lgccjit... yes checking for libgccjit.h... yes configure: error: The installed libgccjit failed to compile and run a test program using the libgccjit library; see config.log for the details of the failure. The test program can be found here: https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html. You can try compiling it yourself to investigate the issues. Please report the issue to your distribution if libgccjit was installed through that. You can find the instructions on how to compile and install libgccjit from source on this site: https://gcc.gnu.org/wiki/JIT.

If reporting this issue please do so at (not Homebrew/brew or Homebrew/homebrew-core): https://github.com/d12frosted/homebrew-emacs-plus/issues

brew doctor output

Your system is ready to brew.

brew config output

HOMEBREW_VERSION: 4.2.21-99-g9a49d67 ORIGIN: https://github.com/Homebrew/brew HEAD: 9a49d677150c074380fbf8c4d184a0f660df2386 Last commit: 18 hours ago Core tap JSON: 11 May 13:24 UTC Core cask tap JSON: 11 May 13:24 UTC HOMEBREW_PREFIX: /usr/local HOMEBREW_CASK_OPTS: [] HOMEBREW_MAKE_JOBS: 12 HOMEBREW_SORBET_RUNTIME: set Homebrew Ruby: 3.1.4 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/bin/ruby CPU: dodeca-core 64-bit kabylake Clang: 15.0.0 build 1500 Git: 2.39.3 => /Library/Developer/CommandLineTools/usr/bin/git Curl: 8.4.0 => /usr/bin/curl macOS: 14.4.1-x86_64 CLT: 15.3.0.0.1.1708646388 Xcode: N/A

Any extra information

This is on a fresh installation of macOS Sonoma.

Probably something to do with the new libgccjit version released a few days ago.

wenzlawski avatar May 11 '24 13:05 wenzlawski

More information for troubleshooting in case you need it.

Termination Reason:    Namespace DYLD, Code 1 Library missing
Library not loaded: @rpath/libgcc_s.1.1.dylib
Referenced from: <C93A88B4-A5C5-3C6F-9F9B-CB9D58FF003E> /usr/local/Cellar/libgccjit/14.1.0/lib/gcc/current/libgccjit.0.dylib
Reason: tried: '/usr/local/Cellar/libgccjit/14.1.0/lib/gcc/current/libgcc_s.1.1.dylib' (no such file), '/usr/local/lib/libgcc_s.1.1.dylib' (no such file), '/usr/lib/libgcc_s.1.1.dylib' (no such file, not in dyld cache)
(terminated at launch; ignore backtrace)

I copied libgcc_s.1.1.dylib from /usr/local/Cellar/gcc/14.1.0/lib/gcc/current to /usr/local/Cellar/libgccjit/14.1.0/lib/gcc/current, and everything worked again.

seagle0128 avatar May 11 '24 14:05 seagle0128

Thanks, that did the trick!

wenzlawski avatar May 11 '24 21:05 wenzlawski

Another temporary workaround is: https://github.com/daviderestivo/homebrew-emacs-head/issues/206#issuecomment-2102197426

daviderestivo avatar May 13 '24 08:05 daviderestivo

Since the workaround wasn't not shared in this thread yet (only a link to other threads), let me keep it here for visibility:

ln -s /usr/local/Cellar/libgccjit/14.1.0/lib/gcc/14/libgccjit.dylib /usr/local/lib/
ln -s /usr/local/Cellar/libgccjit/14.1.0/lib/gcc/14/libgccjit.0.dylib /usr/local/lib/

ln -s /usr/local/Cellar/gcc/14.1.0/lib/gcc/14/libgcc_s.1.dylib /usr/local/lib/
ln -s /usr/local/Cellar/gcc/14.1.0/lib/gcc/14/libgcc_s.1.1.dylib /usr/local/lib/

Let me see if I can reproduce it and we'll probably need to fix these lines:

https://github.com/d12frosted/homebrew-emacs-plus/blob/61a1e971b228f416a95374cb8e5d95631fff3a42/Formula/emacs-plus%4030.rb#L139-L141

@jidicula in case you figured that already out, PR is welcome πŸ™ πŸ˜… you are usually really fast with these kind of things πŸ˜…

d12frosted avatar May 14 '24 05:05 d12frosted

So frankly, I could not reproduce it.

Here is the log with a few irrelevant lines removed (p.s. emacs-plus-local is just a local formula copy to avoid meddling with the Emacs version I am currently using):

~/D/homebrew-emacs-plus masterβ€’ Ξ» ./build 30 --with-native-comp
Uninstalling /opt/homebrew/Cellar/emacs-plus-local/30.0.50... (4,322 files, 196.3MB)
==> Fetching dependencies for emacs-plus-local: awk, openssl@3, unbound, glib, jpeg-turbo, fribidi, tree-sitter, isl, mpfr, libmpc, libgccjit, gcc, jpeg and zlib
..........
==> Fetching libgccjit
==> Downloading https://ghcr.io/v2/homebrew/core/libgccjit/manifests/14.1.0
################################################################################################################################# 100.0%
..........
==> Fetching gcc
==> Downloading https://ghcr.io/v2/homebrew/core/gcc/manifests/14.1.0
################################################################################################################################# 100.0%
..........
==> Fetching emacs-plus-local
==> Cloning https://github.com/emacs-mirror/emacs.git
Cloning into '/Users/d12frosted/Library/Caches/Homebrew/emacs-plus-local--git'...
Updating files: 100% (5267/5267), done.
==> Checking out branch master
Already on 'master'
Your branch is up to date with 'origin/master'.
==> Installing dependencies for emacs-plus-local: awk, openssl@3, unbound, glib, jpeg-turbo, fribidi, tree-sitter, isl, mpfr, libmpc, libgccjit, gcc, jpeg and zlib
..........
==> Installing emacs-plus-local dependency: libgccjit
==> Downloading https://ghcr.io/v2/homebrew/core/libgccjit/manifests/14.1.0
Already downloaded: /Users/d12frosted/Library/Caches/Homebrew/downloads/1eb69fd575bb54084eb68ba3dd69d6a7a26fdf8379073e5181a5f728958e459c--libgccjit-14.1.0.bottle_manifest.json
==> Pouring libgccjit--14.1.0.arm64_sonoma.bottle.tar.gz
🍺  /opt/homebrew/Cellar/libgccjit/14.1.0: 15 files, 40.9MB
==> Installing emacs-plus-local dependency: gcc
==> Downloading https://ghcr.io/v2/homebrew/core/gcc/manifests/14.1.0
Already downloaded: /Users/d12frosted/Library/Caches/Homebrew/downloads/ee68530c6f641f1338c1a2f4143f73efa5d54a1c2fe2e74eb45499b74e1b75c9--gcc-14.1.0.bottle_manifest.json
==> Pouring gcc--14.1.0.arm64_sonoma.bottle.tar.gz
🍺  /opt/homebrew/Cellar/gcc/14.1.0: 1,560 files, 422.6MB
..........
==> Installing emacs-plus-local --with-native-comp
==> Patching
==> Applying fix-window-role.patch
patching file 'src/nsterm.m'
==> Applying system-appearance.patch
patching file 'src/frame.h'
patching file 'src/nsfns.m'
patching file 'src/nsterm.m'
==> Applying round-undecorated-frame.patch
patching file 'src/frame.c'
patching file 'src/frame.h'
patching file 'src/nsfns.m'
patching file 'src/nsterm.h'
patching file 'src/nsterm.m'
==> ./autogen.sh
==> ./configure --disable-silent-rules --enable-locallisppath=/opt/homebrew/share/emacs/site-lisp --infodir=/opt/homebrew/Cellar/emacs-p
==> gmake
==> gmake install
==> Injecting PATH value to Emacs.app/Contents/Info.plist
Patching plist at /opt/homebrew/Cellar/emacs-plus-local/30.0.50/Emacs.app/Contents/Info.plist with following PATH value:
/Users/d12frosted/.amplify/bin
/Users/d12frosted/.config/bin
/Users/d12frosted/.local/bin
/Users/d12frosted/.nix-profile/bin
/opt/homebrew/opt/llvm/bin
/opt/homebrew/bin
/opt/homebrew/sbin
/run/current-system/sw/bin
/nix/var/nix/profiles/default/bin
/usr/local/bin
/System/Cryptexes/App/usr/bin
/opt/X11/bin
/usr/bin
/bin
/usr/sbin
/sbin
==> /usr/libexec/PlistBuddy -c 'Add :LSEnvironment dict' '/opt/homebrew/Cellar/emacs-plus-local/30.0.50/Emacs.app/Contents/Info.plist'
==> /usr/libexec/PlistBuddy -c 'Add :LSEnvironment:PATH string' '/opt/homebrew/Cellar/emacs-plus-local/30.0.50/Emacs.app/Contents/Info.p
==> /usr/libexec/PlistBuddy -c 'Set :LSEnvironment:PATH /Users/d12frosted/.amplify/bin:/Users/d12frosted/.config/bin:/Users/d12frosted/.
==> /usr/libexec/PlistBuddy -c 'Print :LSEnvironment' '/opt/homebrew/Cellar/emacs-plus-local/30.0.50/Emacs.app/Contents/Info.plist'
==> touch '/opt/homebrew/Cellar/emacs-plus-local/30.0.50/Emacs.app'
==> Injecting description for protected resources usage
==> /usr/libexec/PlistBuddy -c 'Add NSCameraUsageDescription string' '/opt/homebrew/Cellar/emacs-plus-local/30.0.50/Emacs.app/Contents/I
==> /usr/libexec/PlistBuddy -c 'Set NSCameraUsageDescription Emacs requires permission to access the Camera.' '/opt/homebrew/Cellar/emac
==> /usr/libexec/PlistBuddy -c 'Add NSMicrophoneUsageDescription string' '/opt/homebrew/Cellar/emacs-plus-local/30.0.50/Emacs.app/Conten
==> /usr/libexec/PlistBuddy -c 'Set NSMicrophoneUsageDescription Emacs requires permission to access the Microphone.' '/opt/homebrew/Cel
==> touch '/opt/homebrew/Cellar/emacs-plus-local/30.0.50/Emacs.app'

As I am not using native-comp I think I didn't have previous version of libgccjit. So it's more or less clean installation.

Did anyone try uninstalling gcc and libgccjit? If it works I would actually prefer telling people to reinstall instead of actually meddling with gcc/libgccjit installation.

d12frosted avatar May 14 '24 06:05 d12frosted

Did anyone try uninstalling gcc and libgccjit?

@d12frosted yes, and didn't help for me sadly.

In my case I ended up installing emacs-mac-app from MacPorts instead of emacs-plus homebrew, that worked without issue for me.

elondres-mim avatar May 14 '24 12:05 elondres-mim

Do they have native comp? 🀨 I can check their formula later, maybe we are doing something completely wrong here πŸ˜…

d12frosted avatar May 14 '24 12:05 d12frosted

Yeah, when you install with the +nativecomp variant.

elondres-mim avatar May 14 '24 12:05 elondres-mim

@elondres-mim thanks, will check.

And I just had a random thought. We are not using brew super env, which might actually causing the issue.

If someone can test if it works when you comment :env std somewhere in the beginning of the formula definition, that would be helpful. I am not near laptop to send actual line, sorry.

d12frosted avatar May 14 '24 12:05 d12frosted

Oh, found how to link on mobile. I was talking about these lines:

https://github.com/d12frosted/homebrew-emacs-plus/blob/master/Formula/[email protected]#L7-L9

d12frosted avatar May 14 '24 13:05 d12frosted

@jidicula in case you figured that already out, PR is welcome πŸ™ πŸ˜… you are usually really fast with these kind of things πŸ˜…

Interesting, I haven't run into this issue and I'm regularly brew-updating and brew-upgrading. I'm currently on emacs-plus@30 too and I didn't notice any hiccups or Emacs rebuilds with libgccjit updates on either of my Macs πŸ€”

❯ brew install libgccjit
Warning: libgccjit 14.1.0 is already installed and up-to-date.
To reinstall 14.1.0, run:
  brew reinstall libgccjit

I'm a tiny bit scared to try the Emacs uninstall+reinstall - I don't have the cycles at the moment to wade through build breakages atm.

jidicula avatar May 18 '24 00:05 jidicula

@d12frosted I did a bit more of analysis in here https://github.com/daviderestivo/homebrew-emacs-head/issues/206#issuecomment-2118742269 ... maybe it helps :)

daviderestivo avatar May 18 '24 09:05 daviderestivo

Didn't do as much digging as @daviderestivo did in the other thread, but anecdotally, I also have an Intel CPU-based Mac and an M1-based Mac, and I had this issue on the one with the Intel CPU but not the one with the M1.

adamliter avatar May 18 '24 14:05 adamliter

but anecdotally, I also have an Intel CPU-based Mac and an M1-based Mac, and I had this issue on the one with the Intel CPU but not the one with the M1.

that might explain why I didn't see this issue - both of my Macs are Apple Silicon Macs.

jidicula avatar May 18 '24 20:05 jidicula

Confirmed. My Mac is also with Intel CPU.

seagle0128 avatar May 19 '24 04:05 seagle0128

FYI, brew update && brew reinstall libgccjit fixes this problem.

  • https://github.com/orgs/Homebrew/discussions/5364
  • https://github.com/Homebrew/homebrew-core/commit/5ffdd7fde52adf55fc967864c04ab4e6f63f6092

soonhokong avatar May 22 '24 14:05 soonhokong

FYI, brew update && brew reinstall libgccjit fixes this problem.

* https://github.com/orgs/Homebrew/discussions/5364

* [Homebrew/homebrew-core@5ffdd7f](https://github.com/Homebrew/homebrew-core/commit/5ffdd7fde52adf55fc967864c04ab4e6f63f6092)

also worked for me, on Intel Mac.

i'd recently run brew after many weeks and then started getting weird crash messages in Emacs (i think trying to native compile). Eventually the whole thing crashed tonight and it was this libgccjit issue. i'm currently trying to upgrade from 29.1 to 29.3

gcentauri avatar May 23 '24 03:05 gcentauri

Cool, so indeed it was an upstream issue, which is already fixed, so closing this one.

Thanks everyone!

d12frosted avatar May 25 '24 06:05 d12frosted

FYI, brew update && brew reinstall libgccjit fixes this problem.

* https://github.com/orgs/Homebrew/discussions/5364

* [Homebrew/homebrew-core@5ffdd7f](https://github.com/Homebrew/homebrew-core/commit/5ffdd7fde52adf55fc967864c04ab4e6f63f6092)

When I ran this, I get the following error when installing emacs-plus:

checking for gcc_jit_context_acquire in -lgccjit... yes
checking for libgccjit.h... yes
configure: error: The installed libgccjit failed to compile and run a test program using
the libgccjit library; see config.log for the details of the failure.
The test program can be found here:
<https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html>.
You can try compiling it yourself to investigate the issues.
Please report the issue to your distribution if libgccjit was installed
through that.
You can find the instructions on how to compile and install libgccjit from
source on this site:
<https://gcc.gnu.org/wiki/JIT>.

If reporting this issue please do so at (not Homebrew/brew or Homebrew/homebrew-core):
  https://github.com/d12frosted/homebrew-emacs-plus/issues

This seems to be the error in config.log:

5221   β”‚ configure:20509: $? = 0
5222   β”‚ configure:20509: ./conftest
5223   β”‚ dyld[21515]: Library not loaded: @rpath/libgccjit.0.dylib
5224   β”‚   Referenced from: <B83F28CD-9C18-3332-BA5E-B8042F6963A9> /private/tmp/emacs-plusA29-20240531-19053-bt1kwq/emacs-29.3/confte
       β”‚ st
5225   β”‚   Reason: no LC_RPATH's found
5226   β”‚ ./configure: line 3448: 21515 Abort trap: 6           ./conftest$ac_exeext
5227   β”‚ configure:20509: $? = 134
5228   β”‚ configure: program exited with status 134
5

elondres-mim avatar May 31 '24 13:05 elondres-mim