diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-04-14 00:19:33 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-04-14 00:19:33 +0900 |
| commit | a7f7ce17959ccf36201338faeecdbf85d404fe7d (patch) | |
| tree | cd6c0f1694ee69dd1543738d902e25fff7dfbec2 /internal | |
| parent | 38c639e35c4af6310ea15ea125db904a61d30793 (diff) | |
internal/rosa/llvm: migrate compiler-rt
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>
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/rosa/llvm.go | 86 | ||||
| -rw-r--r-- | internal/rosa/rosa.go | 4 | ||||
| -rw-r--r-- | internal/rosa/stage0.go | 4 |
3 files changed, 48 insertions, 46 deletions
diff --git a/internal/rosa/llvm.go b/internal/rosa/llvm.go index 773aec52..d0498744 100644 --- a/internal/rosa/llvm.go +++ b/internal/rosa/llvm.go @@ -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] } diff --git a/internal/rosa/rosa.go b/internal/rosa/rosa.go index c70774d2..89f1c900 100644 --- a/internal/rosa/rosa.go +++ b/internal/rosa/rosa.go @@ -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), diff --git a/internal/rosa/stage0.go b/internal/rosa/stage0.go index 0fc0f8f7..ae5dc611 100644 --- a/internal/rosa/stage0.go +++ b/internal/rosa/stage0.go @@ -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, |
