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 58e3d39..5484048 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,11 +35,19 @@ 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} CFLAGS_aarch64_unknown_linux_gnu=--sysroot=/usr/aarch64-linux-gnu) + set(RUST_ENV_VARS ${RUST_ENV_VARS} CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc) + 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_INCLUDE_DIR=${CMAKE_BINARY_DIR}/vcpkg_installed/${VCPKG_TARGET_TRIPLET}/include) + set(RUST_PLATFORM_TARGET "aarch64-unknown-linux-gnu") else() set(RUST_PLATFORM_TARGET "x86_64-unknown-linux-gnu") endif() @@ -56,20 +64,33 @@ elseif("${OS_NAME}" STREQUAL "osx") endif() endif() +string(STRIP "${RUST_ENV_VARS}" RUST_ENV_VARS) + +# 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} GIT_REPOSITORY "https://github.com/nicklan/delta-kernel-rs" GIT_TAG 181232a45562ca78be763c2f5fb46b88a2463b5c - CONFIGURE_COMMAND "" + # Prints the env variables passed to the cargo build to the terminal, useful in debugging because passing them + # through CMake is an error-prone mess + CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ${RUST_UNSET_ENV_VARS} ${RUST_ENV_VARS} env 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"