I have built zig from source before successfully, but now I am stumped. I get a segfault on the step where it builds or is using zig stage3 (I can’t tell which it is).
I use a combination of these instructions:
- How to build LLVM, libclang, and liblld from source · ziglang/zig Wiki · GitHub
- Building Zig From Source · ziglang/zig Wiki · GitHub
Which produces the following procedure:
(I am on x86_64-linux debian 12)
LLVM Build
cd ~/Downloads
# wipe the whole build state
rm -rf llvm-project-20
# wipe my llvm install
rm -rf ~/local/llvm20-assert/
git clone --depth 1 --branch release/20.x https://github.com/llvm/llvm-project llvm-project-20
cd llvm-project-20
git checkout release/20.x
mkdir build-release
cd build-release
cmake ../llvm \
-DCMAKE_INSTALL_PREFIX=$HOME/local/llvm20-assert \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS="lld;clang" \
-DLLVM_ENABLE_LIBXML2=OFF \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_ENABLE_LIBEDIT=OFF \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_PARALLEL_LINK_JOBS=1 \
-G Ninja
ninja install
The LLVM build seems to work fine, it just takes 3 hours and I can’t use my browser otherwise it will OOM.
I did this today. So it should be the most recent llvm 20.x
LLVM Config Output
jeff@jeff-debian:~/Downloads/llvm-project-20/build-release$ rm -rf ~/local/llvm20-assert/
jeff@jeff-debian:~/Downloads/llvm-project-20/build-release$ cd ..
jeff@jeff-debian:~/Downloads/llvm-project-20$ cd ..
jeff@jeff-debian:~/Downloads$ rm -rf llvm-project-20/
jeff@jeff-debian:~/Downloads$ git clone --depth 1 --branch release/20.x https://github.com/llvm/llvm-project llvm-project-20
Cloning into 'llvm-project-20'...
remote: Enumerating objects: 161656, done.
remote: Counting objects: 100% (161656/161656), done.
remote: Compressing objects: 100% (138628/138628), done.
remote: Total 161656 (delta 35020), reused 57379 (delta 18578), pack-reused 0 (from 0)
Receiving objects: 100% (161656/161656), 234.64 MiB | 8.97 MiB/s, done.
Resolving deltas: 100% (35020/35020), done.
Updating files: 100% (154041/154041), done.
jeff@jeff-debian:~/Downloads$ cd llvm-project-20
jeff@jeff-debian:~/Downloads/llvm-project-20$ git checkout release/20.x
Already on 'release/20.x'
Your branch is up to date with 'origin/release/20.x'.
jeff@jeff-debian:~/Downloads/llvm-project-20$ mkdir build-release
jeff@jeff-debian:~/Downloads/llvm-project-20$ cd build-release
jeff@jeff-debian:~/Downloads/llvm-project-20/build-release$ cmake ../llvm -DCMAKE_INSTALL_PREFIX=$HOME/local/llvm20-assert -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="lld;clang" -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_LIBEDIT=OFF -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_PARALLEL_LINK_JOBS=1 -G Ninja
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- 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
-- bolt project is disabled
-- clang project is enabled
-- clang-tools-extra project is disabled
-- compiler-rt project is disabled
-- cross-project-tests project is disabled
-- libc project is disabled
-- libclc project is disabled
-- lld project is enabled
-- lldb project is disabled
-- mlir project is disabled
-- openmp project is disabled
-- polly project is disabled
-- pstl project is disabled
-- flang project is disabled
-- Found Python3: /usr/bin/python3 (found suitable version "3.11.2", minimum required is "3.8") found components: Interpreter
-- Looking for __GLIBC__
-- Looking for __GLIBC__ - found
-- Looking for valgrind/valgrind.h
-- Looking for valgrind/valgrind.h - not found
-- Looking for FE_ALL_EXCEPT
-- Looking for FE_ALL_EXCEPT - found
-- Looking for FE_INEXACT
-- Looking for FE_INEXACT - found
-- Performing Test HAVE_BUILTIN_THREAD_POINTER
-- Performing Test HAVE_BUILTIN_THREAD_POINTER - Success
-- Looking for CrashReporterClient.h
-- Looking for CrashReporterClient.h - not found
-- Looking for linux/magic.h
-- Looking for linux/magic.h - found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Looking for pthread_rwlock_init in pthread
-- Looking for pthread_rwlock_init in pthread - found
-- Looking for pthread_mutex_lock in pthread
-- Looking for pthread_mutex_lock in pthread - found
-- Looking for dlopen in dl
-- Looking for dlopen in dl - found
-- Looking for shm_open in rt
-- Looking for shm_open in rt - found
-- Looking for pfm_initialize in pfm
-- Looking for pfm_initialize in pfm - not found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.13")
-- Looking for compress2
-- Looking for compress2 - found
-- Looking for arc4random
-- Looking for arc4random - found
-- Looking for backtrace
-- Looking for backtrace - found
-- backtrace facility detected in default set of libraries
-- Found Backtrace: /usr/include
-- Performing Test C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW
-- Performing Test C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW - Failed
-- Looking for __register_frame
-- Looking for __register_frame - found
-- Looking for __deregister_frame
-- Looking for __deregister_frame - found
-- Looking for __unw_add_dynamic_fde
-- Looking for __unw_add_dynamic_fde - not found
-- Looking for _Unwind_Backtrace
-- Looking for _Unwind_Backtrace - found
-- Looking for getpagesize
-- Looking for getpagesize - found
-- Looking for sysconf
-- Looking for sysconf - found
-- Looking for getrusage
-- Looking for getrusage - found
-- Looking for isatty
-- Looking for isatty - found
-- Looking for futimens
-- Looking for futimens - found
-- Looking for futimes
-- Looking for futimes - found
-- Looking for sigaltstack
-- Looking for sigaltstack - found
-- Looking for mallctl
-- Looking for mallctl - not found
-- Looking for mallinfo
-- Looking for mallinfo - found
-- Looking for mallinfo2
-- Looking for mallinfo2 - found
-- Looking for malloc_zone_statistics
-- Looking for malloc_zone_statistics - not found
-- Looking for posix_spawn
-- Looking for posix_spawn - found
-- Looking for pread
-- Looking for pread - found
-- Looking for sbrk
-- Looking for sbrk - found
-- Looking for strerror_r
-- Looking for strerror_r - found
-- Looking for strerror_s
-- Looking for strerror_s - not found
-- Looking for setenv
-- Looking for setenv - found
-- Performing Test HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
-- Performing Test HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC - Failed
-- Performing Test HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
-- Performing Test HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC - Success
-- Looking for pthread_getname_np
-- Looking for pthread_getname_np - found
-- Looking for pthread_setname_np
-- Looking for pthread_setname_np - found
-- Looking for pthread_get_name_np
-- Looking for pthread_get_name_np - not found
-- Looking for pthread_set_name_np
-- Looking for pthread_set_name_np - not found
-- Looking for dlopen
-- Looking for dlopen - found
-- Looking for proc_pid_rusage
-- Looking for proc_pid_rusage - not found
-- Performing Test HAVE_CXX_ATOMICS_WITHOUT_LIB
-- Performing Test HAVE_CXX_ATOMICS_WITHOUT_LIB - Success
-- Performing Test HAVE_CXX_ATOMICS64_WITHOUT_LIB
-- Performing Test HAVE_CXX_ATOMICS64_WITHOUT_LIB - Success
-- Performing Test LLVM_HAS_ATOMICS
-- Performing Test LLVM_HAS_ATOMICS - Success
-- LLVM host triple: x86_64-unknown-linux-gnu
-- Native target architecture is X86
-- Threads enabled.
-- Doxygen disabled.
-- Ninja version: 1.11.1
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH)
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH)
-- OCaml bindings disabled.
-- Found Python module pygments
-- Found Python module pygments.lexers.c_cpp
-- Found Python module yaml
-- LLVM default target triple: x86_64-unknown-linux-gnu
-- Performing Test C_SUPPORTS_FPIC
-- Performing Test C_SUPPORTS_FPIC - Success
-- Performing Test CXX_SUPPORTS_FPIC
-- Performing Test CXX_SUPPORTS_FPIC - Success
-- Building with -fPIC
-- Performing Test C_SUPPORTS_FNO_SEMANTIC_INTERPOSITION
-- Performing Test C_SUPPORTS_FNO_SEMANTIC_INTERPOSITION - Success
-- Performing Test CXX_SUPPORTS_FNO_SEMANTIC_INTERPOSITION
-- Performing Test CXX_SUPPORTS_FNO_SEMANTIC_INTERPOSITION - Success
-- Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG
-- Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG - Success
-- Performing Test C_SUPPORTS_CXX98_COMPAT_EXTRA_SEMI_FLAG
-- Performing Test C_SUPPORTS_CXX98_COMPAT_EXTRA_SEMI_FLAG - Failed
-- Performing Test CXX_SUPPORTS_CXX98_COMPAT_EXTRA_SEMI_FLAG
-- Performing Test CXX_SUPPORTS_CXX98_COMPAT_EXTRA_SEMI_FLAG - Failed
-- Performing Test CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG
-- Performing Test CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG - Success
-- Performing Test CXX_WSUGGEST_OVERRIDE_ALLOWS_ONLY_FINAL
-- Performing Test CXX_WSUGGEST_OVERRIDE_ALLOWS_ONLY_FINAL - Success
-- Performing Test C_WCOMMENT_ALLOWS_LINE_WRAP
-- Performing Test C_WCOMMENT_ALLOWS_LINE_WRAP - Failed
-- Performing Test C_SUPPORTS_CTAD_MAYBE_UNSPPORTED_FLAG
-- Performing Test C_SUPPORTS_CTAD_MAYBE_UNSPPORTED_FLAG - Failed
-- Performing Test CXX_SUPPORTS_CTAD_MAYBE_UNSPPORTED_FLAG
-- Performing Test CXX_SUPPORTS_CTAD_MAYBE_UNSPPORTED_FLAG - Success
-- Performing Test LINKER_SUPPORTS_COLOR_DIAGNOSTICS
-- Performing Test LINKER_SUPPORTS_COLOR_DIAGNOSTICS - Failed
-- Looking for os_signpost_interval_begin
-- Looking for os_signpost_interval_begin - not found
-- Linker detection: GNU ld
-- Performing Test HAS_WERROR_GLOBAL_CTORS
-- Performing Test HAS_WERROR_GLOBAL_CTORS - Failed
-- Looking for __x86_64__
-- Looking for __x86_64__ - found
-- Found Git: /usr/bin/git (found version "2.39.5")
-- Looking for logf128
-- Looking for logf128 - found
-- Targeting AArch64
-- Targeting AMDGPU
-- Targeting ARM
-- Targeting AVR
-- Targeting BPF
-- Targeting Hexagon
-- Targeting Lanai
-- Targeting LoongArch
-- Targeting Mips
-- Targeting MSP430
-- Targeting NVPTX
-- Targeting PowerPC
-- Targeting RISCV
-- Targeting Sparc
-- Targeting SPIRV
-- Targeting SystemZ
-- Targeting VE
-- Targeting WebAssembly
-- Targeting X86
-- Targeting XCore
-- LLD version: 20.1.8
-- Looking for sys/resource.h
-- Looking for sys/resource.h - found
-- Looking for dlfcn.h
-- Looking for dlfcn.h - found
-- Looking for dladdr
-- Looking for dladdr - found
-- Clang version: 20.1.8
-- Looking for include file sys/inotify.h
-- Looking for include file sys/inotify.h - found
-- Performing Test HAVE_LINKER_FLAG_LONG_PLT
-- Performing Test HAVE_LINKER_FLAG_LONG_PLT - Failed
-- Found Perl: /usr/bin/perl (found version "5.36.0")
-- Registering ExampleIRTransforms as a pass plugin (static build: OFF)
-- Registering Bye as a pass plugin (static build: OFF)
-- Failed to find LLVM FileCheck
-- Google Benchmark version: v0.0.0, normalized to 0.0.0
-- Looking for shm_open in rt
-- Looking for shm_open in rt - found
-- Performing Test HAVE_CXX_FLAG_WALL
-- Performing Test HAVE_CXX_FLAG_WALL - Success
-- Performing Test HAVE_CXX_FLAG_WEXTRA
-- Performing Test HAVE_CXX_FLAG_WEXTRA - Success
-- Performing Test HAVE_CXX_FLAG_WSHADOW
-- Performing Test HAVE_CXX_FLAG_WSHADOW - Success
-- Performing Test HAVE_CXX_FLAG_WFLOAT_EQUAL
-- Performing Test HAVE_CXX_FLAG_WFLOAT_EQUAL - Success
-- Performing Test HAVE_CXX_FLAG_WOLD_STYLE_CAST
-- Performing Test HAVE_CXX_FLAG_WOLD_STYLE_CAST - Success
-- Performing Test HAVE_CXX_FLAG_WSUGGEST_OVERRIDE
-- Performing Test HAVE_CXX_FLAG_WSUGGEST_OVERRIDE - Success
-- Performing Test HAVE_CXX_FLAG_PEDANTIC
-- Performing Test HAVE_CXX_FLAG_PEDANTIC - Success
-- Performing Test HAVE_CXX_FLAG_PEDANTIC_ERRORS
-- Performing Test HAVE_CXX_FLAG_PEDANTIC_ERRORS - Success
-- Performing Test HAVE_CXX_FLAG_WSHORTEN_64_TO_32
-- Performing Test HAVE_CXX_FLAG_WSHORTEN_64_TO_32 - Failed
-- Performing Test HAVE_CXX_FLAG_FSTRICT_ALIASING
-- Performing Test HAVE_CXX_FLAG_FSTRICT_ALIASING - Success
-- Performing Test HAVE_CXX_FLAG_WNO_DEPRECATED_DECLARATIONS
-- Performing Test HAVE_CXX_FLAG_WNO_DEPRECATED_DECLARATIONS - Success
-- Performing Test HAVE_CXX_FLAG_FNO_EXCEPTIONS
-- Performing Test HAVE_CXX_FLAG_FNO_EXCEPTIONS - Success
-- Performing Test HAVE_CXX_FLAG_WSTRICT_ALIASING
-- Performing Test HAVE_CXX_FLAG_WSTRICT_ALIASING - Success
-- Performing Test HAVE_CXX_FLAG_WD654
-- Performing Test HAVE_CXX_FLAG_WD654 - Failed
-- Performing Test HAVE_CXX_FLAG_WTHREAD_SAFETY
-- Performing Test HAVE_CXX_FLAG_WTHREAD_SAFETY - Failed
-- Performing Test HAVE_CXX_FLAG_COVERAGE
-- Performing Test HAVE_CXX_FLAG_COVERAGE - Success
-- Compiling and running to test HAVE_GNU_POSIX_REGEX
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Compiling and running to test HAVE_POSIX_REGEX
-- Performing Test HAVE_POSIX_REGEX -- success
-- Compiling and running to test HAVE_STEADY_CLOCK
-- Performing Test HAVE_STEADY_CLOCK -- success
-- Compiling and running to test HAVE_PTHREAD_AFFINITY
-- Performing Test HAVE_PTHREAD_AFFINITY -- success
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
LLVM_ENABLE_TERMINFO
-- Build files have been written to: /home/jeff/Downloads/llvm-project-20/build-release
Rest of the LLVM build output not provided becuase its massive.
Zig Build
at commit 7caf40b6f8a5a94876513ab4557e02ef9beb6617
this commit passed CI so its definitely a me-problem.
cd ~/repos/zig/
# wipe the whole build state (does this actually wipe the whole state)?
rm -rf build/
mkdir build/
cd build/
cmake -DCMAKE_PREFIX_PATH=$HOME/local/llvm20-assert ..
make install
# segfault when i get to stage 3 here..
Zig Build Full Output
jeff@jeff-debian:~/repos/zig/build$ git status
On branch 24471-mlock-syscalls
Your branch is up to date with 'origin/24471-mlock-syscalls'.
nothing to commit, working tree clean
jeff@jeff-debian:~/repos/zig/build$ git rev-parse HEAD
7caf40b6f8a5a94876513ab4557e02ef9beb6617
jeff@jeff-debian:~/repos/zig/build$ cd ..
jeff@jeff-debian:~/repos/zig$ rm -rf build
jeff@jeff-debian:~/repos/zig$ mkdir build.zig
mkdir: cannot create directory ‘build.zig’: File exists
jeff@jeff-debian:~/repos/zig$ mkdir build
jeff@jeff-debian:~/repos/zig$ cd build/
jeff@jeff-debian:~/repos/zig/build$ cmake -DCMAKE_PREFIX_PATH=$HOME/local/llvm20-assert ..
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.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.15.0
-- Found llvm: -lLLVMWindowsManifest;-lLLVMXRay;-lLLVMLibDriver;-lLLVMDlltoolDriver;-lLLVMTelemetry;-lLLVMTextAPIBinaryReader;-lLLVMCoverage;-lLLVMLineEditor;-lLLVMXCoreDisassembler;-lLLVMXCoreCodeGen;-lLLVMXCoreDesc;-lLLVMXCoreInfo;-lLLVMX86TargetMCA;-lLLVMX86Disassembler;-lLLVMX86AsmParser;-lLLVMX86CodeGen;-lLLVMX86Desc;-lLLVMX86Info;-lLLVMWebAssemblyDisassembler;-lLLVMWebAssemblyAsmParser;-lLLVMWebAssemblyCodeGen;-lLLVMWebAssemblyUtils;-lLLVMWebAssemblyDesc;-lLLVMWebAssemblyInfo;-lLLVMVEDisassembler;-lLLVMVEAsmParser;-lLLVMVECodeGen;-lLLVMVEDesc;-lLLVMVEInfo;-lLLVMSystemZDisassembler;-lLLVMSystemZAsmParser;-lLLVMSystemZCodeGen;-lLLVMSystemZDesc;-lLLVMSystemZInfo;-lLLVMSPIRVCodeGen;-lLLVMSPIRVDesc;-lLLVMSPIRVInfo;-lLLVMSPIRVAnalysis;-lLLVMSparcDisassembler;-lLLVMSparcAsmParser;-lLLVMSparcCodeGen;-lLLVMSparcDesc;-lLLVMSparcInfo;-lLLVMRISCVTargetMCA;-lLLVMRISCVDisassembler;-lLLVMRISCVAsmParser;-lLLVMRISCVCodeGen;-lLLVMRISCVDesc;-lLLVMRISCVInfo;-lLLVMPowerPCDisassembler;-lLLVMPowerPCAsmParser;-lLLVMPowerPCCodeGen;-lLLVMPowerPCDesc;-lLLVMPowerPCInfo;-lLLVMNVPTXCodeGen;-lLLVMNVPTXDesc;-lLLVMNVPTXInfo;-lLLVMMSP430Disassembler;-lLLVMMSP430AsmParser;-lLLVMMSP430CodeGen;-lLLVMMSP430Desc;-lLLVMMSP430Info;-lLLVMMipsDisassembler;-lLLVMMipsAsmParser;-lLLVMMipsCodeGen;-lLLVMMipsDesc;-lLLVMMipsInfo;-lLLVMLoongArchDisassembler;-lLLVMLoongArchAsmParser;-lLLVMLoongArchCodeGen;-lLLVMLoongArchDesc;-lLLVMLoongArchInfo;-lLLVMLanaiDisassembler;-lLLVMLanaiCodeGen;-lLLVMLanaiAsmParser;-lLLVMLanaiDesc;-lLLVMLanaiInfo;-lLLVMHexagonDisassembler;-lLLVMHexagonCodeGen;-lLLVMHexagonAsmParser;-lLLVMHexagonDesc;-lLLVMHexagonInfo;-lLLVMBPFDisassembler;-lLLVMBPFAsmParser;-lLLVMBPFCodeGen;-lLLVMBPFDesc;-lLLVMBPFInfo;-lLLVMAVRDisassembler;-lLLVMAVRAsmParser;-lLLVMAVRCodeGen;-lLLVMAVRDesc;-lLLVMAVRInfo;-lLLVMARMDisassembler;-lLLVMARMAsmParser;-lLLVMARMCodeGen;-lLLVMARMDesc;-lLLVMARMUtils;-lLLVMARMInfo;-lLLVMAMDGPUTargetMCA;-lLLVMAMDGPUDisassembler;-lLLVMAMDGPUAsmParser;-lLLVMAMDGPUCodeGen;-lLLVMAMDGPUDesc;-lLLVMAMDGPUUtils;-lLLVMAMDGPUInfo;-lLLVMAArch64Disassembler;-lLLVMAArch64AsmParser;-lLLVMAArch64CodeGen;-lLLVMAArch64Desc;-lLLVMAArch64Utils;-lLLVMAArch64Info;-lLLVMOrcDebugging;-lLLVMOrcJIT;-lLLVMWindowsDriver;-lLLVMMCJIT;-lLLVMJITLink;-lLLVMInterpreter;-lLLVMExecutionEngine;-lLLVMRuntimeDyld;-lLLVMOrcTargetProcess;-lLLVMOrcShared;-lLLVMDWP;-lLLVMDebugInfoLogicalView;-lLLVMDebugInfoGSYM;-lLLVMOption;-lLLVMObjectYAML;-lLLVMObjCopy;-lLLVMMCA;-lLLVMMCDisassembler;-lLLVMLTO;-lLLVMPasses;-lLLVMHipStdPar;-lLLVMCFGuard;-lLLVMCoroutines;-lLLVMipo;-lLLVMVectorize;-lLLVMSandboxIR;-lLLVMLinker;-lLLVMInstrumentation;-lLLVMFrontendOpenMP;-lLLVMFrontendOffloading;-lLLVMFrontendOpenACC;-lLLVMFrontendHLSL;-lLLVMFrontendDriver;-lLLVMFrontendAtomic;-lLLVMExtensions;-lLLVMDWARFLinkerParallel;-lLLVMDWARFLinkerClassic;-lLLVMDWARFLinker;-lLLVMGlobalISel;-lLLVMMIRParser;-lLLVMAsmPrinter;-lLLVMSelectionDAG;-lLLVMCodeGen;-lLLVMTarget;-lLLVMObjCARCOpts;-lLLVMCodeGenTypes;-lLLVMCGData;-lLLVMIRPrinter;-lLLVMInterfaceStub;-lLLVMFileCheck;-lLLVMFuzzMutate;-lLLVMScalarOpts;-lLLVMInstCombine;-lLLVMAggressiveInstCombine;-lLLVMTransformUtils;-lLLVMBitWriter;-lLLVMAnalysis;-lLLVMProfileData;-lLLVMSymbolize;-lLLVMDebugInfoBTF;-lLLVMDebugInfoPDB;-lLLVMDebugInfoMSF;-lLLVMDebugInfoCodeView;-lLLVMDebugInfoDWARF;-lLLVMObject;-lLLVMTextAPI;-lLLVMMCParser;-lLLVMIRReader;-lLLVMAsmParser;-lLLVMMC;-lLLVMBitReader;-lLLVMFuzzerCLI;-lLLVMCore;-lLLVMRemarks;-lLLVMBitstreamReader;-lLLVMBinaryFormat;-lLLVMTargetParser;-lLLVMTableGen;-lLLVMSupport;-lLLVMDemangle;-lrt;-ldl;-lm;-lz (Required is at least version "20")
-- Found clang: /home/jeff/local/llvm20-assert/lib/libclangFrontendTool.a;/home/jeff/local/llvm20-assert/lib/libclangCodeGen.a;/home/jeff/local/llvm20-assert/lib/libclangFrontend.a;/home/jeff/local/llvm20-assert/lib/libclangDriver.a;/home/jeff/local/llvm20-assert/lib/libclangSerialization.a;/home/jeff/local/llvm20-assert/lib/libclangSema.a;/home/jeff/local/llvm20-assert/lib/libclangStaticAnalyzerFrontend.a;/home/jeff/local/llvm20-assert/lib/libclangStaticAnalyzerCheckers.a;/home/jeff/local/llvm20-assert/lib/libclangStaticAnalyzerCore.a;/home/jeff/local/llvm20-assert/lib/libclangAnalysis.a;/home/jeff/local/llvm20-assert/lib/libclangASTMatchers.a;/home/jeff/local/llvm20-assert/lib/libclangAST.a;/home/jeff/local/llvm20-assert/lib/libclangParse.a;/home/jeff/local/llvm20-assert/lib/libclangSema.a;/home/jeff/local/llvm20-assert/lib/libclangAPINotes.a;/home/jeff/local/llvm20-assert/lib/libclangBasic.a;/home/jeff/local/llvm20-assert/lib/libclangEdit.a;/home/jeff/local/llvm20-assert/lib/libclangLex.a;/home/jeff/local/llvm20-assert/lib/libclangARCMigrate.a;/home/jeff/local/llvm20-assert/lib/libclangRewriteFrontend.a;/home/jeff/local/llvm20-assert/lib/libclangRewrite.a;/home/jeff/local/llvm20-assert/lib/libclangCrossTU.a;/home/jeff/local/llvm20-assert/lib/libclangIndex.a;/home/jeff/local/llvm20-assert/lib/libclangToolingCore.a;/home/jeff/local/llvm20-assert/lib/libclangExtractAPI.a;/home/jeff/local/llvm20-assert/lib/libclangSupport.a;/home/jeff/local/llvm20-assert/lib/libclangInstallAPI.a;/home/jeff/local/llvm20-assert/lib/libclangAST.a (Required is at least version "20")
-- Found lld: /home/jeff/local/llvm20-assert/lib/liblldMinGW.a;/home/jeff/local/llvm20-assert/lib/liblldELF.a;/home/jeff/local/llvm20-assert/lib/liblldCOFF.a;/home/jeff/local/llvm20-assert/lib/liblldWasm.a;/home/jeff/local/llvm20-assert/lib/liblldMachO.a;/home/jeff/local/llvm20-assert/lib/liblldCommon.a (Required is at least version "20")
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /home/jeff/repos/zig/build
jeff@jeff-debian:~/repos/zig/build$ make install
[ 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/jeff/repos/zig/stage1/zig1.wasm to /home/jeff/repos/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/jeff/repos/zig/build/zig2.c
[ 78%] Running zig1.wasm to produce /home/jeff/repos/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:196: CMakeFiles/stage3.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
I can build just fine on another machine (WSL2 on windows). Not sure what I have done wrong here.
Things I have checked:
- LLVM config output shows detected c and cpp compilers are correct (GNU 12.2.0) and is above the minimum required on zig build from source instructions
- Zig build config output shows correctly detected c, cpp, and llvm. (GNU 12.2.0 again). The llvm build and the zig build used the same cmake, c, and cpp compilers, as required by the zig build from source instructions.
- I deleted the LLVM install before I rebuilt and install LLVM to
~/local/llvm20-assert/
- I am not aware of any addtional caching mechanism / state that I need to wipe between builds.