internal/rosa/llvm: migrate compiler-rt
All checks were successful
Test / Create distribution (push) Successful in 1m24s
Test / Sandbox (push) Successful in 3m33s
Test / Hakurei (push) Successful in 6m17s
Test / ShareFS (push) Successful in 6m14s
Test / Hakurei (race detector) (push) Successful in 8m34s
Test / Sandbox (race detector) (push) Successful in 5m39s
Test / Flake checks (push) Successful in 1m40s

The newLLVM family of functions predate the package system. This change migrates compiler-rt without changing any resulting artifacts.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-04-14 00:19:33 +09:00
parent 38c639e35c
commit a7f7ce1795
4 changed files with 54 additions and 51 deletions

View File

@@ -396,9 +396,9 @@ func main() {
rosa.SetGentooStage3(flagGentoo, checksum)
}
_, _, _, stage1 := (t - 2).NewLLVM()
_, _, _, stage2 := (t - 1).NewLLVM()
_, _, _, stage3 := t.NewLLVM()
_, _, stage1 := (t - 2).NewLLVM()
_, _, stage2 := (t - 1).NewLLVM()
_, _, stage3 := t.NewLLVM()
var (
pathname *check.Absolute
checksum [2]unique.Handle[pkg.Checksum]
@@ -577,8 +577,9 @@ func main() {
root = rosa.Std.AppendPresets(root, presets...)
if flagWithToolchain {
musl, compilerRT, runtimes, clang := (rosa.Std - 1).NewLLVM()
root = append(root, musl, compilerRT, runtimes, clang)
boot := rosa.Std - 1
musl, runtimes, clang := boot.NewLLVM()
root = append(root, musl, boot.Load(rosa.LLVMCompilerRT), runtimes, clang)
} else {
root = append(root, rosa.Std.Load(rosa.Musl))
}

View File

@@ -68,34 +68,12 @@ func (t Toolchain) newLLVMVariant(variant string, attr *llvmAttr) pkg.Artifact {
)
}
// newLLVM returns LLVM toolchain across multiple [pkg.Artifact].
func (t Toolchain) newLLVM() (musl, compilerRT, runtimes, clang pkg.Artifact) {
target := "'AArch64;RISCV;X86'"
if t.isStage0() {
switch runtime.GOARCH {
case "386", "amd64":
target = "X86"
case "arm64":
target = "AArch64"
case "riscv64":
target = "RISCV"
default:
panic("unsupported target " + runtime.GOARCH)
}
}
minimalDeps := []KV{
{"LLVM_ENABLE_ZLIB", "OFF"},
{"LLVM_ENABLE_ZSTD", "OFF"},
{"LLVM_ENABLE_LIBXML2", "OFF"},
}
func (t Toolchain) newCompilerRT() (pkg.Artifact, string) {
muslHeaders, _ := t.newMusl(true, []string{
"CC=clang",
})
compilerRT = t.newLLVMVariant("compiler-rt", &llvmAttr{
return t.newLLVMVariant("compiler-rt", &llvmAttr{
env: stage0ExclConcat(t, []string{},
"LDFLAGS="+earlyLDFLAGS(false),
),
@@ -137,7 +115,42 @@ ln -s \
"clang_rt.crtend-` + linuxArch() + `.o" \
"/work/system/lib/${ROSA_TRIPLE}/crtendS.o"
`,
})
}), llvmVersion
}
func init() {
artifactsM[LLVMCompilerRT] = Metadata{
f: Toolchain.newCompilerRT,
Name: "llvm-compiler-rt",
Description: "LLVM runtime: compiler-rt",
Website: "https://llvm.org/",
}
}
// newLLVM returns LLVM toolchain across multiple [pkg.Artifact].
func (t Toolchain) newLLVM() (musl, runtimes, clang pkg.Artifact) {
target := "'AArch64;RISCV;X86'"
if t.isStage0() {
switch runtime.GOARCH {
case "386", "amd64":
target = "X86"
case "arm64":
target = "AArch64"
case "riscv64":
target = "RISCV"
default:
panic("unsupported target " + runtime.GOARCH)
}
}
minimalDeps := []KV{
{"LLVM_ENABLE_ZLIB", "OFF"},
{"LLVM_ENABLE_ZSTD", "OFF"},
{"LLVM_ENABLE_LIBXML2", "OFF"},
}
compilerRT := t.Load(LLVMCompilerRT)
musl, _ = t.newMusl(false, stage0ExclConcat(t, []string{
"CC=clang",
@@ -227,20 +240,9 @@ ninja check-all
return
}
func init() {
artifactsM[LLVMCompilerRT] = Metadata{
f: func(t Toolchain) (pkg.Artifact, string) {
_, compilerRT, _, _ := t.newLLVM()
return compilerRT, llvmVersion
},
Name: "llvm-compiler-rt",
Description: "LLVM runtime: compiler-rt",
Website: "https://llvm.org/",
}
artifactsM[LLVMRuntimes] = Metadata{
f: func(t Toolchain) (pkg.Artifact, string) {
_, _, runtimes, _ := t.newLLVM()
_, runtimes, _ := t.newLLVM()
return runtimes, llvmVersion
},
@@ -251,7 +253,7 @@ func init() {
artifactsM[LLVMClang] = Metadata{
f: func(t Toolchain) (pkg.Artifact, string) {
_, _, _, clang := t.newLLVM()
_, _, clang := t.newLLVM()
return clang, llvmVersion
},
@@ -286,15 +288,15 @@ func init() {
var (
// llvm stores the result of Toolchain.newLLVM.
llvm [_toolchainEnd][4]pkg.Artifact
llvm [_toolchainEnd][3]pkg.Artifact
// llvmOnce is for lazy initialisation of llvm.
llvmOnce [_toolchainEnd]sync.Once
)
// NewLLVM returns LLVM toolchain across multiple [pkg.Artifact].
func (t Toolchain) NewLLVM() (musl, compilerRT, runtimes, clang pkg.Artifact) {
func (t Toolchain) NewLLVM() (musl, runtimes, clang pkg.Artifact) {
llvmOnce[t].Do(func() {
llvm[t][0], llvm[t][1], llvm[t][2], llvm[t][3] = t.newLLVM()
llvm[t][0], llvm[t][1], llvm[t][2] = t.newLLVM()
})
return llvm[t][0], llvm[t][1], llvm[t][2], llvm[t][3]
return llvm[t][0], llvm[t][1], llvm[t][2]
}

View File

@@ -329,13 +329,13 @@ mkdir -vp /work/system/bin
}
boot := t - 1
musl, compilerRT, runtimes, clang := boot.NewLLVM()
musl, runtimes, clang := boot.NewLLVM()
toybox := Toybox
if flag&TEarly != 0 {
toybox = toyboxEarly
}
std := []pkg.Artifact{cureEtc{newIANAEtc()}, musl}
toolchain := []pkg.Artifact{compilerRT, runtimes, clang}
toolchain := []pkg.Artifact{boot.Load(LLVMCompilerRT), runtimes, clang}
utils := []pkg.Artifact{
boot.Load(Mksh),
boot.Load(toybox),

View File

@@ -7,10 +7,10 @@ import (
)
func (t Toolchain) newStage0() (pkg.Artifact, string) {
musl, compilerRT, runtimes, clang := t.NewLLVM()
musl, runtimes, clang := t.NewLLVM()
return t.New("rosa-stage0", 0, []pkg.Artifact{
musl,
compilerRT,
t.Load(LLVMCompilerRT),
runtimes,
clang,