ziglang / zig-bootstrap

take off every zig
368 stars 86 forks source link

CMake error building from source #130

Closed Vexu closed 1 year ago

Vexu commented 1 year ago

I tried to build Windows tarball for https://github.com/ziglang/zig/issues/12994 but got

ld: cannot find -lzstd.so.1.5.2: No such file or directory

I fixed this with

diff --git a/build b/build
index 96286dd72..35686a7a2 100755
--- a/build
+++ b/build
@@ -36,6 +36,7 @@ cmake "$ROOTDIR/llvm" \
   -DLLVM_ENABLE_BINDINGS=OFF \
   -DLLVM_ENABLE_OCAMLDOC=OFF \
   -DLLVM_ENABLE_Z3_SOLVER=OFF \
+  -DLLVM_ENABLE_ZSTD=OFF \
   -DCLANG_BUILD_TOOLS=OFF \
   -DCLANG_INCLUDE_DOCS=OFF \
   -DLLVM_INCLUDE_DOCS=OFF \

but I'm not sure how correct that is.

I ran into #127 which I was able to fix by applying https://github.com/ziglang/zig/pull/12898 after which I ran into:

CMake Error at /usr/share/cmake/Modules/CMakeDetermineRCCompiler.cmake:47 (get_filename_component):
  get_filename_component unknown component windres
Call Stack (most recent call first):
  /usr/share/cmake/Modules/Platform/Windows-GNU.cmake:163 (enable_language)
  /usr/share/cmake/Modules/Platform/Windows-Clang.cmake:217 (__windows_compiler_gnu)
  /usr/share/cmake/Modules/Platform/Windows-Clang.cmake:227 (__windows_compiler_clang_base)
  /usr/share/cmake/Modules/Platform/Windows-Clang-C.cmake:2 (__windows_compiler_clang)
  /usr/share/cmake/Modules/CMakeCInformation.cmake:48 (include)
  CMakeLists.txt:4 (project)
matu3ba commented 1 year ago

Upstreams definitions are here: https://github.com/Kitware/CMake/blob/master/Modules/CMakeDetermineRCCompiler.cmake

CMake debugging commands are these:

# Debugging
# --trace,  --trace-expand, --debug-output
# run cmake with -LH to get all variables printed after configuration.

# function(PRINT_VAR VARNAME)
#   message(STATUS "${VARNAME}: ${${VARNAME}}")
# endfunction()
# PRINT_VAR("CMAKE_CXX_COMPILER")

# cmake -P to run a single script

You could either use some of the debugging commands or "printf" on the module code.

Vexu commented 1 year ago

I updated my system and pulled the latest changes and was able to build LLVM using system C++ compiler, stage1, stage2 and then failing stage3 with:

[100%] Building stage3
error(compilation): clang failed with stderr: zig-bootstrap/zig/src/stage1/codegen.cpp:4838:17: error: use of undeclared identifier 'LLVMPointerTypeInContext'
zig-bootstrap/zig/src/stage1/codegen.cpp:5183:17: error: use of undeclared identifier 'LLVMPointerTypeInContext'
matu3ba commented 1 year ago

This looks exactly like https://github.com/ziglang/zig/issues/12888, which was fixed in some later Zig commit https://github.com/ziglang/zig/pull/12898 (0b47e69).

Vexu commented 1 year ago

I had that commit patched separately but then also accidentally reverted it in a merge conflict. With the revert reverted it now builds stage3 successfully. I'll let the build run and close when it succeeds.