official-stockfish / Stockfish

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

Cannot compile for android -- again. #2979

Closed MisesEnForce closed 4 years ago

MisesEnForce commented 4 years ago

Hello,

I have seen several issues of the type "cannot compile for android", some being closed, other being left for dead, all without any proper response.

I am using gcc 8.4.0.

I took your Makefile and tweaked it as follows :

$ git diff Makefile
diff --git a/src/Makefile b/src/Makefile
index 3d84f482..7a423ecb 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -241,8 +241,6 @@ ifeq ($(COMP),gcc)

        ifeq ($(ARCH),$(filter $(ARCH),armv7 armv8))
                ifeq ($(OS),Android)
-                       CXXFLAGS += -m$(bits)
-                       LDFLAGS += -m$(bits)
                endif
        else
                CXXFLAGS += -m$(bits)
@@ -369,7 +367,7 @@ ifeq ($(optimize),yes)

        ifeq ($(comp),gcc)
                ifeq ($(OS), Android)
-                       CXXFLAGS += -fno-gcse -mthumb -march=armv7-a -mfloat-abi=softfp
+                       CXXFLAGS += -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small
                endif
        endif

@@ -382,7 +380,7 @@ endif

 ### 3.4 Bits
 ifeq ($(bits),64)
-       CXXFLAGS += -DIS_64BIT
+       CXXFLAGS += -DIS_64BIT -D__ANDROID_API__=28
 endif

 ### 3.5 prefetch

(The -D__ANDROID_API__=28 because without it I have error: 'aligned_alloc' was not declared in this scope issues ...)

I don't understand why you override, when os is android, the armv8 into arvm7 and why you give invalid compiler options (-mthum, -mfloat-abi, or -m64). Did you test these compilations on an android device ?

The produced executable works in a termux android terminal but triggers a "fail to start engine" inside Droidfish, which is a sufficiently thrustable app for me (it runs an lc0 with big nets, several other engines etc) to be sure that there must be a problem with the compilation even if it works in the termux terminal. But I don't see which problem it could be. I put the compilation log below.

Could you please provide the exact makefile you used (with options (arch etc))) you used to build stockfish on an android os, if you did ?

I think that there is a huge number of people trying to do what I tried, without success, so that it would really be useful to have a clear stance from you on this.

Compilation log :

$ make profile-build ARCH=armv8 COMP=gcc COMPCXX=g++

Config:
debug: 'no'
sanitize: 'no'
optimize: 'yes'
arch: 'armv8-a'                                                                         bits: '64'                                                                              kernel: 'Linux'
os: 'Android'                                                                           prefetch: 'yes'                                                                         popcnt: 'yes'                                                                           sse: 'no'
ssse3: 'no'
sse41: 'no'
avx2: 'no'
pext: 'no'
avx512: 'no'
neon: 'yes'
                                                                                        Flags:
CXX: g++
CXXFLAGS: -Wall -Wcast-qual -fno-exceptions -std=c++17  -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE
LDFLAGS:  -Wl,--no-as-needed -Wall -Wcast-qual -fno-exceptions -std=c++17  -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE -flto=jobserver -fPIE -pie                                                                                                                                                                            Testing config sanity. If this fails, try 'make help' ...
                                                                                                                                                                                Step 1/4. Building instrumented executable ...
make ARCH=armv8 COMP=gcc gcc-profile-make                                               make[1]: Entering directory '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src'                                                                                       make ARCH=armv8 COMP=gcc \
EXTRACXXFLAGS='-fprofile-generate' \                                                    EXTRALDFLAGS='-lgcov' \                                                                 all
make[2]: Entering directory '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src'                                                                                       g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o benchmark.o benchmark.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o bitbase.o bitbase.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o bitboard.o bitboard.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o endgame.o endgame.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o evaluate.o evaluate.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o main.o main.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o material.o material.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o misc.o misc.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o movegen.o movegen.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o movepick.o movepick.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o pawns.o pawns.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o position.o position.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o psqt.o psqt.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o search.o search.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o thread.o thread.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o timeman.o timeman.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o tt.o tt.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o uci.o uci.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o ucioption.o ucioption.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o tune.o tune.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o tbprobe.o syzygy/tbprobe.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o evaluate_nnue.o nnue/evaluate_nnue.cpp
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o half_kp.o nnue/features/half_kp.cpp
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_kp.o -lgcov -Wl,--no-as-needed -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-generate -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE -flto=jobserver -fPIE -pie
make[2]: Leaving directory '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src'
make[1]: Leaving directory '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src'

Step 2/4. Running benchmark for pgo-build ...
./stockfish bench > /dev/null

Position: 1/47

Position: 2/47

Position: 3/47

Position: 4/47

Position: 5/47

Position: 6/47

Position: 7/47

Position: 8/47

Position: 9/47

Position: 10/47

Position: 11/47

Position: 12/47

Position: 13/47

Position: 14/47

Position: 15/47

Position: 16/47

Position: 17/47

Position: 18/47

Position: 19/47

Position: 20/47

Position: 21/47

Position: 22/47

Position: 23/47

Position: 24/47

Position: 25/47

Position: 26/47

Position: 27/47

Position: 28/47

Position: 29/47

Position: 30/47

Position: 31/47

Position: 32/47

Position: 33/47

Position: 34/47

Position: 35/47

Position: 36/47

Position: 37/47

Position: 38/47

Position: 39/47

Position: 40/47

Position: 41/47

Position: 42/47

Position: 43/47

Position: 44/47

Position: 45/47

Position: 46/47

Position: 47/47

===========================
Total time (ms) : 7765
Nodes searched  : 4733874
Nodes/second    : 609642

Step 3/4. Building optimized executable ...
make ARCH=armv8 COMP=gcc objclean
make[1]: Entering directory '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src'
make[1]: Leaving directory '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src'
make ARCH=armv8 COMP=gcc gcc-profile-use
make[1]: Entering directory '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src'
make ARCH=armv8 COMP=gcc \
EXTRACXXFLAGS='-fprofile-use -fno-peel-loops -fno-tracer' \
EXTRALDFLAGS='-lgcov' \
all
make[2]: Entering directory '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src'
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o benchmark.o benchmark.cpp
benchmark.cpp: In function '_GLOBAL__sub_I__Z11setup_benchRK8PositionRNSt6__ndk113basic_istreamIcNS2_11char_traitsIcEEEE':
benchmark.cpp:159:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/benchmark.gcda' profile count data file not found [-Wmissing-profile]
  159 | }
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o bitbase.o bitbase.cpp
bitbase.cpp: In member function 'std::__ndk1::vector<(anonymous namespace)::KPKPosition, std::__ndk1::allocator<(anonymous namespace)::KPKPosition> >::__vallocate(unsigned long)':
bitbase.cpp:170:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/bitbase.gcda' profile count data file not found [-Wmissing-profile]
  170 | } // namespace
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o bitboard.o bitboard.cpp
bitboard.cpp: In member function 'std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >::__grow_by_and_replace(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, char const*)':
bitboard.cpp:203:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/bitboard.gcda' profile count data file not found [-Wmissing-profile]
  203 | }
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o endgame.o endgame.cpp
endgame.cpp: In function '_GLOBAL__sub_I__ZN8Endgames4mapsE':
endgame.cpp:743:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/endgame.gcda' profile count data file not found [-Wmissing-profile]
  743 | }
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o evaluate.o evaluate.cpp
evaluate.cpp: In function '_GLOBAL__sub_I__ZN4Eval7useNNUEE':
evaluate.cpp:1007:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/evaluate.gcda' profile count data file not found [-Wmissing-profile]
 1007 | }
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o main.o main.cpp
main.cpp: In member function 'std::__ndk1::basic_streambuf<char, std::__ndk1::char_traits<char> >::overflow(int)':
main.cpp:53:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/main.gcda' profile count data file not found [-Wmissing-profile]
   53 | }
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o material.o material.cpp
material.cpp: In function '_GLOBAL__sub_I__ZN8Material5probeERK8Position':
material.cpp:220:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/material.gcda' profile count data file not found [-Wmissing-profile]
  220 | } // namespace Material
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o misc.o misc.cpp
misc.cpp: In function '_GLOBAL__sub_I__Z11engine_infob':
misc.cpp:570:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/misc.gcda' profile count data file not found [-Wmissing-profile]
  570 | } // namespace WinProcGroup
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o movegen.o movegen.cpp
movegen.cpp: In function '(anonymous namespace)::make_promotions<(GenType)4, (Direction)-8>(ExtMove*, Square, Square)ExtMove*':
movegen.cpp:367:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/movegen.gcda' profile count data file not found [-Wmissing-profile]
  367 | }
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o movepick.o movepick.cpp
movepick.cpp: In member function 'MovePicker::select<(MovePicker::PickType)1, MovePicker::next_move(bool)::{lambda()#7}>(MovePicker::next_move(bool)::{lambda()#7})Move':
movepick.cpp:264:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/movepick.gcda' profile count data file not found [-Wmissing-profile]
  264 | }
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o pawns.o pawns.cpp
pawns.cpp: In member function 'Pawns::Entry::evaluate_shelter<(Color)1>(Position const&, Square) constScore':
pawns.cpp:281:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/pawns.gcda' profile count data file not found [-Wmissing-profile]
  281 | } // namespace Pawns
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o position.o position.cpp
position.cpp: In function '_GLOBAL__sub_I__ZN7Zobrist3psqE':
position.cpp:1397:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/position.gcda' profile count data file not found [-Wmissing-profile]
 1397 | }
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o psqt.o psqt.cpp
psqt.cpp: In function 'PSQT::init()':
psqt.cpp:122:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/psqt.gcda' profile count data file not found [-Wmissing-profile]
  122 | } // namespace PSQT
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o search.o search.cpp
search.cpp: In function '_GLOBAL__sub_I__ZN6Search6LimitsE':
search.cpp:1962:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/search.gcda' profile count data file not found [-Wmissing-profile]
 1962 | }
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o thread.o thread.cpp
thread.cpp: In function '_GLOBAL__sub_I_Threads':
thread.cpp:271:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/thread.gcda' profile count data file not found [-Wmissing-profile]
  271 | }
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o timeman.o timeman.cpp
timeman.cpp: In function 'std::__ndk1::__tree_balance_after_insert<std::__ndk1::__tree_node_base<void*>*>(std::__ndk1::__tree_node_base<void*>*, std::__ndk1::__tree_node_base<void*>*)void':
timeman.cpp:97:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/timeman.gcda' profile count data file not found [-Wmissing-profile]
   97 | }
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o tt.o tt.cpp
tt.cpp: In function '_GLOBAL__sub_I_TT':
tt.cpp:155:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/tt.gcda' profile count data file not found [-Wmissing-profile]
  155 | }
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o uci.o uci.cpp
uci.cpp: In member function 'std::__ndk1::basic_streambuf<char, std::__ndk1::char_traits<char> >::pbackfail(int)':
uci.cpp:371:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/uci.gcda' profile count data file not found [-Wmissing-profile]
  371 | }
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o ucioption.o ucioption.cpp
ucioption.cpp: In function '_GLOBAL__sub_I_Options':
ucioption.cpp:191:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/ucioption.gcda' profile count data file not found [-Wmissing-profile]
  191 | } // namespace UCI
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o tune.o tune.cpp
tune.cpp: In function '_GLOBAL__sub_I__ZN4Tune14update_on_lastE':
tune.cpp:144:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/tune.gcda' profile count data file not found [-Wmissing-profile]
  144 | }
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o tbprobe.o syzygy/tbprobe.cpp
syzygy/tbprobe.cpp: In function '_GLOBAL__sub_I__ZN10Tablebases14MaxCardinalityE':
syzygy/tbprobe.cpp:1610:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/tbprobe.gcda' profile count data file not found [-Wmissing-profile]
 1610 | }
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o evaluate_nnue.o nnue/evaluate_nnue.cpp
nnue/evaluate_nnue.cpp: In function '_GLOBAL__sub_I_kpp_board_index':
nnue/evaluate_nnue.cpp:178:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/evaluate_nnue.gcda' profile count data file not found [-Wmissing-profile]
  178 | } // namespace Eval::NNUE
      | ^
g++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE   -c -o half_kp.o nnue/features/half_kp.cpp
nnue/features/half_kp.cpp: In function 'Eval::NNUE::Features::HalfKP<(Eval::NNUE::Features::Side)0>::GetPieces(Position const&, Color, PieceSquare**, Square*)':
nnue/features/half_kp.cpp:92:1: warning: '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src/half_kp.gcda' profile count data file not found [-Wmissing-profile]
   92 | }  // namespace Eval::NNUE::Features
      | ^
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_kp.o -lgcov -Wl,--no-as-needed -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wextra -Wshadow -DNDEBUG -O3 -fno-gcse -mtune=cortex-a55 -march=armv8-a -mcmodel=small  -DIS_64BIT -D__ANDROID_API__=28 -DUSE_POPCNT -DUSE_NEON -flto -fPIE -flto=jobserver -fPIE -pie
make[2]: Leaving directory '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src'
make[1]: Leaving directory '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src'

Step 4/4. Deleting profile data ...
make ARCH=armv8 COMP=gcc profileclean
make[1]: Entering directory '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src'
make[1]: Leaving directory '/data/data/com.termux/files/home/CODING/CHESS/Stockfish/src'
$ ./stockfish
Stockfish 110820 by the Stockfish developers (see AUTHORS file)
uci
id name Stockfish 110820
id author the Stockfish developers (see AUTHORS file)

option name Debug Log File type string default
option name Contempt type spin default 24 min -100 max 100
option name Analysis Contempt type combo default Both var Off var White var Black var Both
option name Threads type spin default 1 min 1 max 512
option name Hash type spin default 16 min 1 max 33554432
option name Clear Hash type button
option name Ponder type check default false
option name MultiPV type spin default 1 min 1 max 500
option name Skill Level type spin default 20 min 0 max 20
option name Move Overhead type spin default 10 min 0 max 5000
option name Slow Mover type spin default 100 min 10 max 1000
option name nodestime type spin default 0 min 0 max 10000
option name UCI_Chess960 type check default false
option name UCI_AnalyseMode type check default false
option name UCI_LimitStrength type check default false
option name UCI_Elo type spin default 1350 min 1350 max 2850
option name UCI_ShowWDL type check default false
option name SyzygyPath type string default <empty>
option name SyzygyProbeDepth type spin default 1 min 1 max 100
option name Syzygy50MoveRule type check default true
option name SyzygyProbeLimit type spin default 7 min 0 max 7
option name Use NNUE type check default false
option name EvalFile type string default nn-112bb1c8cdb5.nnue
uciok
quit
$
vondele commented 4 years ago

@MisesEnForce I think so far we have had nobody on the regular developers team with Android experience to improve and maintain the makefile. Help would be welcome, so eventually we have a working Android Makefile.

The aligned_alloc issue should be fixed with current master.

Can I ask to take your Makefile changes to the issue https://github.com/official-stockfish/Stockfish/issues/2860 , in the hope that this eventually leads to a pull request.

MisesEnForce commented 4 years ago

@MisesEnForce I think so far we have had nobody on the regular developers team with Android experience to improve and maintain the makefile. Help would be welcome, so eventually we have a working Android Makefile.

The aligned_alloc issue should be fixed with current master.

Can I ask to take your Makefile changes to the issue #2860 , in the hope that this eventually leads to a pull request.

Many thx for fixing the aligned memory allocation issue !

Actually I tried to compile stockfish on my android phone. (With the tools (terminal, compiler etc) provided by the termux app.) With this, stockfish works on the command line on the phone, but not when used in the DroidFish app, which does not satisfy me. I would like next to try to cross compile it (with the toolchain provided with the android sdk) for my android and see if then it works within the DroidFish app. I will take my changes to the makefile (after having made them generic, i.e. not only working for my phone) + add a text tutorial for the cross-build (if it succeeds, fingers crossed).

vondele commented 4 years ago

not working in the droidfish app could be related to not finding the network file (if it works for classical eval but not for NNUE). The EvalFile argument must be the full path to the file, or the file must be in the working directory of the running engine (which is not always where the engine is, depending on GUI).

MisesEnForce commented 4 years ago

not working in the droidfish app could be related to not finding the network file (if it works for classical eval but not for NNUE). The EvalFile argument must be the full path to the file, or the file must be in the working directory of the running engine (which is not always where the engine is, depending on GUI).

Hum, that's what I though at some point (as I had an analogue issue with lc0) but discarded (don't know why now) the hypothesis, and havent' tried. I will rebuild with the last master and without -D__ANDROID_API__=28 (which bans millions of android devices ...) and try.

MisesEnForce commented 4 years ago

The current master doesn't fix the aligned_alloc issue, without -D__ANDROID_API__=28 I still have :

image

MisesEnForce commented 4 years ago

And now with it I also have the same issue ...

vondele commented 4 years ago

wait.. that's not current master the code on master looks different.

void* std_aligned_alloc(size_t alignment, size_t size) {
#if defined(POSIXALIGNEDALLOC)
  void *pointer;
  if(posix_memalign(&pointer, alignment, size) == 0)
      return pointer;
  return nullptr;
#elif defined(_WIN32)
  return _mm_malloc(size, alignment);
#else
  return std::aligned_alloc(alignment, size);
#endif
}
MisesEnForce commented 4 years ago

wait.. that's not current master the code on master looks different.

void* std_aligned_alloc(size_t alignment, size_t size) {
#if defined(POSIXALIGNEDALLOC)
  void *pointer;
  if(posix_memalign(&pointer, alignment, size) == 0)
      return pointer;
  return nullptr;
#elif defined(_WIN32)
  return _mm_malloc(size, alignment);
#else
  return std::aligned_alloc(alignment, size);
#endif
}

You are right, I think I somehow failed in the git reset --hard + fetch + rebase. I got the latest master and compiled it without the -D__ANDROID_API__=28 bit but with my other Makefile changes, and it compiled fine. It works in the terminal as it did. I move the executable + the nn-112bb1c8cdb5.nnue file in DroidFish and it still fails to start the engine :

image

To be more precise, when "there's no problem in droidfish with an engine" (I know it is vague), it does not trigger the "failed to start engine", and you can later access engine options to point to some network file (for lc0 for instance) if needed. Here you can't. So I really suspect there's something inaccurate in my compilation that makes the engine work "inside" the termux terminal, but not within a standard GUI. I will try to cross compile it with android SDK/NDK to see.

vondele commented 4 years ago

I agree, that error message is not due to the net not being available