#Problems building master with zig-bootstrap

1 messages · Page 1 of 1 (latest)

whole dawn
#

I'm trying to build the latest master branch, but my linux distro (ubuntu) does not have llvm 15 in the repo, so I'm trying to use zig-bootstrap. Following the instructions in the wiki (although I can see they haven't been updated since to switch to llvm 15) for option B using zig-bootstrap, I get linking errors when building the compiler. To build the compile I did the following:

  • built zig-bootstrap with ./build native-linux-gnu baseline (also tried with ./build native-linux-gnu native gives the same behaviour later)
  • set $ZIG_PREFIX and LLVM_PREFIX to /path/to/zig-bootstrap/out/host.
  • created the cmake build directory with:
mkdir build
cd build
cmake .. -DCMAKE_PREFIX_PATH=$LLVM_PREFIX

I also tried with -DZIG_LLVM_STATIC=ON set as well

  • attempted to compile zig with "$ZIG_PREFIX/bin/zig" build -p stage3 --search-prefix "$LLVM_PREFIX" --zig-lib-dir lib -Dstatic-llvm the compilation fails with what looks like a few hundred lines of linking errors (all undefined symbols) followed by some
LLD Link... ld.lld: error: undefined symbol: llvm::SubtargetFeatures::getString() const
> referenced by zig_llvm.cpp:101 (src/zig_llvm.cpp:101)
> >>>               /path/to/zig/src/zig-cache/o/81e5cf657f15e4815f5bb4f29e7a6c5d/zig_llvm.o:(ZigLLVMGetNativeFeatures)
> ```.

I have tried uninstalling the system `llvm-dev` package that I used to build older versions of `zig` in case somehow the wrong version of some llvm tools were causing issues (I've just found that apparently I still have the package `llvm-14-linker-tools` on my system, which provides lld so maybe the wrong lld binary is being used?).

I have also tried building without `-Dstatic-llvm` in which case the compiler builds, but when I try to use it it panics with an integer overflow and dumps a bunch of (I think its) ZIR.

Can anyone point me in the right direction to try and get the master branch building?
GitHub

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software. - Building Zig From Source · ziglang/zig Wiki

haughty fossil
#

This is what I do

#

you need everything on 15 llvm related

#

after that static or dynamic doesn't matter

whole dawn
#

So I guess I can try that while pointing cmake to the zig-bootstrap build of llvm with -DCMAKE_PREFIX_PATH?

haughty fossil
#

ye

whole dawn
#

and should I be able to use the resulting compiler to build current master branch with zig build ?

haughty fossil
#

Nah, it already builds it for you for common usage

#

zig build is for development 😄

#

you either take first method or second

#

not both

whole dawn
#

what are the $PKG and $SRC variables meant to point to?

haughty fossil
#

ah

#

that's my linux distro specific

#

$SRC is where I have the source code (in a folder above the actual zig source, like someFolder/zig_source, so $SRC is someFolder)

#

and $PKG is ignorable

#

is just a way not to install into /usr directly

#

instead installs into a temp file where it gets compressed and then I can install it into my system knowing it didn't make any changes yet

#

that's again, all distro specific stuff

whole dawn
#

okay

#

lol I just realised in my haze of compilation attempts I mixed up the two methods above and included part of the cmake steps above... With the cmake route I do seem to get a working compiler, but alas when I try to build mach I get a linking error that it can't find the dawn library, guess I'll have to go ask slimsag about it

#

Seems to just be trying to use the cmake-built compiler to build zig with zig build that crashes - what should I do make/test PRs for the zig standard library in this case?

haughty fossil
#

just do zig test to the file you are concerned