From cd30e0b86ce6ee88386a91cebdf353fc55805c57 Mon Sep 17 00:00:00 2001 From: Treeston Date: Wed, 26 Aug 2020 23:31:45 +0200 Subject: Common/Utilities: Centralize string -> T conversion in StringConvert.h (PR #25335) --- cmake/compiler/clang/settings.cmake | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'cmake/compiler') 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 +#include + +int main() +{ + uint64_t n; + char const c[] = \"0\"; + std::from_chars(c, c+1, n); + return static_cast(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 -- cgit v1.2.3