Skip to content

feat: set clang version min and max at compile time#333

Merged
2bndy5 merged 10 commits into
mainfrom
compile-time-static-bin-info
Jun 7, 2026
Merged

feat: set clang version min and max at compile time#333
2bndy5 merged 10 commits into
mainfrom
compile-time-static-bin-info

Conversation

@2bndy5

@2bndy5 2bndy5 commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

This adds a build script that downloads versions.json from cpp-linter/clang-tools-static-binaries latest release and injects it into the production code using compile-time-only environment variables.

Includes a similar adjustment to the test CI job in some inline nu shell script that employs gh-cli instead of direct download.

Summary by CodeRabbit

  • New Features

    • Added --verbose flag to installer for detailed diagnostic output.
  • Bug Fixes

    • Enhanced version parsing and matching logic for improved tool compatibility.
    • Improved wheel filename handling for package downloads.
  • Chores

    • Version bumped to 2.0.0-rc.16.
    • Optimized CI/build infrastructure for improved reliability.

@2bndy5 2bndy5 added the enhancement New feature or request label Jun 6, 2026
@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

This PR introduces dynamic clang-tools version provisioning by seeding upstream release metadata in CI, parsing it at build time, and embedding the resulting version bounds as compile-time constants. Workflows download versions.json and share it across jobs. A Rust build script reads it to emit environment variables. The static downloader and PyPI wheel handler use these values, and test version specs are updated.

Changes

Dynamic clang-tools version provisioning

Layer / File(s) Summary
Workflow seeding infrastructure
.github/workflows/benchmark.yml, binary-builds.yml, build-docs.yml, node-js-packaging.yml, python-packaging.yml, run-dev-tests.yml
Adds seed-build-script job across six workflows to download versions.json from cpp-linter/clang-tools-static-binaries release via gh release download and upload as static-binary-versions artifact. Build and test jobs now depend on seed-build-script and restore the artifact into clang-installer before execution.
Build script to parse versions.json
clang-installer/Cargo.toml, clang-installer/build.rs
Adds build-dependencies (serde, serde_json, reqwest with default-tls and blocking features). New build.rs reads clang-installer/versions.json (or fetches from GitHub if absent), deserializes VersionInfo, computes min/max LLVM version keys, and emits CLANG_TOOLS_TAG, MIN_CLANG_TOOLS_VERSION, MAX_CLANG_TOOLS_VERSION via cargo:rustc-env.
Static downloader with compile-time bounds
clang-installer/src/downloader/static_dist.rs, clang-installer/tests/static_dist.rs
StaticDistDownloader now uses compile-time env! constants for version/tag config. get_major_version_range() parses embedded strings into u8 bounds with unwrap_or defaults. find_suitable_version() simplified to reverse-iterate and match major versions directly. download_tool() gates unsupported architectures via cfg(any(...)), derives arch/platform from cfg! conditionals, and rebuilds URL base from compile-time constants. Test renamed and updated to verify version 17.
PyPI wheel tag and version handling
clang-installer/src/downloader/pypi.rs
WheelTags drops stored wheel version field, retaining only platform tag. WheelTags::from_str parses only trailing platform tag. get_best_pypi_release now attempts direct semver::Version::parse, synthesizes semver from first four dot-separated components if parsing fails, and returns original ver_str alongside normalized Version. download_tool uses returned ver_str for cached filename and log messages.
Supporting changes
bindings/node/index.js, .gitignore, clang-installer/src/main.rs, clang-installer/src/version.rs
Node binding version updated to 2.0.0-rc.16. .gitignore adds entry for versions.json. CLI adds --verbose / -V flag to enable Debug log level. Test default CLANG_VERSION updated from "12.0.1" to "16".

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • cpp-linter/cpp-linter-rs#278: Both modify .github/workflows/run-dev-tests.yml to change clang version selection; main PR seeds/restores versions.json and derives bounds from it.
  • cpp-linter/cpp-linter-rs#279: Both implement and refactor the static-dist downloader in clang-installer/src/downloader/static_dist.rs with changes to version selection and download URL logic.

Suggested labels

github_actions, rust

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: moving clang version min/max configuration from runtime to compile time via a build script that injects environment variables.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch compile-time-static-bin-info

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@2bndy5 2bndy5 force-pushed the compile-time-static-bin-info branch from 997173f to 291f1a5 Compare June 7, 2026 00:13
coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as low quality.

@codecov

codecov Bot commented Jun 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.59259% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.01%. Comparing base (8e2fcad) to head (19e642c).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
clang-installer/src/downloader/pypi.rs 94.44% 2 Missing ⚠️
clang-installer/src/downloader/static_dist.rs 88.23% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #333      +/-   ##
==========================================
+ Coverage   90.94%   91.01%   +0.07%     
==========================================
  Files          22       22              
  Lines        3368     3374       +6     
==========================================
+ Hits         3063     3071       +8     
+ Misses        305      303       -2     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@2bndy5 2bndy5 marked this pull request as draft June 7, 2026 09:13
2bndy5 added 8 commits June 7, 2026 02:57
This adds a build script that downloads versions.json from `cpp-linter/clang-tools-static-binaries` latest release and injects it into the production code using compile-time-only environment variables.

Includes a similar adjustment to the test CI job in some inline nu shell script that employs gh-cli instead of direct download.
To avoid chances of a network failure in the build script, all CI jobs (except clippy job) use a pre-seeded versions.json artifact. This prevents each build of clang-installer from re-downloading the same versions.json file repeatedly.
compiling aws-ls-sys on these targets are way too flaky, even for me.
for newer static binary releases which
- only use the major version
- support arm64 (on unix but not windows) as well as amd64 (on all OS)
Looks like subsequent releases for
the same clang version are suffixed
with a build number (`11.1.0.2`),
but this is not semver compliant.
It seems PEP440 is not as strict as semver rules.

As a workaround, we use the build number as a prerelease version and append a prerelease version of `0` to those with no build number suffixed.

I also updated the logs to be less confusing about which build number (for identical clang versions) is being downloaded.
@2bndy5 2bndy5 force-pushed the compile-time-static-bin-info branch from 8c9352c to eb27133 Compare June 7, 2026 09:58
@2bndy5 2bndy5 marked this pull request as ready for review June 7, 2026 10:08
coderabbitai[bot]

This comment was marked as resolved.

@2bndy5 2bndy5 linked an issue Jun 7, 2026 that may be closed by this pull request
@2bndy5 2bndy5 merged commit e82885a into main Jun 7, 2026
84 checks passed
@2bndy5 2bndy5 deleted the compile-time-static-bin-info branch June 7, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problems with MacOS when installing clang tools (from static binaries)

1 participant