stellar

Stellar - UCI Chess engine written in C++20
git clone git://git.dimitrijedobrota.com/stellar.git
Log | Files | Refs | README | LICENSE

commit 281e3825c71af5c9f88d0d7ce1972d379f992820
parent 952df70fdab44c483e4eed4ecc7ef5c9451198c7
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date:   Sun, 27 Aug 2023 15:17:04 +0200

clang flags, fix few compilation issues

Diffstat:
MCMakeLists.txt | 16+++++++++++++---
Msrc/attack/attack.hpp | 2+-
Msrc/move/move.hpp | 4++--
3 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -3,7 +3,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) project( Stellar - VERSION 0.0.21 + VERSION 0.0.22 DESCRIPTION "Chess engine written in C" HOMEPAGE_URL https://git.dimitrijedobrota.com/stellar.git LANGUAGES C CXX @@ -24,9 +24,14 @@ function(stellar_target_precompile_headers) endif() endfunction() -CHECK_CXX_COMPILER_FLAG("-flto -fno-fat-lto-objects" COMPILER_SUPPORTS_LTO) +CHECK_CXX_COMPILER_FLAG("-flto" COMPILER_SUPPORTS_LTO) if(COMPILER_SUPPORTS_LTO) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -fno-fat-lto-objects") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto") +endif() + +CHECK_CXX_COMPILER_FLAG("-fno-fat-lto-objects" COMPILER_SUPPORTS_LTO_NOFAT) +if(COMPILER_SUPPORTS_LTO_NOFAT) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-fat-lto-objects") endif() CHECK_CXX_COMPILER_FLAG("-fconstexpr-ops-limit=10000000000" COMPILER_SUPPORTS_CONSTEXPR_OPS_LIMIT) @@ -34,6 +39,11 @@ if(COMPILER_SUPPORTS_CONSTEXPR_OPS_LIMIT) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fconstexpr-ops-limit=1000000000") endif() +CHECK_CXX_COMPILER_FLAG("-fconstexpr-steps=1000000000" COMPILER_SUPPORTS_CONSTEXPR_STEPS) +if(COMPILER_SUPPORTS_CONSTEXPR_STEPS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fconstexpr-steps=1000000000") +endif() + CHECK_CXX_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE) if(COMPILER_SUPPORTS_MARCH_NATIVE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") diff --git a/src/attack/attack.hpp b/src/attack/attack.hpp @@ -185,7 +185,7 @@ class Attack { static inline constexpr const auto slider_attacks = []<std::size_t size>(const Slider &slider) constexpr -> slider_attack_array<size> { - slider_attack_array<size> attacks; + slider_attack_array<size> attacks = {{{0}}}; for (const Square square : SquareIter()) { uint8_t square_i = to_underlying(square); U64 attack_mask = slider.mask(square); diff --git a/src/move/move.hpp b/src/move/move.hpp @@ -30,8 +30,8 @@ struct Move { Move(Square source, Square target, Flag flags) : source_i(to_underlying(source)), target_i(to_underlying(target)), flags_i(flags) {} - bool operator==(Move &m) const { - return source_i == m.source_i && target_i == m.target_i && flags_i == m.flags_i; + friend bool operator==(const Move a, const Move b) { + return a.source_i == b.source_i && a.target_i == b.target_i && a.flags_i == b.flags_i; } Square source(void) const { return static_cast<Square>(source_i); }