rbenv / ruby-build

A tool to download, compile, and install Ruby on Unix-like systems.
https://rbenv.org/man/ruby-build.1
MIT License
3.89k stars 785 forks source link

3.3.1 fails to build YJIT with Homebrew LLVM 18 #2372

Closed ryansdwilson closed 7 months ago

ryansdwilson commented 7 months ago

Discussed in https://github.com/rbenv/ruby-build/discussions/2371

3.3.1 fails to build on Mac OS

Originally posted by **stadia** April 25, 2024 macOS Sonoma 14.4.1 while build it 3.3.1, errors happened in Rust YJIT section ``` building Rust YJIT (release mode) dyld[30190]: Symbol not found: __ZN4llvm10PGOOptionsC1ENSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES7_S7_S7_NS_18IntrusiveRefCntPtrINS_3vfs10FileSystemEEENS0_9PGOActionENS0_11CSPGOActionEbb Referenced from: /opt/homebrew/Cellar/rust/1.77.2_1/lib/librustc_driver-3dc17bded25d4e59.dylib Expected in: /opt/homebrew/Cellar/llvm/18.1.4/lib/libLLVM.dylib make: *** [yjit/target/release/libyjit.a] Abort trap: 6 make: *** Waiting for unfinished jobs.... external command failed with status 2 ```

ruby-build.20240425093458.4257.log

attilagyorffy commented 7 months ago

@ryansdwilson How did you manage to fix the issue? (I'm assuming you managed to do so given that you've closed the issue relatively quickly). I'm also getting a yjit/target/release/libyjit.a Abort trap: 6 error.

ryansdwilson commented 7 months ago

Brew reinstall rust

attilagyorffy commented 7 months ago

thanks @ryansdwilson, I've tried that but didn't seem to solve the problem. I'll keep debugging (and may open another ticket if this one cannot be re-opened)

mislav commented 7 months ago

Reopening this since it still seems to be an issue. brew install rust results in LLVM 18 being installed, but Ruby (or Rust?) seem to prefer LLVM 17.

I was able to work around this by explicitly running brew install llvm@17.

mislav commented 7 months ago

Upon further inspection, this looks like it might be a Homebrew bug. The rust Homebrew formula explicitly depends on llvm@17, but brew install rust for me resulted in LLVM 18 being installed but not LLVM 17. According to what I can reconstruct from Homebrew output, Homebrew first installed rust which was satisfied by LLVM 17 already being installed, but then it allowed the upgrade LLVM 17 → 18, and in the end it deleted LLVM 17 as part of its cleanup process (which should not have happened per rust formula dependency).

I am not going to report this to the Homebrew project because I cannot reproduce it anymore, i.e. because the bug depends on a certain state of my system that I am now unable to get back to and therefore unable to explain to the Homebrew team.

attilagyorffy commented 7 months ago

Thanks @mislav, explicitly installing llvm@17 worked like a charm.

==> Installing ruby-3.3.1...
ruby-build: using libyaml from homebrew
ruby-build: using gmp from homebrew
-> ./configure "--prefix=$HOME/.rbenv/versions/3.3.1" --with-openssl-dir=/opt/homebrew/opt/openssl@3 --enable-shared --with-libyaml-dir=/opt/homebrew/opt/libyaml --with-gmp-dir=/opt/homebrew/opt/gmp --with-ext=openssl,psych,+ --enable-yjit
-> make -j 10
-> make install
==> Installed ruby-3.3.1 to /Users/attila/.rbenv/versions/3.3.1
hsbt commented 7 months ago

FYI: https://github.com/rust-lang/cargo/issues/13795 This issue caused by Homebrew's rust/cargo .