From cd93e86b7f07a76bd97b9c70b6694d58adce89ab Mon Sep 17 00:00:00 2001 From: Anil Mahtani <929854+Anilm3@users.noreply.github.com> Date: Tue, 15 Oct 2024 20:41:28 +0100 Subject: [PATCH] Upgrade runners to macos-14 and fix deployment target (#344) --- .github/workflows/build.yml | 58 ++++++++++++-------------------- CMakeLists.txt | 20 ++++++++--- cmake/objects.cmake | 6 ++++ cmake/package.cmake | 2 +- cmake/try_mem_resource_ftm.cpp | 8 +++++ cmake/try_monotonic_resource.cpp | 7 ++++ cmake/try_rec_map.cpp | 2 ++ tests/CMakeLists.txt | 6 ++++ 8 files changed, 67 insertions(+), 42 deletions(-) create mode 100644 cmake/try_mem_resource_ftm.cpp create mode 100644 cmake/try_monotonic_resource.cpp diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3b9afeb61..ccc91c300 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,7 +54,13 @@ jobs: ${{ github.workspace }}/packages/*.sha256 macos-build: - runs-on: macos-12 + runs-on: macos-14 + strategy: + fail-fast: false + matrix: + arch: + - x86_64 + - arm64 steps: - uses: actions/checkout@v4 with: @@ -62,10 +68,10 @@ jobs: - name: Create Build Directory run: cmake -E make_directory ${{ github.workspace }}/build ${{ github.workspace }}/packages - name: Generating Build Scripts - run: cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMACOSX_DEPLOYMENT_TARGET=10.9 -DCMAKE_INSTALL_PREFIX=${{ github.workspace }} -DCPACK_PACKAGE_DIRECTORY=${{ github.workspace }}/packages ${{ github.workspace }} + run: cmake -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=${{ github.workspace }} -DCPACK_PACKAGE_DIRECTORY=${{ github.workspace }}/packages ${{ github.workspace }} working-directory: ${{ github.workspace }}/build - name: Build Binaries - run: cmake --build . --config RelWithDebInfo --verbose --target all --target waf_test -j + run: cmake --build . --config RelWithDebInfo --verbose --target all --target waf_test -j $(getconf _NPROCESSORS_ONLN) working-directory: ${{ github.workspace }}/build - name: Test run: ${{ github.workspace }}/build/tests/waf_test @@ -81,44 +87,14 @@ jobs: run: for file in *.tar.gz; do shasum -a 256 "$file" > "$file.sha256"; done - uses: actions/upload-artifact@v4 with: - name: libddwaf-macos-x86_64 - path: | - ${{ github.workspace }}/packages/*.tar.gz - ${{ github.workspace }}/packages/*.sha256 - - macos-cross-build: - runs-on: macos-12 - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - name: Create Build Directory - run: cmake -E make_directory ${{ github.workspace }}/build ${{ github.workspace }}/packages - - name: Generating Build Scripts - run: cmake -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DMACOSX_DEPLOYMENT_TARGET=10.9 -DCMAKE_INSTALL_PREFIX=${{ github.workspace }} -DCPACK_PACKAGE_DIRECTORY=${{ github.workspace }}/packages ${{ github.workspace }} - working-directory: ${{ github.workspace }}/build - - name: Build Binaries - run: cmake --build . --config RelWithDebInfo --verbose --target all -j - working-directory: ${{ github.workspace }}/build - - name: Build Packages - run: cmake --build . --target package --config RelWithDebInfo --verbose - working-directory: ${{ github.workspace }}/build - - name: Remove Temporary Files - run: cmake -E remove_directory _CPack_Packages - working-directory: ${{ github.workspace }}/packages - - name: Generate Package sha256 - working-directory: ${{ github.workspace }}/packages - run: for file in *.tar.gz; do shasum -a 256 "$file" > "$file.sha256"; done - - uses: actions/upload-artifact@v4 - with: - name: libddwaf-macos-arm64 + name: libddwaf-macos-${{ matrix.arch }} path: | ${{ github.workspace }}/packages/*.tar.gz ${{ github.workspace }}/packages/*.sha256 macos-universal-package: - runs-on: macos-12 - needs: [macos-build, macos-cross-build] + runs-on: macos-14 + needs: [macos-build] steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 @@ -147,6 +123,14 @@ jobs: # Change the current folder name with the universal name mv ./pack-temp/osx/libddwaf-*-darwin-* ./pack-temp/osx/$universalName + echo "--- x86_64 target ---" + file ./pack-temp/osx-x64/$x64Name/lib/libddwaf.dylib + otool -l ./pack-temp/osx-x64/$x64Name/lib/libddwaf.dylib | egrep "(minos|sdk)" + + echo "--- arm64 target ---" + file ./pack-temp/osx-arm64/$arm64Name/lib/libddwaf.dylib + otool -l ./pack-temp/osx-arm64/$arm64Name/lib/libddwaf.dylib | egrep "(minos|sdk)" + # Create the universal binary for the shared library: libddwaf.dylib lipo ./pack-temp/osx-x64/$x64Name/lib/libddwaf.dylib ./pack-temp/osx-arm64/$arm64Name/lib/libddwaf.dylib -create -output ./pack-temp/osx/$universalName/lib/libddwaf.dylib # Check the universal binary @@ -317,7 +301,7 @@ jobs: path: ${{ github.workspace }}/output-packages release: - needs: [ windows-builds, macos-build, macos-cross-build, docker-builds, linux-musl-build, package-nuget] + needs: [ windows-builds, macos-build, docker-builds, linux-musl-build, package-nuget] runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/') permissions: diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d34722e5..79986d955 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,10 @@ file(READ "version" version) string(REGEX REPLACE "-(alpha|beta)[0-9]*$" "" mmp_version ${version}) +if (APPLE) + set(CMAKE_OSX_DEPLOYMENT_TARGET "12.7" CACHE STRING "Minimum OS X deployment version") +endif() + project(libddwaf VERSION "${mmp_version}") # Resetting the version allows for alpha and beta suffix releases @@ -35,10 +39,6 @@ option(LIBDDWAF_VECTORIZED_TRANSFORMERS "Enable vectorization for transformers" option(LIBDDWAF_ENABLE_LTO "Enable link-time optimisation" OFF) if(NOT MSVC) - if (APPLE) - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum OS X deployment version") - endif() - add_compile_options(-Wall -Wextra -Wno-narrowing) if (CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo) add_compile_options(-ggdb) @@ -65,6 +65,18 @@ try_compile(STDLIB_MAP_RECURSIVE ${CMAKE_CURRENT_BINARY_DIR} SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/try_rec_map.cpp CXX_STANDARD 20) +try_compile(STDLIB_MEMORY_RESOURCE_FTM ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/try_mem_resource_ftm.cpp + CXX_STANDARD 20) + +try_compile(STDLIB_MONOTONIC_RESOURCE ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/try_monotonic_resource.cpp + CXX_STANDARD 20) + +message(STATUS "Has recursive unordered_map : ${STDLIB_MAP_RECURSIVE}") +message(STATUS "Has memory_resource test macro : ${STDLIB_MEMORY_RESOURCE_FTM}") +message(STATUS "Has monotonic_resource : ${STDLIB_MONOTONIC_RESOURCE}") + # System dependencies set(LIBDDWAF_INTERFACE_LIBRARIES "") if(LINUX) diff --git a/cmake/objects.cmake b/cmake/objects.cmake index efc8011de..b8c028d5f 100644 --- a/cmake/objects.cmake +++ b/cmake/objects.cmake @@ -132,6 +132,12 @@ function(gen_objects target_name) target_compile_definitions(${target_name} PRIVATE HAS_NONRECURSIVE_UNORDERED_MAP) endif() + if (NOT STDLIB_MEMORY_RESOURCE_FTM AND STDLIB_MONOTONIC_RESOURCE) + # For some reason __cpp_lib_memory_resource seems to be missing in macos-14 when + # using the correct CMAKE_OSX_DEPLOYMENT_TARGET + target_compile_definitions(${target_name} PRIVATE __cpp_lib_memory_resource) + endif() + if (LIBDDWAF_VECTORIZED_TRANSFORMERS) target_compile_definitions(${target_name} PRIVATE LIBDDWAF_VECTORIZED_TRANSFORMERS) endif() diff --git a/cmake/package.cmake b/cmake/package.cmake index 9c39c398c..bdfd0fa84 100644 --- a/cmake/package.cmake +++ b/cmake/package.cmake @@ -3,7 +3,7 @@ install(FILES ${libddwaf_SOURCE_DIR}/include/ddwaf.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(EXPORT libddwaf-config DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/libddwaf) -if(APPLE AND CMAKE_OSX_ARCHITECTURES MATCHES "arm64") +if(APPLE AND CMAKE_OSX_ARCHITECTURES MATCHES "x86_64") set(LIBDDWAF_PACKAGE_PROCESSOR ${CMAKE_OSX_ARCHITECTURES} CACHE STRING "Alternative processor for packaging purposes") else() set(LIBDDWAF_PACKAGE_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} CACHE STRING "Alternative processor for packaging purposes") diff --git a/cmake/try_mem_resource_ftm.cpp b/cmake/try_mem_resource_ftm.cpp new file mode 100644 index 000000000..b62127277 --- /dev/null +++ b/cmake/try_mem_resource_ftm.cpp @@ -0,0 +1,8 @@ +#include +#include + +#if !defined(__cpp_lib_memory_resource) +# error "No memory resource available" +#endif + +int main() {} diff --git a/cmake/try_monotonic_resource.cpp b/cmake/try_monotonic_resource.cpp new file mode 100644 index 000000000..93ccafe73 --- /dev/null +++ b/cmake/try_monotonic_resource.cpp @@ -0,0 +1,7 @@ +#include + +int main() +{ + std::pmr::monotonic_buffer_resource mr; + return 0; +} diff --git a/cmake/try_rec_map.cpp b/cmake/try_rec_map.cpp index de578c816..d1068594e 100644 --- a/cmake/try_rec_map.cpp +++ b/cmake/try_rec_map.cpp @@ -4,3 +4,5 @@ struct X { std::unordered_map x{}; }; static X x{}; + +int main() {} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5c3a9364f..60b376dd8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -14,6 +14,12 @@ if(NOT STDLIB_MAP_RECURSIVE) target_compile_definitions(waf_test PRIVATE HAS_NONRECURSIVE_UNORDERED_MAP) endif() +if (NOT STDLIB_MEMORY_RESOURCE_FTM AND STDLIB_MONOTONIC_RESOURCE) + # For some reason __cpp_lib_memory_resource seems to be missing in macos-14 when + # using the correct CMAKE_OSX_DEPLOYMENT_TARGET + target_compile_definitions(waf_test PRIVATE __cpp_lib_memory_resource) +endif() + if (LIBDDWAF_VECTORIZED_TRANSFORMERS) target_compile_definitions(waf_test PRIVATE LIBDDWAF_VECTORIZED_TRANSFORMERS) endif()