From 8569fe3e4b326907cda5055cffd880d30bc4593c Mon Sep 17 00:00:00 2001 From: Tsachi Herman <24438559+tsachiherman@users.noreply.github.com> Date: Thu, 8 Jun 2023 09:43:41 -0400 Subject: [PATCH] soroban-rpc: fix compilation on windows (#685) * dummy * test * update * update * update * update * update * update * update * update * update * update * try * update * update * udpate --- .github/workflows/soroban-rpc.yml | 9 ++++++++- cmd/soroban-rpc/internal/preflight/preflight.go | 2 +- cmd/soroban-rpc/lib/preflight/Cargo.toml | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/soroban-rpc.yml b/.github/workflows/soroban-rpc.yml index 01d7d4ea7..d2745d523 100644 --- a/.github/workflows/soroban-rpc.yml +++ b/.github/workflows/soroban-rpc.yml @@ -61,7 +61,14 @@ jobs: with: go-version: 1.20.1 - - run: rustup update + - if: matrix.os == 'windows-latest' + name: Find the minimal supported rust version on windows + run: | + preflight_rust_version=$(sed -n 's/.*rust-version = "\(.*\)"/\1/p' cmd/soroban-rpc/lib/preflight/Cargo.toml) + echo "PREFLIGHT_RUST_VERSION=$preflight_rust_version" >> $GITHUB_ENV + - name: Update rust toolchain as needed + run: | + rustup update $PREFLIGHT_RUST_VERSION - run: rustup target add ${{ matrix.rust_target }} # Use cross-compiler for linux aarch64 diff --git a/cmd/soroban-rpc/internal/preflight/preflight.go b/cmd/soroban-rpc/internal/preflight/preflight.go index 4b1dc4024..b7919f31b 100644 --- a/cmd/soroban-rpc/internal/preflight/preflight.go +++ b/cmd/soroban-rpc/internal/preflight/preflight.go @@ -18,7 +18,7 @@ import ( #include // This assumes that the Rust compiler should be using a -gnu target (i.e. MinGW compiler) in Windows // (I (fons) am not even sure if CGo supports MSVC, see https://github.com/golang/go/issues/20982) -#cgo windows,amd64 LDFLAGS: -L${SRCDIR}/../../../../target/x86_64-pc-windows-gnu/release-with-panic-unwind/ -lpreflight -ldl -lm -static -lws2_32 -lbcrypt -luserenv +#cgo windows,amd64 LDFLAGS: -L${SRCDIR}/../../../../target/x86_64-pc-windows-gnu/release-with-panic-unwind/ -lpreflight -lm -static -lws2_32 -lbcrypt -luserenv // You cannot compile with -static in macOS (and it's not worth it in Linux, at least with glibc) #cgo darwin,amd64 LDFLAGS: -L${SRCDIR}/../../../../target/x86_64-apple-darwin/release-with-panic-unwind/ -lpreflight -ldl -lm #cgo darwin,arm64 LDFLAGS: -L${SRCDIR}/../../../../target/aarch64-apple-darwin/release-with-panic-unwind/ -lpreflight -ldl -lm diff --git a/cmd/soroban-rpc/lib/preflight/Cargo.toml b/cmd/soroban-rpc/lib/preflight/Cargo.toml index e448b6964..0817b0fcf 100644 --- a/cmd/soroban-rpc/lib/preflight/Cargo.toml +++ b/cmd/soroban-rpc/lib/preflight/Cargo.toml @@ -2,6 +2,7 @@ name = "preflight" version = "0.8.0" publish = false +rust-version = "1.69" [lib] crate-type = ["staticlib"]