Skip to content

Commit

Permalink
fix(ci): fix static link for openssl (#18569)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwannoel authored Sep 18, 2024
1 parent 25b0cc9 commit da08cd5
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
6 changes: 3 additions & 3 deletions ci/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ if [[ "$profile" == "ci-dev" ]]; then
RISINGWAVE_FEATURE_FLAGS=(--features rw-dynamic-link --no-default-features)
else
RISINGWAVE_FEATURE_FLAGS=(--features rw-static-link)
export OPENSSL_STATIC=1
configure_static_openssl
fi

cargo build \
Expand All @@ -62,8 +62,8 @@ cargo build \

artifacts=(risingwave sqlsmith compaction-test risingwave_regress_test risingwave_e2e_extended_mode_test risedev-dev)

echo "--- Show link info"
ldd target/"$profile"/risingwave
echo "--- Check link info"
check_link_info "$profile"

echo "--- Upload artifacts"
echo -n "${artifacts[*]}" | parallel -d ' ' "mv target/$profile/{} ./{}-$profile && compress-and-upload-artifact ./{}-$profile"
Expand Down
9 changes: 6 additions & 3 deletions ci/scripts/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ done

source ci/scripts/common.sh

echo "--- Set openssl static link env vars"
configure_static_openssl

echo "--- Run trailing spaces check"
scripts/check/check-trailing-spaces.sh

Expand All @@ -28,11 +31,11 @@ sccache --show-stats
sccache --zero-stats

echo "--- Run clippy check (release)"
OPENSSL_STATIC=1 cargo clippy --release --all-targets --features "rw-static-link" --locked -- -D warnings
cargo clippy --release --all-targets --features "rw-static-link" --locked -- -D warnings

echo "--- Run cargo check on building the release binary (release)"
OPENSSL_STATIC=1 cargo check -p risingwave_cmd_all --features "rw-static-link" --profile release
OPENSSL_STATIC=1 cargo check -p risingwave_cmd --bin risectl --features "rw-static-link" --profile release
cargo check -p risingwave_cmd_all --features "rw-static-link" --profile release
cargo check -p risingwave_cmd --bin risectl --features "rw-static-link" --profile release

echo "--- Show sccache stats"
sccache --show-stats
Expand Down
19 changes: 19 additions & 0 deletions ci/scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,22 @@ get_latest_cassandra_download_url() {
local download_url="https://downloads.apache.org/cassandra/${latest_version}/apache-cassandra-${latest_version}-bin.tar.gz"
echo "$download_url"
}

configure_static_openssl() {
export OPENSSL_STATIC=1
export OPENSSL_LIB_DIR="$(dpkg -L libssl-dev | grep libssl.a | xargs dirname)"
export OPENSSL_INCLUDE_DIR="$(dpkg -L libssl-dev | grep openssl/ssl.h | xargs dirname)"
echo "OPENSSL_STATIC: $OPENSSL_STATIC"
echo "OPENSSL_LIB_DIR: $OPENSSL_LIB_DIR"
echo "OPENSSL_INCLUDE_DIR: $OPENSSL_INCLUDE_DIR"
}

check_link_info() {
ldd_output=$(ldd target/"$1"/risingwave)
echo "$ldd_output"
# enforce that libssl is not present if we are building with static openssl
if [[ "$profile" == "ci-release" ]] && [[ "$ldd_output" == *"libssl"* ]]; then
echo "libssl should not be dynamically linked"
exit 1
fi
}
10 changes: 8 additions & 2 deletions ci/scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,14 @@ if [ "${ARCH}" == "aarch64" ]; then
# see https://github.com/tikv/jemallocator/blob/802969384ae0c581255f3375ee2ba774c8d2a754/jemalloc-sys/build.rs#L218
export JEMALLOC_SYS_WITH_LG_PAGE=16
fi
OPENSSL_STATIC=1 cargo build -p risingwave_cmd_all --features "rw-static-link" --features external-udf --features wasm-udf --features js-udf --profile production
OPENSSL_STATIC=1 cargo build -p risingwave_cmd --bin risectl --features "rw-static-link" --profile production

configure_static_openssl

cargo build -p risingwave_cmd_all --features "rw-static-link" --features external-udf --features wasm-udf --features js-udf --profile production
cargo build -p risingwave_cmd --bin risectl --features "rw-static-link" --profile production

check_link_info production

cd target/production && chmod +x risingwave risectl

echo "--- Upload nightly binary to s3"
Expand Down

0 comments on commit da08cd5

Please sign in to comment.