internal/rosa/llvm: migrate musl
All checks were successful
Test / Create distribution (push) Successful in 2m48s
Test / Sandbox (push) Successful in 6m4s
Test / Hakurei (push) Successful in 7m14s
Test / ShareFS (push) Successful in 7m23s
Test / Sandbox (race detector) (push) Successful in 9m34s
Test / Hakurei (race detector) (push) Successful in 4m2s
Test / Flake checks (push) Successful in 1m33s

This removes the pointless special treatment given to musl.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-04-14 00:35:06 +09:00
parent a7f7ce1795
commit ac825640ab
5 changed files with 32 additions and 33 deletions

View File

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

View File

@@ -69,10 +69,7 @@ func (t Toolchain) newLLVMVariant(variant string, attr *llvmAttr) pkg.Artifact {
} }
func (t Toolchain) newCompilerRT() (pkg.Artifact, string) { func (t Toolchain) newCompilerRT() (pkg.Artifact, string) {
muslHeaders, _ := t.newMusl(true, []string{ muslHeaders, _ := t.newMusl(true)
"CC=clang",
})
return t.newLLVMVariant("compiler-rt", &llvmAttr{ return t.newLLVMVariant("compiler-rt", &llvmAttr{
env: stage0ExclConcat(t, []string{}, env: stage0ExclConcat(t, []string{},
"LDFLAGS="+earlyLDFLAGS(false), "LDFLAGS="+earlyLDFLAGS(false),
@@ -128,7 +125,7 @@ func init() {
} }
// newLLVM returns LLVM toolchain across multiple [pkg.Artifact]. // newLLVM returns LLVM toolchain across multiple [pkg.Artifact].
func (t Toolchain) newLLVM() (musl, runtimes, clang pkg.Artifact) { func (t Toolchain) newLLVM() (runtimes, clang pkg.Artifact) {
target := "'AArch64;RISCV;X86'" target := "'AArch64;RISCV;X86'"
if t.isStage0() { if t.isStage0() {
switch runtime.GOARCH { switch runtime.GOARCH {
@@ -151,16 +148,7 @@ func (t Toolchain) newLLVM() (musl, runtimes, clang pkg.Artifact) {
} }
compilerRT := t.Load(LLVMCompilerRT) compilerRT := t.Load(LLVMCompilerRT)
musl := t.Load(Musl)
musl, _ = t.newMusl(false, stage0ExclConcat(t, []string{
"CC=clang",
"LIBCC=/system/lib/clang/" + llvmVersionMajor + "/lib/" +
triplet() + "/libclang_rt.builtins.a",
"AR=ar",
"RANLIB=ranlib",
},
"LDFLAGS="+earlyLDFLAGS(false),
), compilerRT)
runtimes = t.newLLVMVariant("runtimes", &llvmAttr{ runtimes = t.newLLVMVariant("runtimes", &llvmAttr{
env: stage0ExclConcat(t, []string{}, env: stage0ExclConcat(t, []string{},
@@ -242,7 +230,7 @@ ninja check-all
func init() { func init() {
artifactsM[LLVMRuntimes] = Metadata{ artifactsM[LLVMRuntimes] = Metadata{
f: func(t Toolchain) (pkg.Artifact, string) { f: func(t Toolchain) (pkg.Artifact, string) {
_, runtimes, _ := t.newLLVM() runtimes, _ := t.newLLVM()
return runtimes, llvmVersion return runtimes, llvmVersion
}, },
@@ -253,7 +241,7 @@ func init() {
artifactsM[LLVMClang] = Metadata{ artifactsM[LLVMClang] = Metadata{
f: func(t Toolchain) (pkg.Artifact, string) { f: func(t Toolchain) (pkg.Artifact, string) {
_, _, clang := t.newLLVM() _, clang := t.newLLVM()
return clang, llvmVersion return clang, llvmVersion
}, },
@@ -288,15 +276,15 @@ func init() {
var ( var (
// llvm stores the result of Toolchain.newLLVM. // llvm stores the result of Toolchain.newLLVM.
llvm [_toolchainEnd][3]pkg.Artifact llvm [_toolchainEnd][2]pkg.Artifact
// llvmOnce is for lazy initialisation of llvm. // llvmOnce is for lazy initialisation of llvm.
llvmOnce [_toolchainEnd]sync.Once llvmOnce [_toolchainEnd]sync.Once
) )
// NewLLVM returns LLVM toolchain across multiple [pkg.Artifact]. // NewLLVM returns LLVM toolchain across multiple [pkg.Artifact].
func (t Toolchain) NewLLVM() (musl, runtimes, clang pkg.Artifact) { func (t Toolchain) NewLLVM() (runtimes, clang pkg.Artifact) {
llvmOnce[t].Do(func() { llvmOnce[t].Do(func() {
llvm[t][0], llvm[t][1], llvm[t][2] = t.newLLVM() llvm[t][0], llvm[t][1] = t.newLLVM()
}) })
return llvm[t][0], llvm[t][1], llvm[t][2] return llvm[t][0], llvm[t][1]
} }

View File

@@ -4,7 +4,6 @@ import "hakurei.app/internal/pkg"
func (t Toolchain) newMusl( func (t Toolchain) newMusl(
headers bool, headers bool,
env []string,
extra ...pkg.Artifact, extra ...pkg.Artifact,
) (pkg.Artifact, string) { ) (pkg.Artifact, string) {
const ( const (
@@ -47,7 +46,15 @@ rmdir -v /work/lib
// expected to be writable in copies // expected to be writable in copies
Chmod: true, Chmod: true,
Env: env, Env: stage0ExclConcat(t, []string{
"CC=clang",
"LIBCC=/system/lib/clang/" + llvmVersionMajor + "/lib/" +
triplet() + "/libclang_rt.builtins.a",
"AR=ar",
"RANLIB=ranlib",
},
"LDFLAGS="+earlyLDFLAGS(false),
),
}, &helper, }, &helper,
Coreutils, Coreutils,
), version ), version
@@ -55,7 +62,7 @@ rmdir -v /work/lib
func init() { func init() {
artifactsM[Musl] = Metadata{ artifactsM[Musl] = Metadata{
f: func(t Toolchain) (pkg.Artifact, string) { f: func(t Toolchain) (pkg.Artifact, string) {
return t.newMusl(false, nil) return t.newMusl(false, t.Load(LLVMCompilerRT))
}, },
Name: "musl", Name: "musl",

View File

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

View File

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