-
Notifications
You must be signed in to change notification settings - Fork 44
Building Multi Variant Stockfish
To build Multi Variant Stockfish on Windows you need MinGW-w64 & MSYS2, if you have already installed them for fishtest, simply skip the following paragraph.
MSYS2 is a collection of GNU utilities, based on modern Cygwin (POSIX compatibility layer) that uses pacman (from Arch Linux) as packages manager to install and to update packages. MinGW-w64 is a project created to support the GCC compiler on Windows systems.
MSYS2 provides 3 different shells:
- MSYS2 MinGW 64-bit, used to build 64 bit applications. Use this if you have a 64 bit Windows
- MSYS2 MinGW 32-bit, used to build 32 bit applications. Use this if you have a 32 bit Windows
- MSYS2 MSYS, used to build MSYS2 core packages. You can use this shell to compile with other MinGW-w64, view below the instructions
The default setting installs MSYS2 in to C:\msys64 folder, the user home is the folder C:\msys64\home\<your_username> (C:\msys32 for 32 bit Windows)
Warning: MSYS2 might not work with Windows XP and Windows Server 2003.
Download and install MSYS2 using the default setting, use the 64 bit or 32 bit installer according your operating system and follow the official instruction to update the MSYS2 packages (simply: a. update the core packages executing pacman -Syuu
, when requested close the windows pushing the top right X button b. open a MSYS2 MinGW 64-bit shell and update the others packages executing pacman -Syuu
)
Be sure to have the folder C:\msys64\mingw64\bin
- write with a text editor the file C:\msys64\home\<your_username>\makefish.sh (check the folder in C:\msys64\home if you don't know your username) copying the text below
#!/bin/bash
# makefish.sh
# install packages if not already installed
unzip -v &> /dev/null || pacman -S --noconfirm unzip
make -v &> /dev/null || pacman -S --noconfirm make
g++ -v &> /dev/null || pacman -S --noconfirm mingw-w64-x86_64-gcc
# download the Stockfish source code
wget https://github.com/ddugovic/Stockfish/archive/master.zip
unzip master.zip
cd Stockfish-master/src
# build the stockfish executable
# to speedup the building process you can keep only the section that fits your CPU architecture
# build the binary for CPUs without popcnt and bmi2 instructions (e.g. older than Intel Sandy Bridge)
make profile-build ARCH=x86-64 COMP=mingw
strip stockfish.exe
mv stockfish.exe ../../stockfish_x64.exe
make clean
# build the binary for CPU with popcnt instruction (e.g. Intel Sandy Bridge)
if [ "$(g++ -Q -march=native --help=target | grep mpopcnt | grep enabled)" ] ; then
make profile-build ARCH=x86-64-modern COMP=mingw
strip stockfish.exe
mv stockfish.exe ../../stockfish_x64_modern.exe
make clean
fi
# build the binary for CPU with bmi2 instruction (e.g. Intel Haswell or newer)
if [ "$(g++ -Q -march=native --help=target | grep mbmi2 | grep enabled)" ] ; then
make profile-build ARCH=x86-64-bmi2 COMP=mingw
strip stockfish.exe
mv stockfish.exe ../../stockfish_x64_bmi2.exe
make clean
fi
cd
- open a MSYS2 MinGW 64-bit console (open a Windows Search with the keys "Windows key + Q", write mingw, select MSYS2 MinGW 64-bit)
- check to have the scritp makefish.sh with the command
ls makefish.sh*
. If you view as result makefish.sh.txt, rename the file with the commandmv makefish.sh.txt makefish.sh
- start the building script with
bash makefish.sh
- copy and paste the text in a makefish.sh file
#!/bin/bash
# makefish.sh
# install packages if not already installed
unzip -v &> /dev/null || sudo apt install -y unzip
make -v &> /dev/null || sudo apt install -y make
g++ -v &> /dev/null || sudo apt install -y build-essential
# download the Stockfish source code
wget https://github.com/ddugovic/Stockfish/archive/master.zip
unzip master.zip
cd Stockfish-master/src
# build the executables
# to speedup the building process you can keep only the section that fits your CPU architecture
# build the binary for CPUs without popcnt and bmi2 instructions (e.g. older than Intel Sandy Bridge)
make profile-build ARCH=x86-64 COMP=gcc
strip stockfish
mv stockfish ../../stockfish_x64
make clean
# build the binary for CPU with popcnt instruction (e.g. Intel Sandy Bridge)
if [ "$(g++ -Q -march=native --help=target | grep mpopcnt | grep enabled)" ] ; then
make profile-build ARCH=x86-64-modern COMP=gcc
strip stockfish
mv stockfish ../../stockfish_x64_modern
make clean
fi
# build the binary for CPU with bmi2 instruction (e.g. Intel Haswell or newer)
if [ "$(g++ -Q -march=native --help=target | grep mbmi2 | grep enabled)" ] ; then
make profile-build ARCH=x86-64-bmi2 COMP=gcc
strip stockfish
mv stockfish ../../stockfish_x64_bmi2
make clean
fi
cd
- start the building script with
bash makefish.sh