diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index c8624ad0..470e6b86 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -74,7 +74,6 @@ correctness, and zero overhead. - Windows (MSVC) - Linux (GCC, Clang) - macOS (AppleClang) - - Android and iOS where applicable ## Copilot Tasks - You can find the CMake artifacts for C++20 in build-cxx20 and C++14 in build-cxx14. diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml deleted file mode 100644 index 2d48fa56..00000000 --- a/.github/workflows/android.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: CI_Android - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - Android: - runs-on: macos-latest-large - defaults: - run: - working-directory: build - steps: - - uses: actions/checkout@v6 - - - name: Create build directory - run: mkdir -p build - working-directory: . - - - uses: actions/setup-java@v5 - with: - java-version: 8 - distribution: zulu - - - name: Start Emulator - run: | - echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install 'system-images;android-24;default;x86_64' - echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd -n xamarin_android_emulator -k 'system-images;android-24;default;x86_64' --force - $ANDROID_HOME/emulator/emulator -list-avds - echo "Starting emulator..." - nohup $ANDROID_HOME/emulator/emulator -no-audio -no-snapshot -avd xamarin_android_emulator &> /dev/null & - echo "Emulator starting in background" - - - name: Configure - run: cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_LATEST_HOME/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=16 -DANDROID_ABI=x86_64 -DCMAKE_BUILD_TYPE=Debug .. - - - name: Build - run: cmake --build . --parallel - - - name: Wait for emulator ready - timeout-minutes: 2 - run: | - $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 10; done; input keyevent 82' - $ANDROID_HOME/platform-tools/adb devices - $ANDROID_HOME/platform-tools/adb shell getprop ro.product.cpu.abi - - - name: Deploy tests - run: | - adb push tests /data/local/tmp - adb shell find /data/local/tmp/tests -maxdepth 1 -exec chmod +x {} \\\; - - - name: Test - run: adb shell find /data/local/tmp/tests -name "*_tests" -maxdepth 1 -exec {} \\\; diff --git a/.github/workflows/compilers.yml b/.github/workflows/compilers.yml index 6681e1a1..fd56e8e6 100644 --- a/.github/workflows/compilers.yml +++ b/.github/workflows/compilers.yml @@ -61,7 +61,7 @@ jobs: xcode: strategy: matrix: - xcode_version: [ '16.4' ] + xcode_version: [ '26.6' ] build_type: [ Debug, Release ] cxx_version: [ 14, 17, 20, 23 ] runs-on: macos-latest @@ -88,9 +88,13 @@ jobs: # Regular MSVC builds use Ninja (from preset) - toolset: 'msvc' generator_override: '' - # ClangCL builds require Visual Studio generator - - toolset: 'ClangCL' + # ClangCL builds require Visual Studio generator; version depends on image + - image: windows-2022 + toolset: 'ClangCL' generator_override: '-G "Visual Studio 17 2022" -T ClangCL' + - image: windows-2025 + toolset: 'ClangCL' + generator_override: '-G "Visual Studio 18 2026" -T ClangCL' runs-on: ${{ matrix.image }} steps: - uses: actions/checkout@v6 diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml deleted file mode 100644 index 9b02c4bf..00000000 --- a/.github/workflows/ios.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: CI_iOS -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - iOS: - runs-on: macos-latest - defaults: - run: - working-directory: build - steps: - - uses: actions/checkout@v6 - - - name: Create build directory - run: mkdir -p build - working-directory: . - - - name: Configure - run: | - cmake \ - -Werror=dev \ - -GXcode \ - -DCMAKE_SYSTEM_NAME=iOS \ - "-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64" \ - -DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 \ - -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \ - "-DMACOSX_BUNDLE_GUI_IDENTIFIER=GSL.\$(EXECUTABLE_NAME)" \ - -DMACOSX_BUNDLE_BUNDLE_VERSION=4.2.0 \ - -DMACOSX_BUNDLE_SHORT_VERSION_STRING=4.2.0 \ - -DCMAKE_CXX_FLAGS="-Wno-missing-include-dirs" \ - .. - - - name: Build - run: cmake --build . --parallel `sysctl -n hw.ncpu` --config Release -- -sdk iphonesimulator - - - name: Start simulator - run: | - RUNTIME=`xcrun simctl list runtimes iOS -j|jq '.runtimes|last.identifier'` - UDID=`xcrun simctl list devices iPhone available -j|jq -r ".devices[$RUNTIME]|last.udid"` - xcrun simctl bootstatus $UDID -b - - - name: Test - run: | - for TEST in `find tests/Release-iphonesimulator -depth 1 -name "*.app"` - do - xcrun simctl install booted $TEST - TEST_ID=`plutil -convert json -o - $TEST/Info.plist|jq -r ".CFBundleIdentifier"` - xcrun simctl launch --console booted $TEST_ID - xcrun simctl uninstall booted $TEST_ID - done diff --git a/README.md b/README.md index fbd17a0d..9715db89 100644 --- a/README.md +++ b/README.md @@ -103,19 +103,6 @@ Compiler |Toolset Versions Currently Tested Visual Studio with MSVC | VS2019, VS2022 Visual Studio with LLVM | VS2019, VS2022 ---- -If you successfully port GSL to another platform, we would love to hear from you! -- Submit an issue specifying the platform and target. -- Consider contributing your changes by filing a pull request with any necessary changes. -- If at all possible, add a CI/CD step and add the button to the table below! - -Target | CI/CD Status -:------- | -----------: -iOS | [![CI_iOS](https://github.com/microsoft/GSL/workflows/CI_iOS/badge.svg?branch=main)](https://github.com/microsoft/GSL/actions/workflows/ios.yml?query=branch%3Amain) -Android | [![CI_Android](https://github.com/microsoft/GSL/workflows/CI_Android/badge.svg?branch=main)](https://github.com/microsoft/GSL/actions/workflows/android.yml?query=branch%3Amain) - -Note: These CI/CD steps are run with each pull request, however failures in them are non-blocking. - ## Building the tests To build the tests, you will require the following: diff --git a/docs/upgrade_checklist.md b/docs/upgrade_checklist.md index bf923b3d..7c0c765e 100644 --- a/docs/upgrade_checklist.md +++ b/docs/upgrade_checklist.md @@ -2,8 +2,6 @@ 1. [ ] [CMakeLists.txt](../CMakeLists.txt) Bump `GSL_VERSION` 1. [ ] [README.md](../README.md) Bump `GIT_TAG` -1. [ ] [ios.yml](../.github/workflows/ios.yml) Bump `MACOSX_BUNDLE_BUNDLE_VERSION` and -`MACOSX_BUNDLE_SHORT_VERSION_STRING` > After updating, you need to create a new GitHub release: diff --git a/include/gsl/assert b/include/gsl/assert index 5181c131..daa1a75c 100644 --- a/include/gsl/assert +++ b/include/gsl/assert @@ -31,6 +31,9 @@ #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-noreturn" +#if __clang_major__ >= 22 +#pragma clang diagnostic ignored "-Wunique-object-duplication" +#endif // __clang_major >= 22 #endif // defined(__clang__) #else // defined(_MSC_VER) && (defined(_KERNEL_MODE) || (defined(_HAS_EXCEPTIONS) && diff --git a/include/gsl/dyn_array b/include/gsl/dyn_array index dd6517d4..550cc26b 100644 --- a/include/gsl/dyn_array +++ b/include/gsl/dyn_array @@ -216,9 +216,8 @@ namespace details constexpr auto operator++(int) { - auto rv = *this; ++(*this); - return rv; + return dyn_array_iterator{_ptr, _pos - 1, _end_pos}; } constexpr auto operator--() -> dyn_array_iterator& @@ -230,9 +229,8 @@ namespace details constexpr auto operator--(int) { - auto rv = *this; --(*this); - return rv; + return dyn_array_iterator{_ptr, _pos + 1, _end_pos}; } constexpr auto operator+=(difference_type diff) -> dyn_array_iterator& diff --git a/include/gsl/util b/include/gsl/util index cc171d25..9c2627e0 100644 --- a/include/gsl/util +++ b/include/gsl/util @@ -133,6 +133,12 @@ namespace details } // namespace details // final_action allows you to ensure something gets run at the end of a scope +// The bool member causes trailing padding when F has alignment > 1; suppress +// -Wpadded since the padding is unavoidable for a generic callable wrapper. +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#endif // defined(__clang__) template class final_action { @@ -157,6 +163,9 @@ private: F f; bool invoke = true; }; +#if defined(__clang__) +#pragma clang diagnostic pop +#endif // defined(__clang__) // finally() - convenience function to generate a final_action template diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3ec624c1..82e84cb0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -18,10 +18,6 @@ if(CI_TESTING AND GSL_CXX_STANDARD EQUAL 20) add_compile_definitions(FORCE_STD_SPAN_TESTS=1) endif() -if(IOS) - add_compile_definitions(GTEST_HAS_DEATH_TEST=1 IOS_PROCESS_DELAY_WORKAROUND=1) -endif() - pkg_search_module(GTestMain gtest_main) if (NOT GTestMain_FOUND) # No pre-installed GTest is available, try to download it using Git. @@ -54,6 +50,14 @@ if (NOT GTestMain_FOUND) ${CMAKE_CURRENT_BINARY_DIR}/googletest-build EXCLUDE_FROM_ALL ) + + # googletest is built as its own target, so apply this workaround there. + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" + AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC" + AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 22) + target_compile_options(gtest PRIVATE -Wno-character-conversion) + target_compile_options(gtest_main PRIVATE -Wno-character-conversion) + endif() endif() if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) @@ -111,7 +115,7 @@ if(MSVC) # MSVC or simulating MSVC -Wno-undef # GTest -Wno-used-but-marked-unused # GTest EXPECT_DEATH -Wno-switch-default # GTest EXPECT_DEATH - $<$: # no support for [[maybe_unused]] + $<$: # no support for [[maybe_unused]] -Wno-unused-member-function -Wno-unused-variable $<$,15.0.1>: diff --git a/tests/dyn_array_tests.cpp b/tests/dyn_array_tests.cpp index f67850f4..80bca7a0 100644 --- a/tests/dyn_array_tests.cpp +++ b/tests/dyn_array_tests.cpp @@ -189,6 +189,10 @@ TEST(dyn_array_tests, ranges) #endif /* __cpp_lib_ranges >= 201911L */ #if defined(__cpp_lib_constexpr_dynamic_alloc) && (__cpp_lib_constexpr_dynamic_alloc >= 201907L) +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#endif // defined(__clang__) template struct ConstexprAllocator { @@ -218,6 +222,9 @@ struct ConstexprAllocator constexpr void deallocate(value_type*, std::size_t) noexcept {} }; +#if defined(__clang__) +#pragma clang diagnostic pop +#endif // defined(__clang__) template constexpr auto operator==(const ConstexprAllocator& lhs, diff --git a/tests/no_exception_ensure_tests.cpp b/tests/no_exception_ensure_tests.cpp index 5fde41cf..1460a5e0 100644 --- a/tests/no_exception_ensure_tests.cpp +++ b/tests/no_exception_ensure_tests.cpp @@ -14,11 +14,9 @@ // /////////////////////////////////////////////////////////////////////////////// -#include #include // for std::exit #include // for span #include -#include int operator_subscript_no_throw() noexcept { @@ -46,9 +44,6 @@ void setup_termination_handler() noexcept int main() noexcept { std::cout << "Running main() from " __FILE__ "\n"; -#if defined(IOS_PROCESS_DELAY_WORKAROUND) - std::this_thread::sleep_for(std::chrono::seconds(1)); -#endif setup_termination_handler(); operator_subscript_no_throw(); return -1;