Skip to content

Support distributed ThinLTO for Linux cdylibs - #55

Draft
zbarsky-openai wants to merge 1 commit into
hermeticbuild:mainfrom
zbarsky-openai:codex/cdylib-distributed-thinlto
Draft

zbarsky-openai wants to merge 1 commit into
hermeticbuild:mainfrom
zbarsky-openai:codex/cdylib-distributed-thinlto

Conversation

@zbarsky-openai

Copy link
Copy Markdown

Linux cdylibs currently use rustc-owned linking even when the C++
thin_lto feature is enabled. Route them through cc_common.link while
preserving rustc's ELF export script, symbol roots, and bundled native
archives. Keep the existing paths for other operating systems.

Forward CcInfo through the PyO3 toolchain adapters so the separate link
receives their inputs. Keep Cargo build-script C/C++ compilation outside
ThinLTO because opaque archive members have no Bazel backend actions.
The existing one-codegen-unit-per-crate distributed model is unchanged.

This is a draft: native bitcode passed through build scripts without
CcInfo remains unsupported. Custom native linker arguments and dynamic
native dependencies need further coverage before general enablement.

All 21 focused LTO and process-wrapper tests pass on the rebased source,
as does the new runtime fixture with normal linking. The LLVM runtime
fixture is blocked while building process_wrapper because
the toolchain cannot find -lgcc_s. Earlier Linux integration probes
covered dependency C exports, native archives, allocation, and Python
extension loading. Buildifier formatting passes; its lint diagnostics are
unchanged from main.

Preserve rustc export metadata and bundled native archives while letting
the C++ toolchain own ThinLTO backends and the shared-library link.
Forward PyO3 CcInfo and keep opaque Cargo native objects outside
distributed LTO.

Assisted-by: OpenAI Codex
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.

1 participant