Closed zd08135 closed 3 months ago
Hello guys, after a long time of hard work. I found a way to build zig successfully.
Using ubuntu 23.04 for building may work. if your machine is not, please use docker for compile as I did.
Steps:
start a docker instance of ubuntu 23.04.
If your machine is it, go to step 2.
docker pull ubuntu:23.04
docker run --itd --name ziglang-dev -v ${path_in_machine}:${path_in_docker} -w ${path_in_docker} ubuntu:23.04 /bin/bash
docker exec -it ziglang-dev /bin/bash
install dependency tools
apt update
apt install -y git gcc g++ cmake
apt install -y vim tar xz wget
your gcc --version
maybe like this:
root@02f2988b2401:~/work# gcc --version
gcc (Ubuntu 12.2.0-17ubuntu1) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Installing llvm & clang is not recommended, as zig-bootstrap contains the src itself clang & llvm libs installed in your os may conflict with the ones built, and cause some unexcepted problems
download zig-bootstrap to your working directory either git clone this repo or download from https://ziglang.org/download/ is OK
wget https://ziglang.org/builds/zig-bootstrap-0.11.0-dev.3334+cd1417dbd.tar.xz
tar -xvf zig-bootstrap-0.11.0-dev.3334+cd1417dbd.tar.xz
mv zig-bootstrap-0.11.0-dev.3334+cd1417dbd zig-bootstrap-0.11.0-dev.3334
cd zig-bootstrap-0.11.0-dev.3334
The next steps require your working directory changed to zig-bootstrap-0.11.0-dev.3334
build now
env CMAKE_BUILD_PARALLEL_LEVEL=24 ./build x86_64-linux-musl baseline > build.log 2>&1
I recommend to redirect all the outputs and errors to a log file, because the whole building job may cost several hours depending on your hardware, you may go to drink coffee and back a moment later. If the building failed somewhere, your terminal will display tons of errors which makes debugging hard.
Although my issue solved, I prefer to keep this issue open until official docs come out the build steps in detail.
I added Solved in the title so anyone who quering may see this.
Issue #17018 as Zig bootstrapping bug should be fixed with https://github.com/ziglang/zig/commit/3cf71580c460a30bb52da6e2cbc4482a67bd2930. I had the same problem on ubuntu at work.
Suggestion to close or provide further information.
Sorry to reply too late, since it's solved, I will try it later, thks Let me close it now.
env:
centos 8 + gcc 12 / clang 14(with no libc++ installed)
build cmd
(use build.log because the error message is too large to scroll on my terminal/screen)
the building of LLVM libs is ok but after that it complained:
(rootdir is /root/work/zig-build/zig-bootstrap)
As I see, all the undefined symbol is gcc internal defined in libstdc++ while clang/zig's libc++ doesn't have. Seems that the LLVM libs are compiled using libstdc++ headers but will be linked by libc++ in 'Building stage3'
When I try to force all to use libstdc++ ( I know it is not recommended) I saw zig force using libc++ in the code. So I doubt whether the build script ever worked. If true, please give some details for how to build the dep env(I guess a custom clang with libc++ is used). If not, can anyone help to figure out how to make it work?