From d4e4f2380c5f58892d4a4862ef08d7bc5c3ae8d9 Mon Sep 17 00:00:00 2001 From: Yihau Chen Date: Mon, 14 Oct 2024 19:11:01 +0800 Subject: [PATCH] link openssl statically for Windows (#3118) * ci: fix windows pipeline * vendor openssl for windows * add comment for the workaround (cherry picked from commit 49d22987621067ab6401140695cdd69a306e61c3) --- .github/scripts/install-all-deps.sh | 12 ++++++++++++ .github/scripts/install-openssl.sh | 18 ++++++++++++++++++ ...lippy-before-script.sh => install-proto.sh} | 2 -- .github/workflows/cargo.yml | 9 +++++++-- .github/workflows/release-artifacts.yml | 13 +++++++++---- storage-bigtable/Cargo.toml | 13 +++---------- 6 files changed, 49 insertions(+), 18 deletions(-) create mode 100755 .github/scripts/install-all-deps.sh create mode 100644 .github/scripts/install-openssl.sh rename .github/scripts/{cargo-clippy-before-script.sh => install-proto.sh} (79%) mode change 100755 => 100644 diff --git a/.github/scripts/install-all-deps.sh b/.github/scripts/install-all-deps.sh new file mode 100755 index 00000000000000..33d154453795c3 --- /dev/null +++ b/.github/scripts/install-all-deps.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -e + +here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +os_name="$1" + +# shellcheck source=.github/scripts/install-openssl.sh +source "$here/install-openssl.sh" "$os_name" +# shellcheck source=.github/scripts/install-proto.sh +source "$here/install-proto.sh" "$os_name" diff --git a/.github/scripts/install-openssl.sh b/.github/scripts/install-openssl.sh new file mode 100644 index 00000000000000..1bbcbd01a3773b --- /dev/null +++ b/.github/scripts/install-openssl.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -e + +os_name="$1" + +case "$os_name" in +"Windows") + choco install openssl --version 3.3.2 --install-arguments="'/DIR=C:\OpenSSL'" -y + export OPENSSL_LIB_DIR="C:\OpenSSL\lib\VC\x64\MT" + export OPENSSL_INCLUDE_DIR="C:\OpenSSL\include" + ;; +"macOS") ;; +"Linux") ;; +*) + echo "Unknown Operating System" + ;; +esac diff --git a/.github/scripts/cargo-clippy-before-script.sh b/.github/scripts/install-proto.sh old mode 100755 new mode 100644 similarity index 79% rename from .github/scripts/cargo-clippy-before-script.sh rename to .github/scripts/install-proto.sh index bba03060877434..478847562fdc0f --- a/.github/scripts/cargo-clippy-before-script.sh +++ b/.github/scripts/install-proto.sh @@ -6,8 +6,6 @@ os_name="$1" case "$os_name" in "Windows") - vcpkg install openssl:x64-windows-static-md - vcpkg integrate install choco install protoc export PROTOC='C:\ProgramData\chocolatey\lib\protoc\tools\bin\protoc.exe' ;; diff --git a/.github/workflows/cargo.yml b/.github/workflows/cargo.yml index e64852e42835e6..fc0d7b9418298b 100644 --- a/.github/workflows/cargo.yml +++ b/.github/workflows/cargo.yml @@ -40,11 +40,16 @@ jobs: with: version: "v0.8.1" - - shell: bash - run: .github/scripts/cargo-clippy-before-script.sh ${{ runner.os }} + # took the workaround from https://github.com/sfackler/rust-openssl/issues/2149 + - name: Set Perl environment variables + if: runner.os == 'Windows' + run: | + echo "PERL=$((where.exe perl)[0])" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 + echo "OPENSSL_SRC_PERL=$((where.exe perl)[0])" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 - shell: bash run: | + source .github/scripts/install-all-deps.sh ${{ runner.os }} source ci/rust-version.sh nightly rustup component add clippy --toolchain "$rust_nightly" scripts/cargo-clippy-nightly.sh diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml index de32cee71dfc97..ed5eab0325bda1 100644 --- a/.github/workflows/release-artifacts.yml +++ b/.github/workflows/release-artifacts.yml @@ -39,14 +39,19 @@ jobs: run: | git checkout ${{ inputs.commit }} + # took the workaround from https://github.com/sfackler/rust-openssl/issues/2149 + - name: Set Perl environment variables + run: | + echo "PERL=$((where.exe perl)[0])" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 + echo "OPENSSL_SRC_PERL=$((where.exe perl)[0])" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 + - name: Build id: build shell: bash run: | - vcpkg install openssl:x64-windows-static-md - vcpkg integrate install - choco install protoc - export PROTOC="C:\ProgramData\chocolatey\lib\protoc\tools\bin\protoc.exe" + # install all deps + source .github/scripts/install-all-deps.sh ${{ runner.os }} + source /tmp/env.sh echo "tag=$CI_TAG" >> $GITHUB_OUTPUT eval "$(ci/channel-info.sh)" diff --git a/storage-bigtable/Cargo.toml b/storage-bigtable/Cargo.toml index fafacf0292da72..4234cf3eec234a 100644 --- a/storage-bigtable/Cargo.toml +++ b/storage-bigtable/Cargo.toml @@ -22,6 +22,9 @@ http = { workspace = true } hyper = { workspace = true } hyper-proxy = { workspace = true } log = { workspace = true } +# openssl is a dependency of the goauth and smpl_jwt crates, but explicitly +# declare it here as well to activate the "vendored" feature that builds OpenSSL +openssl = { workspace = true, features = ["vendored"] } prost = { workspace = true } prost-types = { workspace = true } serde = { workspace = true } @@ -36,16 +39,6 @@ tokio = { workspace = true } tonic = { workspace = true, features = ["tls", "transport"] } zstd = { workspace = true } -# openssl is a dependency of the goauth and smpl_jwt crates, but explicitly -# declare it here as well to activate the "vendored" feature that builds OpenSSL -# statically... -[target."cfg(not(windows))".dependencies] -openssl = { workspace = true, features = ["vendored"] } -# ...except on Windows to avoid having to deal with getting CI past a build-time -# Perl dependency -[target."cfg(windows)".dependencies] -openssl = { workspace = true, features = [] } - [lib] crate-type = ["lib"] name = "solana_storage_bigtable"