https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121115
Bug ID: 121115 Summary: GCC 15+ miscompiles Julia programming language Product: gcc Version: 15.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: keno at juliacomputing dot com Target Milestone: --- As mentioned in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115236#c7 (and originally reported in https://github.com/JuliaLang/julia/issues/58466), building the Julia programming language with GCC 15 results in a crashing build. This was bisected on the Julia issue tracker to https://gcc.gnu.org/cgit/gcc/commit/?id=c08b0d3f7b3539b26031de31d88dea6b94474577. I have attempted to come up with a minimal reproducer, but the bug is somewhat fragile. As a result, the reduced reproducer I have still depends on the julia/llvm libraries, but it should be standalone enough to not require a lot of setup. For completeness, I am also providing reproduction instructions for the original issue below. # Instructions for reduced reproducer The attached reproducer.expanded.cpp is a preprecossor-expanded and manually reduced version of Julia's aotcompile.cpp. However, running it depends on the julia/llvm external libraries, but not particularly closely, so the easiest way is to grab these from any recent nightly build of julia: ``` $ curl -LO https://julialangnightlies-s3.julialang.org/bin/linux/x86_64/julia-latest-linux-x86_64.tar.gz $ tar --strip-components=1 --wildcards -xf julia-latest-linux-x86_64.tar.gz '*LLVM.so*' '*libjulia*.so*' '*libunwind.so*' '*libopenlibm.so*' $ g++-15 -mprefer-vector-width=256 -std=c++17 -fno-exceptions -funwind-tables -fno-rtti -Llib -Llib/julia -lLLVM -ljulia-internal -ljulia -Wl,-rpath lib -Wl,-rpath lib/julia -O3 reproducer.expanded.cpp [snip warnings] $ ./a.out Unreachable reached at 0x4022b9 [3424449] signal 4 (2): Illegal instruction in expression starting at none:0 jl_emit_native_impl.cold at ./a.out (unknown line) main at ./a.out (unknown line) unknown function (ip: 0x746dbbe2a1c9) at /lib/x86_64-linux-gnu/libc.so.6 __libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line) _start at ./a.out (unknown line) Allocations: 1 (Pool: 1; Big: 0); GC: 0 Illegal instruction $ g++-15 -mprefer-vector-width=256 -std=c++17 -fno-exceptions -funwind-tables -fno-rtti -Llib -Llib/julia -lLLVM -ljulia-internal -ljulia -Wl,-rpath lib -Wl,-rpath lib/julia -O0 reproducer.expanded.cpp [snip warnings] $ ./a.out [no crash] ``` The `Illegal instruction` here is a `__builtin_trap` that marks the bug - the original reproducer segfaults on the next line instead. The `-mprefer-vector-width=256` is not required on current GCC, but I've included it to facilitate bisect, since the regression commit range includes a commit that switches the default for this flag (and it affects the presence of the bug). # Instructions for upstream reproducer To test upstream, ``` $ git clone https://github.com/JuliaLang/julia.git $ cd julia $ cat > Make.user <<END CC=gcc-15 CXX=g++-15 END $ make -j40 ``` The symptoms of the bug are that julia will fail to compile some of it's stdlibs, crashing in aotcompile.cpp. After a build like the above failed, a good quick test is `./julia -e 'using Unicode'`, which will attempt to compile the Julia unicode standard library and will crash if the bug is present.