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

Compilation fails for Android #3167

Closed ghost closed 3 years ago

ghost commented 3 years ago

$ make stockfish COMP=ndk COMPCC="/home/max/ndk/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=armv7a-linux-androideabi21" ARCH=armv7 armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o benchmark.o benchmark.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o bitbase.o bitbase.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o bitboard.o bitboard.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o endgame.o endgame.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o evaluate.o evaluate.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o main.o main.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o material.o material.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o misc.o misc.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o movegen.o movegen.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o movepick.o movepick.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o pawns.o pawns.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o position.o position.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o psqt.o psqt.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o search.o search.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o thread.o thread.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o timeman.o timeman.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o tt.o tt.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o uci.o uci.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o ucioption.o ucioption.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o tune.o tune.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o tbprobe.o syzygy/tbprobe.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o evaluate_nnue.o nnue/evaluate_nnue.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o half_kp.o nnue/features/half_kp.cpp armv7a-linux-androideabi16-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_kp.o -static-libstdc++ -pie -lm -latomic -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin /home/max/ndk/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: fatal error: stockfish: Input/output error clang++: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [Makefile:843: stockfish] Error 1

Same with make build ARCH=armv7 COMP=ndk:

$ make build ARCH=armv7 COMP=ndk

Config: debug: 'no' sanitize: 'no' optimize: 'yes' arch: 'armv7' bits: '32' kernel: 'Linux' os: 'GNU/Linux' prefetch: 'yes' popcnt: 'no' pext: 'no' sse: 'no' mmx: 'no' sse2: 'no' ssse3: 'no' sse41: 'no' avx2: 'no' avx512: 'no' vnni256: 'no' vnni512: 'no' neon: 'no'

Flags: CXX: armv7a-linux-androideabi16-clang++ CXXFLAGS: -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin LDFLAGS: -static-libstdc++ -pie -lm -latomic -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin

Testing config sanity. If this fails, try 'make help' ...

Default net: nn-baeb9ef2d183.nnue Already available. make ARCH=armv7 COMP=ndk all make[1]: Entering directory '/mnt/hgfs/Massimiliano Goi/Stockfish-master/src' armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o benchmark.o benchmark.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o bitbase.o bitbase.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o bitboard.o bitboard.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o endgame.o endgame.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o evaluate.o evaluate.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o main.o main.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o material.o material.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o misc.o misc.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o movegen.o movegen.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o movepick.o movepick.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o pawns.o pawns.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o position.o position.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o psqt.o psqt.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o search.o search.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o thread.o thread.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o timeman.o timeman.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o tt.o tt.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o uci.o uci.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o ucioption.o ucioption.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o tune.o tune.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o tbprobe.o syzygy/tbprobe.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o evaluate_nnue.o nnue/evaluate_nnue.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o half_kp.o nnue/features/half_kp.cpp armv7a-linux-androideabi16-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_kp.o -static-libstdc++ -pie -lm -latomic -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin /home/max/ndk/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: fatal error: stockfish: Input/output error clang++: error: linker command failed with exit code 1 (use -v to see invocation) make[1]: [Makefile:843: stockfish] Error 1 make[1]: Leaving directory '/mnt/hgfs/Massimiliano Goi/Stockfish-master/src' make: [Makefile:715: build] Error 2 max@max-virtual-machine:/mnt/hgfs/Massimiliano Goi/Stockfish-master/src$

With make stockfish COMP=ndk COMPCC="/home/max/ndk/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=aarch64-linux-android21" ARCH=armv8 the compilation has no errors but the produced binary doesn't start.

I have changed the line 101 of ucioption.cpp with o["EvalFile"] << Option("/storage/emulated/0/DroidFish/uci/nn-baeb9ef2d183.nnue", on_eval_file); that worked with the previous beta versions. Tried also without changing it, same thing.

vondele commented 3 years ago

Do you follow the instructions as detailed in this commit ? https://github.com/official-stockfish/Stockfish/commit/65b976439f8867e81682c0b66da6796ad3176177 for me these work.

syzygy1 commented 3 years ago

make stockfish_polyglot suggests that @massimilianogoi is trying to compile some fork.

ghost commented 3 years ago

@vondele getting the same error by following the commands in the commit:

1) with armv8: the compilation runs and ends but the Android binary doesn't work

2) with armv7 I got clang++: error: linker command failed with exit code 1 (use -v to see invocation)

$ make clean && make -j build ARCH=armv7 COMP=ndk && make -j build ARCH=armv7 COMP=ndk strip

Config: debug: 'no' sanitize: 'no' Default net: nn-baeb9ef2d183.nnue optimize: 'yes' Already available. arch: 'armv7' bits: '32' kernel: 'Linux' os: 'GNU/Linux' prefetch: 'yes' popcnt: 'no' pext: 'no' sse: 'no' mmx: 'no' sse2: 'no' ssse3: 'no' sse41: 'no' avx2: 'no' avx512: 'no' vnni256: 'no' vnni512: 'no' neon: 'no'

Flags: CXX: armv7a-linux-androideabi16-clang++ CXXFLAGS: -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin LDFLAGS: -static-libstdc++ -pie -lm -latomic -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin

Testing config sanity. If this fails, try 'make help' ...

make ARCH=armv7 COMP=ndk all make[1]: Entering directory '/mnt/hgfs/Massimiliano Goi/Stockfish-master/src' armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o benchmark.o benchmark.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o bitbase.o bitbase.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o bitboard.o bitboard.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o endgame.o endgame.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o evaluate.o evaluate.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o main.o main.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o material.o material.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o misc.o misc.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o movegen.o movegen.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o movepick.o movepick.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o pawns.o pawns.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o position.o position.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o psqt.o psqt.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o search.o search.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o thread.o thread.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o timeman.o timeman.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o tt.o tt.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o uci.o uci.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o ucioption.o ucioption.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o tune.o tune.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o tbprobe.o syzygy/tbprobe.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o evaluate_nnue.o nnue/evaluate_nnue.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o half_kp.o nnue/features/half_kp.cpp armv7a-linux-androideabi16-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_kp.o -static-libstdc++ -pie -lm -latomic -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin /home/max/ndk/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: fatal error: stockfish: Input/output error clang++: error: linker command failed with exit code 1 (use -v to see invocation) make[1]: [Makefile:843: stockfish] Error 1 make[1]: Leaving directory '/mnt/hgfs/Massimiliano Goi/Stockfish-master/src' make: [Makefile:715: build] Error 2

and

$ make -j ARCH=armv7 COMP=ndk build

Config: debug: 'no' sanitize: 'no' Default net: nn-baeb9ef2d183.nnue optimize: 'yes' Already available. arch: 'armv7' bits: '32' kernel: 'Linux' os: 'GNU/Linux' prefetch: 'yes' popcnt: 'no' pext: 'no' sse: 'no' mmx: 'no' sse2: 'no' ssse3: 'no' sse41: 'no' avx2: 'no' avx512: 'no' vnni256: 'no' vnni512: 'no' neon: 'no'

Flags: CXX: armv7a-linux-androideabi16-clang++ CXXFLAGS: -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin LDFLAGS: -static-libstdc++ -pie -lm -latomic -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin

Testing config sanity. If this fails, try 'make help' ...

make ARCH=armv7 COMP=ndk all make[1]: Entering directory '/mnt/hgfs/Massimiliano Goi/Stockfish-master/src' armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o benchmark.o benchmark.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o bitbase.o bitbase.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o bitboard.o bitboard.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o endgame.o endgame.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o evaluate.o evaluate.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o main.o main.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o material.o material.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o misc.o misc.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o movegen.o movegen.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o movepick.o movepick.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o pawns.o pawns.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o position.o position.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o psqt.o psqt.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o search.o search.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o thread.o thread.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o timeman.o timeman.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o tt.o tt.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o uci.o uci.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o ucioption.o ucioption.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o tune.o tune.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o tbprobe.o syzygy/tbprobe.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o evaluate_nnue.o nnue/evaluate_nnue.cpp armv7a-linux-androideabi16-clang++ -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin -c -o half_kp.o nnue/features/half_kp.cpp armv7a-linux-androideabi16-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_kp.o -static-libstdc++ -pie -lm -latomic -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon -DUSE_PTHREADS -DNDEBUG -O3 -flto=thin /home/max/ndk/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: fatal error: stockfish: Input/output error clang++: error: linker command failed with exit code 1 (use -v to see invocation) make[1]: [Makefile:843: stockfish] Error 1 make[1]: Leaving directory '/mnt/hgfs/Massimiliano Goi/Stockfish-master/src' make: [Makefile:715: build] Error 2

ghost commented 3 years ago

make stockfish_polyglot suggests that @massimilianogoi is trying to compile some fork.

Type error as I was working with a vanilla package after having failed with the polyglot modification for the same reason. A vanilla package is an original package.

ghost commented 3 years ago

The armv8 compilation works perfecly now with the commands:

make stockfish COMP=ndk COMPCC="/home/max/ndk/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=aarch64-linux-android21" ARCH=armv8

and

/home/max/ndk/android-ndk-r21d/toolchains/llvm/prebuilt/linux-x86_64/aarch64-linux-android/bin/strip stockfish

It didn't work because I set the ucioption.cpp line 83 as o["EvalFile"] << Option("/storage/emulated/0/DroidFish/uci/nn-03744f8d56d8.nnue", on_eval_file); instead of leaving o["EvalFile"] << Option(EvalFileDefaultName, on_eval_file); like the default. On previous versions this was a (partial) workaround to make it work so I took for granted that it was the correct procedure, my fault.

Anyway, the armv7 compilation still gives error as above.

vondele commented 3 years ago

so, can you repeat the experiment with the unmodified master? without specifying the COMPCC, and following the instructions in https://github.com/official-stockfish/Stockfish/commit/65b976439f8867e81682c0b66da6796ad3176177 ? If it doesn't reproduce following those steps on master, we should close this issue.

ghost commented 3 years ago

Compilation runs ok for armv7 and armv7-neon, both of them don't work in Droidfish: ".Engine error: failed to start the engine".

Tried also some workaround like

o["EvalFile"] << Option("/storage/emulated/0/Droidfish/uci/nn-04cf2b4ed1da.nnue", on_eval_file);

or

o["EvalFile"] << Option("nn-04cf2b4ed1da.nnue", on_eval_file);

in ucioption.cpp, nothing to do.

Commands used:

make build ARCH=armv7 COMP=ndk

and

make build ARCH=armv7-neon COMP=ndk

The binary doesn't work either in armv8, with the command

make build ARCH=armv8 COMP=ndk

Same error of the previous ones.

ghost commented 3 years ago

My bad, I've forgot that for some unkown reason if I directly upload the binary on the cloud it goes corrupted; uploading it and downloading it zipped solved the problem.

The engines work with the following compilation commands:

make build ARCH=armv7 COMP=ndk make build ARCH=armv7-neon COMP=ndk make clean && make -j build ARCH=armv8 COMP=ndk && make -j build ARCH=armv8 COMP=ndk strip as in https://github.com/official-stockfish/Stockfish/commit/65b976439f8867e81682c0b66da6796ad3176177

Not tried the other options but I guess it's just a formality, as armv7, armv7-neon and armv8 work.

I can safely close this thread now if the compilation indications for Android remain the same in the source for the further releases.

MisesEnForce commented 3 years ago

@massimilianogoi I saw your https://chess.massimilianogoi.com/articles/30-09-20-How-To-Compile-Stockfish-And-Stockfish-like-Programs-For-Android/ yesterday evening with great joy as it is how I also succeeded myself in cross-compiling stockfish for android from linux. I was not happy because it forces to uses linux, either by having one, or a virtual machine. Hence I decided to make it work under windows, and I succedeed. See my Q&A on stackexchange : https://stackoverflow.com/questions/66305360/how-to-cross-compile-stockfish-13-from-windows-10-to-armv8

Question : how could optimized the (cross)compilation even more, if possible ?