From bdc21ad1a713f08241003daf77f40450a5bcfa1b Mon Sep 17 00:00:00 2001 From: Florian Albrechtskirchinger Date: Sun, 1 May 2022 22:46:45 +0200 Subject: [PATCH] Add build step for ICPC (with fixes) (#3465) * :arrow_up: Doctest 2.4.7 * :construction_worker: add CI step for ICPC * :construction_worker: add CI step for ICPC * :construction_worker: add CI step for ICPC * :arrow_down: downgrade to Doctest 2.4.6 * :construction_worker: add CI step for ICPC * :construction_worker: add CI step for ICPC * :construction_worker: add CI step for ICPC * :construction_worker: add CI step for ICPC * :construction_worker: add CI step for ICPC * :mute: suppress warning #2196: routine is both "inline" and "noinline" * Re-enable detection on ICPC * Limit regression test for #3070 to Clang and GCC >=8.4 * Disable deprecation warnings on ICPC * Disable regression test for #1647 on ICPC (C++20) * Fix compilation failure of regression test for #3077 on ICPC * Disable wstring unit test on ICPC Fixes: error 913: invalid multibyte character sequence * Add ICPC to README Co-authored-by: Niels Lohmann --- .github/workflows/ubuntu.yml | 12 ++++++++++ README.md | 25 ++++++++++---------- cmake/ci.cmake | 15 ++++++++++++ include/nlohmann/detail/meta/type_traits.hpp | 9 ++++++- single_include/nlohmann/json.hpp | 9 ++++++- tests/CMakeLists.txt | 4 ++++ tests/src/unit-regression2.cpp | 7 ++++-- tests/src/unit-wstring.cpp | 3 +++ 8 files changed, 68 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index b5f583367..4d037e060 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -112,3 +112,15 @@ jobs: run: cmake -S . -B build -DJSON_CI=On - name: build run: cmake --build build --target ci_cuda_example + + ci_icpc: + runs-on: ubuntu-latest + container: ghcr.io/nlohmann/json-ci:v2.2.0 + steps: + - uses: actions/checkout@v2 + - name: cmake + run: cmake -S . -B build -DJSON_CI=On + - name: build + run: | + . /opt/intel/oneapi/setvars.sh + cmake --build build --target ci_icpc diff --git a/README.md b/README.md index a46a8569c..3f61377ba 100644 --- a/README.md +++ b/README.md @@ -1083,18 +1083,6 @@ The following compilers are currently used in continuous integration at [AppVeyo | Apple Clang 12.0.0 (clang-1200.0.32.27); Xcode 12.2 | macOS 10.15.7 | GitHub Actions | | Apple Clang 12.0.0 (clang-1200.0.32.28); Xcode 12.3 | macOS 10.15.7 | GitHub Actions | | Apple Clang 12.0.0 (clang-1200.0.32.29); Xcode 12.4 | macOS 10.15.7 | GitHub Actions | -| GCC 4.8.5 (Ubuntu 4.8.5-4ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions | -| GCC 4.9.3 (Ubuntu 4.9.3-13ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions | -| GCC 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) | Ubuntu 20.04.3 LTS | GitHub Actions | -| GCC 6.4.0 (Ubuntu 6.4.0-17ubuntu1) | Ubuntu 20.04.3 LTS | GitHub Actions | -| GCC 7.5.0 (Ubuntu 7.5.0-6ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions | -| GCC 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) | Windows-10.0.17763 | GitHub Actions | -| GCC 8.1.0 (i686-posix-dwarf-rev0, Built by MinGW-W64 project) | Windows-10.0.17763 | GitHub Actions | -| GCC 8.4.0 (Ubuntu 8.4.0-3ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions | -| GCC 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) | Ubuntu 20.04.3 LTS | GitHub Actions | -| GCC 10.2.0 (Ubuntu 10.2.0-5ubuntu1~20.04) | Ubuntu 20.04.3 LTS | GitHub Actions | -| GCC 11.1.0 | Ubuntu (aarch64) | Drone CI | -| GCC 12.0.0 20211219 (experimental) | Ubuntu 20.04.3 LTS | GitHub Actions | | Clang 3.5.2 (3.5.2-3ubuntu1) | Ubuntu 20.04.3 LTS | GitHub Actions | | Clang 3.6.2 (3.6.2-3ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions | | Clang 3.7.1 (3.7.1-2ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions | @@ -1115,6 +1103,19 @@ The following compilers are currently used in continuous integration at [AppVeyo | Clang 13.0.1 (13.0.1-++20211015123032+cf15ccdeb6d5-1exp120211015003613.5) | Ubuntu 20.04.3 LTS | GitHub Actions | | Clang 14.0.0 (14.0.0-++20211221052852+55c71c9eac9b-1exp120211221172954.95) | Ubuntu 20.04.3 LTS | GitHub Actions | | Clang 15.0.0 (15.0.0-++20220403052648+896770c9a92e-1~exp1~20220403172744.209) | Ubuntu 20.04.3 LTS | GitHub Actions | +| GCC 4.8.5 (Ubuntu 4.8.5-4ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions | +| GCC 4.9.3 (Ubuntu 4.9.3-13ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions | +| GCC 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) | Ubuntu 20.04.3 LTS | GitHub Actions | +| GCC 6.4.0 (Ubuntu 6.4.0-17ubuntu1) | Ubuntu 20.04.3 LTS | GitHub Actions | +| GCC 7.5.0 (Ubuntu 7.5.0-6ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions | +| GCC 8.1.0 (i686-posix-dwarf-rev0, Built by MinGW-W64 project) | Windows-10.0.17763 | GitHub Actions | +| GCC 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) | Windows-10.0.17763 | GitHub Actions | +| GCC 8.4.0 (Ubuntu 8.4.0-3ubuntu2) | Ubuntu 20.04.3 LTS | GitHub Actions | +| GCC 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) | Ubuntu 20.04.3 LTS | GitHub Actions | +| GCC 10.2.0 (Ubuntu 10.2.0-5ubuntu1~20.04) | Ubuntu 20.04.3 LTS | GitHub Actions | +| GCC 11.1.0 | Ubuntu (aarch64) | Drone CI | +| GCC 12.0.0 20211219 (experimental) | Ubuntu 20.04.3 LTS | GitHub Actions | +| Intel C++ Compiler 2021.5.0.20211109 | Ubuntu 20.04.3 LTS | GitHub Actions | | NVCC 11.0.221 | Ubuntu 20.04.3 LTS | GitHub Actions | | Visual Studio 14 2015 MSVC 19.0.24241.7 (Build Engine version 14.0.25420.1) | Windows-6.3.9600 | AppVeyor | | Visual Studio 15 2017 MSVC 19.16.27035.0 (Build Engine version 15.9.21+g9802d43bc3 for .NET Framework) | Windows-10.0.14393 | AppVeyor | diff --git a/cmake/ci.cmake b/cmake/ci.cmake index b2a2f470f..56a80c066 100644 --- a/cmake/ci.cmake +++ b/cmake/ci.cmake @@ -877,6 +877,21 @@ add_custom_target(ci_cuda_example COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_cuda_example ) +############################################################################### +# Intel C++ Compiler +############################################################################### + +add_custom_target(ci_icpc + COMMAND ${CMAKE_COMMAND} + -DCMAKE_BUILD_TYPE=Debug -GNinja + -DCMAKE_C_COMPILER=icc -DCMAKE_CXX_COMPILER=icpc + -DJSON_BuildTests=ON -DJSON_FastTests=ON + -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_icpc + COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_icpc + COMMAND cd ${PROJECT_BINARY_DIR}/build_icpc && ${CMAKE_CTEST_COMMAND} --parallel ${N} --exclude-regex "test-unicode" --output-on-failure + COMMENT "Compile and test with ICPC" +) + ############################################################################### # Clean up all generated files. ############################################################################### diff --git a/include/nlohmann/detail/meta/type_traits.hpp b/include/nlohmann/detail/meta/type_traits.hpp index 2cc13f3ac..5e3ea3737 100644 --- a/include/nlohmann/detail/meta/type_traits.hpp +++ b/include/nlohmann/detail/meta/type_traits.hpp @@ -347,8 +347,15 @@ struct is_compatible_string_type template struct is_constructible_string_type { + // launder type through decltype() to fix compilation failure on ICPC +#ifdef __INTEL_COMPILER + using laundered_type = decltype(std::declval()); +#else + using laundered_type = ConstructibleStringType; +#endif + static constexpr auto value = - is_constructible::value; }; diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index ad777c92c..949ac14be 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -3482,8 +3482,15 @@ struct is_compatible_string_type template struct is_constructible_string_type { + // launder type through decltype() to fix compilation failure on ICPC +#ifdef __INTEL_COMPILER + using laundered_type = decltype(std::declval()); +#else + using laundered_type = ConstructibleStringType; +#endif + static constexpr auto value = - is_constructible::value; }; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1d5c78697..75bc6f980 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -49,8 +49,12 @@ target_compile_options(test_main PUBLIC # https://github.com/nlohmann/json/issues/1114 $<$:/bigobj> $<$:-Wa,-mbig-obj> + # https://github.com/nlohmann/json/pull/3229 + $<$:-diag-disable=2196> + $<$>:-Wno-deprecated;-Wno-float-equal> $<$:-Wno-deprecated-declarations> + $<$:-diag-disable=1786> ) target_include_directories(test_main PUBLIC thirdparty/doctest diff --git a/tests/src/unit-regression2.cpp b/tests/src/unit-regression2.cpp index e034593ed..04cbac679 100644 --- a/tests/src/unit-regression2.cpp +++ b/tests/src/unit-regression2.cpp @@ -512,12 +512,15 @@ TEST_CASE("regression tests 2") SECTION("issue #1647 - compile error when deserializing enum if both non-default from_json and non-member operator== exists for other type") { + // does not compile on ICPC when targeting C++20 +#if !(defined(__INTEL_COMPILER) && __cplusplus >= 202000) { json j; NonDefaultFromJsonStruct x(j); NonDefaultFromJsonStruct y; CHECK(x == y); } +#endif auto val = nlohmann::json("one").get(); CHECK(val == for_1647::one); @@ -793,8 +796,8 @@ TEST_CASE("regression tests 2") const auto j_path = j.get(); CHECK(j_path == text_path); -#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ == 8 && __GNUC_MINOR__ < 4) - // works everywhere but on MSVC and GCC <8.4 +#if defined(__clang__) || ((defined(__GNUC__) && !defined(__INTEL_COMPILER)) && (__GNUC__ > 8 || (__GNUC__ == 8 && __GNUC_MINOR__ >= 4))) + // only known to work on Clang and GCC >=8.4 CHECK_THROWS_WITH_AS(nlohmann::detail::std_fs::path(json(1)), "[json.exception.type_error.302] type must be string, but is number", json::type_error); #endif } diff --git a/tests/src/unit-wstring.cpp b/tests/src/unit-wstring.cpp index d15ac8491..fa655988c 100644 --- a/tests/src/unit-wstring.cpp +++ b/tests/src/unit-wstring.cpp @@ -32,6 +32,8 @@ SOFTWARE. #include using nlohmann::json; +// ICPC errors out on multibyte character sequences in source files +#ifndef __INTEL_COMPILER namespace { bool wstring_is_utf16(); @@ -115,3 +117,4 @@ TEST_CASE("wide strings") } } } +#endif