official-stockfish / Stockfish

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

Error build latest git Stockfish on Pinephone (armv8, musl, PmOS/Alpine Linux) #3865

Closed merinfor2021 closed 2 years ago

merinfor2021 commented 2 years ago
pine64-pinephone:~/stockfish/src$ make build
 ARCH=armv8
Default net: nn-4401e826ebcc.nnue
Already available.

Config:
debug: 'no'
sanitize: 'none'
optimize: 'yes'
arch: 'armv8'
bits: '64'
kernel: 'Linux'
os: 'Linux'
prefetch: 'yes'
popcnt: 'yes'
pext: 'no'
sse: 'no'
mmx: 'no'
sse2: 'no'
ssse3: 'no'
sse41: 'no'
avx2: 'no'
avxvnni: 'no'
avx512: 'no'
vnni256: 'no'
vnni512: 'no'
neon: 'yes'
arm_version: '8'

Flags:
CXX: g++
CXXFLAGS: -Wall -Wcast-qual -fno-exceptions -std=c++17  -pedantic -Wextra -Wshadow -DUSE_PTHREADS -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -DUSE_NEON=8 -flto
LDFLAGS:  -Wl,--no-as-needed -lpthread -Wall -Wcast-qual -fno-exceptions -std=c++17  -pedantic -Wextra -Wshadow -DUSE_PTHREADS -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -DUSE_NEON=8 -flto -flto=jobserver

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

make ARCH=armv8 COMP=gcc all
make[1]: Entering directory '/home/user/stockfish/src'
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  -Wl,--no-as-needed -lpthread -Wall -Wcast-qual -fno-exceptions -std=c++17  -pedantic -Wextra -Wshadow -DUSE_PTHREADS -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -DUSE_NEON=8 -flto -flto=jobserver
/usr/include/c++/10.3.1/ext/string_conversions.h: In function '__to_xstring.constprop':
/usr/include/fortify/stdio.h:70:28: error: inlining failed in call to 'always_inline' 'vsnprintf': function body can be overwritten at link time
   70 | RTIFY_FN(vsnprintf) int vsnprintf(char *__s, size_t __n, const char *__f,
      |                         ^

/usr/include/c++/10.3.1/ext/string_conversions.h:111:32: note: called from here
  111 | onst int __len = __convf(__s, __n, __fmt, __args);
      |                         ^

make[2]: *** [/tmp/cchENIBi.mk:17: /tmp/stockfish.aEaEEB.ltrans5.ltrans.o] Error 1
lto-wrapper: fatal error: make returned 2 exit status
compilation terminated.
/usr/lib/gcc/aarch64-alpine-linux-musl/10.3.1/../../../../aarch64-alpine-linux-musl/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:907: stockfish] Error 1
make[1]: Leaving directory '/home/user/stockfish/src'
make: *** [Makefile:775: build] Error 2
pine64-pinephone:~/stockfish/src$ 
Dantist commented 2 years ago

Hi!

This is a compiler bug: https://gitlab.alpinelinux.org/alpine/aports/issues/8626. It is not considered as a bug by the Alpine maintainers, but it is the way they implement the std library..

Anyway, you should either add CXXFLAGS=-U_FORTIFY_SOURCE or delete fortify-headers package from the system.

More info can be found in the #3041: https://github.com/official-stockfish/Stockfish/issues/3041#issuecomment-678490037 https://github.com/official-stockfish/Stockfish/issues/3041#issuecomment-678562884

vondele commented 2 years ago

as per the above comment, I'll close the issue. Using CXXFLAGS=-U_FORTIFY_SOURCE make ... seems a suitable workaround for the time being.