#Is building llvm and zig with MSVC still supported?

1 messages · Page 1 of 1 (latest)

royal juniper
#

I've been working through this here: https://github.com/ziglang/zig/issues/12703 , but it seems like building llvm with MSVC (https://github.com/ziglang/zig/wiki/Building-Zig-on-Windows#option-2-using-cmake-and-microsoft-visual-studio) doesn't work atm because of conflicting C libs (zig tries to link the mingw crt2 while llvm pulls in libcmt). I think the CI must build llvm with a different compiler?

GitHub

Zig Version 26e9839 Steps to Reproduce Within the zig folder: mkdir build-release pushd build-release "c:\Program Files\CMake\bin\cmake.exe" .. -Thost=x64 -G "Visual Stud...

GitHub

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

bright quiver
#

CI builds LLVM with zig cc

#

Which is required because of different C++ calling conventions between compilers

#

Which would be an issue even if you could fix the linking errors

royal juniper
#

It didn't use to be that way, at least in 0.9.1 and part way through the pre-10 release I was able to follow the wiki directions to build it with MSVC

#

ie. build llvm with MSVC, then build zig from scratch via MSVC

#

So I'm wondering if it was decided to not support that anymore, or of it regressed (I noticed it when I made that issue)

#

If indeed it's not intended to work then the wiki should probably not indicate that it's possible

#

I did try building with -msvc instead of -gnu for zig build itself, but hit a bunch of compile errors instead.

bright quiver
#

It's possible you could build LLVM's C bindings with MSVC and then link them into the Zig part of the compiler, but it's much more annoying to do

#

I'd recommend building LLVM with zig cc for best results

royal juniper
#

This did use to work though, and it would be nice to be able to use only msvc to get things going

#

I'm working on trying to get things to build with the msvc target, there are issues building libcxx and libcxxabi which I'm trying to understand

bright quiver
#

It's possible you can still use msvc to build stage1, which you could then use to rebuild llvm and build stage2

#

Have a look at the zig-bootstrap repo and see what it does

#

Though that may only work on Linux? Not sure

#

Ah, yeah, requires posix

#

If you can build LLVM and Clang using MSVC, you should be able to bootstrap Zig with it

#

But honestly it may be simpler to just get a clang build for windows and bootstrap from there

#

Or to bootstrap on WSL and cross compile, meaning you can use zig-bootstrap to handle the build process for you