From 443de06756b7f29c9b00b9ce069035c6cfd1e969 Mon Sep 17 00:00:00 2001 From: Akash Anand Date: Fri, 31 Oct 2025 11:45:58 +0000 Subject: [PATCH 1/2] Fix: Resolve CI failure during aarch64-linux native build --- .github/workflows/build-native-binaries.yml | 13 ++++++++-- spannerlib/wrappers/spannerlib-ruby/Rakefile | 27 ++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-native-binaries.yml b/.github/workflows/build-native-binaries.yml index 4d59d219..8e00e327 100644 --- a/.github/workflows/build-native-binaries.yml +++ b/.github/workflows/build-native-binaries.yml @@ -50,8 +50,17 @@ jobs: if: matrix.os == 'ubuntu-latest' run: | sudo apt-get update - # This installs the C compiler for aarch64-linux - sudo apt-get install -y gcc-aarch64-linux-gnu + # GCC cross toolchain and binutils for aarch64 + sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu + # Mingw-w64 cross toolchain for Windows target (x86_64) + sudo apt-get install -y gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 + # Verify tools exist (helps debugging CI failures) + echo "=== cross compiler versions ===" + aarch64-linux-gnu-gcc --version || true + aarch64-linux-gnu-g++ --version || true + x86_64-w64-mingw32-gcc --version || true + which aarch64-linux-gnu-gcc || true + which x86_64-w64-mingw32-gcc || true # The cross-compiler step for macOS is removed, # as the built-in Clang on macOS runners can handle both Intel and ARM. diff --git a/spannerlib/wrappers/spannerlib-ruby/Rakefile b/spannerlib/wrappers/spannerlib-ruby/Rakefile index f5a1d24f..bb9d0eac 100644 --- a/spannerlib/wrappers/spannerlib-ruby/Rakefile +++ b/spannerlib/wrappers/spannerlib-ruby/Rakefile @@ -71,6 +71,33 @@ namespace :compile do "CGO_ENABLED" => "1" # Ensure CGO is enabled for c-shared } + # Set platform-specific C toolchain environment vars so cgo invokes the correct compiler/assembler/linker. + case config[:goos] + when "linux" + if config[:goarch] == "arm64" || config[:goarch] == "arm" || arch.include?("aarch64") + # Use the aarch64 cross-compiler installed via apt (aarch64-linux-gnu-*) + env["CC"] = ENV.fetch("CC", "aarch64-linux-gnu-gcc") + env["CXX"] = ENV.fetch("CXX", "aarch64-linux-gnu-g++") + env["AR"] = ENV.fetch("AR", "aarch64-linux-gnu-ar") + env["RANLIB"] = ENV.fetch("RANLIB", "aarch64-linux-gnu-ranlib") + else + # For x86_64 linux, host gcc should work on linux runners + env["CC"] ||= ENV.fetch("CC", "gcc") + end + when "windows" + # Use mingw-w64 cross compiler binaries (installed via apt on linux) + if config[:goarch] == "amd64" || arch.include?("mingw") || arch.include?("x64") + env["CC"] = ENV.fetch("CC", "x86_64-w64-mingw32-gcc") + env["CXX"] = ENV.fetch("CXX", "x86_64-w64-mingw32-g++") + env["AR"] = ENV.fetch("AR", "x86_64-w64-mingw32-ar") + env["RANLIB"] = ENV.fetch("RANLIB", "x86_64-w64-mingw32-ranlib") + end + when "darwin" + # Note: cross-compiling darwin/arm64 on an x86 mac runner is NOT reliably supported + # unless you use osxcross or an ARM mac runner. We try nothing here; rely on runner's clang. + env["CC"] ||= ENV.fetch("CC", "clang") + end + command = [ "go", "build", "-buildmode=c-shared", From 26e99e7c3d31d76f63a9a648c7876b0933de8d49 Mon Sep 17 00:00:00 2001 From: Akash Anand Date: Fri, 31 Oct 2025 12:30:00 +0000 Subject: [PATCH 2/2] chore(ruby): fixed naming for ruby wrapper gem workflow --- .../{build-native-binaries.yml => release-ruby-wrapper.yml} | 5 ++--- .../wrappers/spannerlib-ruby/lib/spannerlib/ruby/version.rb | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) rename .github/workflows/{build-native-binaries.yml => release-ruby-wrapper.yml} (97%) diff --git a/.github/workflows/build-native-binaries.yml b/.github/workflows/release-ruby-wrapper.yml similarity index 97% rename from .github/workflows/build-native-binaries.yml rename to .github/workflows/release-ruby-wrapper.yml index 8e00e327..f213cdda 100644 --- a/.github/workflows/build-native-binaries.yml +++ b/.github/workflows/release-ruby-wrapper.yml @@ -1,10 +1,10 @@ -name: Build and Publish Native Gem +name: Build and Publish Native Ruby Gem on: workflow_dispatch: jobs: - build: + build-shared-library-binaries: strategy: matrix: os: [ubuntu-latest, macos-13, windows-latest] @@ -54,7 +54,6 @@ jobs: sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu # Mingw-w64 cross toolchain for Windows target (x86_64) sudo apt-get install -y gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 - # Verify tools exist (helps debugging CI failures) echo "=== cross compiler versions ===" aarch64-linux-gnu-gcc --version || true aarch64-linux-gnu-g++ --version || true diff --git a/spannerlib/wrappers/spannerlib-ruby/lib/spannerlib/ruby/version.rb b/spannerlib/wrappers/spannerlib-ruby/lib/spannerlib/ruby/version.rb index 100ee429..4ba1aeb0 100644 --- a/spannerlib/wrappers/spannerlib-ruby/lib/spannerlib/ruby/version.rb +++ b/spannerlib/wrappers/spannerlib-ruby/lib/spannerlib/ruby/version.rb @@ -2,6 +2,6 @@ module Spannerlib module Ruby - VERSION = "0.1.0" + VERSION = "0.1.0.alpha1" end end