Trouble building from source using LLVM 19

I’m attempting to build Zig from source by following the instruction on the repo’s wiki. Per the recommendation from one of my previous topics, I am using LLVM 19 built from source using more instructions from the wiki.

However, when I run make install I get the following error:

$ make install
[  5%] Building CXX object CMakeFiles/zigcpp.dir/src/zig_llvm.cpp.o
/home/theshinx317/Coding/zig/src/zig_llvm.cpp:753:68: error: static assertion failed
  753 | static_assert((Triple::EnvironmentType)ZigLLVM_LastEnvironmentType == Triple::LastEnvironmentType, "");
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/theshinx317/Coding/zig/src/zig_llvm.cpp:753:68: note: the comparison reduces to ‘(42 == 45)’
make[2]: *** [CMakeFiles/zigcpp.dir/build.make:76: CMakeFiles/zigcpp.dir/src/zig_llvm.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:91: CMakeFiles/zigcpp.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

I suspect the small difference between EnvironmentTypes are do to subtly different version of the LLVM’s git commits, but I’m not fluent enough in this domain to know for sure.

Any thoughts on what could be causing this error?

System details:

I don’t know, but this sounds suspiciously related: Reduce our exposure to LLVM API breakage by alexrp · Pull Request #21862 · ziglang/zig

3 Likes

Sorry, our friends over at LLVM made API breaking changes in a bug fix release. You have to use the 19.1.0 tag for now. I plan to wait to update the zig codebase to the latest 19.x release in December to reduce churn, in case they do it again.

Edit: nevermind. You can thank @alexrp for the fix.

3 Likes

I checked out the commit with @alexrp 's fix and, sure enough, that fixed my problem! Thanks everyone!

I was trying to build zig 2024.10.0-mach from source and I was hitting the same error as in this post.

Andrew linked to PR 21862 which contained three commits, of which cherry-picking f1f804e532e603a3f58d559d32a1c8120691d891 got me past that build error.

So, specifically, from a full clone of ziglang/zig, I ran:

  • git checkout 3bf89f55c (per “Zig 2024.10.0-mach and 0.14.0-dev.1911+3bf89f55c are identical” on the mach page)
  • git cherry-pick f1f804e532e603a3f58d559d32a1c8120691d891

I am out of time tonight to try using it, so I can’t say for certain whether it works correctly with the application I want to build (I presume it will work), but at least I was able to build Zig without error.