aboutsummaryrefslogtreecommitdiff
path: root/cmake/compiler
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2020-08-26 23:31:45 +0200
committerShauren <shauren.trinity@gmail.com>2022-02-04 00:27:13 +0100
commitbe9dadc18949c6877f486eab9ee95237224a237e (patch)
treef34fcd28a0acf43d54c4bf853a24800090a2761b /cmake/compiler
parent7b88fd607e974843481d3055eb2eebc53c2a4b49 (diff)
Common/Utilities: Centralize string -> T conversion in StringConvert.h (PR #25335)
(cherry picked from commit cd30e0b86ce6ee88386a91cebdf353fc55805c57)
Diffstat (limited to 'cmake/compiler')
-rw-r--r--cmake/compiler/clang/settings.cmake25
1 files changed, 25 insertions, 0 deletions
diff --git a/cmake/compiler/clang/settings.cmake b/cmake/compiler/clang/settings.cmake
index 716750d8715..1fe89542a84 100644
--- a/cmake/compiler/clang/settings.cmake
+++ b/cmake/compiler/clang/settings.cmake
@@ -13,6 +13,31 @@ else()
message(STATUS "Clang: Minimum version required is ${CLANG_EXPECTED_VERSION}, found ${CMAKE_CXX_COMPILER_VERSION} - ok!")
endif()
+# This tests for a bug in clang-7 that causes linkage to fail for 64-bit from_chars (in some configurations)
+# If the clang requirement is bumped to >= clang-8, you can remove this check, as well as
+# the associated ifdef block in src/common/Utilities/StringConvert.h
+include(CheckCXXSourceCompiles)
+
+check_cxx_source_compiles("
+#include <charconv>
+#include <cstdint>
+
+int main()
+{
+ uint64_t n;
+ char const c[] = \"0\";
+ std::from_chars(c, c+1, n);
+ return static_cast<int>(n);
+}
+" CLANG_HAVE_PROPER_CHARCONV)
+
+if (NOT CLANG_HAVE_PROPER_CHARCONV)
+ message(STATUS "Clang: Detected from_chars bug for 64-bit integers, workaround enabled")
+ target_compile_definitions(trinity-compile-option-interface
+ INTERFACE
+ -DTRINITY_NEED_CHARCONV_WORKAROUND)
+endif()
+
if(WITH_WARNINGS)
target_compile_options(trinity-warning-interface
INTERFACE