From eaff312d0c2b49a527a7a169eee4180f951dc797 Mon Sep 17 00:00:00 2001 From: Quentin Sabah Date: Fri, 15 Mar 2024 10:29:11 +0100 Subject: [PATCH] Add CI job for Apple ARM Using `macos14` runner and build with `gcc-13`. --- .github/actions/cmake-test/action.yml | 2 +- .github/workflows/CI-Tests.yml | 45 +++++++++++++++++++++++---- .github/workflows/VS-CI-Tests.yml | 2 +- .github/workflows/create-packages.yml | 6 ++-- .github/workflows/populate-deps.yml | 2 +- sh/setup/install_macos_arm_deps.sh | 21 +++++++++++++ src/CMakeLists.txt | 17 ++++++++-- src/interpreter/Engine.cpp | 2 +- src/synthesiser/Synthesiser.cpp | 2 +- tests/profile/CMakeLists.txt | 2 ++ 10 files changed, 85 insertions(+), 16 deletions(-) create mode 100755 sh/setup/install_macos_arm_deps.sh diff --git a/.github/actions/cmake-test/action.yml b/.github/actions/cmake-test/action.yml index 918565d4874..90ddfabeb55 100644 --- a/.github/actions/cmake-test/action.yml +++ b/.github/actions/cmake-test/action.yml @@ -14,7 +14,7 @@ runs: using: "composite" steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: setup-env run: | diff --git a/.github/workflows/CI-Tests.yml b/.github/workflows/CI-Tests.yml index 5e9c051e260..933235299f5 100644 --- a/.github/workflows/CI-Tests.yml +++ b/.github/workflows/CI-Tests.yml @@ -13,7 +13,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 2 @@ -31,7 +31,7 @@ jobs: chunks: ${{ steps.set-test-ids.outputs.chunks }} steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - id: set-test-ids uses: ./.github/actions/set-test-ids with: @@ -54,7 +54,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: install-lcov if: ${{ matrix.domain == '32bit' }} @@ -123,7 +123,7 @@ jobs: xcode-version: '13.4' - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: install-deps run: sh/setup/install_macos_deps.sh @@ -135,6 +135,39 @@ jobs: n-chunks: ${{ needs.Test-Setup.outputs.n-chunks }} chunk: ${{ matrix.chunk }} + AppleM-CMake: + needs: Test-Setup + timeout-minutes: 150 + + name: AppleM-CMake (chunk ${{ matrix.chunk }}) + + strategy: + fail-fast: false + matrix: + chunk: ${{ fromJSON(needs.Test-Setup.outputs.chunks) }} + + runs-on: macos-14 + + steps: + - name: Select XCode version + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: '15.2' + + - name: checkout + uses: actions/checkout@v4 + + - name: install-deps + run: sh/setup/install_macos_arm_deps.sh + + - name: cmake-test-64bit + uses: ./.github/actions/cmake-test + with: + # disable openmp on ARM architecture, see souffle-lang/souffle#2476 + cmake-flags: -DSOUFFLE_DOMAIN_64BIT=ON -DSOUFFLE_USE_OPENMP=OFF + n-chunks: ${{ needs.Test-Setup.outputs.n-chunks }} + chunk: ${{ matrix.chunk }} + Memory-Check: needs: Test-Setup timeout-minutes: 150 @@ -150,7 +183,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: install-deps run: sudo sh/setup/install_ubuntu_deps.sh @@ -170,7 +203,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/VS-CI-Tests.yml b/.github/workflows/VS-CI-Tests.yml index a194d1c14d9..3955a6f3cc5 100644 --- a/.github/workflows/VS-CI-Tests.yml +++ b/.github/workflows/VS-CI-Tests.yml @@ -16,7 +16,7 @@ jobs: Windows-CMake-MSVC: runs-on: windows-2019 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Dependencies Cache uses: actions/cache@v3 diff --git a/.github/workflows/create-packages.yml b/.github/workflows/create-packages.yml index d81ac29ddd8..c50316de26f 100644 --- a/.github/workflows/create-packages.yml +++ b/.github/workflows/create-packages.yml @@ -26,7 +26,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -57,7 +57,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -133,7 +133,7 @@ jobs: runs-on: ubuntu-18.04 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 clean: false diff --git a/.github/workflows/populate-deps.yml b/.github/workflows/populate-deps.yml index a265714a9c1..cc01a908426 100644 --- a/.github/workflows/populate-deps.yml +++ b/.github/workflows/populate-deps.yml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: 'recursive' diff --git a/sh/setup/install_macos_arm_deps.sh b/sh/setup/install_macos_arm_deps.sh new file mode 100755 index 00000000000..166df8636b5 --- /dev/null +++ b/sh/setup/install_macos_arm_deps.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Install MACOS dependencies on a Github Action VM + +# Enable debugging and logging of shell operations +# that are executed. +set -e +set -x + +# Install requirements of MAC OS X +brew install libtool mcpp swig bison libffi +brew install gcc@13 +brew link gcc@13 + +echo "/usr/local/opt/bison/bin:$PATH" >> $GITHUB_PATH +echo 'PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig/"' >> $GITHUB_ENV +echo 'CC=gcc-13' >> $GITHUB_ENV +echo 'CXX=g++-13' >> $GITHUB_ENV + +set +e +set +x diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e3354deae5b..fa159d5923a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -421,7 +421,16 @@ if (MSVC) target_compile_definitions(souffleprof PUBLIC USE_CUSTOM_GETOPTLONG) endif (MSVC) - +if (APPLE) + if ("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "arm64") + # work around a known issue with xcode15 linker + # c++ exceptions handling is broken otherwise + set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,-ld_classic") + target_link_options(libsouffle PUBLIC "-ld_classic") + target_link_options(compiled PUBLIC "-ld_classic") + target_link_options(souffleprof PUBLIC "-ld_classic") + endif() +endif() # -------------------------------------------------- # Substitutions for souffle-compile.py @@ -437,6 +446,7 @@ set(SOUFFLE_COMPILED_DEBUG_CXX_FLAGS ${CMAKE_CXX_FLAGS_DEBUG}) get_target_property(SOUFFLE_COMPILED_DEFS compiled COMPILE_DEFINITIONS) get_target_property(SOUFFLE_COMPILED_OPTS compiled COMPILE_OPTIONS) get_target_property(SOUFFLE_COMPILED_INCS compiled INCLUDE_DIRECTORIES) +get_property(SOUFFLE_COMPILED_LINK_OPTS TARGET compiled PROPERTY LINK_OPTIONS) set(SOUFFLE_COMPILED_LIBS "") set(SOUFFLE_COMPILED_RPATHS "") @@ -524,7 +534,10 @@ endif () list(JOIN SOUFFLE_COMPILED_OPTS " " SOUFFLE_COMPILED_CXX_OPTIONS) -list(JOIN SOUFFLE_COMPILED_LIBS " " SOUFFLE_COMPILED_LINK_OPTIONS) +list(JOIN SOUFFLE_COMPILED_LIBS " " SOUFFLE_COMPILED_LINK_OPTIONS1) +list(JOIN SOUFFLE_COMPILED_LINK_OPTS " " SOUFFLE_COMPILED_LINK_OPTIONS2) +set(SOUFFLE_COMPILED_LINK_OPTIONS "") +string(APPEND SOUFFLE_COMPILED_LINK_OPTIONS " ${SOUFFLE_COMPILED_LINK_OPTIONS1}" " ${SOUFFLE_COMPILED_LINK_OPTIONS2}") if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") set(SOUFFLE_COMPILED_LINK_OPTIONS "/link ${SOUFFLE_COMPILED_LINK_OPTIONS}") diff --git a/src/interpreter/Engine.cpp b/src/interpreter/Engine.cpp index b29982dab98..dd6dd7ecb60 100644 --- a/src/interpreter/Engine.cpp +++ b/src/interpreter/Engine.cpp @@ -775,7 +775,7 @@ RamDomain Engine::execute(const Node* node, Context& ctxt) { std::string sub_str; try { sub_str = str.substr(idx, len); - } catch (...) { + } catch (std::out_of_range&) { std::cerr << "warning: wrong index position provided by substr(\""; std::cerr << str << "\"," << (int32_t)idx << "," << (int32_t)len << ") functor.\n"; } diff --git a/src/synthesiser/Synthesiser.cpp b/src/synthesiser/Synthesiser.cpp index a475c284b5e..59e76067174 100644 --- a/src/synthesiser/Synthesiser.cpp +++ b/src/synthesiser/Synthesiser.cpp @@ -2812,7 +2812,7 @@ void Synthesiser::generateCode(GenDb& db, const std::string& id, bool& withShare wrapper.setNextArg("std::size_t", "idx"); wrapper.setNextArg("std::size_t", "len"); wrapper.body() << "std::string result; \n" - << "try { result = str.substr(idx,len); } catch(...) { \n" + << "try { result = str.substr(idx,len); } catch(std::out_of_range&) { \n" << " std::cerr << \"warning: wrong index position provided by substr(\\\"\";\n" << " std::cerr << str << \"\\\",\" << (int32_t)idx << \",\" << (int32_t)len << " "\") functor.\\n\";\n" diff --git a/tests/profile/CMakeLists.txt b/tests/profile/CMakeLists.txt index 37f37a54b4d..9ffb9c72541 100644 --- a/tests/profile/CMakeLists.txt +++ b/tests/profile/CMakeLists.txt @@ -119,6 +119,8 @@ function(SOUFFLE_POSITIVE_PROF_TEST TEST_NAME) endfunction() if (NOT MSVC) +if (NOT (APPLE AND ("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "arm64"))) souffle_positive_prof_test(lrg_attr_id) souffle_positive_prof_test(recursive) +endif() endif ()