Skip to content

fix: make tarball-installed LLVM usable from fresh shells (bootstrap → make build LTO=1) - #10373

Merged
oshadmi merged 3 commits into
RediSearch:masterfrom
gabsow:bootstrap-lto-fresh-shell
Jul 9, 2026
Merged

oshadmi merged 3 commits into
RediSearch:masterfrom
gabsow:bootstrap-lto-fresh-shell

Conversation

@gabsow

@gabsow gabsow commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Companion to #10372 (same theme: make bootstrap should fully provision what the documented flows need).

Problem

install_llvm.sh's package-manager paths (apt / apt.llvm.org / apk / dnf) land versioned binaries in /usr/bin, so after make bootstrap a later shell can run make build LTO=1 and build.sh finds clang-21/lld-21. The tarball fallback (Azure Linux, Mariner, any distro without matching packages) unpacks to /usr/local/llvm and wires PATH only via $GITHUB_PATH/the current shell - so outside GitHub Actions, a fresh shell can't see the toolchain: LTO refuses to enable (Please either: 1. Install clang-21 ...) even though bootstrap just installed it, and bindgen has no libclang.

Fix

After extracting the tarball, symlink the tools build.sh looks up (clang-21, clang++-21, lld-21, ld.lld-21, ld.lld) and llvm-config - through which bindgen's clang-sys resolves libclang (llvm-config --libdir), so no persisted LIBCLANG_PATH is needed - into /usr/local/bin (default PATH everywhere). This mirrors what the package paths already provide, and the same pattern rocky_linux_8.sh uses for its gcc-toolset shims.

The follow-up commit also fixes the related LTO bootstrap issues found while validating the Redis bundled-modules flow: native apt installs llvm-21 for CMake IPO archive tools, Alpine uses a GROUP() linker script for static LLVM libs, Azure Linux retries flaky tdnf metadata fetches, Rocky 8 installs lld, and build.sh keeps LTO enabled when reusing an LTO-configured build directory.

Verified

Clean mcr.microsoft.com/azurelinux/base/core:3.0 container -> ./install_llvm.sh -> then a deliberately clean shell (env -i PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin):

/usr/local/bin/clang-21
clang version 21.1.8
/usr/local/bin/lld-21
/usr/local/bin/ld.lld
/usr/local/bin/clang++-21
$ llvm-config --libdir
/usr/local/llvm/lib   (contains libclang.so, libclang.so.21.1)

The broader LTO validation is for supported Linux targets where RediSearch/Redis build sanity enables LTO. macOS and explicitly non-LTO rows remain outside this claim.

Context: found while wiring the redis/redis bundled-modules flow (redis/redis#15253), whose docs currently tell users bootstrap can't provision the LTO toolchain.

Release Notes

  • This PR requires release notes
  • This PR does not require release notes

Generated with Claude Code

…LTO=1)

The package-manager paths of install_llvm.sh land versioned binaries in
/usr/bin, so 'make bootstrap' then 'make build LTO=1' from a later shell
finds clang-<ver> fine. The tarball fallback (Azure Linux, Mariner, and
any distro without matching packages) unpacks to /usr/local/llvm and
wires PATH only for GitHub Actions ($GITHUB_PATH) and the shell that ran
the script — in a fresh shell build.sh cannot find clang-<ver> and LTO
refuses to enable, and bindgen has no libclang.

Symlink the tools build.sh looks up (clang-<ver>, clang++-<ver>,
lld-<ver>, ld.lld) and llvm-config — through which bindgen's clang-sys
locates libclang without a persisted LIBCLANG_PATH — into
/usr/local/bin, mirroring what the package paths give and the
gcc-toolset shims rocky_linux_8.sh already creates.

Verified in a clean azurelinux 3.0 container: after install_llvm.sh, a
fresh 'env -i PATH=<default>' shell resolves clang-21/clang++-21/lld-21/
ld.lld from /usr/local/bin and 'llvm-config --libdir' yields
/usr/local/llvm/lib containing libclang.so.

Co-Authored-By: Claude Fable 5 <[email protected]>
@CLAassistant

CLAassistant commented Jul 6, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d637a34f79

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread .install/install_llvm.sh Outdated
target="${bindir}/${tool}"
[[ -e "$target" ]] || target="${bindir}/${tool%-${LLVM_VER}}"
[[ -e "$target" ]] || continue
$MODE ln -sf "$target" "/usr/local/bin/${tool}" || true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fail when fresh-shell symlinks cannot be installed

When /usr/local/bin is missing or unwritable (for example a non-root/manual install using a writable LLVM_INSTALL_DIR), this suppresses the ln failure, so the script exits successfully and the final verification still passes because export_path_gha already modified the current shell's PATH. A later clean shell will still not find clang-21/lld-21, which is the failure this change is meant to fix; create the destination and propagate/report the error instead of ignoring it.

Useful? React with 👍 / 👎.

Comment thread .install/install_llvm.sh Outdated
link_tools_for_fresh_shells() {
local bindir="${INSTALL_DIR}/bin"
local tool target
for tool in "clang-${LLVM_VER}" "clang++-${LLVM_VER}" "lld-${LLVM_VER}" ld.lld llvm-config; do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid exposing lld-21 as a fuse-ld value

In the tarball/fresh-shell path, adding lld-${LLVM_VER} makes build.sh choose LINKER="lld-$RUSTC_LLVM_VERSION" and pass -fuse-ld=$LINKER in the LTO CMake/Rust flags. Clang's -fuse-ld= accepts lld (which invokes ld.lld) but rejects versioned names such as lld-21 as an invalid linker name, so make build LTO=1 can get past compiler discovery and then fail at the first link. Keep lld/ld.lld discoverable without causing build.sh to select lld-21, or update the LTO path to pass a valid linker selector.

Useful? React with 👍 / 👎.

Extends the fresh-shell LLVM fix so a default (LTO=1) bundled build works
on every OS, each reproduced and verified in a clean container:

- install_llvm.sh: symlink ld.lld-${LLVM_VER} too — build.sh links with
  -fuse-ld=lld-${LLVM_VER}, which clang resolves to an executable named
  ld.lld-${LLVM_VER}; the tarball ships only unversioned ld.lld (broke
  amazonlinux2023, azurelinux3). Also install llvm-${LLVM_VER} on the apt
  native path — CMake's IPO archive rules need llvm-ar/llvm-ranlib, which
  --no-install-recommends skips (broke ubuntu 26.04).
- rocky_linux_8.sh: install lld — EL8's llvm-toolset ships clang-21 but
  lld is a separate RPM, so -fuse-ld=lld failed with 'invalid linker name'.
- alpine_linux_3.sh: emit a GROUP() linker script for libLLVM-<ver>.a
  instead of a GNU thin archive (ar rcT), which ld.lld cannot parse; add
  compiler-rt for the clang-built test-dep sdists.
- microsoft_azure_linux_3.0.sh: retry tdnf with a repogpgcheck-plugin
  fallback — Azure Linux mirrors intermittently 404 the metadata sig.
- build.sh: add -Wno-unknown-warning-option in the LTO (clang) branch so
  GCC-only -W options in the environment don't become fatal under vendored
  -Werror; inherit LTO=1 when reusing a build dir whose CMake cache has
  IPO enabled, so a non-LTO 'make test' re-drive doesn't reject the LTO
  bitcode static libs.

Co-Authored-By: Claude Fable 5 <[email protected]>
@gabsow

gabsow commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Pushed f7fba21ec: extends this fix so a default LTO=1 make bootstrap && make build succeeds on every OS the bundle targets, not just the fresh-shell case. Each fix was reproduced and verified in a clean container (both arches): EL8 lld, alpine GROUP() archive (ld.lld can't parse GNU thin archives), ld.lld-${LLVM_VER} symlink for the tarball path (amazonlinux2023/azurelinux3), llvm-${LLVM_VER} for CMake IPO's llvm-ar on ubuntu 26.04, azurelinux tdnf retry, and build.sh's -Wno-unknown-warning-option + LTO-inherit-on-reused-build-dir. Surfaced by the redis/redis#15253 bundled-modules nightly across a 15-OS × 2-arch matrix.

Note: the alpine compiler-rt line here is what the musl python test-deps in #10372 rely on — the two PRs are best merged together (or this one first).

@codecov

codecov Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.51%. Comparing base (54cc622) to head (12b1af7).
⚠️ Report is 25 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10373      +/-   ##
==========================================
+ Coverage   81.16%   81.51%   +0.35%     
==========================================
  Files         552      558       +6     
  Lines       74367    75289     +922     
  Branches    29707    30271     +564     
==========================================
+ Hits        60359    61375    +1016     
+ Misses      13730    13631      -99     
- Partials      278      283       +5     
Flag Coverage Δ
flow 83.50% <ø> (-0.52%) ⬇️
unit 52.02% <ø> (+0.65%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 12b1af7c98

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

local i
for i in 1 2 3; do
$MODE tdnf install -y "$@" && return 0
$MODE tdnf --disableplugin=tdnfrepogpgcheck install -y "$@" && return 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use a tdnf-supported plugin switch

On Azure Linux when the first install hits the tdnfrepogpgcheck/TDNFVerifySignature 2004 failure this fallback is meant to handle, this command still fails before installing anything because --disableplugin=... is a DNF option, not one of tdnf's supported command options (the upstream tdnf options list --nogpgcheck, --disablerepo, etc., but not --disableplugin). The Azure setup workflow in this repo already uses tdnf install -y --noplugins ..., so use a tdnf-supported way to skip that repo-metadata plugin; otherwise the new retry loop does not actually recover from the documented failure mode.

Useful? React with 👍 / 👎.

Comment on lines 44 to +48
if [ ! -e /usr/lib/llvm${LLVM_VER}/lib/libLLVM-${LLVM_VER}.a ]; then
# shellcheck disable=SC2046
$MODE ar rcT /usr/lib/llvm${LLVM_VER}/lib/libLLVM-${LLVM_VER}.a \
/usr/lib/llvm${LLVM_VER}/lib/libLLVM*.a \
/usr/lib/libzstd.a
# Expand the glob before tee creates the output file, so the combined
# archive never lists itself.
# shellcheck disable=SC2086
LLVM_COMPONENT_LIBS=$(echo /usr/lib/llvm${LLVM_VER}/lib/libLLVM*.a /usr/lib/libzstd.a)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Replace stale Alpine thin archives

On Alpine hosts that have already run the previous bootstrap, /usr/lib/llvm${LLVM_VER}/lib/libLLVM-${LLVM_VER}.a already exists as the old thin archive this change says ld.lld cannot parse. Because the new GROUP() linker script is only written behind the existing if [ ! -e ... ] guard, rerunning bootstrap after taking this commit leaves the stale archive in place and the static bindgen/LTO link still fails; replace or validate an existing generated archive instead of skipping solely on existence.

Useful? React with 👍 / 👎.

@gabsow gabsow left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omer's fail-fast commit LGTM — reviewed and verified:

  • link_tools_for_fresh_shells is only called from install_from_tarball, so the native apt/dnf/apk paths (tools in /usr/bin, not $INSTALL_DIR/bin) never run it — no regression there.
  • Propagation is real: install_llvm.sh runs set -eo pipefail, install_from_tarball is invoked as bare statements, and install_script.sh is also set -e — so return 1 genuinely fails bootstrap instead of the old silent || true/|| continue (which is exactly how the missing ld.lld-N symlink slipped through before).
  • The version-suffix fallback is preserved, so it doesn't spuriously fail: ran the tarball path on amazonlinux:2023 — install_llvm.sh exits 0 with all symlinks created (clang-21, ld.lld, ld.lld-21→ld.lld, llvm-config) and resolvable on PATH.

(Can't hit the Approve button — it's my own PR — but consider this an approve.)

@oshadmi
oshadmi enabled auto-merge July 9, 2026 11:34
@oshadmi
oshadmi added this pull request to the merge queue Jul 9, 2026
Merged via the queue into RediSearch:master with commit 543b79b Jul 9, 2026
47 checks passed
gabsow added a commit to redis/redis that referenced this pull request Jul 22, 2026
…ml changes (#15442)

Follow-up to #15253 (bundled data-type modules). Adds a GitHub Actions
workflow (`.github/workflows/modules-build-flow.yml`) that replays the
from-source flow documented in
[modules/README.md](https://github.com/redis/redis/blob/unstable/modules/README.md)
on **every OS the bundled modules support** — the same 15-OS list the
modules' own nightlies build against — across **x64 and arm64**, each in
a **clean stock container** (no Dockerfiles):

```
make modules-update          # clone each module pinned in modules.yaml
make bootstrap               # per-module build/test prereqs
make -j all BUILD_TLS=yes    # Redis + all modules (LTO=1 via redisearch build_env)
./src/redis-server redis-full.conf   +   redis-cli MODULE LIST   # smoke test
```

### When it runs
- **On pull requests that change `modules/modules.yaml`.** Bumping a
module's pinned `ref` is exactly when the from-source build/load can
break on some OS, so the whole matrix re-verifies then. On a PR it
checks out the PR merge ref, so it builds the **bumped pins**, not
`unstable` (works for fork PRs too).
- **`workflow_dispatch`** for manual runs, with `use_repo`/`use_git_ref`
inputs to point at any repo/branch.

It **builds and smoke-tests only** — starts the server and asserts
`MODULE LIST` contains `bf`/`search`/`ReJSON`/`timeseries`. It does
**not** run the per-module `make test all` suites; those live in each
module's own CI.

### Design
- **Clean containers, no Dockerfiles** — one matrix job per `arch ×
osnick`; every image is a stock multi-arch base
(ubuntu/debian/alma/rocky/amazonlinux/azurelinux/alpine).
- **Prereqs = only what the manual assumes present** before its first
command (git, make, CA certs; `gawk`/`findutils` on minimal rpm images;
`bash` on alpine; `openssl` + dev headers). Compilers and per-module
toolchains must come from `make bootstrap` — if they don't, the manual
is broken on that OS and this workflow catches exactly that.
- **`BUILD_TLS=yes`** — the README's documented full-build flag
(redisearch's TLS test env expects it).
- **No node-based actions inside containers** (plain `git clone`) — they
can't start on older-glibc images.

### Validation
Ran the full matrix on a fork against the upcoming module refs
(redisearch + redistimeseries at `master`, i.e. post-RediSearch#10372):
**30/30 jobs green** across all 15 OSes on both arches — build + `MODULE
LIST` smoke (fork Actions run `29747001924`). Once `modules.yaml` is
bumped to the retagged versions carrying the merged bootstrap/LTO fixes
(RediSearch
[#10372](RediSearch/RediSearch#10372) /
[#10373](RediSearch/RediSearch#10373),
RedisTimeSeries
[#2089](RedisTimeSeries/RedisTimeSeries#2089)),
the matrix is green with no per-module workarounds in the workflow.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Adds CI-only automation with no changes to Redis runtime, auth, or
data paths.
> 
> **Overview**
> Adds **`.github/workflows/modules-build-flow.yml`**, a GitHub Actions
workflow that replays the documented from-source modules flow (`make
modules-update` → `make bootstrap` → `make all BUILD_TLS=yes`) inside
**stock** container images on **x64 and arm64** across **15 OS
variants** (Ubuntu, Debian, Alma/Rocky, Amazon Linux 2023, Azure Linux
3, Alpine).
> 
> It runs on **PRs that touch `modules/modules.yaml`** and on
**`workflow_dispatch`** (optional repo/ref). Each job installs only the
manual’s baseline packages (git, make, TLS/openssl tooling, etc.), uses
a **plain `git fetch` checkout** (including the PR merge ref on
path-filtered PRs) instead of `actions/checkout`, then **starts
`redis-server` with `redis-full.conf`** and asserts **`MODULE LIST`**
includes **bf**, **search**, **ReJSON**, and **timeseries**.
> 
> The workflow also encodes several container-specific fixes: pinned
**`PATH`** after bootstrap, job-level **`CXXFLAGS`** for GCC/clang
`-Werror` noise, **`rm /.dockerenv`** so module bootstrap installs test
Python envs, and **tdnf install retries** on Azure Linux.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
80d2e37. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Claude Fable 5 <[email protected]>
Co-authored-by: TalBarYakar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants