aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2020-08-26 23:31:45 +0200
committerGitHub <noreply@github.com>2020-08-26 23:31:45 +0200
commitcd30e0b86ce6ee88386a91cebdf353fc55805c57 (patch)
tree1453f0e4dcbe2f2197913e916ab3e99116a29080 /cmake
parent7cc027401e4a2837872db54c835a4ed1a98e4a03 (diff)
Common/Utilities: Centralize string -> T conversion in StringConvert.h (PR #25335)
Diffstat (limited to 'cmake')
-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 780aec48cbd..2bd16a57579 100644
--- a/cmake/compiler/clang/settings.cmake
+++ b/cmake/compiler/clang/settings.cmake
@@ -11,6 +11,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