Skip to content

Commit 1dae958

Browse files
committed
[CI] Fix shared build on Ubuntu 24
1 parent 1677043 commit 1dae958

File tree

3 files changed

+125
-0
lines changed

3 files changed

+125
-0
lines changed

.github/workflows/sycl-nightly.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
build_cache_root: "/__w/"
3333
build_cache_suffix: sprod_shared
3434
build_artifact_suffix: sprod_shared
35+
build_image: ghcr.io/intel/llvm/ubuntu2404_build:latest
3536
build_configure_extra_args: '--shared-libs --hip --cuda --native_cpu'
3637
merge_ref: ''
3738

devops/containers/ubuntu2404_base.Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ USER root
88
COPY scripts/install_build_tools.sh /install.sh
99
RUN /install.sh
1010

11+
# Build zstd from sources with -fPIC flag.
12+
COPY scripts/build_zstd_1_5_6_ub24.sh /build_zstd_1_5_6_ub24.sh
13+
RUN /build_zstd_1_5_6_ub24.sh
14+
1115
COPY scripts/create-sycl-user.sh /user-setup.sh
1216
RUN /user-setup.sh
1317

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#!/bin/bash
2+
3+
# Function to check if the OS is Ubuntu 24
4+
check_os() {
5+
. /etc/os-release
6+
if [[ "$NAME" != "Ubuntu" || "$VERSION_ID" != "24.04" ]]; then
7+
echo "Warning: This script has only been tested with Ubuntu 24."
8+
exit 1
9+
fi
10+
}
11+
12+
# Function to install packages with or without sudo
13+
install_packages() {
14+
if [ "$USE_SUDO" = true ]; then
15+
sudo apt-get update
16+
sudo apt-get install -y build-essential wget
17+
else
18+
apt-get update
19+
apt-get install -y build-essential wget
20+
fi
21+
}
22+
23+
# Function to check if zstd is built correctly
24+
check_zstd() {
25+
if command -v zstd &> /dev/null; then
26+
echo "zstd has been built and installed successfully!"
27+
else
28+
echo "Error: zstd was not built correctly."
29+
exit 1
30+
fi
31+
}
32+
33+
# Function to uninstall libzstd-dev if installed
34+
uninstall_libzstd_dev() {
35+
if dpkg -l | grep -q libzstd-dev; then
36+
if [ "$USE_SUDO" = true ]; then
37+
sudo apt-get remove -y libzstd-dev
38+
else
39+
apt-get remove -y libzstd-dev
40+
fi
41+
fi
42+
}
43+
44+
# Function to build and run a simple test program
45+
build_test_program() {
46+
cat <<EOF > test_zstd.c
47+
#include <zstd.h>
48+
int main() {
49+
ZSTD_CCtx* cctx = ZSTD_createCCtx();
50+
ZSTD_freeCCtx(cctx);
51+
return 0;
52+
}
53+
EOF
54+
55+
# Try to use zstd's static library with -fPIC
56+
gcc test_zstd.c -lzstd -fPIC -shared
57+
if [ $? -ne 0 ]; then
58+
echo "zstd installation verification failed."
59+
else
60+
echo "zstd installation verification passed."
61+
fi
62+
63+
# There won't be a.out file if verification failed.
64+
rm test_zstd.c a.out || true
65+
}
66+
67+
# Check the OS
68+
check_os
69+
70+
# Set USE_SUDO to true or false based on your preference
71+
USE_SUDO=false
72+
73+
# Install necessary build tools
74+
install_packages
75+
76+
# Uninstall libzstd-dev if installed
77+
uninstall_libzstd_dev
78+
79+
# Define the version and URL for zstd
80+
ZSTD_VERSION="1.5.6"
81+
ZSTD_URL="https://github.com/facebook/zstd/releases/download/v$ZSTD_VERSION/zstd-$ZSTD_VERSION.tar.gz"
82+
83+
# Create a directory for the source code
84+
mkdir -p zstd_build
85+
cd zstd_build
86+
87+
# Download the source code
88+
wget $ZSTD_URL
89+
90+
# Extract the tarball
91+
tar -xzf zstd-$ZSTD_VERSION.tar.gz
92+
cd zstd-$ZSTD_VERSION
93+
94+
# Build zstd with -fPIC flag for both static and dynamic libraries
95+
CFLAGS="-fPIC" make
96+
if [ $? -ne 0 ]; then
97+
echo "Error: make failed."
98+
exit 1
99+
fi
100+
101+
# Optionally, install zstd
102+
if [ "$USE_SUDO" = true ]; then
103+
sudo make install
104+
else
105+
make install
106+
fi
107+
if [ $? -ne 0 ]; then
108+
echo "Error: make install failed."
109+
exit 1
110+
fi
111+
112+
# Check if zstd is built correctly
113+
check_zstd
114+
115+
# Build and run a simple test program
116+
build_test_program
117+
118+
# Clean up
119+
cd ~
120+
rm -rf zstd_build

0 commit comments

Comments
 (0)