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

Profile Build fails on my system #4306

Closed Zibri closed 1 year ago

Zibri commented 1 year ago

Describe the issue

$ make -j profile-build ARCH=x86-64-modern COMP=clang-10

[...]

clang++  -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -m64 -DUSE_PTHREADS -DNDEBUG -O3 -fexperimental-new-pass-manager -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DGIT_SHA=\"64656f85\" -DGIT_DATE=\"20221224\" -flto=full   -c -o tune.o tune.cpp
clang++  -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -m64 -DUSE_PTHREADS -DNDEBUG -O3 -fexperimental-new-pass-manager -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DGIT_SHA=\"64656f85\" -DGIT_DATE=\"20221224\" -flto=full   -c -o tbprobe.o syzygy/tbprobe.cpp
clang++  -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -m64 -DUSE_PTHREADS -DNDEBUG -O3 -fexperimental-new-pass-manager -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DGIT_SHA=\"64656f85\" -DGIT_DATE=\"20221224\" -flto=full   -c -o evaluate_nnue.o nnue/evaluate_nnue.cpp
clang++  -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -m64 -DUSE_PTHREADS -DNDEBUG -O3 -fexperimental-new-pass-manager -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DGIT_SHA=\"64656f85\" -DGIT_DATE=\"20221224\" -flto=full   -c -o half_ka_v2_hm.o nnue/features/half_ka_v2_hm.cpp
clang++ -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  -fprofile-instr-generate -latomic -m64 -lpthread  -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -m64 -DUSE_PTHREADS -DNDEBUG -O3 -fexperimental-new-pass-manager -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2 -DGIT_SHA=\"64656f85\" -DGIT_DATE=\"20221224\" -flto=full
ld: error: cannot open /opt/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.6/lib/linux/libclang_rt.profile-x86_64.a: No such file or directory
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [Makefile:964: stockfish] Error 1
make[2]: Leaving directory '/home/zibri/Stockfish/src'
make[1]: *** [Makefile:971: clang-profile-make] Error 2
make[1]: Leaving directory '/home/zibri/Stockfish/src'
make: *** [Makefile:824: profile-build] Error 2

Expected behavior

.

Steps to reproduce

make clean;make -j profile-build ARCH=x86-64-modern COMP=clang

Anything else?

$ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=20.04 DISTRIB_CODENAME=focal DISTRIB_DESCRIPTION="Ubuntu 20.04.5 LTS"

Operating system

All

Stockfish version

latest

Disservin commented 1 year ago

Mh this works just fine for my WSL

cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.4 LTS"

whats the output of g++-9 -v maybe?

Disservin commented 1 year ago

Ah, please also change the Steps to reproduce

Zibri commented 1 year ago

I changed the issue... I don't know what was messed up before but I removed the directory and cloned again the full repository. Now "build" works.. but profile-build does not. $ make -j profile-build ARCH=x86-64-modern COMP=clang

Zibri commented 1 year ago

I rechecked everything:

this works: make clean;make -j build ARCH=x86-64-modern COMP=clang this fails: make clean;make -j build ARCH=x86-64-modern COMP=gcc COMPCXX=g++-9 and this fails too: make clean;make -j profile-build ARCH=x86-64-modern COMP=clang

vondele commented 1 year ago

This is typically an issue with how you have installed the toolchains. For example, your first post contains the following error message:

cannot open /opt/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.6/lib/linux/libclang_rt.profile-x86_64.a

That's not something we can fix from our side.

Zibri commented 1 year ago

if I remove flto lines in Makefile everything works:

713:# CXXFLAGS += -flto -flto-partition=one 714:# LDFLAGS += $(CXXFLAGS) -flto=jobserver 716:# CXXFLAGS += -flto=full

Can anyone explain me why?

Zibri commented 1 year ago

This is typically an issue with how you have installed the toolchains. For example, your first post contains the following error message:

cannot open /opt/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.6/lib/linux/libclang_rt.profile-x86_64.a

That's not something we can fix from our side.

Yep.. sorry.. I noticed now.. I had the paths set for ndk compile. With normal paths clang works too... BUT, I have to remove flto lines from Makefile if I want to use gcc-9

MinetaS commented 1 year ago

Please provide detailed information in each specific case.

  1. The command you tried to run
  2. The entire make output, including error messages
Zibri commented 1 year ago

Nevermind... with the correct PATH variable, everything works. My bad. Perhaps, as a hint, set the PATH variable to the default at the top of the makefile. That will solve any similar problems people might have.

Zibri commented 1 year ago

You may close this. Sorry.

Zibri commented 1 year ago

Just for reference, this is now my build script and it works, no matter how the PATH variable is set:

#!/bin/bash

export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
cd Stockfish/src
rm -rf stockfish.armv8 stockfish.bmi2
git pull
make clean;make -j8 build ARCH=armv8 COMP=ndk;make -j strip ARCH=armv8 COMP=ndk
mv stockfish stockfish.armv8
make clean;make -j8 profile-build ARCH=x86-64-bmi2 COMP=gcc COMPCXX=g++-9;make -j strip ARCH=x86-64-bmi2 COMP=gcc COMPCXX=g++-9
mv stockfish stockfish.bmi2