Skip to content

Commit

Permalink
soroban-rpc: fix compilation on windows (#685)
Browse files Browse the repository at this point in the history
* dummy

* test

* update

* update

* update

* update

* update

* update

* update

* update

* update

* update

* try

* update

* update

* udpate
  • Loading branch information
tsachiherman authored Jun 8, 2023
1 parent 42d9a8a commit 8569fe3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/soroban-rpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-rpc/internal/preflight/preflight.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
#include <stdlib.h>
// 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
Expand Down
1 change: 1 addition & 0 deletions cmd/soroban-rpc/lib/preflight/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "preflight"
version = "0.8.0"
publish = false
rust-version = "1.69"

[lib]
crate-type = ["staticlib"]
Expand Down

0 comments on commit 8569fe3

Please sign in to comment.