Skip to content

cmd: select custom LLVM through dist parameters - #2

Merged
zhouguangyuan0718 merged 5 commits into
go1.27.masterfrom
codex/explicit-llvm-config-pr
Jul 27, 2026
Merged

cmd: select custom LLVM through dist parameters#2
zhouguangyuan0718 merged 5 commits into
go1.27.masterfrom
codex/explicit-llvm-config-pr

Conversation

@zhouguangyuan0718

@zhouguangyuan0718 zhouguangyuan0718 commented Jul 27, 2026

Copy link
Copy Markdown

Summary

  • add -llvm-dir, -llvm-version, and -llvm-link to cmd/dist bootstrap / make.bash
  • resolve the payload from explicit -llvm-dir, then GOALLC_LLVM_DIR, then $GOROOT/llvm
  • default to LLVM 23 and dynamic linking; validate the payload version and selected library
  • atomically map the resolved payload to the binding's ${SRCDIR}/llvm path with an ignored symlink
  • inject orthogonal llvm23,dynamicllvm or llvm23,staticllvm build tags without using ambient CGO_* variables or generated files
  • vendor go-llvm: select custom LLVM by orthogonal build tags go-llvm#3 and update the project architecture/build document

Depends on goallc/go-llvm#3 and, for static mode, goallc/llvm-project#2.

Validation

  • src/make.bash -a (default $GOROOT/llvm, LLVM 23, dynamic)
  • src/make.bash -a -llvm-dir=$GOROOT/llvm -llvm-link=dynamic -llvm-version=23
  • src/make.bash -a -llvm-dir=$GOROOT/llvm -llvm-link=static -llvm-version=23
  • bin/go test cmd/dist
  • bin/go test -tags="llvm23 dynamicllvm" cmd/compile/internal/ssa cmd/objview
  • standalone binding dynamic and static test suites

The local Debug LLVM was built with the macOS 26 SDK while Go targets macOS 16, so the existing deployment-target linker warning remains.

@zhouguangyuan0718 zhouguangyuan0718 changed the title cmd: make LLVM configuration explicit cmd: select custom LLVM through dist parameters Jul 27, 2026
@zhouguangyuan0718

Copy link
Copy Markdown
Author

Updated to move static aggregation into cmd/dist:

  • Dynamic mode still uses the ${SRCDIR}/llvm payload link.
  • Static mode asks payload-local llvm-config for normal component archives and merges them with payload-local llvm-ar into the vendored binding directory.
  • Non-platform static dependencies such as zstd are resolved as archives internally; no ambient CGO_*, LLVMROOT, generated Go source, or LLVM source changes are used.
  • The aggregate is cached using LLVM version, component list, and input archive metadata.
  • Vendored go-llvm is updated to PR cmd/compile: add LLVM IR-only toolexec pipeline #3 commit 223f6a971614.
  • The superseded LLVM PR cmd: select custom LLVM through dist parameters #2 is closed with zero net source diff.

Validation: standalone go-llvm dynamic/static tests passed; full Go three-stage make.bash passed in both -llvm-link=dynamic and -llvm-link=static. The existing macOS 26 LLVM payload versus macOS 16 Go target warnings remain and should be removed when rebuilding the payload with an aligned deployment target.

@zhouguangyuan0718

Copy link
Copy Markdown
Author

Follow-up after go-llvm PR #3 merged:

  • Updated the dependency to merged go-llvm master commit 33267b8eb4a0 (v0.0.0-20260727072003-33267b8eb4a0).
  • Removed GOALLC_LLVM_DIR, GOALLC_LLVM_VERSION, and GOALLC_LLVM_LINK as configuration inputs.
  • LLVM payload, API version, and link mode now use only -llvm-dir, -llvm-version, and -llvm-link, with defaults $GOROOT/llvm, 23, and dynamic.

Validation: full three-stage builds passed in both dynamic and static modes while the removed environment variables were deliberately set to invalid values, confirming that only the command-line parameters are honored.

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