From e2abbe436795526c5a6146c4031b4465f0fb794d Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Tue, 14 May 2024 22:34:45 -0700 Subject: [PATCH] Fix compilation with GCC 14 (#528) --- CMakeLists.txt | 5 ++ ...precation-warnings-for-std-has_denor.patch | 87 +++++++++++++++++++ ...failures-on-constexpr-matrices-with-.patch | 48 ++++++++++ 3 files changed, 140 insertions(+) create mode 100644 cmake/0001-Suppress-C-23-deprecation-warnings-for-std-has_denor.patch create mode 100644 cmake/0002-Fix-compilation-failures-on-constexpr-matrices-with-.patch diff --git a/CMakeLists.txt b/CMakeLists.txt index b61b72d0..97d6d60f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,6 +107,11 @@ if(NOT USE_SYSTEM_EIGEN) GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git # master on 2024-05-08 GIT_TAG ff174f79264d3f8dc0115dea7a288f98208b694f + PATCH_COMMAND + git apply + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/0001-Suppress-C-23-deprecation-warnings-for-std-has_denor.patch + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/0002-Fix-compilation-failures-on-constexpr-matrices-with-.patch + UPDATE_DISCONNECTED 1 ) fetchcontent_makeavailable(Eigen3) else() diff --git a/cmake/0001-Suppress-C-23-deprecation-warnings-for-std-has_denor.patch b/cmake/0001-Suppress-C-23-deprecation-warnings-for-std-has_denor.patch new file mode 100644 index 00000000..f6d350e5 --- /dev/null +++ b/cmake/0001-Suppress-C-23-deprecation-warnings-for-std-has_denor.patch @@ -0,0 +1,87 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tyler Veness +Date: Mon, 13 May 2024 12:46:15 -0700 +Subject: [PATCH 1/2] Suppress C++23 deprecation warnings for std::has_denorm + and std::has_denorm_loss + +--- + Eigen/src/Core/arch/Default/BFloat16.h | 14 ++++++++++++++ + Eigen/src/Core/arch/Default/Half.h | 14 ++++++++++++++ + 2 files changed, 28 insertions(+) + +diff --git a/Eigen/src/Core/arch/Default/BFloat16.h b/Eigen/src/Core/arch/Default/BFloat16.h +index f31c6cee6e97e8f1ad6fa4341fec2c1e65dec705..c6fa034b04896e7666e8de53e0e011f9551d5d78 100644 +--- a/Eigen/src/Core/arch/Default/BFloat16.h ++++ b/Eigen/src/Core/arch/Default/BFloat16.h +@@ -139,8 +139,15 @@ struct numeric_limits_bfloat16_impl { + static EIGEN_CONSTEXPR const bool has_infinity = true; + static EIGEN_CONSTEXPR const bool has_quiet_NaN = true; + static EIGEN_CONSTEXPR const bool has_signaling_NaN = true; ++#if __cplusplus >= 202302L ++ EIGEN_DIAGNOSTICS(push) ++ EIGEN_DISABLE_DEPRECATION_WARNING ++#endif + static EIGEN_CONSTEXPR const std::float_denorm_style has_denorm = std::denorm_present; + static EIGEN_CONSTEXPR const bool has_denorm_loss = false; ++#if __cplusplus >= 202302L ++ EIGEN_DIAGNOSTICS(pop) ++#endif + static EIGEN_CONSTEXPR const std::float_round_style round_style = std::numeric_limits::round_style; + static EIGEN_CONSTEXPR const bool is_iec559 = true; + // The C++ standard defines this as "true if the set of values representable +@@ -187,10 +194,17 @@ template + EIGEN_CONSTEXPR const bool numeric_limits_bfloat16_impl::has_quiet_NaN; + template + EIGEN_CONSTEXPR const bool numeric_limits_bfloat16_impl::has_signaling_NaN; ++#if __cplusplus >= 202302L ++EIGEN_DIAGNOSTICS(push) ++EIGEN_DISABLE_DEPRECATION_WARNING ++#endif + template + EIGEN_CONSTEXPR const std::float_denorm_style numeric_limits_bfloat16_impl::has_denorm; + template + EIGEN_CONSTEXPR const bool numeric_limits_bfloat16_impl::has_denorm_loss; ++#if __cplusplus >= 202302L ++EIGEN_DIAGNOSTICS(pop) ++#endif + template + EIGEN_CONSTEXPR const std::float_round_style numeric_limits_bfloat16_impl::round_style; + template +diff --git a/Eigen/src/Core/arch/Default/Half.h b/Eigen/src/Core/arch/Default/Half.h +index 9c195c12a17fcb791c96a0ce6cf873f455c4f8be..506feca058bb7940663d9cda8b2fe902060fdc8f 100644 +--- a/Eigen/src/Core/arch/Default/Half.h ++++ b/Eigen/src/Core/arch/Default/Half.h +@@ -208,8 +208,15 @@ struct numeric_limits_half_impl { + static EIGEN_CONSTEXPR const bool has_infinity = true; + static EIGEN_CONSTEXPR const bool has_quiet_NaN = true; + static EIGEN_CONSTEXPR const bool has_signaling_NaN = true; ++#if __cplusplus >= 202302L ++ EIGEN_DIAGNOSTICS(push) ++ EIGEN_DISABLE_DEPRECATION_WARNING ++#endif + static EIGEN_CONSTEXPR const std::float_denorm_style has_denorm = std::denorm_present; + static EIGEN_CONSTEXPR const bool has_denorm_loss = false; ++#if __cplusplus >= 202302L ++ EIGEN_DIAGNOSTICS(pop) ++#endif + static EIGEN_CONSTEXPR const std::float_round_style round_style = std::round_to_nearest; + static EIGEN_CONSTEXPR const bool is_iec559 = true; + // The C++ standard defines this as "true if the set of values representable +@@ -256,10 +263,17 @@ template + EIGEN_CONSTEXPR const bool numeric_limits_half_impl::has_quiet_NaN; + template + EIGEN_CONSTEXPR const bool numeric_limits_half_impl::has_signaling_NaN; ++#if __cplusplus >= 202302L ++EIGEN_DIAGNOSTICS(push) ++EIGEN_DISABLE_DEPRECATION_WARNING ++#endif + template + EIGEN_CONSTEXPR const std::float_denorm_style numeric_limits_half_impl::has_denorm; + template + EIGEN_CONSTEXPR const bool numeric_limits_half_impl::has_denorm_loss; ++#if __cplusplus >= 202302L ++EIGEN_DIAGNOSTICS(pop) ++#endif + template + EIGEN_CONSTEXPR const std::float_round_style numeric_limits_half_impl::round_style; + template diff --git a/cmake/0002-Fix-compilation-failures-on-constexpr-matrices-with-.patch b/cmake/0002-Fix-compilation-failures-on-constexpr-matrices-with-.patch new file mode 100644 index 00000000..06bf927f --- /dev/null +++ b/cmake/0002-Fix-compilation-failures-on-constexpr-matrices-with-.patch @@ -0,0 +1,48 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tyler Veness +Date: Tue, 14 May 2024 14:53:02 -0700 +Subject: [PATCH 2/2] Fix compilation failures on constexpr matrices with GCC + 14 + +DenseBase must have a trivial default constructor. +`constexpr DenseBase() {}` is not sufficient. +--- + Eigen/src/Core/DenseBase.h | 22 +++++++++++----------- + 1 file changed, 11 insertions(+), 11 deletions(-) + +diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h +index 5ab54efa3d8d454b2d5e02cb9d6145a723683b91..297c42679d978c36388ccba5831dab6624b6cb92 100644 +--- a/Eigen/src/Core/DenseBase.h ++++ b/Eigen/src/Core/DenseBase.h +@@ -621,20 +621,20 @@ class DenseBase + protected: + EIGEN_DEFAULT_COPY_CONSTRUCTOR(DenseBase) + /** Default constructor. Do nothing. */ +- EIGEN_DEVICE_FUNC constexpr DenseBase() { +- /* Just checks for self-consistency of the flags. +- * Only do it when debugging Eigen, as this borders on paranoia and could slow compilation down +- */ + #ifdef EIGEN_INTERNAL_DEBUGGING +- EIGEN_STATIC_ASSERT( +- (internal::check_implication(MaxRowsAtCompileTime == 1 && MaxColsAtCompileTime != 1, int(IsRowMajor)) && +- internal::check_implication(MaxColsAtCompileTime == 1 && MaxRowsAtCompileTime != 1, int(!IsRowMajor))), +- INVALID_STORAGE_ORDER_FOR_THIS_VECTOR_EXPRESSION) ++ EIGEN_DEVICE_FUNC constexpr DenseBase(){ ++ /* Just checks for self-consistency of the flags. ++ * Only do it when debugging Eigen, as this borders on paranoia and could slow compilation down ++ */ ++ EIGEN_STATIC_ASSERT( ++ (internal::check_implication(MaxRowsAtCompileTime == 1 && MaxColsAtCompileTime != 1, int(IsRowMajor)) && ++ internal::check_implication(MaxColsAtCompileTime == 1 && MaxRowsAtCompileTime != 1, int(!IsRowMajor))), ++ INVALID_STORAGE_ORDER_FOR_THIS_VECTOR_EXPRESSION)} ++#else ++ EIGEN_DEVICE_FUNC constexpr DenseBase() = default; + #endif +- } + +- private: +- EIGEN_DEVICE_FUNC explicit DenseBase(int); ++ private : EIGEN_DEVICE_FUNC explicit DenseBase(int); + EIGEN_DEVICE_FUNC DenseBase(int, int); + template + EIGEN_DEVICE_FUNC explicit DenseBase(const DenseBase&);