From dd095c4458026d6187fd61f6f3dd7a54116390c1 Mon Sep 17 00:00:00 2001 From: Jan Dorniak Date: Tue, 25 Jun 2024 11:31:42 +0200 Subject: [PATCH 01/15] first implementation of constexpr CRCs --- include/etl/frame_check_sequence.h | 12 ++++++------ include/etl/private/crc_implementation.h | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/etl/frame_check_sequence.h b/include/etl/frame_check_sequence.h index ec67e1bac..b3c6b5e2a 100644 --- a/include/etl/frame_check_sequence.h +++ b/include/etl/frame_check_sequence.h @@ -107,7 +107,7 @@ namespace etl //************************************************************************* /// Default constructor. //************************************************************************* - frame_check_sequence() + ETL_CONSTEXPR frame_check_sequence() { reset(); } @@ -118,7 +118,7 @@ namespace etl /// \param end End of the range. //************************************************************************* template - frame_check_sequence(TIterator begin, const TIterator end) + ETL_CONSTEXPR frame_check_sequence(TIterator begin, const TIterator end) { ETL_STATIC_ASSERT(sizeof(typename etl::iterator_traits::value_type) == 1, "Type not supported"); @@ -129,7 +129,7 @@ namespace etl //************************************************************************* /// Resets the FCS to the initial state. //************************************************************************* - void reset() + ETL_CONSTEXPR void reset() { frame_check = policy.initial(); } @@ -140,7 +140,7 @@ namespace etl /// \param end //************************************************************************* template - void add(TIterator begin, const TIterator end) + ETL_CONSTEXPR void add(TIterator begin, const TIterator end) { ETL_STATIC_ASSERT(sizeof(typename etl::iterator_traits::value_type) == 1, "Type not supported"); @@ -154,7 +154,7 @@ namespace etl //************************************************************************* /// \param value The uint8_t to add to the FCS. //************************************************************************* - void add(uint8_t value_) + ETL_CONSTEXPR void add(uint8_t value_) { frame_check = policy.add(frame_check, value_); } @@ -162,7 +162,7 @@ namespace etl //************************************************************************* /// Gets the FCS value. //************************************************************************* - value_type value() const + ETL_CONSTEXPR value_type value() const { return policy.final(frame_check); } diff --git a/include/etl/private/crc_implementation.h b/include/etl/private/crc_implementation.h index d94f0f181..2fe0e4ac1 100644 --- a/include/etl/private/crc_implementation.h +++ b/include/etl/private/crc_implementation.h @@ -183,7 +183,7 @@ namespace etl template static typename etl::enable_if<(Accumulator_Bits > Chunk_Bits) && Reflect, TAccumulator>::type - crc_update_chunk(TAccumulator crc, uint8_t value, const TAccumulator table[]) + ETL_CONSTEXPR crc_update_chunk(TAccumulator crc, uint8_t value, const TAccumulator table[]) { value &= Chunk_Mask; @@ -319,7 +319,7 @@ namespace etl struct crc_table { //************************************************************************* - TAccumulator add(TAccumulator crc, uint8_t value) const + ETL_CONSTEXPR TAccumulator add(TAccumulator crc, uint8_t value) const { static ETL_CONSTANT TAccumulator table[256U] = { @@ -615,7 +615,7 @@ namespace etl } //************************************************************************* - accumulator_type final(accumulator_type crc) const + ETL_CONSTEXPR accumulator_type final(accumulator_type crc) const { return crc ^ TCrcParameters::Xor_Out; } @@ -691,7 +691,7 @@ namespace etl //************************************************************************* /// Default constructor. //************************************************************************* - crc_type() + ETL_CONSTEXPR crc_type() { this->reset(); } @@ -702,7 +702,7 @@ namespace etl /// \param end End of the range. //************************************************************************* template - crc_type(TIterator begin, const TIterator end) + ETL_CONSTEXPR crc_type(TIterator begin, const TIterator end) { this->reset(); this->add(begin, end); From f3894c2183f4eeb2b2af0f3d050d1fbb70af6fef Mon Sep 17 00:00:00 2001 From: Jan Dorniak Date: Tue, 25 Jun 2024 14:20:17 +0200 Subject: [PATCH 02/15] platform.h: add CONSTEXPR23 --- include/etl/platform.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/etl/platform.h b/include/etl/platform.h index 17c7961d5..afb1ae365 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -351,8 +351,10 @@ SOFTWARE. // C++23 #if ETL_USING_CPP23 && !defined(ETL_FORCE_NO_ADVANCED_CPP) #define ETL_ASSUME(expression) [[assume(expression)]] + #define ETL_CONSTEXPR23 constexpr #else #define ETL_ASSUME ETL_DO_NOTHING + #define ETL_CONSTEXPR23 #endif //************************************* From 741187a0fcc25fde0ec20dd819be3f529056bd87 Mon Sep 17 00:00:00 2001 From: Jan Dorniak Date: Tue, 25 Jun 2024 14:20:47 +0200 Subject: [PATCH 03/15] crc: add constexpr for C++23 --- include/etl/frame_check_sequence.h | 12 ++++++------ include/etl/private/crc_implementation.h | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/etl/frame_check_sequence.h b/include/etl/frame_check_sequence.h index b3c6b5e2a..1e6a1a0b4 100644 --- a/include/etl/frame_check_sequence.h +++ b/include/etl/frame_check_sequence.h @@ -107,7 +107,7 @@ namespace etl //************************************************************************* /// Default constructor. //************************************************************************* - ETL_CONSTEXPR frame_check_sequence() + ETL_CONSTEXPR14 frame_check_sequence() { reset(); } @@ -118,7 +118,7 @@ namespace etl /// \param end End of the range. //************************************************************************* template - ETL_CONSTEXPR frame_check_sequence(TIterator begin, const TIterator end) + ETL_CONSTEXPR14 frame_check_sequence(TIterator begin, const TIterator end) { ETL_STATIC_ASSERT(sizeof(typename etl::iterator_traits::value_type) == 1, "Type not supported"); @@ -129,7 +129,7 @@ namespace etl //************************************************************************* /// Resets the FCS to the initial state. //************************************************************************* - ETL_CONSTEXPR void reset() + ETL_CONSTEXPR14 void reset() { frame_check = policy.initial(); } @@ -140,7 +140,7 @@ namespace etl /// \param end //************************************************************************* template - ETL_CONSTEXPR void add(TIterator begin, const TIterator end) + ETL_CONSTEXPR23 void add(TIterator begin, const TIterator end) { ETL_STATIC_ASSERT(sizeof(typename etl::iterator_traits::value_type) == 1, "Type not supported"); @@ -154,7 +154,7 @@ namespace etl //************************************************************************* /// \param value The uint8_t to add to the FCS. //************************************************************************* - ETL_CONSTEXPR void add(uint8_t value_) + ETL_CONSTEXPR23 void add(uint8_t value_) { frame_check = policy.add(frame_check, value_); } @@ -162,7 +162,7 @@ namespace etl //************************************************************************* /// Gets the FCS value. //************************************************************************* - ETL_CONSTEXPR value_type value() const + ETL_CONSTEXPR14 value_type value() const { return policy.final(frame_check); } diff --git a/include/etl/private/crc_implementation.h b/include/etl/private/crc_implementation.h index 2fe0e4ac1..e8708635c 100644 --- a/include/etl/private/crc_implementation.h +++ b/include/etl/private/crc_implementation.h @@ -241,7 +241,7 @@ namespace etl struct crc_table { //************************************************************************* - TAccumulator add(TAccumulator crc, uint8_t value) const + ETL_CONSTEXPR23 TAccumulator add(TAccumulator crc, uint8_t value) const { static ETL_CONSTANT TAccumulator table[4U] = { @@ -276,7 +276,7 @@ namespace etl struct crc_table { //************************************************************************* - TAccumulator add(TAccumulator crc, uint8_t value) const + ETL_CONSTEXPR23 TAccumulator add(TAccumulator crc, uint8_t value) const { static ETL_CONSTANT TAccumulator table[16U] = { @@ -319,7 +319,7 @@ namespace etl struct crc_table { //************************************************************************* - ETL_CONSTEXPR TAccumulator add(TAccumulator crc, uint8_t value) const + ETL_CONSTEXPR23 TAccumulator add(TAccumulator crc, uint8_t value) const { static ETL_CONSTANT TAccumulator table[256U] = { @@ -691,7 +691,7 @@ namespace etl //************************************************************************* /// Default constructor. //************************************************************************* - ETL_CONSTEXPR crc_type() + ETL_CONSTEXPR14 crc_type() { this->reset(); } @@ -702,7 +702,7 @@ namespace etl /// \param end End of the range. //************************************************************************* template - ETL_CONSTEXPR crc_type(TIterator begin, const TIterator end) + ETL_CONSTEXPR14 crc_type(TIterator begin, const TIterator end) { this->reset(); this->add(begin, end); From 5be56425d72d1244d7c4e8881540504a4adedc54 Mon Sep 17 00:00:00 2001 From: Jan Dorniak Date: Tue, 25 Jun 2024 14:21:36 +0200 Subject: [PATCH 04/15] testing: add C++23 option --- test/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index eaf80ec13..86826396d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -310,9 +310,12 @@ elseif (ETL_CXX_STANDARD MATCHES "14") elseif (ETL_CXX_STANDARD MATCHES "17") message(STATUS "Compiling for C++17") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 17) -else() +elseif (ETL_CXX_STANDARD MATCHES "20") message(STATUS "Compiling for C++20") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 20) +else() + message(STATUS "Compiling for C++23") + set_property(TARGET etl_tests PROPERTY CXX_STANDARD 23) endif() if (NO_STL OR ETL_NO_STL) From 6adf56a2b01231b20ad4800caea1abdecb9517b8 Mon Sep 17 00:00:00 2001 From: Jan Dorniak Date: Tue, 25 Jun 2024 14:21:51 +0200 Subject: [PATCH 05/15] CI: add a C++23 pipeline --- .github/workflows/gcc-c++23.yml | 96 +++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 .github/workflows/gcc-c++23.yml diff --git a/.github/workflows/gcc-c++23.yml b/.github/workflows/gcc-c++23.yml new file mode 100644 index 000000000..3ab925b24 --- /dev/null +++ b/.github/workflows/gcc-c++23.yml @@ -0,0 +1,96 @@ +name: gcc-c++23 +on: + push: + branches: [ master, development, pull-request/* ] + pull_request: + branches: [ master, pull-request/* ] + +jobs: + + build-gcc-cpp23-linux-stl: + name: GCC C++23 Linux - STL + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + + steps: + - uses: actions/checkout@v3 + + - name: Build + run: | + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + export CC=gcc + export CXX=g++ + cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ + gcc --version + make + + - name: Run tests + run: ./test/etl_tests + + build-gcc-cpp23-linux-no-stl: + name: GCC C++23 Linux - No STL + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + + steps: + - uses: actions/checkout@v3 + + - name: Build + run: | + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + export CC=gcc + export CXX=g++ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ + gcc --version + make + + - name: Run tests + run: ./test/etl_tests + + build-gcc-cpp23-linux-stl-force-cpp03: + name: GCC C++23 Linux - STL - Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + + steps: + - uses: actions/checkout@v3 + + - name: Build + run: | + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + export CC=gcc + export CXX=g++ + cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + gcc --version + make + + - name: Run tests + run: ./test/etl_tests + + build-gcc-cpp23-linux-no-stl-force-cpp03: + name: GCC C++23 Linux - No STL - Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04] + + steps: + - uses: actions/checkout@v3 + + - name: Build + run: | + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + export CC=gcc + export CXX=g++ + cmake -DBUILD_TESTS=ON -DNO_STL=OON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + gcc --version + make + + - name: Run tests + run: ./test/etl_tests \ No newline at end of file From 6e62cff678e7288fdca8d19a5d6a546597dd276b Mon Sep 17 00:00:00 2001 From: Jan Dorniak Date: Tue, 25 Jun 2024 14:23:02 +0200 Subject: [PATCH 06/15] tests: fix C++23 deprecations --- test/test_mem_cast_ptr.cpp | 4 ++++ test/test_murmur3.cpp | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/test/test_mem_cast_ptr.cpp b/test/test_mem_cast_ptr.cpp index ec8eadefd..6ee7ee1e5 100644 --- a/test/test_mem_cast_ptr.cpp +++ b/test/test_mem_cast_ptr.cpp @@ -72,7 +72,11 @@ namespace return reinterpret_cast(uintptr_t(i)); } + #if __cplusplus >= 202302L + alignas(Alignment) uint8_t buffer[Size]; +#else typename std::aligned_storage::type buffer; +#endif SUITE(test_mem_cast_ptr) { diff --git a/test/test_murmur3.cpp b/test/test_murmur3.cpp index c8dc0d81f..274557f63 100644 --- a/test/test_murmur3.cpp +++ b/test/test_murmur3.cpp @@ -44,7 +44,11 @@ namespace //************************************************************************* TEST(test_murmur3_32_constructor) { + #if __cplusplus >= 202302L + alignas(uint32_t) uint8_t storage[10]; +#else typename std::aligned_storage::value>::type storage[10]; +#endif std::string data("123456789"); char* begin = (char*)&storage[0]; @@ -61,7 +65,11 @@ namespace //************************************************************************* TEST(test_murmur3_32_add_values) { + #if __cplusplus >= 202302L + alignas(uint32_t) uint8_t storage[10]; +#else typename std::aligned_storage::value>::type storage[10]; +#endif std::string data("123456789"); char* begin = (char*)&storage[0]; @@ -85,7 +93,11 @@ namespace //************************************************************************* TEST(test_murmur3_32_add_range) { + #if __cplusplus >= 202302L + alignas(uint32_t) uint8_t storage[10]; +#else typename std::aligned_storage::value>::type storage[10]; +#endif std::string data("123456789"); char* begin = (char*)&storage[0]; From 4df7644ed28337e2ad1d05e7743917ec51bdb9e7 Mon Sep 17 00:00:00 2001 From: Jan Dorniak Date: Tue, 25 Jun 2024 14:33:51 +0200 Subject: [PATCH 07/15] compiler_language_support: add a rudimentary check for C++23 --- include/etl/profiles/determine_compiler_language_support.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/etl/profiles/determine_compiler_language_support.h b/include/etl/profiles/determine_compiler_language_support.h index e8a004411..8f0b39393 100644 --- a/include/etl/profiles/determine_compiler_language_support.h +++ b/include/etl/profiles/determine_compiler_language_support.h @@ -37,8 +37,12 @@ SOFTWARE. // Determine C++23 support #if !defined(ETL_CPP23_SUPPORTED) +#if defined(__cplusplus) && (__cplusplus >= 202302L) + #define ETL_CPP23_SUPPORTED 1 +#else #define ETL_CPP23_SUPPORTED 0 #endif +#endif #if ETL_CPP23_SUPPORTED #define ETL_CPP11_SUPPORTED 1 From 9e3bf5df67eebc973f053f0ef959bd8a8e97df26 Mon Sep 17 00:00:00 2001 From: Jan Dorniak Date: Tue, 25 Jun 2024 14:40:00 +0200 Subject: [PATCH 08/15] CI: c++23: use Ubuntu 24.04 --- .github/workflows/gcc-c++23.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gcc-c++23.yml b/.github/workflows/gcc-c++23.yml index 3ab925b24..dc5ddd7c2 100644 --- a/.github/workflows/gcc-c++23.yml +++ b/.github/workflows/gcc-c++23.yml @@ -12,7 +12,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-22.04] + os: [ubuntu-24.04] steps: - uses: actions/checkout@v3 @@ -34,7 +34,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-22.04] + os: [ubuntu-24.04] steps: - uses: actions/checkout@v3 @@ -56,7 +56,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-22.04] + os: [ubuntu-24.04] steps: - uses: actions/checkout@v3 @@ -78,7 +78,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-22.04] + os: [ubuntu-24.04] steps: - uses: actions/checkout@v3 From afe4eb4fea015ef9edf4d8522e39d6db8052f5fb Mon Sep 17 00:00:00 2001 From: Jan Dorniak Date: Tue, 25 Jun 2024 14:40:08 +0200 Subject: [PATCH 09/15] CI: c++23: clang --- .github/workflows/clang-c++23.yml | 184 ++++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 .github/workflows/clang-c++23.yml diff --git a/.github/workflows/clang-c++23.yml b/.github/workflows/clang-c++23.yml new file mode 100644 index 000000000..6e03fd40c --- /dev/null +++ b/.github/workflows/clang-c++23.yml @@ -0,0 +1,184 @@ +name: clang-c++23 +on: + push: + branches: [ master, development, pull-request/* ] + pull_request: + branches: [ master, pull-request/* ] + +jobs: + + build-clang-cpp23-linux-no-stl: + name: Clang C++23 Linux - No STL + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-24.04] + + steps: + - uses: actions/checkout@v3 + + # Temporary fix. See https://github.com/actions/runner-images/issues/8659 + - name: Install newer Clang + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x ./llvm.sh + sudo ./llvm.sh 17 + + - name: Build + run: | + export CC=clang-17 + export CXX=clang++-17 + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ + clang-17 --version + make + + - name: Run tests + run: ./test/etl_tests + + build-clang-cpp23-linux-stl-force-cpp03: + name: Clang C++23 Linux - STL - Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-24.04] + + steps: + - uses: actions/checkout@v3 + + # Temporary fix. See https://github.com/actions/runner-images/issues/8659 + - name: Install newer Clang + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x ./llvm.sh + sudo ./llvm.sh 17 + + - name: Build + run: | + export CC=clang-17 + export CXX=clang++-17 + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + clang-17 --version + make + + - name: Run tests + run: ./test/etl_tests + + build-clang-cpp23-linux-no-stl-force-cpp03: + name: Clang C++23 Linux - No STL - Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-24.04] + + steps: + - uses: actions/checkout@v3 + + # Temporary fix. See https://github.com/actions/runner-images/issues/8659 + - name: Install newer Clang + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x ./llvm.sh + sudo ./llvm.sh 17 + + - name: Build + run: | + export CC=clang-17 + export CXX=clang++-17 + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + clang-17 --version + make + + - name: Run tests + run: ./test/etl_tests + + build-clang-cpp23-osx-stl: + name: Clang C++23 OSX - STL + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-12] + + steps: + - uses: actions/checkout@v3 + + - name: Build + run: | + export CC=clang + export CXX=clang++ + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ + clang --version + make + + - name: Run tests + run: ./test/etl_tests + + build-clang-cpp23-osx-no-stl: + name: Clang C++23 OSX - No STL + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-12] + + steps: + - uses: actions/checkout@v3 + + - name: Build + run: | + export CC=clang + export CXX=clang++ + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ + clang --version + make + + - name: Run tests + run: ./test/etl_tests + + build-clang-cpp23-osx-stl-force-cpp03: + name: Clang C++23 OSX - STL - Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-12] + + steps: + - uses: actions/checkout@v3 + + - name: Build + run: | + export CC=clang + export CXX=clang++ + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + clang --version + make + + - name: Run tests + run: ./test/etl_tests + + build-clang-cpp23-osx-no-stl-force-cpp03: + name: Clang C++23 OSX - No STL - Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-12] + + steps: + - uses: actions/checkout@v3 + + - name: Build + run: | + export CC=clang + export CXX=clang++ + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + clang --version + make + + - name: Run tests + run: ./test/etl_tests + From 5489e9ff3a13d7bdfc517822c79b9f887dcc9b9a Mon Sep 17 00:00:00 2001 From: Jan Dorniak Date: Tue, 25 Jun 2024 15:00:18 +0200 Subject: [PATCH 10/15] test: etl_traits: fix for C++23 --- test/test_etl_traits.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/test_etl_traits.cpp b/test/test_etl_traits.cpp index a071960e4..2ef48dc82 100644 --- a/test/test_etl_traits.cpp +++ b/test/test_etl_traits.cpp @@ -84,7 +84,9 @@ namespace CHECK_EQUAL(ETL_VERSION_MINOR, etl::traits::version_minor); CHECK_EQUAL(ETL_VERSION_PATCH, etl::traits::version_patch); CHECK_EQUAL(ETL_VERSION_VALUE, etl::traits::version); -#if ETL_USING_CPP20 +#if ETL_USING_CPP23 + CHECK_EQUAL(23, etl::traits::language_standard); +#elif ETL_USING_CPP20 CHECK_EQUAL(20, etl::traits::language_standard); #elif ETL_USING_CPP17 CHECK_EQUAL(17, etl::traits::language_standard); From 3e167096a0673b2bb74397556056c05f7a8f9cbd Mon Sep 17 00:00:00 2001 From: Jan Dorniak Date: Tue, 25 Jun 2024 15:00:41 +0200 Subject: [PATCH 11/15] tests: mem_cast_tr, murmur3: properly use etl::aligned_storage --- test/test_mem_cast_ptr.cpp | 6 +----- test/test_murmur3.cpp | 19 ++++--------------- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/test/test_mem_cast_ptr.cpp b/test/test_mem_cast_ptr.cpp index 6ee7ee1e5..49fecb9a6 100644 --- a/test/test_mem_cast_ptr.cpp +++ b/test/test_mem_cast_ptr.cpp @@ -72,11 +72,7 @@ namespace return reinterpret_cast(uintptr_t(i)); } - #if __cplusplus >= 202302L - alignas(Alignment) uint8_t buffer[Size]; -#else - typename std::aligned_storage::type buffer; -#endif + etl::aligned_storage::type buffer; SUITE(test_mem_cast_ptr) { diff --git a/test/test_murmur3.cpp b/test/test_murmur3.cpp index 274557f63..72b1c3b0c 100644 --- a/test/test_murmur3.cpp +++ b/test/test_murmur3.cpp @@ -35,6 +35,7 @@ SOFTWARE. #include #include +#include "etl/alignment.h" #include "etl/murmur3.h" namespace @@ -44,11 +45,7 @@ namespace //************************************************************************* TEST(test_murmur3_32_constructor) { - #if __cplusplus >= 202302L - alignas(uint32_t) uint8_t storage[10]; -#else - typename std::aligned_storage::value>::type storage[10]; -#endif + typename etl::aligned_storage::value>::type storage[10]; std::string data("123456789"); char* begin = (char*)&storage[0]; @@ -65,11 +62,7 @@ namespace //************************************************************************* TEST(test_murmur3_32_add_values) { - #if __cplusplus >= 202302L - alignas(uint32_t) uint8_t storage[10]; -#else - typename std::aligned_storage::value>::type storage[10]; -#endif + typename etl::aligned_storage::value>::type storage[10]; std::string data("123456789"); char* begin = (char*)&storage[0]; @@ -93,11 +86,7 @@ namespace //************************************************************************* TEST(test_murmur3_32_add_range) { - #if __cplusplus >= 202302L - alignas(uint32_t) uint8_t storage[10]; -#else - typename std::aligned_storage::value>::type storage[10]; -#endif + typename etl::aligned_storage::value>::type storage[10]; std::string data("123456789"); char* begin = (char*)&storage[0]; From ac8def79a7080b8ceddbaa7a820397d219fd6648 Mon Sep 17 00:00:00 2001 From: Jan Dorniak Date: Thu, 27 Jun 2024 16:50:20 +0200 Subject: [PATCH 12/15] crc: bump some constexpr to C++14 to fix builds --- include/etl/private/crc_implementation.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/etl/private/crc_implementation.h b/include/etl/private/crc_implementation.h index e8708635c..4061cd7f5 100644 --- a/include/etl/private/crc_implementation.h +++ b/include/etl/private/crc_implementation.h @@ -183,7 +183,7 @@ namespace etl template static typename etl::enable_if<(Accumulator_Bits > Chunk_Bits) && Reflect, TAccumulator>::type - ETL_CONSTEXPR crc_update_chunk(TAccumulator crc, uint8_t value, const TAccumulator table[]) + ETL_CONSTEXPR14 crc_update_chunk(TAccumulator crc, uint8_t value, const TAccumulator table[]) { value &= Chunk_Mask; @@ -608,14 +608,14 @@ namespace etl typedef accumulator_type value_type; //************************************************************************* - ETL_CONSTEXPR accumulator_type initial() const + ETL_CONSTEXPR14 accumulator_type initial() const { return TCrcParameters::Reflect ? etl::reverse_bits_const::value : TCrcParameters::Initial; } //************************************************************************* - ETL_CONSTEXPR accumulator_type final(accumulator_type crc) const + ETL_CONSTEXPR14 accumulator_type final(accumulator_type crc) const { return crc ^ TCrcParameters::Xor_Out; } @@ -636,7 +636,7 @@ namespace etl typedef accumulator_type value_type; //************************************************************************* - ETL_CONSTEXPR accumulator_type initial() const + ETL_CONSTEXPR14 accumulator_type initial() const { return TCrcParameters::Reflect ? etl::reverse_bits_const::value : TCrcParameters::Initial; @@ -664,7 +664,7 @@ namespace etl typedef accumulator_type value_type; //************************************************************************* - ETL_CONSTEXPR accumulator_type initial() const + ETL_CONSTEXPR14 accumulator_type initial() const { return TCrcParameters::Reflect ? etl::reverse_bits_const::value : TCrcParameters::Initial; From 89acdfdf3018f257aefb599ca7259601c06fb2c5 Mon Sep 17 00:00:00 2001 From: Jan Dorniak Date: Tue, 2 Jul 2024 20:51:05 +0200 Subject: [PATCH 13/15] github workflows: clang/C++23: don't install LLVM 17 since 18 is the default in Ubuntu 24.04 --- .github/workflows/clang-c++23.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/clang-c++23.yml b/.github/workflows/clang-c++23.yml index 6e03fd40c..3e2588ed1 100644 --- a/.github/workflows/clang-c++23.yml +++ b/.github/workflows/clang-c++23.yml @@ -17,17 +17,8 @@ jobs: steps: - uses: actions/checkout@v3 - # Temporary fix. See https://github.com/actions/runner-images/issues/8659 - - name: Install newer Clang - run: | - wget https://apt.llvm.org/llvm.sh - chmod +x ./llvm.sh - sudo ./llvm.sh 17 - - name: Build run: | - export CC=clang-17 - export CXX=clang++-17 export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ clang-17 --version From 2c6dac192b52bfc58787073b135d0367eca8b004 Mon Sep 17 00:00:00 2001 From: Jan Dorniak Date: Tue, 2 Jul 2024 20:53:04 +0200 Subject: [PATCH 14/15] github actions: C++23: fix half-assed clang-17 removal --- .github/workflows/clang-c++23.yml | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/.github/workflows/clang-c++23.yml b/.github/workflows/clang-c++23.yml index 3e2588ed1..8354a0c89 100644 --- a/.github/workflows/clang-c++23.yml +++ b/.github/workflows/clang-c++23.yml @@ -21,7 +21,6 @@ jobs: run: | export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ - clang-17 --version make - name: Run tests @@ -37,20 +36,10 @@ jobs: steps: - uses: actions/checkout@v3 - # Temporary fix. See https://github.com/actions/runner-images/issues/8659 - - name: Install newer Clang - run: | - wget https://apt.llvm.org/llvm.sh - chmod +x ./llvm.sh - sudo ./llvm.sh 17 - - name: Build run: | - export CC=clang-17 - export CXX=clang++-17 export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ - clang-17 --version make - name: Run tests @@ -66,20 +55,10 @@ jobs: steps: - uses: actions/checkout@v3 - # Temporary fix. See https://github.com/actions/runner-images/issues/8659 - - name: Install newer Clang - run: | - wget https://apt.llvm.org/llvm.sh - chmod +x ./llvm.sh - sudo ./llvm.sh 17 - - name: Build run: | - export CC=clang-17 - export CXX=clang++-17 export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ - clang-17 --version make - name: Run tests From ffa01d85651883f3258f54531f0438f11d4ed09f Mon Sep 17 00:00:00 2001 From: Jan Dorniak Date: Tue, 2 Jul 2024 20:54:56 +0200 Subject: [PATCH 15/15] another fix for actions, shouldn't be in so much of a hurry --- .github/workflows/clang-c++23.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/clang-c++23.yml b/.github/workflows/clang-c++23.yml index 8354a0c89..542f13795 100644 --- a/.github/workflows/clang-c++23.yml +++ b/.github/workflows/clang-c++23.yml @@ -19,8 +19,11 @@ jobs: - name: Build run: | + export CC=clang-18 + export CXX=clang++-18 export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ + clang-18 --version make - name: Run tests @@ -38,8 +41,11 @@ jobs: - name: Build run: | + export CC=clang-18 + export CXX=clang++-18 export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + clang-18 --version make - name: Run tests @@ -57,8 +63,11 @@ jobs: - name: Build run: | + export CC=clang-18 + export CXX=clang++-18 export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + clang-18 --version make - name: Run tests