Skip to content

Commit b405dcc

Browse files
Enable RediSearch LTO on Rocky Linux 10
RediSearch enables LTO by default in unstable and requires a clang whose LLVM major matches rustc's (currently LLVM 21 from rustc 1.94). The LLVM project does not publish a dnf repository for RHEL/Rocky, so we install the official LLVM 21 tarball into /opt/llvm and add it to PATH. Restricted to Rocky 10. The upstream LLVM 21 binaries require GLIBCXX_3.4.30+ which is only available on Rocky 10's system libstdc++; Rocky 8 and 9 ship 3.4.25 and 3.4.28 respectively. Making LTO work there would require bundling a newer libstdc++ alongside the produced redisearch.so on every customer machine, which is out of scope for now. Rocky 8/9 continue to build with LTO=0. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 995632b commit b405dcc

3 files changed

Lines changed: 53 additions & 3 deletions

File tree

.github/actions/build-package/action.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,15 @@ runs:
9292
export DISABLE_WERRORS=yes
9393
export BUILD_TLS=yes
9494
export USE_SYSTEMD=yes
95-
# Override RediSearch's new LTO=1 default; toolchain support TBD.
96-
export LTO=0
95+
# Enable RediSearch LTO only where LLVM 21 is available (Rocky 10).
96+
# Rocky 8/9 lack libstdc++ with GLIBCXX_3.4.30+ that upstream LLVM 21
97+
# binaries require, so keep LTO=0 there.
98+
if [ -x /opt/llvm/bin/clang-21 ]; then
99+
export LTO=1
100+
export PATH=/opt/llvm/bin:$PATH
101+
else
102+
export LTO=0
103+
fi
97104
98105
if [ "${{ steps.version.outputs.VERSION }}" = "unstable" ]; then
99106
# Clone Redis unstable branch instead of downloading release tarball

dockerfiles/Dockerfile.rockylinux10

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,12 @@ RUN echo '[goreleaser]\nname=GoReleaser\nbaseurl=https://repo.goreleaser.com/yum
4242
COPY install/install_cmake.sh /tmp/
4343
RUN bash /tmp/install_cmake.sh
4444

45+
# Install LLVM 21 for RediSearch LTO (Rocky 10 only; see install_llvm.sh).
46+
COPY install/install_llvm.sh /tmp/
47+
RUN bash /tmp/install_llvm.sh
48+
4549
# Set environment
46-
ENV PATH="/usr/local/bin:/opt/venv/bin:${PATH}"
50+
ENV PATH="/opt/llvm/bin:/usr/local/bin:/opt/venv/bin:${PATH}"
4751
WORKDIR /build
4852

4953
# Default command

install/install_llvm.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
# Install LLVM 21 for RediSearch's cross-language (C/Rust) LTO build.
3+
# LLVM has no dnf repo, so we use the official upstream tarball.
4+
#
5+
# Rocky 10 only: prebuilt LLVM 21 binaries need GLIBCXX_3.4.30+; Rocky 10
6+
# ships it (3.4.32). Rocky 8/9 don't — gcc-toolset ships compile-time headers
7+
# only, no newer libstdc++.so.6 runtime, so there is nothing to vendor.
8+
9+
set -euo pipefail
10+
11+
LLVM_VERSION="${LLVM_VERSION:-21.1.8}"
12+
MAJOR="${LLVM_VERSION%%.*}"
13+
14+
case "$(uname -m)" in
15+
x86_64) asset="LLVM-${LLVM_VERSION}-Linux-X64.tar.xz" ;;
16+
aarch64) asset="LLVM-${LLVM_VERSION}-Linux-ARM64.tar.xz" ;;
17+
*) echo "Unsupported arch: $(uname -m)" >&2; exit 1 ;;
18+
esac
19+
20+
install_root="/opt/llvm-${LLVM_VERSION}"
21+
mkdir -p "$install_root"
22+
curl -fsSL "https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/${asset}" \
23+
| tar -xJ -C "$install_root" --strip-components=1
24+
ln -sfn "$install_root" /opt/llvm
25+
26+
# RediSearch's build scripts look up clang-${MAJOR}, lld-${MAJOR}, etc. on PATH;
27+
# the upstream tarball ships unsuffixed names only, so alias them.
28+
for tool in clang clang++ clang-cpp lld ld.lld ld64.lld lld-link llc opt \
29+
llvm-ar llvm-nm llvm-ranlib llvm-strip llvm-objcopy llvm-objdump \
30+
llvm-readelf llvm-config; do
31+
src="/opt/llvm/bin/${tool}"
32+
dst="/opt/llvm/bin/${tool}-${MAJOR}"
33+
[ -e "$src" ] && [ ! -e "$dst" ] && ln -sfn "$src" "$dst"
34+
done
35+
36+
echo 'export PATH=/opt/llvm/bin:$PATH' > /etc/profile.d/llvm.sh
37+
38+
/opt/llvm/bin/clang-${MAJOR} --version
39+
/opt/llvm/bin/ld.lld-${MAJOR} --version

0 commit comments

Comments
 (0)