-
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
Changes from 10 commits
1dae958
4904081
34ed3c1
898df58
7c12bbf
89b1595
95e96f4
5802344
a518f88
df8cd18
5099ffa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#!/bin/bash | ||
|
||
# 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 and run a simple test program | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah no if it has a use thats totally fine, thx |
||
|
||
# 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 the source code | ||
wget $ZSTD_URL | ||
|
||
# Extract the tarball | ||
tar -xzf zstd-$ZSTD_VERSION.tar.gz | ||
cd zstd-$ZSTD_VERSION | ||
|
||
# Build zstd with -fPIC flag for both static and dynamic libraries | ||
CFLAGS="-fPIC" make | ||
uditagarwal97 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
if [ $? -ne 0 ]; then | ||
echo "Error: make failed." | ||
exit 1 | ||
fi | ||
|
||
# Optionally, 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 |
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.
could we maybe add a link to the ubuntu bug report so we can check to remove this in the future?
Uh oh!
There was an error while loading. Please reload this page.
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've added the link to intel/llvm bug report instead: #15935
I'll likely have to open another bug report to Debian (as suggested here: https://bugs.launchpad.net/ubuntu/+source/libzstd/+bug/2086543/comments/3).
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.
sure, thx