Skip to content

Commit

Permalink
fix(ci): fix static link for openssl (#18569) (#18671)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwannoel authored Sep 24, 2024
1 parent f8ad15f commit e475a15
Show file tree
Hide file tree
Showing 4 changed files with 34 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 delete-range-test)

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 @@ -127,3 +127,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
}
8 changes: 6 additions & 2 deletions ci/scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ 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 release
OPENSSL_STATIC=1 cargo build -p risingwave_cmd --bin risectl --features "rw-static-link" --profile release

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

cd target/release && chmod +x risingwave risectl

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

0 comments on commit e475a15

Please sign in to comment.