Skip to content

Commit

Permalink
preflight: Resolve compilation issue rust 1.70 on windows (#690)
Browse files Browse the repository at this point in the history
* update

* update

* update

* update

* update

* more debug info.

* update

* update

* update

* update

* update

* cleanup

* update
  • Loading branch information
tsachiherman authored Jun 14, 2023
1 parent 8e8ee83 commit 1abb58d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
SYSTEM_TEST_RUST_TOOLCHAIN_VERSION: stable

# sets the version of soroban-js-client used by tests
SYSTEM_TEST_JS_SOROBAN_CLIENT_NPM_VERSION: "0.7.0"
SYSTEM_TEST_JS_SOROBAN_CLIENT_NPM_VERSION: "0.8.1"

# system test will build quickstart image internally to use for running the service stack
# configured in standalone network mode(core, rpc)
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/soroban-rpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,16 @@ jobs:
with:
go-version: 1.20.1

- 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 }}

# On windows, make sure we have the same compiler (linker) used by rust.
# This is important since the symbols names won't match otherwise.
- if: matrix.os == 'windows-latest'
name: Configure preflight library to use explicit rust version
name: Install the same mingw gcc compiler used by rust
run: |
cd cmd/soroban-rpc/lib/preflight
rustup override set $PREFLIGHT_RUST_VERSION-${{ matrix.rust_target }}
cd ../../../..
C:\\msys64\\usr\\bin\\pacman.exe -S mingw-w64-x86_64-gcc --noconfirm
echo "CC=C:\\msys64\\mingw64\\bin\\gcc.exe" >> $GITHUB_ENV
echo "C:\\msys64\\mingw64\\bin" >> $GITHUB_PATH
# Use cross-compiler for linux aarch64
- if: matrix.rust_target == 'aarch64-unknown-linux-gnu'
Expand All @@ -86,13 +81,18 @@ jobs:
echo 'CC=aarch64-linux-gnu-gcc-10' >> $GITHUB_ENV
- name: Build libpreflight
run: CARGO_BUILD_TARGET=${{ matrix.rust_target }} make build-libpreflight
run: make build-libpreflight
env:
CARGO_BUILD_TARGET: ${{ matrix.rust_target }}

- name: Build Soroban RPC reproducible build
run: |
CGO_ENABLED=1 GOARCH=${{ matrix.go_arch }} go build -trimpath -buildvcs=false ./cmd/soroban-rpc
go build -trimpath -buildvcs=false ./cmd/soroban-rpc
ls -lh soroban-rpc
file soroban-rpc
env:
CGO_ENABLED: 1
GOARCH: ${{ matrix.go_arch }}

integration:
name: Integration tests
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 -lm -static -lws2_32 -lbcrypt -luserenv
#cgo windows,amd64 LDFLAGS: -L${SRCDIR}/../../../../target/x86_64-pc-windows-gnu/release-with-panic-unwind/ -lpreflight -lntdll -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: 0 additions & 1 deletion cmd/soroban-rpc/lib/preflight/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name = "preflight"
version = "0.8.0"
publish = false
rust-version = "1.69"

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

0 comments on commit 1abb58d

Please sign in to comment.