Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3a7a729
add cross compilation support to build_dependencies.sh script
Ninja3047 Aug 4, 2022
4a4243f
Update vcpkg to fix grpc cross compile
ekilmer Aug 5, 2022
b64da00
Make host triplet the release-only triplet
ekilmer Aug 5, 2022
4bf4602
specify system name for cross compilation
Ninja3047 Aug 8, 2022
49f015e
bump remill/rellic to fix cross compilation bug with z3
Ninja3047 Aug 8, 2022
64c4e6f
disable remill/rellic/anvil build on non x64
Ninja3047 Aug 8, 2022
9786f96
remove explicit CMAKE_SYSTEM_NAME to avoid triggering cross compilation
Ninja3047 Aug 10, 2022
a32a0be
Use latest vcpkg commit
ekilmer Aug 10, 2022
ffc7498
Fix protobuf cross compile (ekilmer branch)
ekilmer Aug 11, 2022
da33c57
Revert "bump remill/rellic to fix cross compilation bug with z3"
Ninja3047 Aug 24, 2022
6bc9013
debug artifacts
Ninja3047 Aug 24, 2022
4f31b74
Fix flatc targets. debug artifacts
ekilmer Aug 29, 2022
13391c2
remove host compiled artifacts if the target and host do not match, d…
Ninja3047 Sep 1, 2022
e87dfbe
add back aws to ci
Ninja3047 Sep 1, 2022
3d8a9f2
Merge remote-tracking branch 'origin' into will/cross-compile-for-m1-…
Ninja3047 Sep 29, 2022
a9c0350
debug artifacts
Ninja3047 Sep 30, 2022
c43e281
revert remove host artifacts, debug artifacts
Ninja3047 Sep 30, 2022
2f8601e
Merge branch 'master' into will/cross-compile-for-m1-in-ci
ekilmer Oct 4, 2022
4070ac1
Fix conditional for remill test on mac
ekilmer Oct 5, 2022
3c1babd
Fix anvill test conditional
ekilmer Oct 5, 2022
0d1fc65
Merge branch 'master' into will/cross-compile-for-m1-in-ci
ekilmer Oct 12, 2022
393597a
Fix LLVM-15 for cross-compilation
ekilmer Oct 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 37 additions & 12 deletions .github/workflows/vcpkg_ci_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -150,54 +154,75 @@ 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
cmake -G Ninja \
-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: |
Expand Down
26 changes: 18 additions & 8 deletions build_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ARCH>"
echo " Override target triplet architecture for cross compilation"
echo " --asan"
echo " Build with ASAN triplet as detected in this script"
echo " --upgrade-ports"
Expand Down Expand Up @@ -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"
Expand All @@ -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
}
Expand Down Expand Up @@ -118,7 +124,7 @@ export VCPKG_DISABLE_METRICS=1

msg "Building dependencies from source"

triplet=""
target_triplet=""
extra_vcpkg_args=()
extra_cmake_usage_args=()

Expand Down Expand Up @@ -147,20 +153,24 @@ 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

# 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)"
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ gtest
gflags
protobuf
abseil
grpc[absl-sync,codegen]
grpc[codegen]
flatbuffers
roaring
rocksdb[zstd]
Expand Down
1 change: 1 addition & 0 deletions ports/llvm-15/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion ports/llvm-15/vcpkg.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -72,7 +73,8 @@
"enable-eh",
"enable-threads",
"enable-z3",
"enable-zlib"
"enable-zlib",
"enable-zstd"
]
}
]
Expand Down Expand Up @@ -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": [
Expand Down
7 changes: 7 additions & 0 deletions triplets/arm64-osx-rel.cmake
Original file line number Diff line number Diff line change
@@ -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)