Skip to content

Commit f37416d

Browse files
committed
use prebuilt libc
1 parent 159a775 commit f37416d

File tree

1 file changed

+29
-75
lines changed

1 file changed

+29
-75
lines changed

.ci/scripts/wheel/pre_build_script.sh

Lines changed: 29 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -45,90 +45,44 @@ fi
4545

4646
"${GITHUB_WORKSPACE}/${REPOSITORY}/install_requirements.sh" --example
4747

48-
# Install glibc-2.34
49-
50-
# Prefer older GCC to avoid glibc build errors
51-
if [ -f /opt/rh/devtoolset-9/enable ]; then
52-
echo ">>> Enabling devtoolset-9 (GCC 9)"
53-
source /opt/rh/devtoolset-9/enable
54-
elif [ -f /opt/rh/devtoolset-8/enable ]; then
55-
echo ">>> Enabling devtoolset-8 (GCC 8)"
56-
source /opt/rh/devtoolset-8/enable
57-
fi
48+
# ----------------------------
49+
# Stage prebuilt glibc 2.34
50+
# ----------------------------
5851

59-
echo "GCC version: $(gcc -dumpfullversion)"
52+
set -euo pipefail
6053

61-
# 👇 only change this line to bump version
6254
GLIBC_VERSION=2.34
63-
6455
PREFIX=/tmp/glibc-install-$GLIBC_VERSION
65-
BUILD_DIR=/tmp/glibc-build
66-
TARBALL=/tmp/glibc-$GLIBC_VERSION.tar.xz
67-
SRC_DIR=/tmp/glibc-$GLIBC_VERSION
68-
69-
# Clean old dirs
70-
rm -rf "$PREFIX" "$BUILD_DIR" "$SRC_DIR" "$TARBALL"
71-
mkdir -p "$BUILD_DIR"
72-
73-
# Download tarball from canonical GNU FTP
74-
MIRROR=https://ftp.gnu.org/gnu/libc
75-
curl -L "$MIRROR/glibc-$GLIBC_VERSION.tar.xz" -o "$TARBALL"
76-
77-
# Sanity check tarball
78-
ls -lh "$TARBALL"
79-
file "$TARBALL" || true
80-
81-
# Extract
82-
tar -C /tmp -xf "$TARBALL"
56+
mkdir -p "$PREFIX/lib"
8357

84-
cd "$BUILD_DIR"
58+
echo ">>> Downloading prebuilt glibc-$GLIBC_VERSION (CentOS Stream 9)"
8559

86-
# Unset LD_LIBRARY_PATH to satisfy glibc configure
87-
unset LD_LIBRARY_PATH
60+
# Choose a mirror (can switch if one dies)
61+
RPM_URL="http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/Packages/glibc-${GLIBC_VERSION}-100.el9.x86_64.rpm"
8862

89-
# Suppress GCC warnings (GCC 11 is more compatible, but keep flags)
90-
COMMON_FLAGS="-O2 -fPIC -fcommon -Wno-error"
91-
export CFLAGS="$COMMON_FLAGS"
92-
export CPPFLAGS="$COMMON_FLAGS"
93-
export CXXFLAGS="$COMMON_FLAGS"
63+
# Download RPM
64+
curl -L "$RPM_URL" -o /tmp/glibc.rpm
9465

95-
# Configure
96-
../glibc-$GLIBC_VERSION/configure \
97-
--prefix="$PREFIX" \
98-
--without-selinux
66+
# Extract without root
67+
command -v rpm2cpio >/dev/null 2>&1 || {
68+
echo ">>> rpm2cpio not found, downloading static helper..."
69+
curl -L https://raw.githubusercontent.com/rpm-software-management/rpm/main/scripts/rpm2cpio.sh -o /tmp/rpm2cpio.sh
70+
chmod +x /tmp/rpm2cpio.sh
71+
RPM2CPIO=/tmp/rpm2cpio.sh
72+
}
73+
RPM2CPIO=${RPM2CPIO:-rpm2cpio}
9974

100-
# Build and install
101-
make -j"$(nproc)"
102-
make install
75+
$RPM2CPIO /tmp/glibc.rpm | cpio -idmv
10376

104-
echo ">>> Finished make install"
105-
echo ">>> PREFIX=$PREFIX"
77+
# Copy only runtime loader + libc
78+
cp ./usr/lib64/libc.so.6 \
79+
./usr/lib64/ld-2.34.so \
80+
./usr/lib64/ld-linux-x86-64.so.2 \
81+
"$PREFIX/lib"
10682

107-
# List everything under $PREFIX
108-
echo ">>> ls -l $PREFIX"
109-
ls -l "$PREFIX" || true
110-
111-
echo ">>> ls -l $PREFIX/lib"
112-
ls -l "$PREFIX/lib" || true
113-
114-
echo ">>> ls -l $PREFIX/lib64"
115-
ls -l "$PREFIX/lib64" || true
116-
117-
# Explicitly show libc/ld files
118-
echo ">>> Checking for libc.so.6"
119-
if [ -e "$PREFIX/lib/libc.so.6" ]; then
120-
ls -l "$PREFIX/lib/libc.so.6"
121-
else
122-
echo "libc.so.6 NOT FOUND in $PREFIX/lib"
123-
fi
124-
125-
echo ">>> Checking for ld-$GLIBC_VERSION.so"
126-
if [ -e "$PREFIX/lib/ld-$GLIBC_VERSION.so" ]; then
127-
ls -l "$PREFIX/lib/ld-$GLIBC_VERSION.so"
128-
else
129-
echo "ld-$GLIBC_VERSION.so NOT FOUND in $PREFIX/lib"
130-
fi
83+
echo ">>> Staged glibc $GLIBC_VERSION to $PREFIX/lib"
84+
ls -l "$PREFIX/lib"
13185

132-
# Run version checks only if files exist
133-
[ -x "$PREFIX/lib/ld-$GLIBC_VERSION.so" ] && "$PREFIX/lib/ld-$GLIBC_VERSION.so" --version || echo "ld-$GLIBC_VERSION.so missing or not executable"
134-
[ -x "$PREFIX/lib/libc.so.6" ] && "$PREFIX/lib/libc.so.6" --version || echo "libc.so.6 missing or not executable"
86+
# Verify
87+
"$PREFIX/lib/libc.so.6" --version || true
88+
"$PREFIX/lib/ld-2.34.so" --version || true

0 commit comments

Comments
 (0)