Skip to content

llvm: allow disabling split LTO unit for full LTO#41

Merged
xushiwei merged 1 commit into
xgo-dev:xgofrom
zhouguangyuan0718:codex/support-llgo-lto
Jun 18, 2026
Merged

llvm: allow disabling split LTO unit for full LTO#41
xushiwei merged 1 commit into
xgo-dev:xgofrom
zhouguangyuan0718:codex/support-llgo-lto

Conversation

@zhouguangyuan0718

@zhouguangyuan0718 zhouguangyuan0718 commented Jun 18, 2026

Copy link
Copy Markdown

Summary

This PR adds a Full LTO bitcode writer binding for llgo and lets callers decide whether the generated summary index enables split LTO units.

Changes:

  • add WriteFullLTOBitcodeToMemoryBuffer(m Module, enableSplitLTOUnit bool)
  • build a full-LTO ModuleSummaryIndex and emit bitcode with the ThinLTO = 0 module flag
  • only call Index.setEnableSplitLTOUnit() when enableSplitLTOUnit is true
  • keep split-unit state in the summary index rather than exposing it as a module flag
  • add a regression test for the full-LTO writer path

Motivation

llgo needs full-LTO bitcode for whole-program optimization, but Darwin's ld64.lld rejects mixed split-LTO-unit state with:

ld64.lld: error: inconsistent LTO Unit splitting (recompile with -fsplit-lto-unit)

Making split LTO unit emission explicit lets llgo use the same full-LTO writer on all platforms while disabling split units for Darwin links.

Test

go test

@xushiwei xushiwei merged commit afa3201 into xgo-dev:xgo Jun 18, 2026
32 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