Skip to content

[CI][ORCJIT] Source manylinux LLVM from a release, link libstdc++ dynamically - #688

Merged
tqchen merged 1 commit into
apache:mainfrom
cyx-6:ci/llvm-from-source
Jul 29, 2026
Merged

tqchen merged 1 commit into
apache:mainfrom
cyx-6:ci/llvm-from-source

Conversation

@cyx-6

@cyx-6 cyx-6 commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

The orcjit addon links against conda-forge's LLVM, which is built with a newer GCC whose libstdc++ carries GLIBCXX_3.4.29+ symbols. Those exceed the manylinux_2_28 floor this project standardized on in #675, which is why the addon has carried a -static-libstdc++/-static-libgcc workaround since the original addon PR (#254).

This builds LLVM from source inside the manylinux_2_28 image instead, publishes the install prefix as a release asset, and has CI download it. Because that toolchain already sits at the manylinux ABI floor, the workaround is no longer needed.

What changes

  • LLVM acquisition (Linux). /opt/llvm is obtained by downloading llvm-<version>-linux-<arch>.tar.zst and extracting it, instead of being built or installed via conda. macOS/Windows keep the conda-forge binaries (no GLIBCXX floor); their actions/cache step is split out so their install gating is unchanged. Everything downstream is untouched — same /opt/llvm, same LLVM_PREFIX, same bind-mount into the build container.
  • Drop -static-libstdc++/-static-libgcc, so the addon no longer bakes in a private copy of the C++ runtime.

The by-name --exclude-libs list is deliberately kept rather than collapsed to --exclude-libs,ALL. I tried that; it fails. The embedded liborc_rt.a is linked by the JIT at run time and resolves its C++ runtime through the process, including archive-only helpers such as _ZSt28__throw_bad_array_new_lengthv that libstdc++.so does not export — ALL localizes those and the ORC platform fails to materialize (Failed to materialize symbols: { (<Platform>, ...) }). That holds whether libstdc++ is static or dynamic, so the comment there is corrected rather than the flag changed.

Results

Full CI green on all four platforms. The repaired wheel names are the ABI evidence — auditwheel tags them:

apache_tvm_ffi_orcjit-0.1.1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

i.e. the prefix stays under the floor with libstdc++ linked dynamically. The addon's exported dynamic symbols drop from ~965 to ~30, since it no longer re-exports a private libstdc++ that could interpose with a host's own copy (e.g. PyTorch's bundled LLVM), and the C++ runtime references (_Znwm, __cxa_throw, __gxx_personality_v0) are now UND, served by the process. Tests: 89 passed x86_64 / 87 passed aarch64, plus the quick-start C and C++ examples.

Prebuilt LLVM is produced out-of-band, so this also removes a ~50 minute from-source build from the CI path; the Linux orcjit jobs now spend a few minutes downloading.

Notes for reviewers

Two things worth flagging that are not visible in the diff:

  1. Artifact provenance. Linux LLVM now comes from a release asset in mlc-ai/package, which is outside the ASF org. The asset is currently a pre-release, and the workflow that produces it lives on an unmerged branch there. That side should land (and ideally be promoted out of pre-release) before this is merged — hence the draft status. The download source is parameterized via the llvm_release_repo input if you would prefer it mirrored elsewhere.
  2. publish_orcjit_wheel.yml inherits this. It calls the same composite action without passing llvm_version/llvm_release_repo, so published PyPI wheels will also start sourcing LLVM from that release. This is a supply-chain change to a published artifact that the diff does not visibly touch.

Builds on #675 (manylinux_2_28 standardization), which is what makes the floor the right target.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

…amically

The orcjit addon linked against conda-forge's LLVM, which is built with a newer
GCC whose libstdc++ carries GLIBCXX_3.4.29+ symbols. Those exceed the
manylinux_2_28 floor the project standardized on in apache#675, which is why the addon
carried a -static-libstdc++/-static-libgcc workaround.

Build LLVM from source inside the manylinux_2_28 image instead (gcc-toolset-14,
static + PIC + RTTI, native target only), publish the install prefix as a
compressed release asset, and have CI download it. Because that toolchain sits at
the manylinux ABI floor, the workaround is no longer needed:

* Linux acquires /opt/llvm by downloading llvm-<version>-linux-<arch>.tar.zst and
  extracting it. macOS/Windows keep the conda-forge binaries (no GLIBCXX floor);
  their actions/cache step is split out so their install gating is unchanged.
  Everything downstream is unchanged -- same /opt/llvm, same LLVM_PREFIX, same
  bind-mount into the build container.
* Drop -static-libstdc++/-static-libgcc, so the addon no longer bakes in a private
  copy of the C++ runtime. The repaired wheels are tagged
  manylinux_2_27/manylinux_2_28, confirming the prefix stays under the floor, and
  the addon's exported dynamic symbols drop from ~965 to ~30 -- it no longer
  re-exports a private libstdc++ that could interpose with a host's own copy.

The by-name --exclude-libs list is deliberately kept rather than collapsed to
--exclude-libs,ALL. The embedded liborc_rt.a is linked by the JIT at run time and
resolves its C++ runtime through the process, including archive-only helpers such
as _ZSt28__throw_bad_array_new_lengthv that libstdc++.so does not export; ALL
localizes those and the ORC platform fails to materialize. That is true whether
libstdc++ is static or dynamic, so the comment there is corrected accordingly.

Prebuilt LLVM is produced out-of-band, so this removes the ~50 minute from-source
build from the CI path; the Linux orcjit jobs now spend a few minutes downloading.
@cyx-6
cyx-6 force-pushed the ci/llvm-from-source branch from c24bbeb to 03f5df4 Compare July 28, 2026 13:47
@cyx-6
cyx-6 marked this pull request as ready for review July 28, 2026 14:11
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@tqchen
tqchen merged commit 6893243 into apache:main Jul 29, 2026
12 checks passed
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