Zig 0.14 bootstrap fails on Void Linux
Description
Recently, building zig on Void Linux ends up in a segfault during the stage3 step.
The issue started happening roughly after we updated system toolchain to gcc 14.2.1, and curiously enough, doesn't reproduce with musl libc.
Info
Zig version: 0.14.0, 0.14.1
Zig package PR: https://github.com/void-linux/void-packages/pull/54650
configure log
-- The C compiler identification is GNU 14.2.1
-- The CXX compiler identification is GNU 14.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring zig version 0.14.1
-- Found llvm: -lLLVM-19;-lrt;-ldl;-lm;/usr/lib/libz3.so;-lz;-lzstd;-lxml2 (Required is at least version "19")
-- Found clang: /usr/lib/llvm/19/lib/libclang-cpp.so.19.1 (Required is at least version "19")
-- Found lld: /usr/lib/llvm/19/lib/liblldMinGW.a;/usr/lib/llvm/19/lib/liblldELF.a;/usr/lib/llvm/19/lib/liblldCOFF.a;/usr/lib/llvm/19/lib/liblldWasm.a;/usr/lib/llvm/19/lib/liblldMachO.a;/usr/lib/llvm/19/lib/liblldCommon.a (Required is at least version "19")
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Configuring done (0.7s)
-- Generating done (0.0s)
CMake Warning:
Manually-specified variables were not used by the project:
CMAKE_INSTALL_LIBDIR
CMAKE_INSTALL_SBINDIR
CMAKE_INSTALL_SYSCONFDIR
-- Build files have been written to: /builddir/zig-0.14.1/build
build log
[1/19] /usr/bin/cc -DNDEBUG -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -ffile-prefix-map=/builddir/zig-0.14.1/build=. -std=c99 -O2 -MD -MT CMakeFiles/zig-wasm2c.dir/stage1/wasm2c.c.o -MF CMakeFiles/zig-wasm2c.dir/stage1/wasm2c.c.o.d -o CMakeFiles/zig-wasm2c.dir/stage1/wasm2c.c.o -c /builddir/zig-0.14.1/stage1/wasm2c.c
[2/19] : && /usr/bin/cc -DNDEBUG -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -ffile-prefix-map=/builddir/zig-0.14.1/build=. -Wl,-z,relro -Wl,-z,now -Wl,--as-needed CMakeFiles/zig-wasm2c.dir/stage1/wasm2c.c.o -o zig-wasm2c -L/usr/lib/llvm/19/lib && :
[3/19] cd /builddir/zig-0.14.1 && /builddir/zig-0.14.1/build/zig-wasm2c /builddir/zig-0.14.1/stage1/zig1.wasm /builddir/zig-0.14.1/build/zig1.c
[4/19] /usr/bin/cc -DNDEBUG -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -ffile-prefix-map=/builddir/zig-0.14.1/build=. -std=c99 -Os -MD -MT CMakeFiles/zig1.dir/stage1/wasi.c.o -MF CMakeFiles/zig1.dir/stage1/wasi.c.o.d -o CMakeFiles/zig1.dir/stage1/wasi.c.o -c /builddir/zig-0.14.1/stage1/wasi.c
[5/19] /usr/bin/g++ -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/usr/lib/llvm/19/include -DNDEBUG -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -ffile-prefix-map=/builddir/zig-0.14.1/build=. -fPIC -fno-exceptions -fno-rtti -fno-stack-protector -fvisibility-inlines-hidden -Wno-type-limits -Wno-missing-braces -Wno-comment -MD -MT CMakeFiles/zigcpp.dir/src/zig_llvm-ar.cpp.o -MF CMakeFiles/zigcpp.dir/src/zig_llvm-ar.cpp.o.d -o CMakeFiles/zigcpp.dir/src/zig_llvm-ar.cpp.o -c /builddir/zig-0.14.1/src/zig_llvm-ar.cpp
[6/19] /usr/bin/g++ -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/usr/lib/llvm/19/include -DNDEBUG -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -ffile-prefix-map=/builddir/zig-0.14.1/build=. -fPIC -fno-exceptions -fno-rtti -fno-stack-protector -fvisibility-inlines-hidden -Wno-type-limits -Wno-missing-braces -Wno-comment -MD -MT CMakeFiles/zigcpp.dir/src/zig_clang_cc1as_main.cpp.o -MF CMakeFiles/zigcpp.dir/src/zig_clang_cc1as_main.cpp.o.d -o CMakeFiles/zigcpp.dir/src/zig_clang_cc1as_main.cpp.o -c /builddir/zig-0.14.1/src/zig_clang_cc1as_main.cpp
[7/19] /usr/bin/g++ -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/usr/lib/llvm/19/include -DNDEBUG -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -ffile-prefix-map=/builddir/zig-0.14.1/build=. -fPIC -fno-exceptions -fno-rtti -fno-stack-protector -fvisibility-inlines-hidden -Wno-type-limits -Wno-missing-braces -Wno-comment -MD -MT CMakeFiles/zigcpp.dir/src/zig_clang_driver.cpp.o -MF CMakeFiles/zigcpp.dir/src/zig_clang_driver.cpp.o.d -o CMakeFiles/zigcpp.dir/src/zig_clang_driver.cpp.o -c /builddir/zig-0.14.1/src/zig_clang_driver.cpp
[8/19] /usr/bin/g++ -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/usr/lib/llvm/19/include -DNDEBUG -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -ffile-prefix-map=/builddir/zig-0.14.1/build=. -fPIC -fno-exceptions -fno-rtti -fno-stack-protector -fvisibility-inlines-hidden -Wno-type-limits -Wno-missing-braces -Wno-comment -MD -MT CMakeFiles/zigcpp.dir/src/zig_clang.cpp.o -MF CMakeFiles/zigcpp.dir/src/zig_clang.cpp.o.d -o CMakeFiles/zigcpp.dir/src/zig_clang.cpp.o -c /builddir/zig-0.14.1/src/zig_clang.cpp
[9/19] /usr/bin/g++ -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/usr/lib/llvm/19/include -DNDEBUG -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -ffile-prefix-map=/builddir/zig-0.14.1/build=. -fPIC -fno-exceptions -fno-rtti -fno-stack-protector -fvisibility-inlines-hidden -Wno-type-limits -Wno-missing-braces -Wno-comment -MD -MT CMakeFiles/zigcpp.dir/src/zig_clang_cc1_main.cpp.o -MF CMakeFiles/zigcpp.dir/src/zig_clang_cc1_main.cpp.o.d -o CMakeFiles/zigcpp.dir/src/zig_clang_cc1_main.cpp.o -c /builddir/zig-0.14.1/src/zig_clang_cc1_main.cpp
[10/19] /usr/bin/g++ -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/usr/lib/llvm/19/include -DNDEBUG -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -ffile-prefix-map=/builddir/zig-0.14.1/build=. -fPIC -fno-exceptions -fno-rtti -fno-stack-protector -fvisibility-inlines-hidden -Wno-type-limits -Wno-missing-braces -Wno-comment -MD -MT CMakeFiles/zigcpp.dir/src/zig_llvm.cpp.o -MF CMakeFiles/zigcpp.dir/src/zig_llvm.cpp.o.d -o CMakeFiles/zigcpp.dir/src/zig_llvm.cpp.o -c /builddir/zig-0.14.1/src/zig_llvm.cpp
[11/19] : && /usr/libexec/xbps-src/bin/cmake -E rm -f zigcpp/libzigcpp.a && /usr/bin/ar qc zigcpp/libzigcpp.a CMakeFiles/zigcpp.dir/src/zig_llvm.cpp.o CMakeFiles/zigcpp.dir/src/zig_llvm-ar.cpp.o CMakeFiles/zigcpp.dir/src/zig_clang.cpp.o CMakeFiles/zigcpp.dir/src/zig_clang_driver.cpp.o CMakeFiles/zigcpp.dir/src/zig_clang_cc1_main.cpp.o CMakeFiles/zigcpp.dir/src/zig_clang_cc1as_main.cpp.o && /usr/bin/ranlib zigcpp/libzigcpp.a && :
[12/19] /usr/bin/cc -DNDEBUG -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -ffile-prefix-map=/builddir/zig-0.14.1/build=. -std=c99 -Os -MD -MT CMakeFiles/zig1.dir/zig1.c.o -MF CMakeFiles/zig1.dir/zig1.c.o.d -o CMakeFiles/zig1.dir/zig1.c.o -c /builddir/zig-0.14.1/build/zig1.c
[13/19] : && /usr/bin/cc -DNDEBUG -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -ffile-prefix-map=/builddir/zig-0.14.1/build=. -Wl,-z,relro -Wl,-z,now -Wl,--as-needed CMakeFiles/zig1.dir/zig1.c.o CMakeFiles/zig1.dir/stage1/wasi.c.o -o zig1 -L/usr/lib/llvm/19/lib -Wl,-rpath,/usr/lib/llvm/19/lib -lm && :
[14/19] cd /builddir/zig-0.14.1 && /builddir/zig-0.14.1/build/zig1 /builddir/zig-0.14.1/lib build-obj -ofmt=c -OReleaseSmall --name compiler_rt -femit-bin="/builddir/zig-0.14.1/build/compiler_rt.c" -target x86_64-linux -Mroot=lib/compiler_rt.zig
[15/19] cd /builddir/zig-0.14.1 && /builddir/zig-0.14.1/build/zig1 /builddir/zig-0.14.1/lib build-exe -ofmt=c -lc -OReleaseSmall --name zig2 -femit-bin="/builddir/zig-0.14.1/build/zig2.c" -target x86_64-linux --dep build_options --dep aro -Mroot=src/main.zig -Mbuild_options=/builddir/zig-0.14.1/build/config.zig -Maro=lib/compiler/aro/aro.zig
[16/19] /usr/bin/cc -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/builddir/zig-0.14.1/stage1 -I/usr/lib/llvm/19/include -DNDEBUG -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -ffile-prefix-map=/builddir/zig-0.14.1/build=. -std=c99 -O0 -fno-stack-protector -MD -MT CMakeFiles/zig2.dir/compiler_rt.c.o -MF CMakeFiles/zig2.dir/compiler_rt.c.o.d -o CMakeFiles/zig2.dir/compiler_rt.c.o -c /builddir/zig-0.14.1/build/compiler_rt.c
In file included from /usr/include/bits/libc-header-start.h:33,
from /usr/include/limits.h:26,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/14.2/include/limits.h:210,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/14.2/include/syslimits.h:7,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/14.2/include/limits.h:34,
from /builddir/zig-0.14.1/stage1/zig.h:481,
from /builddir/zig-0.14.1/build/compiler_rt.c:2:
/usr/include/features.h:435:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
435 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O)
| ^~~~~~~
[17/19] /usr/bin/cc -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/builddir/zig-0.14.1/stage1 -I/usr/lib/llvm/19/include -DNDEBUG -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -ffile-prefix-map=/builddir/zig-0.14.1/build=. -std=c99 -O0 -fno-stack-protector -MD -MT CMakeFiles/zig2.dir/zig2.c.o -MF CMakeFiles/zig2.dir/zig2.c.o.d -o CMakeFiles/zig2.dir/zig2.c.o -c /builddir/zig-0.14.1/build/zig2.c
In file included from /usr/include/bits/libc-header-start.h:33,
from /usr/include/limits.h:26,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/14.2/include/limits.h:210,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/14.2/include/syslimits.h:7,
from /usr/lib/gcc/x86_64-unknown-linux-gnu/14.2/include/limits.h:34,
from /builddir/zig-0.14.1/stage1/zig.h:481,
from /builddir/zig-0.14.1/build/zig2.c:2:
/usr/include/features.h:435:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
435 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O)
| ^~~~~~~
[18/19] : && /usr/bin/g++ -DNDEBUG -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -ffile-prefix-map=/builddir/zig-0.14.1/build=. -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -Wl,-z,stack-size=0x10000000 CMakeFiles/zig2.dir/zig2.c.o CMakeFiles/zig2.dir/compiler_rt.c.o -o zig2 -L/usr/lib/llvm/19/lib -Wl,-rpath,/usr/lib/llvm/19/lib zigcpp/libzigcpp.a /usr/lib/llvm/19/lib/libclang-cpp.so.19.1 /usr/lib/llvm/19/lib/liblldMinGW.a /usr/lib/llvm/19/lib/liblldELF.a /usr/lib/llvm/19/lib/liblldCOFF.a /usr/lib/llvm/19/lib/liblldWasm.a /usr/lib/llvm/19/lib/liblldMachO.a /usr/lib/llvm/19/lib/liblldCommon.a -lLLVM-19 -lrt -ldl -lm /usr/lib/libz3.so -lz -lzstd -lxml2 && :
[19/19] cd /builddir/zig-0.14.1 && /builddir/zig-0.14.1/build/zig2 build --prefix /builddir/zig-0.14.1/build/stage3 --zig-lib-dir /builddir/zig-0.14.1/lib -Dversion-string=0.14.1 -Dtarget=native -Dcpu=baseline -Denable-llvm -Dconfig_h=/builddir/zig-0.14.1/build/config.h -Dno-langref -Doptimize=ReleaseFast -Dstrip -Dpie
FAILED: stage3/bin/zig /builddir/zig-0.14.1/build/stage3/bin/zig
cd /builddir/zig-0.14.1 && /builddir/zig-0.14.1/build/zig2 build --prefix /builddir/zig-0.14.1/build/stage3 --zig-lib-dir /builddir/zig-0.14.1/lib -Dversion-string=0.14.1 -Dtarget=native -Dcpu=baseline -Denable-llvm -Dconfig_h=/builddir/zig-0.14.1/build/config.h -Dno-langref -Doptimize=ReleaseFast -Dstrip -Dpie
ninja: build stopped: subcommand failed.
[1m[31m=> ERROR: zig-0.14.1_1: do_build: '${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}' exited with 1
[m[1m[31m=> ERROR: in do_build() at common/build-style/cmake.sh:95
[m
gdb backtrace
#0 ConstantFoldScalarCall1 () at ./../lib/Analysis/ConstantFolding.cpp:2127
No locals.
#1 ConstantFoldScalarCall () at ./../lib/Analysis/ConstantFolding.cpp:3239
No locals.
#2 0x00007ffff18e83f1 in ConstantFoldCall () at ./../lib/Analysis/ConstantFolding.cpp:3502
No locals.
#3 0x00007ffff1958baf in simplifyCallSite () at ./../lib/Analysis/InlineCost.cpp:2253
No locals.
#4 visitCallBase () at ./../lib/Analysis/InlineCost.cpp:2293
No locals.
#5 0x00007ffff1954e5a in visit () at ./../lib/Analysis/InlineCost.cpp:2566
No locals.
#6 visit () at ../include/llvm/IR/InstVisitor.h:111
No locals.
#7 analyzeBlock () at ./../lib/Analysis/InlineCost.cpp:2566
No locals.
#8 0x00007ffff19501ca in analyze () at ./../lib/Analysis/InlineCost.cpp:2794
No locals.
#9 0x00007ffff194f4ab in getInlineCost () at ./../lib/Analysis/InlineCost.cpp:3074
No locals.
#10 0x00007ffff194f36a in getInlineCost () at ./../lib/Analysis/InlineCost.cpp:2938
No locals.
#11 0x00007ffff195f9ca in operator() () at ./../lib/Analysis/InlineAdvisor.cpp:160
No locals.
#12 callback_fn<(lambda at ../lib/Analysis/InlineAdvisor.cpp:154:24)>(void) () at ../include/llvm/ADT/STLFunctionalExtras.h:45
No locals.
#13 0x00007ffff195cc93 in operator() () at ../include/llvm/ADT/STLFunctionalExtras.h:68
No locals.
#14 shouldInline () at ./../lib/Analysis/InlineAdvisor.cpp:382
No locals.
#15 0x00007ffff195c31a in getDefaultInlineAdvice () at ./../lib/Analysis/InlineAdvisor.cpp:163
No locals.
#16 0x00007ffff195c0bc in getAdviceImpl () at ./../lib/Analysis/InlineAdvisor.cpp:170
No locals.
#17 0x00007ffff195f21f in getAdvice () at ./../lib/Analysis/InlineAdvisor.cpp:618
No locals.
#18 0x00007ffff15c8784 in run () at ./../lib/Transforms/IPO/Inliner.cpp:364
No locals.
#19 0x00007ffff15cd35d in llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::InlinerPass, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) () at ../include/llvm/IR/PassManagerInternal.h:90
No locals.
#20 0x00007ffff18c9779 in run () at ./../lib/Analysis/CGSCCPassManager.cpp:87
No locals.
#21 0x00007ffff15cd73d in llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) () at ../include/llvm/IR/PassManagerInternal.h:90
No locals.
#22 0x00007ffff18cb4e2 in run () at ./../lib/Analysis/CGSCCPassManager.cpp:413
No locals.
#23 0x00007ffff15cdc9d in llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::DevirtSCCRepeatedPass, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) () at ../include/llvm/IR/PassManagerInternal.h:90
No locals.
#24 0x00007ffff18cadae in run () at ./../lib/Analysis/CGSCCPassManager.cpp:274
No locals.
#25 0x00007ffff15cdacd in llvm::detail::PassModel<llvm::Module, llvm::ModuleToPostOrderCGSCCPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) () at ../include/llvm/IR/PassManagerInternal.h:90
No locals.
#26 0x00007ffff04a1889 in run () at ../include/llvm/IR/PassManagerImpl.h:81
No locals.
#27 0x00007ffff15cb0de in run () at ./../lib/Transforms/IPO/Inliner.cpp:631
No locals.
#28 0x00007ffff376002d in llvm::detail::PassModel<llvm::Module, llvm::ModuleInlinerWrapperPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) () at ../include/llvm/IR/PassManagerInternal.h:90
No locals.
#29 0x00007ffff04a1889 in run () at ../include/llvm/IR/PassManagerImpl.h:81
No locals.
#30 0x00005555584dda9b in ZigLLVMTargetMachineEmitToFile ()
No symbol table info available.
#31 0x0000555555824e18 in codegen_llvm_Object_emit__12092 ()
No symbol table info available.
#32 0x00005555557322d3 in Compilation_emitLlvmObject__5475 ()
No symbol table info available.
#33 0x0000555555ac9d07 in link_File_emitLlvmObject__5153 ()
No symbol table info available.
#34 0x0000555555b68fda in link_Elf_flushModule__5192 ()
No symbol table info available.
#35 0x0000555555ac865f in link_File_flushModule__5127 ()
No symbol table info available.
#36 0x000055555590bcf1 in link_File_linkAsArchiveInner__5142 ()
No symbol table info available.
#37 0x000055555590eb84 in link_File_linkAsArchive__5141 ()
No symbol table info available.
#38 0x000055555581be63 in link_File_flush__5126 ()
No symbol table info available.
#39 0x00005555557323f2 in Compilation_flush__5468 ()
No symbol table info available.
#40 0x0000555555739f3e in Compilation_update__5466 ()
No symbol table info available.
#41 0x000055555607e551 in Compilation_updateSubCompilation__5560 ()
No symbol table info available.
#42 0x000055555608096e in Compilation_buildOutputFromZig__5561 ()
No symbol table info available.
#43 0x0000555556080e36 in Compilation_buildRt__5513 ()
No symbol table info available.
#44 0x0000555555d0b34f in Thread_WaitGroup_spawnManager__anon_93887_Manager_run__69101 ()
No symbol table info available.
#45 0x000055555641064b in Thread_callFn__anon_242819__91961 ()
No symbol table info available.
#46 0x000055555607e414 in Thread_PosixThreadImpl_spawn__anon_183151_Instance_entryFn__83824 ()
No symbol table info available.
#47 0x00007fffec221579 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:448
ret = <optimized out>
pd = <optimized out>
out = <optimized out>
unwind_buf = {cancel_jmp_buf = {{jmp_buf = {128, -7799371119545422695, 32, 2, 140737488326752, 140736546025472, -7799250356318497946, -7799329716818013338}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
not_first_call = <optimized out>
#48 0x00007fffec29b858 in __GI___clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
No locals.
I mean this really looks like either a bug in LLVM or a miscompilation by GCC to me.
FWIW I got the same result when
a) using LLVM instead of GCC as compiler b) updating LLVM version used by zig from 19.1.4 to 19.1.7
Does it happen with LLVM 19.1.0?
(This may well be an upstream or downstream issue, but labeling and milestone-ing for now so it doesn't get lost.)
getting similar issues here on Debian trying to build 0.14.1 from source.
cmake output
-- The C compiler identification is GNU 14.2.0
-- The CXX compiler identification is GNU 14.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring zig version 0.14.1
-- Found llvm: -lLLVM-19;-lrt;-ldl;-lm;/usr/lib/x86_64-linux-gnu/libz3.so;-lz;-lzstd;-lxml2 (Required is at least version "19")
-- Found clang: /usr/lib/llvm-19/lib/libclang-cpp.so.19.1 (Required is at least version "19")
-- Found lld: /usr/lib/llvm-19/lib/liblldMinGW.a;/usr/lib/llvm-19/lib/liblldELF.a;/usr/lib/llvm-19/lib/liblldCOFF.a;/usr/lib/llvm-19/lib/liblldWasm.a;/usr/lib/llvm-19/lib/liblldMachO.a;/usr/lib/llvm-19/lib/liblldCommon.a (Required is at least version "19")
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Configuring done (0.7s)
-- Generating done (0.0s)
-- Build files have been written to: /home/||||||||/dev/zig/build
make install output
[ 5%] Building CXX object CMakeFiles/zigcpp.dir/src/zig_llvm.cpp.o
[ 10%] Building CXX object CMakeFiles/zigcpp.dir/src/zig_llvm-ar.cpp.o
[ 15%] Building CXX object CMakeFiles/zigcpp.dir/src/zig_clang.cpp.o
[ 21%] Building CXX object CMakeFiles/zigcpp.dir/src/zig_clang_driver.cpp.o
[ 26%] Building CXX object CMakeFiles/zigcpp.dir/src/zig_clang_cc1_main.cpp.o
[ 31%] Building CXX object CMakeFiles/zigcpp.dir/src/zig_clang_cc1as_main.cpp.o
[ 36%] Linking CXX static library zigcpp/libzigcpp.a
[ 36%] Built target zigcpp
[ 42%] Building C object CMakeFiles/zig-wasm2c.dir/stage1/wasm2c.c.o
[ 47%] Linking C executable zig-wasm2c
[ 47%] Built target zig-wasm2c
[ 52%] Converting /home/||||||||/dev/zig/stage1/zig1.wasm to /home/||||||||/dev/zig/build/zig1.c
[ 57%] Building C object CMakeFiles/zig1.dir/zig1.c.o
[ 63%] Building C object CMakeFiles/zig1.dir/stage1/wasi.c.o
[ 68%] Linking C executable zig1
[ 68%] Built target zig1
[ 73%] Running zig1.wasm to produce /home/||||||||/dev/zig/build/zig2.c
[ 78%] Running zig1.wasm to produce /home/||||||||/dev/zig/build/compiler_rt.c
[ 84%] Building C object CMakeFiles/zig2.dir/zig2.c.o
[ 89%] Building C object CMakeFiles/zig2.dir/compiler_rt.c.o
[ 94%] Linking CXX executable zig2
[ 94%] Built target zig2
[100%] Building stage3
Segmentation faultScript
make[2]: *** [CMakeFiles/stage3.dir/build.make:73: stage3/bin/zig] Error 139
make[1]: *** [CMakeFiles/Makefile2:228: CMakeFiles/stage3.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
FWIW I got the same result when
a) using LLVM instead of GCC as compiler b) updating LLVM version used by zig from 19.1.4 to 19.1.7
Hello, late to the party, I have tried other gcc versions in openSUSE, and the one that works is gcc 7. i am quite not sure if this is relevant. Tested image is leap 15.6 and opensuse:factory (since both have gcc 7).
Maybe I'll open a new issue since this is a different distribution? I am hesitating since the original C compiler I set was clang 19.x. I tried testing other C compilers like gcc versions 7 to 13. I also have the same errors like this issue when using clang except it only happens in openSUSE:Factory image. It builds successfully on x86_64 images of leap 15.6 and leap 16.0. I will share logs later since I didn't save them.
I'm getting the same stacktrace building on Gentoo with Clang 19.1.7.
FWIW, the bleeding edge build got past stage3 without issue (with Clang 20).
With more debug info:
#0 (anonymous namespace)::ConstantFoldScalarCall1 (Name=..., IntrinsicID=165, Ty=0x7fffbcb78818, Operands=..., TLI=0x0, Call=0x7fffbd415160) at /usr/src/debug/llvm-19.1.7.src/lib/Analysis/ConstantFolding.cpp:2127
We're at https://github.com/llvm/llvm-project/blob/llvmorg-19.1.7/llvm/lib/Analysis/ConstantFolding.cpp#L2127. So the problem is a null pointer access (TLI=0x0). This should be fixed by https://github.com/llvm/llvm-project/commit/83a5c7cb62e404a713a35445b755cf0109650279.
Thanks for investigating! Sounds like this is/was an upstream issue then.