-
Notifications
You must be signed in to change notification settings - Fork 794
[CI] Build zstd for release build container #20445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
232afaa
[CI] Build zstd for release build container
KornevNikita 94be7b8
build with -fPIE
KornevNikita 285ed2b
do not use cd trivy is angry
KornevNikita ff1a9b5
use script instead
KornevNikita dc3532c
drop paths-ignore
KornevNikita e0eaca7
update GetStartedGuide
KornevNikita e6807ff
fix jenkins
KornevNikita File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Script to build and install zstd on Ubuntu 24, with -fPIC flag. | ||
| # The default installation of zstd on Ubuntu 24 does not have -fPIC flag | ||
| # enabled, which is required for building DPC++ in shared libraries mode. | ||
|
|
||
| # OR on Rocky Linux 8.10 (used for nightly release builds). There is no static | ||
| # library (libzstd.a) in available packages, therefore it is necessary to build | ||
| # it from source. | ||
|
|
||
| # Function to check OS | ||
| check_os() { | ||
| local expected_name="$1" | ||
| local expected_version="$2" | ||
| . /etc/os-release | ||
| if [[ "$NAME" == "$expected_name" && "$VERSION_ID" == "$expected_version" ]]; then | ||
| return 0 | ||
| else | ||
| return 1 | ||
| fi | ||
| } | ||
|
|
||
| # Function to install packages with or without sudo | ||
| install_packages() { | ||
| if [ "$USE_SUDO" = true ]; then | ||
| sudo apt-get update | ||
| sudo apt-get install -y build-essential wget | ||
| else | ||
| apt-get update | ||
| apt-get install -y build-essential wget | ||
| fi | ||
| } | ||
|
|
||
| # Function to uninstall libzstd-dev if installed | ||
| uninstall_libzstd_dev() { | ||
| if dpkg -l | grep -q libzstd-dev; then | ||
| if [ "$USE_SUDO" = true ]; then | ||
| sudo apt-get remove -y libzstd-dev | ||
| else | ||
| apt-get remove -y libzstd-dev | ||
| fi | ||
| fi | ||
| } | ||
|
|
||
| # Function to build a shared library by linking zstd static lib. | ||
| # This is used to verify that zstd is built correctly, with -fPIC flag. | ||
| build_test_program() { | ||
| cat <<EOF > test_zstd.c | ||
| #include <zstd.h> | ||
| int main() { | ||
| ZSTD_CCtx* cctx = ZSTD_createCCtx(); | ||
| ZSTD_freeCCtx(cctx); | ||
| return 0; | ||
| } | ||
| EOF | ||
|
|
||
| # Try to use zstd's static library with -fPIC | ||
| gcc test_zstd.c -lzstd -fPIC -shared | ||
| if [ $? -ne 0 ]; then | ||
| echo "zstd installation verification failed." | ||
| else | ||
| echo "zstd installation verification passed." | ||
| fi | ||
|
|
||
| # There won't be a.out file if verification failed. | ||
| rm test_zstd.c a.out || true | ||
| } | ||
|
|
||
| # Check the OS | ||
| if ! check_os "Ubuntu" "24.04" && ! check_os "Rocky Linux" "8.10"; then | ||
| echo "Warning: This script has only been tested with Ubuntu 24.04 and Rocky Linux 8.10." | ||
| fi | ||
|
|
||
| # Set USE_SUDO to true or false based on your preference | ||
| USE_SUDO=true | ||
|
|
||
| # Install necessary build tools & uninstall libzstd-dev package if installed | ||
| if check_os "Ubuntu" "24.04"; then | ||
| install_packages | ||
| uninstall_libzstd_dev | ||
| fi | ||
|
|
||
| # Define the version and URL for zstd | ||
| ZSTD_VERSION="1.5.7" | ||
| ZSTD_URL="https://github.com/facebook/zstd/releases/download/v$ZSTD_VERSION/zstd-$ZSTD_VERSION.tar.gz" | ||
|
|
||
| # Create a directory for the source code | ||
| mkdir -p zstd_build | ||
| cd zstd_build | ||
|
|
||
| # Download and extract zstd source code | ||
| wget $ZSTD_URL | ||
| tar -xzf zstd-$ZSTD_VERSION.tar.gz | ||
| cd zstd-$ZSTD_VERSION | ||
|
|
||
| # Build zstd with -fPIC flag. | ||
| CFLAGS="-fPIC" CXXFLAGS="-fPIC" make | ||
| if [ $? -ne 0 ]; then | ||
| echo "Error: make failed." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Install zstd. | ||
| if [ "$USE_SUDO" = true ]; then | ||
| sudo make install | ||
| else | ||
| make install | ||
| fi | ||
| if [ $? -ne 0 ]; then | ||
| echo "Error: make install failed." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Verify zstd installation. | ||
| build_test_program | ||
|
|
||
| # Clean up | ||
| rm -rf zstd_build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.