compile Windows version with Wine + MSYS2 #232

Closed
opened 2022-03-21 23:47:15 +08:00 by sb10q · 1 comment

This actually produces a fully working compiler which does not crash and does not depend on wacko libraries like mcfgthread, without involving Visual Studio trashware at all.

Remaining issues:

  • #231 (worked around by disabling IRRT),
  • LLD is somewhat annoying to install on Windows as the MSYS2 package depends on LLVM and overwrites our version (#18).
  • Clean up commands below and put into Nix derivation:
nix-shell -p pacman fakeroot

mkdir -p /home/sb/msys/var/lib/pacman /home/sb/msys/etc
curl -L https://mirror.msys2.org/msys/x86_64/pacman-mirrors-20220205-1-any.pkg.tar.zst | tar xvf - -C /home/sb/msys --zstd
curl https://raw.githubusercontent.com/msys2/MSYS2-packages/master/pacman/pacman.conf > /home/sb/msys/etc/pacman.conf

# edit pacman.conf:
# remove SigLevel
# add /home/sb/msys prefix to paths

fakeroot pacman --root /home/sb/msys --config /home/sb/msys/etc/pacman.conf -Syy
fakeroot pacman --root /home/sb/msys --config /home/sb/msys/etc/pacman.conf --cachedir /home/sb/msys/cache -S mingw-w64-x86_64-rust mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-python3.9  mingw-w64-x86_64-python-numpy --noscriptlet

nix-shell -p wineWowPackages.stable
WINEDEBUG=-all WINEPATH=Z:\\home\\sb\\msys\\mingw64\\bin wine cmd

# run all commands below in Windows cmd

cmake .. -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_UNWIND_TABLES=OFF -DLLVM_ENABLE_THREADS=OFF -DLLVM_TARGETS_TO_BUILD=X86;ARM;RISCV -DLLVM_LINK_LLVM_DYLIB=OFF -DLLVM_ENABLE_FFI=OFF -DLLVM_BUILD_TOOLS=OFF -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_INSTALL_PREFIX=Z:\home\sb\msys\mingw64
ninja
ninja llvm-config
copy bin\llvm-config.exe Z:\home\sb\msys\mingw64\bin
ninja llvm-as
copy bin\llvm-as.exe Z:\home\sb\msys\mingw64\bin



> type Z:\home\sb\msys\pyo3_config.txt
implementation=CPython
version=3.9
shared=true
abi3=false
lib_name=python3.9
lib_dir=Z:\home\sb\msys\mingw64\lib
pointer_width=64
build_flags=WITH_THREAD
suppress_build_script_link_lines=false


> set PYO3_CONFIG_FILE=Z:\home\sb\msys\pyo3_config.txt

> cargo build --release -p nac3artiq

##

cp nac3/target/release/nac3artiq.dll msys/mingw64/lib/python3.9/site-packages/nac3artiq.pyd
This actually produces a fully working compiler which does not crash and does not depend on wacko libraries like mcfgthread, without involving Visual Studio trashware at all. Remaining issues: * #231 (worked around by disabling IRRT), * LLD is somewhat annoying to install on Windows as the MSYS2 package depends on LLVM and overwrites our version (#18). * Clean up commands below and put into Nix derivation: ``` nix-shell -p pacman fakeroot mkdir -p /home/sb/msys/var/lib/pacman /home/sb/msys/etc curl -L https://mirror.msys2.org/msys/x86_64/pacman-mirrors-20220205-1-any.pkg.tar.zst | tar xvf - -C /home/sb/msys --zstd curl https://raw.githubusercontent.com/msys2/MSYS2-packages/master/pacman/pacman.conf > /home/sb/msys/etc/pacman.conf # edit pacman.conf: # remove SigLevel # add /home/sb/msys prefix to paths fakeroot pacman --root /home/sb/msys --config /home/sb/msys/etc/pacman.conf -Syy fakeroot pacman --root /home/sb/msys --config /home/sb/msys/etc/pacman.conf --cachedir /home/sb/msys/cache -S mingw-w64-x86_64-rust mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-python3.9 mingw-w64-x86_64-python-numpy --noscriptlet nix-shell -p wineWowPackages.stable WINEDEBUG=-all WINEPATH=Z:\\home\\sb\\msys\\mingw64\\bin wine cmd # run all commands below in Windows cmd cmake .. -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_UNWIND_TABLES=OFF -DLLVM_ENABLE_THREADS=OFF -DLLVM_TARGETS_TO_BUILD=X86;ARM;RISCV -DLLVM_LINK_LLVM_DYLIB=OFF -DLLVM_ENABLE_FFI=OFF -DLLVM_BUILD_TOOLS=OFF -DLLVM_ENABLE_LIBXML2=OFF -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_INSTALL_PREFIX=Z:\home\sb\msys\mingw64 ninja ninja llvm-config copy bin\llvm-config.exe Z:\home\sb\msys\mingw64\bin ninja llvm-as copy bin\llvm-as.exe Z:\home\sb\msys\mingw64\bin > type Z:\home\sb\msys\pyo3_config.txt implementation=CPython version=3.9 shared=true abi3=false lib_name=python3.9 lib_dir=Z:\home\sb\msys\mingw64\lib pointer_width=64 build_flags=WITH_THREAD suppress_build_script_link_lines=false > set PYO3_CONFIG_FILE=Z:\home\sb\msys\pyo3_config.txt > cargo build --release -p nac3artiq ## cp nac3/target/release/nac3artiq.dll msys/mingw64/lib/python3.9/site-packages/nac3artiq.pyd ```
Poster
Owner

done

done
sb10q closed this issue 2022-03-22 19:58:46 +08:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nac3#232
There is no content yet.