zig-bootstrap
zig-bootstrap copied to clipboard
Segmentation fault in LLVM optimisation phase
I'm trying to bootstrap zig. However, stage1 compiler crashes on code generation phase.
Build errors
$ ./build -j2 native baseline
...
[100%] Built target zig
Install the project...
-- Install configuration: "Release"
-- Installing: /tmp/zig-bootstrap-0.9.1/out/host/bin/zig
-- Installing: /tmp/zig-bootstrap-0.9.1/out/host/lib
::
:: ERROR: Segmentation fault
:: (execute_process)
::
:: argv: /tmp/zig-bootstrap-0.9.1/out/build-zig-host/zig build --zig-lib-dir /tmp/zig-bootstrap-0.9.1/zig/lib -Dlib-files-only --prefix /tmp/zig-bootstrap-0.9.1/out/host -Dconfig_h=/tmp/zig-bootstrap-0.9.1/out/build-zig-host/config.h install
::
:: argv[0]: /tmp/zig-bootstrap-0.9.1/out/build-zig-host/zig
:: argv[1]: build
:: argv[2]: --zig-lib-dir
:: argv[3]: /tmp/zig-bootstrap-0.9.1/zig/lib
:: argv[4]: -Dlib-files-only
:: argv[5]: --prefix
:: argv[6]: /tmp/zig-bootstrap-0.9.1/out/host
:: argv[7]: -Dconfig_h=/tmp/zig-bootstrap-0.9.1/out/build-zig-host/config.h
:: argv[8]: install
::
CMake Error at /tmp/zig-bootstrap-0.9.1/zig/cmake/install.cmake:36 (message):
Call Stack (most recent call first):
cmake_install.cmake:78 (include)
Makefile:92: recipe for target 'install' failed
make: *** [install] Error 1
Running zig build inside zig directory:
$ zig build
Code Generation [630/572] compiler_rt.udivmod.udivmod... Segmentation fault
Stack seems to be corrupted, so backtrace looks like this:
(gdb) bt
#0 0x0b9f602e in __libc_realloc ()
#1 0x00000000 in ?? ()
With single stepping I've located crash in LLVM's ModulePassManager::run (zig_llvm.cpp, line 386). Even more precisely, it seems to be somewhere in llvm::ModuleToFunctionPassAdaptor::run, but I can't get closer.
My build environment is custom Linux chroot with musl libc, i386. Tried to bootstrap with both gcc (7.5) and clang (13). The only thing I've altered was build script, adding -DLLVM_BUILD_STATIC=ON -DLIBCLANG_BUILD_STATIC=ON to first stage LLVM's config.