MINGW-packages: mingw-w64-x86_64-zig: `zig` fails to start, `libLLVM.dll` is missing

I updated MSYS2 an hour ago, and installed zig package:

$ pacman -S mingw64/mingw-w64-x86_64-zig
   ...
$ pacman -Q mingw-w64-x86_64-zig
mingw-w64-x86_64-zig 0.7.1-2

$ zig
bash: zig: command not found

$ PATH=$PATH:/mingw64/bin

$ zig
C:/msys64/mingw64/bin/zig.exe: error while loading shared libraries: libwinpthread-1.dll: cannot open shared object file: No such file or directory

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 18 (7 by maintainers)

Most upvoted comments

master branch of Zig depends on LLVM 14, however I am actively working to merge the llvm15 branch of Zig as soon as upgrade issues are solved. This will be done within a few days.

Upcoming Zig version (0.10.0) has a release date of 2022-11-01 and will link against LLVM 15.

Thank you both.

@jeremyd2019, as you suggested in #8272, should we try adding mingw-w64-x86_64-compiler-rt as build dependency?

Not sure what else would be needed, like adding -lcompiler-rt flag somewhere.

By the way, in https://andrewkelley.me/post/zig-cc-powerful-drop-in-replacement-gcc-clang.html Andrew says:

Zig’s compiler-rt is not yet complete. However, completing it is a prerequisite for releasing Zig version 1.0.0.

@kassane: thanks for the pointers. Looks like their progress with missing compiler-rt functions is blocked by:

  • deciding between the the amount of hand-rolled asm & the speed of functions.
  • Zig signal handling port missing a strategy.
  • missing benchmarking against realistic workloads to prevent regressions.
  • missing efforts to debug using posix_spawn instead of fork.

A lot of stuff here!

The new undefined references are due to us needing to disable some targets in LLVM 13 to avoid hitting an intrinsic limit of 65535 exported symbols from a DLL. Zig does not support building against an LLVM that was not built with all targets enabled. I tried hacking out targets in msys2/MINGW-packages-dev#16 but still hit the out-of-memory or __emutls_get_address errors

@sskras This case the bug is only in zig because it has no link to libgcc or compiler-rt or any mingw-specific lib. Perhaps the only viable alternative would be to try compiling with the official zig build itself instead of mingw’s clang/gcc. Because the old-version available in msys2/mingw is broken to compile under windows-gnu.

Yes, but now the stable version is 0.9.0. Which seems to use LLVM 13 already:

This release of Zig upgrades to LLVM 13. Good news: we noticed something like a 12% improvement in compilation speed when we upgraded Zig from LLVM 12 to 13.

I guess the PKGBUILD just needs an update. Ping @kassane.

Hi @sskras

So far I stopped updating the mingw package waiting to fix zig0 and its high memory consumption during build causing the error process to stop in some cases. And also because there was a bug during the binary linking generating conflict between mingw/msvc.

[ 98%] Linking CXX executable zig0.exe
D:/M/msys64/mingw64/lib\liblldELF.a(InputFiles.cpp.obj): duplicate section `.rdata$_ZZNSt8__detail18__to_chars_10_implIjEEvPcjT_E8__digits[_ZZNSt8__detail18__to_chars_10_implIjEEvPcjT_E8__digits]' has different size
D:/M/msys64/mingw64/lib\liblldELF.a(InputSection.cpp.obj): duplicate section `.rdata$_ZZNSt8__detail18__to_chars_10_implIjEEvPcjT_E8__digits[_ZZNSt8__detail18__to_chars_10_implIjEEvPcjT_E8__digits]' has different size
D:/M/msys64/mingw64/lib\liblldCOFF.a(InputFiles.cpp.obj): duplicate section `.rdata$_ZZNSt8__detail18__to_chars_10_implIjEEvPcjT_E8__digits[_ZZNSt8__detail18__to_chars_10_implIjEEvPcjT_E8__digits]' has different size
D:/M/msys64/mingw64/lib\liblldWasm.a(Writer.cpp.obj): duplicate section `.rdata$_ZZNSt8__detail18__to_chars_10_implIjEEvPcjT_E8__digits[_ZZNSt8__detail18__to_chars_10_implIjEEvPcjT_E8__digits]' has different size
D:/M/msys64/mingw64/lib\liblldWasm.a(WriterUtils.cpp.obj): duplicate section `.rdata$_ZZNSt8__detail18__to_chars_10_implIjEEvPcjT_E8__digits[_ZZNSt8__detail18__to_chars_10_implIjEEvPcjT_E8__digits]' has different size
[ 98%] Built target zig0
[ 99%] Building self-hosted component C:/_/mingw-w64-zig/src/zig-0.9.0/build-x86_64-w64-mingw32/zig1.o
allocation failed
make[2]: *** [CMakeFiles/zig.dir/build.make:347: zig1.o] Error 3