official-stockfish / Stockfish

A free and strong UCI chess engine
https://stockfishchess.org/
GNU General Public License v3.0
11.61k stars 2.28k forks source link

Using LTO and static linking while compiling under windows produces an error #3758

Closed Karma-Tron closed 3 years ago

Karma-Tron commented 3 years ago

Hi,

I compile Stockfish in MSYS2 using MINGW64 on my Windows 10 machine. I was always able to use use LTO and static linking by exluding line 649 and its subsequent endif, and adding -save-temps to line 652.

image

I update MSYS2 and MINGW64 in a regular basis. After updating MGWIN64 to version 11.2.0 I get the following error while compiling Stockfish.

lto-wrapper.exe: warning: jobserver is not available: '--jobserver-auth=' is not present in 'MAKEFLAGS'

The produced executable works, but is about 7% slower than before.

Adding --jobserver-auth=3,4 and or i.e. -j8 doesn't solve the problem.

I understand that this is nog a Stockfish issue per se, but I hope someone knowledgeable can point me to the right direction solving this.

Thanks.

ppigazzini commented 3 years ago

EDIT_000: fixed a pasto... EDIT_001: this the PR #2943 that introduced the -lto=jobserver

The option should trigger the parallel linking, see https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html, but perhaps we could use -lto=auto that on Ubuntu 20.04 gcc 11 speedup the linking step.

Use -flto=auto to use GNU make’s job server, if available, or otherwise fall back to autodetection of the number of CPU threads present in your system.

These the build times with a 32 threads CPU, time make -j profile-build ARCH=x86-64-bmi2 COMP=gcc:

BTW same problem with -flto=jobserver with Ubuntu 20.04 gcc 11

g++ -o stockfish benchmark.o bitbase.o bitboard.o endgame.o evaluate.o main.o material.o misc.o movegen.o movepick.o pawns.o position.o psqt.o search.o thread.o timeman.o tt.o uci.o ucioption.o tune.o tbprobe.o evaluate_nnue.o half_ka_v2_hm.o -lgcov -m64 -Wl,--no-as-needed -lpthread -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate=profdir -pedantic -Wextra -Wshadow -m64 -DUSE_PTHREADS -DNDEBUG -O3 -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_AVX2 -mavx2 -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DUSE_PEXT -mbmi2 -flto -flto=jobserver
lto-wrapper: warning: jobserver is not available: ‘--jobserver-auth=’ is not present in ‘MAKEFLAGS’
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.1.0-1ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --disable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-2V7zgg/gcc-11-11.1.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-2V7zgg/gcc-11-11.1.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.1.0 (Ubuntu 11.1.0-1ubuntu1~20.04)
ppigazzini commented 3 years ago

Ops, duplicated of this still open Issue #3656

Karma-Tron commented 3 years ago

Thank you, lto=auto did the job. The perceived speed difference probably was a fluke.