Open1
gcc 13.3.0 での ruby 3.4.4 コンパイル

TLDR
- gcc 13.3.0 で mise install ruby 3.4.4 のコンパイルが失敗する。最適化をやめることで解決
- gcc 14.2.0 ならコンパイル成功
環境
WSL2 の Ubuntu 24.04
$ uname -a
Linux Windows11 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=24.04
DISTRIB_CODENAME=noble
DISTRIB_DESCRIPTION="Ubuntu 24.04.2 LTS"
$ gcc --version
gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
エラー内容
Segmentation fault で落ちる場所はばらばら。過去、コンパイルできた 3.4.2, 3.4.3 もコンパイル失敗する。
$ MISE_JOBS=28 mise install ruby 3.4.4
INFO ruby@3.4.4 compiling vm_dump.c
INFO ruby@3.4.4 compiling vm_sync.c
during GIMPLE pass: threadfull
rational.c: In function ‘rb_gcdlcm’:
rational.c:1953:1: internal compiler error: Segmentation fault
1953 | rb_gcdlcm(VALUE self, VALUE other)
| ^~~~~~~~~
0x108d8f4 internal_error(char const*, ...)
???:0
0x12a2ac4 bitmap_copy(bitmap_head*, bitmap_head const*)
???:0
0x13aced4 path_range_query::compute_ranges(bitmap_head const*)
???:0
0x13b9f00 back_threader::find_taken_edge_cond(vec<basic_block_def*, va_heap, vl_ptr> const&, gcond*)
???:0
0x13a7c80 back_threader::maybe_register_path(back_threader_profitability&)
???:0
0x13a1161 back_threader::find_paths_to_names(basic_block_def*, bitmap_head*, unsigned int, back_threader_profitability&)
???:0
0x13a1546 back_threader::find_paths_to_names(basic_block_def*, bitmap_head*, unsigned int, back_threader_profitability&)
???:0
0x139ffa6 back_threader::maybe_thread_block(basic_block_def*)
???:0
0x136c451 back_threader::thread_blocks()
???:0
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-13/README.Bugs> for instructions.
make: *** [Makefile:463: rational.o] Error 1
make: *** Waiting for unfinished jobs....
during RTL pass: bbpart
In file included from compile.c:14733:
prism_compile.c: In function ‘pm_static_literal_value’:
prism_compile.c:830:1: internal compiler error: Segmentation fault
830 | }
| ^
0x108d8f4 internal_error(char const*, ...)
???:0
0x12a2ac4 bitmap_copy(bitmap_head*, bitmap_head const*)
???:0
0x149002b run_fast_df_dce()
???:0
0x141e49b df_analyze_problem(dataflow*, bitmap_head*, int*, int)
???:0
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-13/README.Bugs> for instructions.
make: *** [Makefile:462: compile.o] Error 1
INFO ruby@3.4.4 external command failed with status 2
BUILD FAILED (Ubuntu 24.04 on x86_64 using ruby-build 20250516)
You can inspect the build directory at /tmp/ruby-build.20250524174059.29769.igifpG
ERROR ~/.cache/mise/ruby/ruby-build/bin/ruby-build failed
Error:
0: failed to install core:ruby@3.4.4
1: ~/.cache/mise/ruby/ruby-build/bin/ruby-build exited with non-zero status: exit code 1
Location:
src/cmd.rs:479
Version:
2025.4.11 linux-x64 (2025-04-27)
Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
最適化をやめる
13.3.0 は最適化をやめることでコンパイル成功。
$ export CFLAGS="-O0"
export CPPFLAGS="-O0"
export CXXFLAGS="-O0"
export LDFLAGS=""
$ MISE_JOBS=28 mise install ruby 3.4.4
$ ruby -v
ruby 3.4.4 (2025-05-14 revision a38531fd3f) +PRISM [x86_64-linux]
14.2.0 なら普通にコンパイル成功する
gcc 13.x から 14.x にアップグレード
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install gcc-14 g++-14
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
$ gcc --version
gcc (Ubuntu 14.2.0-4ubuntu2~24.04) 14.2.0
$ mise uninstall ruby 3.4.4
$ MISE_JOBS=28 mise install ruby 3.4.4
$ ruby -v
ruby 3.4.4 (2025-05-14 revision a38531fd3f) +PRISM [x86_64-linux]