Skip to content

Add workflow and scripts to build LLVM prebuilts#3

Merged
LegNeato merged 1 commit into
Rust-GPU:masterfrom
brandonros:master
Apr 30, 2026
Merged

Add workflow and scripts to build LLVM prebuilts#3
LegNeato merged 1 commit into
Rust-GPU:masterfrom
brandonros:master

Conversation

@brandonros
Copy link
Copy Markdown
Contributor

part of #2

@brandonros
Copy link
Copy Markdown
Contributor Author

cc @LegNeato

@LegNeato
Copy link
Copy Markdown
Contributor

Sweet, I've been meaning to do this. Thanks! I was thinking of switching it from committing into the repo, which is pretty big, and switching to pulling from GitHub releases. What do you think?

@brandonros
Copy link
Copy Markdown
Contributor Author

absolutely. I will help drive that. I'm getting my butt kicked (as expected) with "compile LLVM on windows" but i'll power through and figure it out. will ping you when it's ready! thanks for the support.

@brandonros brandonros force-pushed the master branch 10 times, most recently from 1ae5483 to f8d5df8 Compare April 30, 2026 02:27
Introduces the build pipeline that produces the prebuilt LLVM tarballs
consumed by rustc_codegen_nvvm's build.rs, and switches distribution
from in-repo binaries to GitHub release assets.

Workflow (.github/workflows/build-llvm.yml)

* workflow_dispatch with two inputs: llvm_version (e.g. 7.1.0 or
  19.1.7) and release (default true).
* Matrix builds on ubuntu-22.04 (glibc 2.35 floor matching the
  rust-cuda container baseline) and windows-2022, each producing
  <triple>.tar.xz uploaded as a run artifact.
* Final `release` job needs both matrix legs, downloads the artifacts,
  and either creates or --clobber-uploads to a release tagged
  llvm-<version>. Re-running a build for the same version is therefore
  idempotent. Uncheck the release input for a build-only run.

Build scripts

* scripts/build-llvm-linux.sh — fetches the upstream tarball, configures
  cmake with X86;NVPTX targets, dylib link, assertions off, examples
  /tests/benchmarks off, then ninja install. Handles the 7.x vs 8+
  layout split (llvm-X.Y.Z.src vs llvm-project-X.Y.Z.src monorepo).
* scripts/build-llvm-windows.ps1 — same shape, with a few Windows
  specifics worth flagging:
    - Calls Git for Windows' GNU tar by full path. The default tar.exe
      on PATH is Microsoft's bsdtar, which hangs indefinitely on
      .tar.xz (actions/runner-images#282).
    - For LLVM 8+ extracts only llvm/, cmake/, and third-party/ from
      the monorepo. clang/test/Driver/Inputs contains out-of-order
      symlinks that msys-tar cannot create on Windows
      (CreateSymbolicLink requires the target's FILE/DIR type, which
      msys resolves via stat — it fails when the target hasn't been
      extracted yet).
    - LLVM 7 is built with clang-cl from the runner's preinstalled
      LLVM toolchain because MSVC v143 rejects 7.x sources without
      patches.
* scripts/package-prebuilt.sh — repackages the install tree into the
  layout build.rs expects (bin/llvm-config[.exe], bin/llvm-as[.exe],
  include/llvm{,-c}, lib/*), strips lib/cmake and lib/pkgconfig (build
  .rs goes through llvm-config, and pkgconfig contains absolute
  build-host paths), and tars to .tar.xz.

Distribution

* Tarballs no longer live in the repo. The previous prebuilt/ tree
  (~300 MB working-tree, ~30 MB on disk via xz) is removed; assets are
  pulled from the release at
    github.com/<owner>/<repo>/releases/download/llvm-<version>/<triple>.tar.xz
* .gitignore prevents the build/install/source dirs and stray *.tar.xz
  from being committed back in.
* README rewritten around the release-based flow.

Note: removing prebuilt/ from HEAD shrinks future commits but the
binaries remain in earlier history (dd512c5, e6b86c6, b432cd4, a90da8c,
596215d). A follow-up filter-repo + force-push would be needed to
actually shrink fresh clones.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@brandonros brandonros marked this pull request as ready for review April 30, 2026 02:50
@brandonros
Copy link
Copy Markdown
Contributor Author

@LegNeato went to damn war with this thing!!!!

https://github.com/brandonros/rustc_codegen_nvvm-llvm/releases/tag/llvm-7.1.0
https://github.com/brandonros/rustc_codegen_nvvm-llvm/releases/tag/llvm-19.1.7

windows + linux, should be ready to merge. i'll go to https://github.com/Rust-GPU/rust-cuda and wire up the prebuild for llvm-19 now once we merge this and then trigger the releases on the official Rust-GPU org

@LegNeato
Copy link
Copy Markdown
Contributor

Yay!

@LegNeato LegNeato merged commit 4f9ff46 into Rust-GPU:master Apr 30, 2026
LegNeato added a commit that referenced this pull request Apr 30, 2026
Add workflow and scripts to build LLVM prebuilts
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.

2 participants