Repository navigation
Add LLVM 23 build support - #5782
Conversation
| @@ -1,4 +1,4 @@ | |||
| //go:build !llvm22 && !llvm14 && !llvm15 && !llvm16 && !llvm17 && !llvm18 && !llvm19 | |||
| //go:build !llvm22 && !llvm23 && !llvm14 && !llvm15 && !llvm16 && !llvm17 && !llvm18 && !llvm19 | |||
There was a problem hiding this comment.
Out of order here (why are some files one way, some the other)
92b7ee8 to
7186e2b
Compare
|
This passes my test corpus as well as the stdlib tests on darwin/arm64 and wasip1. |
|
Will need to merge tinygo-org/go-llvm#79 first for llvm23 support and then update go.mod. |
|
Add some commits from @davecheney to make the condition branch argument stuff a bit nicer. |
|
@dgryski awesome; i'm testing on arch and osx which have llvm23 as their default now |
|
@dgryski tinygo-org/go-llvm#83 (and a stacked branch on dgryski#18) removes the aliasing of OpBr before / after llvm23; before llvm23 there is only OpBr, llvm23 and later there is only CondBr and UncondBr. |
|
@dgryski dgryski#20 incorporates tinygo-org/go-llvm#83 |
Lets the fork build on a system whose LLVM is 23, with go build -tags llvm23. The conflicts were additions on one side only, except makeStrongFromWeak, where both sides return the pointer as it is.
|
The static build needed two more changes for LLVM 23, in case they are useful here. cc1as.cpp follows three MC API changes, as clang's cc1as_main.cpp did, which only the static build compiles: 0magnet@34fc049. The static link also lists the libraries LLVM 23 added (LLVMABI, clangDependencyScanning, the clangScalableStaticAnalysis libraries and clangUnifiedSymbolResolution): 0magnet@0f8bccc |
|
@dgryski dgryski#21 fixes the go mod tidy break |
|
@dgryski I've been testing this locally and its working well for me on osx with homebrews llvm22 and llvm23. go-llvm has moved forward a few commits since the last push, could you please update this branch to use the latest there, make go mod tidy happy, and push again and I think we can land this. |
|
PTAL |
174334d to
887ac2f
Compare
Adds the llvm23 build-tag config files, mirroring the existing llvm22 ones. Requires go-llvm branch dgryski/add-llvm23, not yet merged, so go.mod still points at the current go-llvm commit. Verified against real LLVM 23.1.1: a native build and a wasi build both produce working binaries. LLVM 23 keeps the wasm32-unknown-wasi triple deprecation and the Xtensa feature renames from LLVM 22. LLVM 23 removed the Os/Oz pipeline levels from the new pass manager's textual syntax. transform/optimizer.go now runs O2 instead on LLVM 23+, relying on the optsize/minsize function attributes already set elsewhere to steer size-conscious passes. LLVM 23 requires the llvm.returnaddress intrinsic's mangled name to include its pointer type suffix. Patches the linkName for that //export pragma in compiler/symbol.go. LLVM 23 splits the branch instruction into separate opcodes and reorders a conditional branch's operands from (cond, else, then) to (cond, then, else). interp/compiler.go hardcoded the old order, which silently inverted every branch condition the compile-time interpreter evaluated, sending most packages into infinite recursion during interp. Fixed with a version-gated operand read. Also normalizes the LLVM 23 nosync attribute (newly inferred for llvm.memcpy/llvm.memmove) in the golden IR test comparators, and updates a hardcoded Oz pipeline string in transform/unwind_test.go. Known gaps: a few golden IR comparison tests in compiler_test.go show cosmetic diffs from LLVM 23 output formatting (float hex constants, a GEP canonicalization change, attribute group renumbering). These are printer text drift, not correctness bugs. The Xtensa feature rename shim is extended to LLVM 23 by assumption, not verified against a real Xtensa-enabled toolchain.
cgo/libclang_config_llvm23.go: also search Homebrew's unversioned llvm formula, same reasoning as the matching go-llvm change. builder/commands.go: same idea for locating clang/lld/wasm-ld/lldb at run time, plus a bug fix this exposed. LookupCommand only recognized a bare command missing from $PATH as a reason to try the next candidate. A missing absolute path surfaces a different error and was treated as fatal, aborting the search before it reached a working fallback.
887ac2f to
47ad8e2
Compare
|
Fixed the conflicts and then squashed all the interp patches that were working around the rapidly-changing go-llvm bits. |
davecheney
left a comment
There was a problem hiding this comment.
@dgryski LGTM. Thank you very much. Lets land this before it bit rots again :)
% tinygo version
tinygo version 0.44.0-dev-6ff7684a darwin/arm64 (using go version go1.27.2 and LLVM version 23.1.3)
Adds
llvm23build-tag config, mirroring the existingllvm22support.Requires tinygo-org/go-llvm#79, which is not yet merged/tagged, so
go.modis left pointing at the current go-llvm commit for now.
Verified against real LLVM 23.1.1 headers and libraries (via Homebrew): both
a native build and a wasi build produce working binaries that run correctly.
LLVM 23 keeps the
wasm32-unknown-wasitriple deprecation and the Xtensafeature renames introduced in LLVM 22 (confirmed for the triple; the Xtensa
renames are assumed unchanged, not yet verified against an Xtensa-enabled
LLVM 23 toolchain).
LLVM 23 removed the
Os/Ozpipeline levels from the new pass manager'stextual pipeline syntax (
"thinlto-pre-link<Os>"now aborts with a fatalLLVM error).
transform/optimizer.gonow runs theO2pipeline levelinstead on LLVM 23+, relying on the
optsize/minsizefunction attributesalready set elsewhere to keep steering size-conscious passes.
LLVM 23 requires the
llvm.returnaddressintrinsic's mangled name to includeits pointer type suffix (
llvm.returnaddress.p0). Patches thelinkNameforthat specific
//exportpragma incompiler/symbol.go.LLVM 23 splits the conditional/unconditional branch instruction into separate
opcodes and, more importantly, reorders a conditional branch's operands from
(cond, else, then)to(cond, then, else).interp/compiler.gohardcodedthe old order when building its own branch instruction, which silently
inverted every branch condition evaluated by the compile-time interpreter
under LLVM 23, sending essentially all packages into infinite recursion
during interp. Fixed with a version-gated operand read.
Also normalizes away the LLVM 23
nosyncattribute (newly inferred forllvm.memcpy/llvm.memmove) in the golden-IR test comparators incompiler_test.go,transform_test.goandinterp_test.go, and updates ahardcoded
"Oz"pipeline string intransform/unwind_test.gothe same wayas the production code path.
Known gaps
compiler_test.goshowcosmetic diffs from LLVM 23's own output-formatting changes (float
hex-constant syntax, a GEP-canonicalization preference change, and
attribute-group renumbering). These are optimizer/printer text drift, not
correctness bugs; fixing them properly needs per-LLVM-version golden
fixtures, which is out of scope here.
compileopts/features_llvm22.go)is extended to LLVM 23 by assumption, not verified against a real
Xtensa-enabled LLVM 23 toolchain.
Closes #5775