From 862082c4683007dda11261a1b955f68e3315a8f8 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Tue, 1 Jun 2021 09:35:25 -0400 Subject: [PATCH 1/5] Adding permissive- flag to VS builds. --- CMakeLists.txt | 3 +++ tests/installation_tests/find/CMakeLists.txt | 4 +++- tests/installation_tests/issue72_installation/CMakeLists.txt | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5304a2a..4332ce0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,9 @@ project(fast_float VERSION 1.0.0 LANGUAGES CXX) option(FASTFLOAT_TEST "Enable tests" OFF) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) +if(MSVC_VERSION GREATER 1910) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -permissive-") +endif() if(FASTFLOAT_TEST) enable_testing() add_subdirectory(tests) diff --git a/tests/installation_tests/find/CMakeLists.txt b/tests/installation_tests/find/CMakeLists.txt index 2acc7a7..7443107 100644 --- a/tests/installation_tests/find/CMakeLists.txt +++ b/tests/installation_tests/find/CMakeLists.txt @@ -4,7 +4,9 @@ project(test_simdjson_install VERSION 0.1.0 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) - +if(MSVC_VERSION GREATER 1910) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -permissive-") +endif() find_package(FastFloat REQUIRED) diff --git a/tests/installation_tests/issue72_installation/CMakeLists.txt b/tests/installation_tests/issue72_installation/CMakeLists.txt index da72433..e8234f9 100644 --- a/tests/installation_tests/issue72_installation/CMakeLists.txt +++ b/tests/installation_tests/issue72_installation/CMakeLists.txt @@ -4,6 +4,9 @@ project(test_simdjson_install VERSION 0.1.0 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +if(MSVC_VERSION GREATER 1910) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -permissive-") +endif() find_package(FastFloat REQUIRED) @@ -20,6 +23,5 @@ int main() { return 0; }") file(WRITE foo.cpp " #include \"test.h\" void foo() { }") - add_executable(issue72 main.cpp main.cpp) target_link_libraries(issue72 PUBLIC FastFloat::fast_float) \ No newline at end of file From 799f24ba0708b31c6ddc9a7931f3c0e55877835a Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Tue, 1 Jun 2021 09:36:38 -0400 Subject: [PATCH 2/5] Making vs builds verbose. --- .github/workflows/vs15-ci.yml | 2 +- .github/workflows/vs16-ci.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/vs15-ci.yml b/.github/workflows/vs15-ci.yml index 03838da..a6207a7 100644 --- a/.github/workflows/vs15-ci.yml +++ b/.github/workflows/vs15-ci.yml @@ -22,7 +22,7 @@ jobs: mkdir build cd build && cmake -G "${{matrix.gen}}" -A ${{matrix.arch}} -DFASTFLOAT_TEST=ON .. - name: Build - run: cmake --build build --config Release --parallel + run: cmake --build build --verbose --config Release --parallel - name: 'Run CTest' run: | cd build diff --git a/.github/workflows/vs16-ci.yml b/.github/workflows/vs16-ci.yml index 94abcfd..9c9c7de 100644 --- a/.github/workflows/vs16-ci.yml +++ b/.github/workflows/vs16-ci.yml @@ -20,10 +20,10 @@ jobs: mkdir build && cd build && cmake ${{matrix.cxx}} ${{matrix.arch}} -DFASTFLOAT_TEST=ON -DCMAKE_INSTALL_PREFIX:PATH=destination .. && - cmake --build . && + cmake --build . --verbose && ctest --output-on-failure && cmake --install . && cd ../tests/installation_tests/find && - mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=../../../build/destination .. && cmake --build . + mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=../../../build/destination .. && cmake --verbose --build . cd ../../issue72_installation && - mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=../../../build/destination .. && cmake --build . \ No newline at end of file + mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=../../../build/destination .. && cmake --verbose --build . \ No newline at end of file From 06e61729c95e4963a8b04983fd4bcb42a36c9534 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Tue, 1 Jun 2021 09:46:43 -0400 Subject: [PATCH 3/5] making constexpr as inline. --- include/fast_float/float_common.h | 72 +++++++++++++++---------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/include/fast_float/float_common.h b/include/fast_float/float_common.h index 0368843..22b721d 100644 --- a/include/fast_float/float_common.h +++ b/include/fast_float/float_common.h @@ -210,68 +210,68 @@ constexpr static float powers_of_ten_float[] = {1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10}; template struct binary_format { - static constexpr int mantissa_explicit_bits(); - static constexpr int minimum_exponent(); - static constexpr int infinite_power(); - static constexpr int sign_index(); - static constexpr int min_exponent_fast_path(); - static constexpr int max_exponent_fast_path(); - static constexpr int max_exponent_round_to_even(); - static constexpr int min_exponent_round_to_even(); - static constexpr uint64_t max_mantissa_fast_path(); - static constexpr int largest_power_of_ten(); - static constexpr int smallest_power_of_ten(); - static constexpr T exact_power_of_ten(int64_t power); + static inline constexpr int mantissa_explicit_bits(); + static inline constexpr int minimum_exponent(); + static inline constexpr int infinite_power(); + static inline constexpr int sign_index(); + static inline constexpr int min_exponent_fast_path(); + static inline constexpr int max_exponent_fast_path(); + static inline constexpr int max_exponent_round_to_even(); + static inline constexpr int min_exponent_round_to_even(); + static inline constexpr uint64_t max_mantissa_fast_path(); + static inline constexpr int largest_power_of_ten(); + static inline constexpr int smallest_power_of_ten(); + static inline constexpr T exact_power_of_ten(int64_t power); }; -template <> constexpr int binary_format::mantissa_explicit_bits() { +template <> inline constexpr int binary_format::mantissa_explicit_bits() { return 52; } -template <> constexpr int binary_format::mantissa_explicit_bits() { +template <> inline constexpr int binary_format::mantissa_explicit_bits() { return 23; } -template <> constexpr int binary_format::max_exponent_round_to_even() { +template <> inline constexpr int binary_format::max_exponent_round_to_even() { return 23; } -template <> constexpr int binary_format::max_exponent_round_to_even() { +template <> inline constexpr int binary_format::max_exponent_round_to_even() { return 10; } -template <> constexpr int binary_format::min_exponent_round_to_even() { +template <> inline constexpr int binary_format::min_exponent_round_to_even() { return -4; } -template <> constexpr int binary_format::min_exponent_round_to_even() { +template <> inline constexpr int binary_format::min_exponent_round_to_even() { return -17; } -template <> constexpr int binary_format::minimum_exponent() { +template <> inline constexpr int binary_format::minimum_exponent() { return -1023; } -template <> constexpr int binary_format::minimum_exponent() { +template <> inline constexpr int binary_format::minimum_exponent() { return -127; } -template <> constexpr int binary_format::infinite_power() { +template <> inline constexpr int binary_format::infinite_power() { return 0x7FF; } -template <> constexpr int binary_format::infinite_power() { +template <> inline constexpr int binary_format::infinite_power() { return 0xFF; } -template <> constexpr int binary_format::sign_index() { return 63; } -template <> constexpr int binary_format::sign_index() { return 31; } +template <> inline constexpr int binary_format::sign_index() { return 63; } +template <> inline constexpr int binary_format::sign_index() { return 31; } -template <> constexpr int binary_format::min_exponent_fast_path() { +template <> inline constexpr int binary_format::min_exponent_fast_path() { #if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0) return 0; #else return -22; #endif } -template <> constexpr int binary_format::min_exponent_fast_path() { +template <> inline constexpr int binary_format::min_exponent_fast_path() { #if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0) return 0; #else @@ -279,46 +279,46 @@ template <> constexpr int binary_format::min_exponent_fast_path() { #endif } -template <> constexpr int binary_format::max_exponent_fast_path() { +template <> inline constexpr int binary_format::max_exponent_fast_path() { return 22; } -template <> constexpr int binary_format::max_exponent_fast_path() { +template <> inline constexpr int binary_format::max_exponent_fast_path() { return 10; } -template <> constexpr uint64_t binary_format::max_mantissa_fast_path() { +template <> inline constexpr uint64_t binary_format::max_mantissa_fast_path() { return uint64_t(2) << mantissa_explicit_bits(); } -template <> constexpr uint64_t binary_format::max_mantissa_fast_path() { +template <> inline constexpr uint64_t binary_format::max_mantissa_fast_path() { return uint64_t(2) << mantissa_explicit_bits(); } template <> -constexpr double binary_format::exact_power_of_ten(int64_t power) { +inline constexpr double binary_format::exact_power_of_ten(int64_t power) { return powers_of_ten_double[power]; } template <> -constexpr float binary_format::exact_power_of_ten(int64_t power) { +inline constexpr float binary_format::exact_power_of_ten(int64_t power) { return powers_of_ten_float[power]; } template <> -constexpr int binary_format::largest_power_of_ten() { +inline constexpr int binary_format::largest_power_of_ten() { return 308; } template <> -constexpr int binary_format::largest_power_of_ten() { +inline constexpr int binary_format::largest_power_of_ten() { return 38; } template <> -constexpr int binary_format::smallest_power_of_ten() { +inline constexpr int binary_format::smallest_power_of_ten() { return -342; } template <> -constexpr int binary_format::smallest_power_of_ten() { +inline constexpr int binary_format::smallest_power_of_ten() { return -65; } From 0ece926e6dfd0c9a7232c31e328293c67b2c077c Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Tue, 1 Jun 2021 09:49:41 -0400 Subject: [PATCH 4/5] Fixing --verbose. --- .github/workflows/vs16-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/vs16-ci.yml b/.github/workflows/vs16-ci.yml index 9c9c7de..fe40ddd 100644 --- a/.github/workflows/vs16-ci.yml +++ b/.github/workflows/vs16-ci.yml @@ -24,6 +24,6 @@ jobs: ctest --output-on-failure && cmake --install . && cd ../tests/installation_tests/find && - mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=../../../build/destination .. && cmake --verbose --build . + mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=../../../build/destination .. && cmake --build . --verbose cd ../../issue72_installation && - mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=../../../build/destination .. && cmake --verbose --build . \ No newline at end of file + mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=../../../build/destination .. && cmake --build . --verbose \ No newline at end of file From 9519835573ca06db763c8a8cdb50f3f5e82f3508 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Tue, 1 Jun 2021 10:03:05 -0400 Subject: [PATCH 5/5] Cleaner flag setting. --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4332ce0..163a655 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,9 +4,6 @@ project(fast_float VERSION 1.0.0 LANGUAGES CXX) option(FASTFLOAT_TEST "Enable tests" OFF) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) -if(MSVC_VERSION GREATER 1910) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -permissive-") -endif() if(FASTFLOAT_TEST) enable_testing() add_subdirectory(tests) @@ -40,6 +37,10 @@ if(FASTFLOAT_SANITIZE) target_link_libraries(fast_float INTERFACE -fuse-ld=gold) endif() endif() +if(MSVC_VERSION GREATER 1910) + target_compile_options(fast_float INTERFACE /permissive-) +endif() + include(CMakePackageConfigHelpers)