-
Notifications
You must be signed in to change notification settings - Fork 791
[CI] Fix shared build on Ubuntu 24 #16595
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
11 commits
Select commit
Hold shift + click to select a range
1dae958
[CI] Fix shared build on Ubuntu 24
uditagarwal97 4904081
Cleanup
uditagarwal97 34ed3c1
Change permission of build_zstd_1_5_6_ub24.sh
uditagarwal97 898df58
Use Ubuntu 24 docker container for build
uditagarwal97 7c12bbf
More experiments
uditagarwal97 89b1595
More experiment
uditagarwal97 95e96f4
More experiments
uditagarwal97 5802344
More experiments
uditagarwal97 a518f88
More experiments
uditagarwal97 df8cd18
Revert experimental changes.
uditagarwal97 5099ffa
Address reviews. Add/fix comments in script
uditagarwal97 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#!/bin/bash | ||
|
||
# Script to build and install zstd 1.5.6 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. | ||
|
||
# Function to check if the OS is Ubuntu 24 | ||
check_os() { | ||
. /etc/os-release | ||
if [[ "$NAME" != "Ubuntu" || "$VERSION_ID" != "24.04" ]]; then | ||
echo "Warning: This script has only been tested with Ubuntu 24." | ||
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 | ||
check_os | ||
|
||
# Set USE_SUDO to true or false based on your preference | ||
USE_SUDO=true | ||
|
||
# Install necessary build tools | ||
install_packages | ||
|
||
# Uninstall libzstd-dev package if installed | ||
uninstall_libzstd_dev | ||
|
||
# Define the version and URL for zstd | ||
ZSTD_VERSION="1.5.6" | ||
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 |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we're always using sudo can we just use it directly without this var?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a slight preference towards keeping this variable because it makes it a lot easier for me to test this script internally using podman (which requires not using
sudo
). I can remove this variable if you strongly feel so.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah no if it has a use thats totally fine, thx