mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-22 18:17:02 +08:00
Fix Raspberry Pi Compilation
Reported by @Torom over discord. > dev build fails on Raspberry Pi 5 with clang ``` clang++ -o stockfish benchmark.o bitboard.o evaluate.o main.o misc.o movegen.o movepick.o position.o search.o thread.o timeman.o tt.o uci.o ucioption.o tune.o tbprobe.o nnue_misc.o half_ka_v2_hm.o network.o -fprofile-instr-generate -latomic -lpthread -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-instr-generate -pedantic -Wextra -Wshadow -Wmissing-prototypes -Wconditional-uninitialized -DUSE_PTHREADS -DNDEBUG -O3 -funroll-loops -DIS_64BIT -DUSE_POPCNT -DUSE_NEON=8 -march=armv8.2-a+dotprod -DUSE_NEON_DOTPROD -DGIT_SHA=627974c9 -DGIT_DATE=20240312 -DARCH=armv8-dotprod -flto=full /tmp/lto-llvm-e9300e.o: in function `_GLOBAL__sub_I_network.cpp': ld-temp.o:(.text.startup+0x704c): relocation truncated to fit: R_AARCH64_LDST64_ABS_LO12_NC against symbol `gEmbeddedNNUEBigEnd' defined in .rodata section in /tmp/lto-llvm-e9300e.o /usr/bin/ld: ld-temp.o:(.text.startup+0x704c): warning: one possible cause of this error is that the symbol is being referenced in the indicated code as if it had a larger alignment than was declared where it was defined ld-temp.o:(.text.startup+0x7068): relocation truncated to fit: R_AARCH64_LDST64_ABS_LO12_NC against symbol `gEmbeddedNNUESmallEnd' defined in .rodata section in /tmp/lto-llvm-e9300e.o /usr/bin/ld: ld-temp.o:(.text.startup+0x7068): warning: one possible cause of this error is that the symbol is being referenced in the indicated code as if it had a larger alignment than was declared where it was defined clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [Makefile:1051: stockfish] Error 1 make[2]: Leaving directory '/home/torsten/chess/Stockfish_master/src' make[1]: *** [Makefile:1058: clang-profile-make] Error 2 make[1]: Leaving directory '/home/torsten/chess/Stockfish_master/src' make: *** [Makefile:886: profile-build] Error 2 ``` closes https://github.com/official-stockfish/Stockfish/pull/5106 No functional change
This commit is contained in:
@@ -502,7 +502,7 @@ endif
|
|||||||
# In earlier NDK versions, you'll need to pass -fno-addrsig if using GNU binutils.
|
# In earlier NDK versions, you'll need to pass -fno-addrsig if using GNU binutils.
|
||||||
# Currently we don't know how to make PGO builds with the NDK yet.
|
# Currently we don't know how to make PGO builds with the NDK yet.
|
||||||
ifeq ($(COMP),ndk)
|
ifeq ($(COMP),ndk)
|
||||||
CXXFLAGS += -stdlib=libc++ -fPIE -mcmodel=large
|
CXXFLAGS += -stdlib=libc++ -fPIE
|
||||||
comp=clang
|
comp=clang
|
||||||
ifeq ($(arch),armv7)
|
ifeq ($(arch),armv7)
|
||||||
CXX=armv7a-linux-androideabi16-clang++
|
CXX=armv7a-linux-androideabi16-clang++
|
||||||
|
|||||||
@@ -55,15 +55,33 @@ const unsigned char gEmbeddedNNUESmallData[1] = {0x0};
|
|||||||
const unsigned char* const gEmbeddedNNUESmallEnd = &gEmbeddedNNUESmallData[1];
|
const unsigned char* const gEmbeddedNNUESmallEnd = &gEmbeddedNNUESmallData[1];
|
||||||
const unsigned int gEmbeddedNNUESmallSize = 1;
|
const unsigned int gEmbeddedNNUESmallSize = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct EmbeddedNNUE {
|
||||||
|
EmbeddedNNUE(const unsigned char* embeddedData,
|
||||||
|
const unsigned char* embeddedEnd,
|
||||||
|
const unsigned int embeddedSize) :
|
||||||
|
data(embeddedData),
|
||||||
|
end(embeddedEnd),
|
||||||
|
size(embeddedSize) {}
|
||||||
|
const unsigned char* data;
|
||||||
|
const unsigned char* end;
|
||||||
|
const unsigned int size;
|
||||||
|
};
|
||||||
|
|
||||||
|
using namespace Stockfish::Eval::NNUE;
|
||||||
|
|
||||||
|
EmbeddedNNUE get_embedded(EmbeddedNNUEType type) {
|
||||||
|
if (type == EmbeddedNNUEType::BIG)
|
||||||
|
return EmbeddedNNUE(gEmbeddedNNUEBigData, gEmbeddedNNUEBigEnd, gEmbeddedNNUEBigSize);
|
||||||
|
else
|
||||||
|
return EmbeddedNNUE(gEmbeddedNNUESmallData, gEmbeddedNNUESmallEnd, gEmbeddedNNUESmallSize);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace Stockfish::Eval::NNUE {
|
namespace Stockfish::Eval::NNUE {
|
||||||
|
|
||||||
const EmbeddedNNUE embeddedNNUEBig(gEmbeddedNNUEBigData, gEmbeddedNNUEBigEnd, gEmbeddedNNUEBigSize);
|
|
||||||
const EmbeddedNNUE
|
|
||||||
embeddedNNUESmall(gEmbeddedNNUESmallData, gEmbeddedNNUESmallEnd, gEmbeddedNNUESmallSize);
|
|
||||||
|
|
||||||
|
|
||||||
namespace Detail {
|
namespace Detail {
|
||||||
|
|
||||||
@@ -302,6 +320,8 @@ void Network<Arch, Transformer>::load_internal() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const auto embedded = get_embedded(embeddedType);
|
||||||
|
|
||||||
MemoryBuffer buffer(const_cast<char*>(reinterpret_cast<const char*>(embedded.data)),
|
MemoryBuffer buffer(const_cast<char*>(reinterpret_cast<const char*>(embedded.data)),
|
||||||
size_t(embedded.size));
|
size_t(embedded.size));
|
||||||
|
|
||||||
|
|||||||
@@ -34,27 +34,19 @@
|
|||||||
|
|
||||||
namespace Stockfish::Eval::NNUE {
|
namespace Stockfish::Eval::NNUE {
|
||||||
|
|
||||||
struct EmbeddedNNUE {
|
|
||||||
EmbeddedNNUE(const unsigned char* embeddedData,
|
enum class EmbeddedNNUEType {
|
||||||
const unsigned char* embeddedEnd,
|
BIG,
|
||||||
const unsigned int embeddedSize) :
|
SMALL,
|
||||||
data(embeddedData),
|
|
||||||
end(embeddedEnd),
|
|
||||||
size(embeddedSize) {}
|
|
||||||
const unsigned char* data;
|
|
||||||
const unsigned char* end;
|
|
||||||
const unsigned int size;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const EmbeddedNNUE embeddedNNUEBig;
|
|
||||||
extern const EmbeddedNNUE embeddedNNUESmall;
|
|
||||||
|
|
||||||
template<typename Arch, typename Transformer>
|
template<typename Arch, typename Transformer>
|
||||||
class Network {
|
class Network {
|
||||||
public:
|
public:
|
||||||
Network(EvalFile file, EmbeddedNNUE embeddedEval) :
|
Network(EvalFile file, EmbeddedNNUEType type) :
|
||||||
evalFile(file),
|
evalFile(file),
|
||||||
embedded(embeddedEval) {}
|
embeddedType(type) {}
|
||||||
|
|
||||||
void load(const std::string& rootDirectory, std::string evalfilePath);
|
void load(const std::string& rootDirectory, std::string evalfilePath);
|
||||||
bool save(const std::optional<std::string>& filename) const;
|
bool save(const std::optional<std::string>& filename) const;
|
||||||
@@ -92,8 +84,8 @@ class Network {
|
|||||||
// Evaluation function
|
// Evaluation function
|
||||||
AlignedPtr<Arch> network[LayerStacks];
|
AlignedPtr<Arch> network[LayerStacks];
|
||||||
|
|
||||||
EvalFile evalFile;
|
EvalFile evalFile;
|
||||||
EmbeddedNNUE embedded;
|
EmbeddedNNUEType embeddedType;
|
||||||
|
|
||||||
// Hash value of evaluation function structure
|
// Hash value of evaluation function structure
|
||||||
static constexpr std::uint32_t hash = Transformer::get_hash_value() ^ Arch::get_hash_value();
|
static constexpr std::uint32_t hash = Transformer::get_hash_value() ^ Arch::get_hash_value();
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ namespace NN = Eval::NNUE;
|
|||||||
|
|
||||||
UCI::UCI(int argc, char** argv) :
|
UCI::UCI(int argc, char** argv) :
|
||||||
networks(NN::Networks(
|
networks(NN::Networks(
|
||||||
NN::NetworkBig({EvalFileDefaultNameBig, "None", ""}, NN::embeddedNNUEBig),
|
NN::NetworkBig({EvalFileDefaultNameBig, "None", ""}, NN::EmbeddedNNUEType::BIG),
|
||||||
NN::NetworkSmall({EvalFileDefaultNameSmall, "None", ""}, NN::embeddedNNUESmall))),
|
NN::NetworkSmall({EvalFileDefaultNameSmall, "None", ""}, NN::EmbeddedNNUEType::SMALL))),
|
||||||
cli(argc, argv) {
|
cli(argc, argv) {
|
||||||
|
|
||||||
options["Debug Log File"] << Option("", [](const Option& o) { start_logger(o); });
|
options["Debug Log File"] << Option("", [](const Option& o) { start_logger(o); });
|
||||||
|
|||||||
Reference in New Issue
Block a user