d12frosted / homebrew-emacs-plus

Emacs Plus formulae for the Homebrew package manager
MIT License
2.24k stars 175 forks source link

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

Closed wenzlawski closed 1 month ago

wenzlawski commented 1 month ago

Version

emacs-plus@30

Make sure to follow these steps before submitting the issue

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
==> 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=/usr/local/share/e
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:
.
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:
.

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.

seagle0128 commented 1 month ago

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.

wenzlawski commented 1 month ago

Thanks, that did the trick!

daviderestivo commented 1 month ago

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

d12frosted commented 1 month ago

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 commented 1 month ago

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.

elondres-mim commented 1 month ago

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.

d12frosted commented 1 month ago

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

elondres-mim commented 1 month ago

Yeah, when you install with the +nativecomp variant.

d12frosted commented 1 month ago

@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 commented 1 month ago

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

https://github.com/d12frosted/homebrew-emacs-plus/blob/master/Formula/emacs-plus@30.rb#L7-L9

jidicula commented 1 month ago

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

daviderestivo commented 1 month ago

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

adamliter commented 1 month ago

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.

jidicula commented 1 month ago

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.

seagle0128 commented 1 month ago

Confirmed. My Mac is also with Intel CPU.

soonhokong commented 1 month ago

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

gcentauri commented 1 month ago

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

d12frosted commented 1 month ago

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

Thanks everyone!

elondres-mim commented 1 month ago

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