From 6683426bab099cabbdc4fc8534cf8a9c9ac8a460 Mon Sep 17 00:00:00 2001 From: darshankabariya Date: Wed, 15 Oct 2025 22:56:53 +0530 Subject: [PATCH] chore: macos ci failure --- .github/workflows/ci.yml | 31 +++++++++++++++++++++++++------ Makefile | 3 ++- scripts/build_rln.sh | 34 ++++++++++++++++++++++++++++++++-- 3 files changed, 59 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5cf64b66a..c55d85b6e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,10 +55,17 @@ jobs: fail-fast: false matrix: os: [ubuntu-22.04, macos-15] + arch: [amd64] + exclude: + - os: macos-15 + arch: amd64 + include: + - os: macos-15 + arch: arm64 runs-on: ${{ matrix.os }} timeout-minutes: 45 - name: build-${{ matrix.os }} + name: build-${{ matrix.os }}-${{ matrix.arch }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -74,10 +81,12 @@ jobs: path: | vendor/ .git/modules - key: ${{ runner.os }}-vendor-modules-${{ steps.submodules.outputs.hash }} + key: ${{ runner.os }}-${{ matrix.arch }}-vendor-modules-${{ steps.submodules.outputs.hash }} - name: Build binaries - run: make V=1 QUICK_AND_DIRTY_COMPILER=1 all tools + run: | + OS=$([[ "${{runner.os}}" == "macOS" ]] && echo "macosx" || echo "linux") + make V=1 QUICK_AND_DIRTY_COMPILER=1 NIMFLAGS="-d:disableMarchNative --os:${OS} --cpu:${{matrix.arch}}" LIBRLN_TARGET_ARCH=${{matrix.arch}} all tools build-windows: needs: changes @@ -93,10 +102,17 @@ jobs: fail-fast: false matrix: os: [ubuntu-22.04, macos-15] + arch: [amd64] + exclude: + - os: macos-15 + arch: amd64 + include: + - os: macos-15 + arch: arm64 runs-on: ${{ matrix.os }} timeout-minutes: 45 - name: test-${{ matrix.os }} + name: test-${{ matrix.os }}-${{ matrix.arch }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -112,7 +128,7 @@ jobs: path: | vendor/ .git/modules - key: ${{ runner.os }}-vendor-modules-${{ steps.submodules.outputs.hash }} + key: ${{ runner.os }}-${{ matrix.arch }}-vendor-modules-${{ steps.submodules.outputs.hash }} - name: Run tests run: | @@ -123,8 +139,11 @@ jobs: fi export MAKEFLAGS="-j1" - export NIMFLAGS="--colors:off -d:chronicles_colors:none" export USE_LIBBACKTRACE=0 + export LIBRLN_TARGET_ARCH=${{matrix.arch}} + + OS=$([[ "${{runner.os}}" == "macOS" ]] && echo "macosx" || echo "linux") + export NIMFLAGS="--colors:off -d:chronicles_colors:none -d:disableMarchNative --os:${OS} --cpu:${{matrix.arch}}" make V=1 LOG_LEVEL=DEBUG QUICK_AND_DIRTY_COMPILER=1 POSTGRES=$postgres_enabled test make V=1 LOG_LEVEL=DEBUG QUICK_AND_DIRTY_COMPILER=1 POSTGRES=$postgres_enabled testwakunode2 diff --git a/Makefile b/Makefile index 37341792c..6c7ef5d53 100644 --- a/Makefile +++ b/Makefile @@ -178,6 +178,7 @@ nimbus-build-system-nimble-dir: LIBRLN_BUILDDIR := $(CURDIR)/vendor/zerokit LIBRLN_VERSION := v0.9.0 +LIBRLN_TARGET_ARCH ?= ifeq ($(detected_OS),Windows) LIBRLN_FILE := rln.lib @@ -187,7 +188,7 @@ endif $(LIBRLN_FILE): echo -e $(BUILD_MSG) "$@" && \ - ./scripts/build_rln.sh $(LIBRLN_BUILDDIR) $(LIBRLN_VERSION) $(LIBRLN_FILE) + ./scripts/build_rln.sh $(LIBRLN_BUILDDIR) $(LIBRLN_VERSION) $(LIBRLN_FILE) $(LIBRLN_TARGET_ARCH) librln: | $(LIBRLN_FILE) $(eval NIM_PARAMS += --passL:$(LIBRLN_FILE) --passL:-lm) diff --git a/scripts/build_rln.sh b/scripts/build_rln.sh index 5e1b0caa5..17588f9fe 100755 --- a/scripts/build_rln.sh +++ b/scripts/build_rln.sh @@ -9,6 +9,7 @@ set -e build_dir=$1 rln_version=$2 output_filename=$3 +target_arch=$4 # Optional: target architecture (e.g., amd64, arm64) [[ -z "${build_dir}" ]] && { echo "No build directory specified"; exit 1; } [[ -z "${rln_version}" ]] && { echo "No rln version specified"; exit 1; } @@ -17,6 +18,28 @@ output_filename=$3 # Get the host triplet host_triplet=$(rustc --version --verbose | awk '/host:/{print $2}') +# If target architecture is specified, map it to the appropriate rust target triplet +if [[ -n "${target_arch}" ]]; then + detected_OS=$(uname -s) + case "${detected_OS}" in + Darwin) + if [[ "${target_arch}" == "arm64" || "${target_arch}" == "aarch64" ]]; then + host_triplet="aarch64-apple-darwin" + elif [[ "${target_arch}" == "amd64" || "${target_arch}" == "x86_64" ]]; then + host_triplet="x86_64-apple-darwin" + fi + ;; + Linux) + if [[ "${target_arch}" == "arm64" || "${target_arch}" == "aarch64" ]]; then + host_triplet="aarch64-unknown-linux-gnu" + elif [[ "${target_arch}" == "amd64" || "${target_arch}" == "x86_64" ]]; then + host_triplet="x86_64-unknown-linux-gnu" + fi + ;; + esac + echo "Target architecture specified: ${target_arch}, using triplet: ${host_triplet}" +fi + tarball="${host_triplet}" tarball+="-rln.tar.gz" @@ -49,6 +72,13 @@ else exit 1 fi # if submodule version = version in Makefile, build rln - cargo build --release -p rln --manifest-path "${build_dir}/rln/Cargo.toml" - cp "${build_dir}/target/release/librln.a" "${output_filename}" + # Determine the target directory based on whether we're cross-compiling + if [[ -n "${target_arch}" ]]; then + # Extract the rust target from host_triplet (which was already adjusted above if target_arch was set) + cargo build --release -p rln --manifest-path "${build_dir}/rln/Cargo.toml" --target "${host_triplet}" + cp "${build_dir}/target/${host_triplet}/release/librln.a" "${output_filename}" + else + cargo build --release -p rln --manifest-path "${build_dir}/rln/Cargo.toml" + cp "${build_dir}/target/release/librln.a" "${output_filename}" + fi fi