From ea6f569f37651c6a370938d190877853de9accca Mon Sep 17 00:00:00 2001 From: Sam Ansmink Date: Mon, 17 Jun 2024 14:49:35 +0200 Subject: [PATCH] add linux arm64 builds --- .../workflows/MainDistributionPipeline.yml | 4 ++-- .github/workflows/_extension_distribution.yml | 8 ++++++- CMakeLists.txt | 21 ++++++++++++++++--- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/.github/workflows/MainDistributionPipeline.yml b/.github/workflows/MainDistributionPipeline.yml index d0d7916..40ff65e 100644 --- a/.github/workflows/MainDistributionPipeline.yml +++ b/.github/workflows/MainDistributionPipeline.yml @@ -18,7 +18,7 @@ jobs: with: duckdb_version: v1.0.0 extension_name: delta - exclude_archs: 'wasm_mvp;wasm_eh;wasm_threads;windows_amd64_rtools;windows_amd64;linux_arm64' + exclude_archs: 'wasm_mvp;wasm_eh;wasm_threads;windows_amd64_rtools;windows_amd64' duckdb-stable-deploy: name: Deploy extension binaries @@ -28,5 +28,5 @@ jobs: with: extension_name: delta duckdb_version: v1.0.0 - exclude_archs: 'wasm_mvp;wasm_eh;wasm_threads;windows_amd64_rtools;windows_amd64;linux_arm64' + exclude_archs: 'wasm_mvp;wasm_eh;wasm_threads;windows_amd64_rtools;windows_amd64' deploy_latest: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' }} \ No newline at end of file diff --git a/.github/workflows/_extension_distribution.yml b/.github/workflows/_extension_distribution.yml index b20bbb8..f38506e 100644 --- a/.github/workflows/_extension_distribution.yml +++ b/.github/workflows/_extension_distribution.yml @@ -140,9 +140,15 @@ jobs: ./duckdb/scripts/setup_manylinux2014.sh general aws-cli ccache ssh python_alias openssl - name: Setup Rust - if: ${{ matrix.duckdb_arch == 'linux_amd64' }} + if: ${{ matrix.duckdb_arch == 'linux_amd64'}} uses: dtolnay/rust-toolchain@stable + - name: Setup Rust for cross compilation + if: ${{ matrix.duckdb_arch == 'linux_arm64'}} + uses: dtolnay/rust-toolchain@stable + with: + targets: aarch64-unknown-linux-gnu + - name: Setup Rust for manylinux (dtolnay/rust-toolchain doesn't work due to curl being old here) if: ${{ matrix.duckdb_arch == 'linux_amd64_gcc4' }} run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index f8d12ec..0a24d70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,11 +35,17 @@ set(KERNEL_NAME delta_kernel) # Set default ExternalProject root directory set_directory_properties(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/rust) +set(RUST_ENV_VARS "") + # Propagate arch to rust build for CI set(RUST_PLATFORM_TARGET "") if("${OS_NAME}" STREQUAL "linux") if ("${OS_ARCH}" STREQUAL "arm64") set(RUST_PLATFORM_TARGET "aarch64-unknown-linux-gnu") + elseif("${CMAKE_CXX_COMPILER}" MATCHES "aarch64") + set(RUST_ENV_VARS "${RUST_ENV_VARS} OPENSSL_LIB_DIR=${CMAKE_BINARY_DIR}/vcpkg_installed/${VCPKG_TARGET_TRIPLET}/lib" + set(RUST_ENV_VARS "${RUST_ENV_VARS} OPENSSL_DIR=${CMAKE_BINARY_DIR}/vcpkg_installed/${VCPKG_TARGET_TRIPLET}/include/openssl" + set(RUST_PLATFORM_TARGET "aarch64-unknown-linux-gnu") else() set(RUST_PLATFORM_TARGET "x86_64-unknown-linux-gnu") endif() @@ -56,6 +62,9 @@ elseif("${OS_NAME}" STREQUAL "osx") endif() endif() +# Having these set will mess up cross compilation to linux arm +set(RUST_UNSET_ENV_VARS --unset=CC --unset=CXX --unset=LD) + # Add rust_example as a CMake target ExternalProject_Add( ${KERNEL_NAME} @@ -65,11 +74,17 @@ ExternalProject_Add( UPDATE_COMMAND "" BUILD_IN_SOURCE 1 # Build debug build - BUILD_COMMAND cargo build --package delta_kernel_ffi --workspace --all-features --target=${RUST_PLATFORM_TARGET} + BUILD_COMMAND + ${CMAKE_COMMAND} -E env ${RUST_UNSET_ENV_VARS} ${RUST_ENV_VARS} + cargo build --package delta_kernel_ffi --workspace --all-features --target=${RUST_PLATFORM_TARGET} # Build release build - COMMAND cargo build --package delta_kernel_ffi --workspace --all-features --release --target=${RUST_PLATFORM_TARGET} + COMMAND + ${CMAKE_COMMAND} -E env ${RUST_UNSET_ENV_VARS} ${RUST_ENV_VARS} + cargo build --package delta_kernel_ffi --workspace --all-features --release --target=${RUST_PLATFORM_TARGET} # Build DATs - COMMAND cargo build --manifest-path=${CMAKE_BINARY_DIR}/rust/src/delta_kernel/acceptance/Cargo.toml + COMMAND + ${CMAKE_COMMAND} -E env ${RUST_UNSET_ENV_VARS} ${RUST_ENV_VARS} + cargo build --manifest-path=${CMAKE_BINARY_DIR}/rust/src/delta_kernel/acceptance/Cargo.toml BUILD_BYPRODUCTS "${CMAKE_BINARY_DIR}/rust/src/delta_kernel/target/${RUST_PLATFORM_TARGET}/debug/libdelta_kernel_ffi.a" BUILD_BYPRODUCTS "${CMAKE_BINARY_DIR}/rust/src/delta_kernel/target/${RUST_PLATFORM_TARGET}/release/libdelta_kernel_ffi.a" BUILD_BYPRODUCTS "${CMAKE_BINARY_DIR}/rust/src/delta_kernel/target/ffi-headers/delta_kernel_ffi.h"