diff --git a/.github/workflows/vcpkg_ci_mac.yml b/.github/workflows/vcpkg_ci_mac.yml index d9b67f97..8e7f2bb2 100644 --- a/.github/workflows/vcpkg_ci_mac.yml +++ b/.github/workflows/vcpkg_ci_mac.yml @@ -3,7 +3,6 @@ name: MacOS Continuous Integration env: # "Source" is set in the setup-dotnet action VCPKG_BINARY_SOURCES: 'clear;nuget,Source,readwrite;nugettimeout,3601' - TRIPLET: 'x64-osx-rel' VCPKG_DEFAULT_HOST_TRIPLET: 'x64-osx-rel' on: @@ -38,11 +37,15 @@ jobs: 'llvm-14', 'llvm-15' ] + target_arch: [ + 'x64', + 'arm64' + ] runs-on: ${{ matrix.os.runner }} env: - ARTIFACT_NAME: vcpkg_${{ matrix.os.runner }}_${{ matrix.llvm }}_xcode-${{ matrix.os.xcode }}_amd64 + ARTIFACT_NAME: vcpkg_${{ matrix.os.runner }}_${{ matrix.llvm }}_xcode-${{ matrix.os.xcode }}_${{ matrix.target_arch }} steps: - uses: actions/checkout@v3 @@ -94,9 +97,10 @@ jobs: -source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \ "${{ secrets.GITHUB_TOKEN }}" - ./build_dependencies.sh --release --export-dir ./${{ env.ARTIFACT_NAME }} ${{ matrix.llvm }} --clean-after-build --debug + ./build_dependencies.sh --release --target-arch ${{ matrix.target_arch }} --export-dir ./${{ env.ARTIFACT_NAME }} ${{ matrix.llvm }} --clean-after-build --debug echo "VCPKG_ROOT=$(pwd)/${{ env.ARTIFACT_NAME }}" >> $GITHUB_ENV + echo "TARGET_TRIPLET=${{ matrix.target_arch }}-osx-rel" >> $GITHUB_ENV - name: 'Export Packages' if: contains(env.COMMIT_MESSAGE, 'debug artifacts') || github.event.release @@ -139,9 +143,9 @@ jobs: uses: actions/cache@v3 with: path: ${{ github.workspace }}/.ccache - key: ccache-${{ matrix.os.runner }}-${{ matrix.os.xcode }}-${{ matrix.llvm }}-${{ steps.ccache_prep.outputs.timestamp }} + key: ccache-${{ matrix.os.runner }}-${{ matrix.os.xcode }}-${{ matrix.llvm }}-${{ matrix.target_arch }}-${{ steps.ccache_prep.outputs.timestamp }} restore-keys: | - ccache-${{ matrix.os.runner }}-${{ matrix.os.xcode }}-${{ matrix.llvm }}- + ccache-${{ matrix.os.runner }}-${{ matrix.os.xcode }}-${{ matrix.llvm }}-$${{ matrix.target_arch }} - name: ccache Initial stats shell: bash @@ -150,39 +154,53 @@ jobs: - name: 'Rellic build' shell: 'bash' - if: ${{ matrix.llvm == 'llvm-14' }} + if: ${{ matrix.llvm == 'llvm-14' && matrix.target_arch == 'x64' }} run: | cd rellic mkdir -p build && cd build cmake -G Ninja \ -DCMAKE_VERBOSE_MAKEFILE=ON \ -DVCPKG_ROOT="${VCPKG_ROOT}" \ + -DVCPKG_TARGET_TRIPLET=${TARGET_TRIPLET} \ + -DCMAKE_OSX_ARCHITECTURES=${{ matrix.target_arch == 'x64' && 'x86_64' || matrix.target_arch }} \ -DCMAKE_INSTALL_PREFIX="$(pwd)/install" \ .. cmake --build . cmake --build . --target install - ../scripts/roundtrip.py ./tools/rellic-decomp ../tests/tools/decomp "${VCPKG_ROOT}/installed/${TRIPLET}/tools/llvm/clang" - + - name: 'Rellic test' + shell: 'bash' + if: ${{ matrix.llvm == 'llvm-14' && matrix.target_arch == 'x64' }} + run: | + # Test only should run when we're not cross compiling + cd rellic/build + ../scripts/roundtrip.py ./tools/rellic-decomp ../tests/tools/decomp "${VCPKG_ROOT}/installed/${TARGET_TRIPLET}/tools/llvm/clang" - name: 'Remill build' shell: 'bash' - if: ${{ matrix.llvm == 'llvm-14' }} + if: ${{ matrix.llvm == 'llvm-14' && matrix.target_arch == 'x64' }} run: | cd remill mkdir -p build && cd build cmake -G Ninja \ -DCMAKE_VERBOSE_MAKEFILE=ON \ -DVCPKG_ROOT="${VCPKG_ROOT}" \ + -DVCPKG_TARGET_TRIPLET=${TARGET_TRIPLET} \ + -DCMAKE_OSX_ARCHITECTURES=${{ matrix.target_arch == 'x64' && 'x86_64' || matrix.target_arch }} \ -DCMAKE_INSTALL_PREFIX="$(pwd)/install" \ .. cmake --build . cmake --build . --target install cmake --build . --target test_dependencies + - name: 'Remill test' + shell: 'bash' + if: ${{ matrix.llvm == 'llvm-14' && matrix.target_arch == 'x64' }} + run: | + # Only run test on x64 # Sometimes fails on a flaky test + cd remill/build env CTEST_OUTPUT_ON_FAILURE=1 cmake --build . --target test || true - - name: 'Anvill build' shell: 'bash' - if: ${{ matrix.llvm == 'llvm-14' }} + if: ${{ matrix.llvm == 'llvm-14' && matrix.target_arch == 'x64' }} run: | cd anvill mkdir -p build && cd build @@ -190,14 +208,21 @@ jobs: -DCMAKE_VERBOSE_MAKEFILE=ON \ -DCMAKE_INSTALL_PREFIX="$(pwd)/install" \ -DVCPKG_ROOT="${VCPKG_ROOT}" \ + -DVCPKG_TARGET_TRIPLET=${TARGET_TRIPLET} \ + -DCMAKE_OSX_ARCHITECTURES=${{ matrix.target_arch == 'x64' && 'x86_64' || matrix.target_arch }} \ -DANVILL_ENABLE_INSTALL_TARGET=ON \ -DANVILL_ENABLE_PYTHON3_LIBS=OFF \ -Dremill_DIR="$(pwd)/../../remill/build/install/lib/cmake/remill" \ .. cmake --build . cmake --build . --target install + - name: 'Anvil test' + shell: 'bash' + if: ${{ matrix.llvm == 'llvm-14' && matrix.target_arch == 'x64' }} + run: | + # Only run test on x64 + cd anvill/build ./install/bin/anvill-decompile-json -spec ../bin/Decompile/tests/specs/ret0.json -bc_out ./ret0.bc -ir_out ret0.ir - - name: Cache cleanup and reporting shell: 'bash' run: | diff --git a/build_dependencies.sh b/build_dependencies.sh index bb39d287..1ed92267 100755 --- a/build_dependencies.sh +++ b/build_dependencies.sh @@ -12,12 +12,14 @@ function die { function Help { - echo "Usage: ./build_dependencies.sh [--release] [--asan] [--upgrade-ports] [--export-dir DIR] [...]" + echo "Usage: ./build_dependencies.sh [--release] [--target-arch ARCH] [--asan] [--upgrade-ports] [--export-dir DIR] [...]" echo "" echo "Options:" echo " --release" echo " Build only release versions with triplet as detected in" echo " this script" + echo " --target-arch " + echo " Override target triplet architecture for cross compilation" echo " --asan" echo " Build with ASAN triplet as detected in this script" echo " --upgrade-ports" @@ -57,6 +59,10 @@ while [[ $# -gt 0 ]] ; do RELEASE="true" msg "Building Release-only binaries" ;; + --target-arch) + shift + TARGET_ARCH=${1} + ;; --asan) ASAN="true" msg "Building ASAN binaries" @@ -75,7 +81,7 @@ msg "Passing extra args to 'vcpkg install':" msg " " "${VCPKG_ARGS[@]}" function die_if_not_installed { - if ! type $1 &>/dev/null; then + if ! type "$1" &>/dev/null; then die "Please install the package providing [${1}] command for your OS" fi } @@ -118,7 +124,7 @@ export VCPKG_DISABLE_METRICS=1 msg "Building dependencies from source" -triplet="" +target_triplet="" extra_vcpkg_args=() extra_cmake_usage_args=() @@ -147,12 +153,16 @@ else die "Could not detect OS. OS detection required for release-only builds." fi -triplet="${triplet_arch}-${triplet_os}" +host_triplet="${triplet_arch}-${triplet_os}-rel" +if [[ -v TARGET_ARCH ]]; then + triplet_arch=${TARGET_ARCH} +fi +target_triplet="${triplet_arch}-${triplet_os}" # Build-Type triplet if [[ ${RELEASE} == "true" ]]; then msg "Only building release versions" - triplet="${triplet}-rel" + target_triplet="${target_triplet}-rel" else msg "Building Release and Debug versions" fi @@ -160,7 +170,7 @@ fi # ASAN triplet if [[ ${ASAN} == "true" ]]; then msg "Building with asan" - triplet="${triplet}-asan" + target_triplet="${target_triplet}-asan" fi repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" @@ -171,9 +181,9 @@ if [[ -z ${EXPORT_DIR} ]]; then EXPORT_DIR="${vcpkg_dir}" fi -extra_vcpkg_args+=("--triplet=${triplet}" "--host-triplet=${triplet}" "--x-install-root=${EXPORT_DIR}/installed") +extra_vcpkg_args+=("--triplet=${target_triplet}" "--host-triplet=${host_triplet}" "--x-install-root=${EXPORT_DIR}/installed") -extra_cmake_usage_args+=("-DVCPKG_TARGET_TRIPLET=${triplet}" "-DVCPKG_HOST_TRIPLET=${triplet}") +extra_cmake_usage_args+=("-DVCPKG_TARGET_TRIPLET=${target_triplet}" "-DVCPKG_HOST_TRIPLET=${host_triplet}") repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" vcpkg_info_file="${repo_dir}/vcpkg_info.txt" diff --git a/dependencies.txt b/dependencies.txt index c0ce437d..51b86e0e 100644 --- a/dependencies.txt +++ b/dependencies.txt @@ -5,7 +5,7 @@ gtest gflags protobuf abseil -grpc[absl-sync,codegen] +grpc[codegen] flatbuffers roaring rocksdb[zstd] diff --git a/ports/llvm-15/portfile.cmake b/ports/llvm-15/portfile.cmake index 68666c65..58d02ba7 100644 --- a/ports/llvm-15/portfile.cmake +++ b/ports/llvm-15/portfile.cmake @@ -96,6 +96,7 @@ list(APPEND FEATURE_OPTIONS # Force enable or disable external libraries set(llvm_external_libraries zlib + zstd libxml2 ) foreach(external_library IN LISTS llvm_external_libraries) diff --git a/ports/llvm-15/vcpkg.json b/ports/llvm-15/vcpkg.json index 639f8b0c..e02d10e3 100644 --- a/ports/llvm-15/vcpkg.json +++ b/ports/llvm-15/vcpkg.json @@ -1,6 +1,7 @@ { "name": "llvm-15", "version": "15.0.1", + "port-version": 1, "description": "The LLVM Compiler Infrastructure.", "homepage": "https://llvm.org", "license": "Apache-2.0", @@ -72,7 +73,8 @@ "enable-eh", "enable-threads", "enable-z3", - "enable-zlib" + "enable-zlib", + "enable-zstd" ] } ] @@ -191,6 +193,12 @@ "zlib" ] }, + "enable-zstd": { + "description": "Build with ZSTD.", + "dependencies": [ + "zstd" + ] + }, "enable-z3": { "description": "Compile with Z3 SMT solver support for Clang static analyzer.", "dependencies": [ diff --git a/triplets/arm64-osx-rel.cmake b/triplets/arm64-osx-rel.cmake new file mode 100644 index 00000000..22c04c9f --- /dev/null +++ b/triplets/arm64-osx-rel.cmake @@ -0,0 +1,7 @@ +set(VCPKG_TARGET_ARCHITECTURE arm64) +set(VCPKG_CRT_LINKAGE dynamic) +set(VCPKG_LIBRARY_LINKAGE static) +set(VCPKG_BUILD_TYPE release) + +set(VCPKG_CMAKE_SYSTEM_NAME Darwin) +set(VCPKG_OSX_ARCHITECTURES arm64)