internal/rosa/llvm: migrate runtimes and clang
All checks were successful
Test / Create distribution (push) Successful in 1m56s
Test / ShareFS (push) Successful in 8m1s
Test / Sandbox (race detector) (push) Successful in 8m31s
Test / Hakurei (race detector) (push) Successful in 9m57s
Test / Sandbox (push) Successful in 2m13s
Test / Hakurei (push) Successful in 3m17s
Test / Flake checks (push) Successful in 1m38s
All checks were successful
Test / Create distribution (push) Successful in 1m56s
Test / ShareFS (push) Successful in 8m1s
Test / Sandbox (race detector) (push) Successful in 8m31s
Test / Hakurei (race detector) (push) Successful in 9m57s
Test / Sandbox (push) Successful in 2m13s
Test / Hakurei (push) Successful in 3m17s
Test / Flake checks (push) Successful in 1m38s
This eliminates most newLLVM family of functions. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -3,7 +3,6 @@ package rosa
|
||||
import (
|
||||
"runtime"
|
||||
"slices"
|
||||
"sync"
|
||||
|
||||
"hakurei.app/internal/pkg"
|
||||
)
|
||||
@@ -130,40 +129,26 @@ func init() {
|
||||
Name: "llvm-compiler-rt",
|
||||
Description: "LLVM runtime: compiler-rt",
|
||||
Website: "https://llvm.org/",
|
||||
|
||||
Dependencies: P{
|
||||
Musl,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// newLLVM returns LLVM toolchain across multiple [pkg.Artifact].
|
||||
func (t Toolchain) newLLVM() (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.Load(Musl)
|
||||
|
||||
runtimes = t.newLLVMVariant("runtimes", &llvmAttr{
|
||||
env: stage0ExclConcat(t, []string{},
|
||||
func (t Toolchain) newLLVMRuntimes() (pkg.Artifact, string) {
|
||||
return t.NewPackage("llvm", llvmVersion, llvmSource, &PackageAttr{
|
||||
Patches: llvmPatches,
|
||||
NonStage0: t.AppendPresets(nil, LLVMCompilerRT),
|
||||
Env: stage0ExclConcat(t, []string{},
|
||||
"LDFLAGS="+earlyLDFLAGS(false),
|
||||
),
|
||||
cmake: slices.Concat([]KV{
|
||||
Flag: TExclusive,
|
||||
}, &CMakeHelper{
|
||||
Variant: "runtimes",
|
||||
Append: []string{"runtimes"},
|
||||
|
||||
Cache: []KV{
|
||||
{"CMAKE_BUILD_TYPE", "Release"},
|
||||
|
||||
{"LLVM_HOST_TRIPLE", `"${ROSA_TRIPLE}"`},
|
||||
@@ -181,21 +166,61 @@ func (t Toolchain) newLLVM() (runtimes, clang pkg.Artifact) {
|
||||
|
||||
{"LIBCXX_HAS_ATOMIC_LIB", "OFF"},
|
||||
{"LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL", "OFF"},
|
||||
}, minimalDeps),
|
||||
append: []string{"runtimes"},
|
||||
nonStage0: []pkg.Artifact{
|
||||
compilerRT,
|
||||
musl,
|
||||
},
|
||||
})
|
||||
|
||||
clang = t.newLLVMVariant("clang", &llvmAttr{
|
||||
env: stage0ExclConcat(t, []string{},
|
||||
{"LLVM_ENABLE_ZLIB", "OFF"},
|
||||
{"LLVM_ENABLE_ZSTD", "OFF"},
|
||||
{"LLVM_ENABLE_LIBXML2", "OFF"},
|
||||
},
|
||||
},
|
||||
Python,
|
||||
|
||||
KernelHeaders,
|
||||
), llvmVersion
|
||||
}
|
||||
func init() {
|
||||
artifactsM[LLVMRuntimes] = Metadata{
|
||||
f: Toolchain.newLLVMRuntimes,
|
||||
|
||||
Name: "llvm-runtimes",
|
||||
Description: "LLVM runtimes: libunwind, libcxx, libcxxabi",
|
||||
Website: "https://llvm.org/",
|
||||
|
||||
Dependencies: P{
|
||||
LLVMCompilerRT,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (t Toolchain) newLLVMClang() (pkg.Artifact, string) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
return t.NewPackage("llvm", llvmVersion, llvmSource, &PackageAttr{
|
||||
Patches: llvmPatches,
|
||||
NonStage0: t.AppendPresets(nil, LLVMRuntimes),
|
||||
Env: stage0ExclConcat(t, []string{},
|
||||
"CFLAGS="+earlyCFLAGS,
|
||||
"CXXFLAGS="+earlyCXXFLAGS(),
|
||||
"LDFLAGS="+earlyLDFLAGS(false),
|
||||
),
|
||||
cmake: slices.Concat([]KV{
|
||||
Flag: TExclusive,
|
||||
}, &CMakeHelper{
|
||||
Variant: "clang",
|
||||
Append: []string{"llvm"},
|
||||
|
||||
Cache: []KV{
|
||||
{"CMAKE_BUILD_TYPE", "Release"},
|
||||
|
||||
{"LLVM_HOST_TRIPLE", `"${ROSA_TRIPLE}"`},
|
||||
@@ -218,13 +243,12 @@ func (t Toolchain) newLLVM() (runtimes, clang pkg.Artifact) {
|
||||
{"LLVM_TARGETS_TO_BUILD", target},
|
||||
{"CMAKE_CROSSCOMPILING", "OFF"},
|
||||
{"CXX_SUPPORTS_CUSTOM_LINKER", "ON"},
|
||||
}, minimalDeps),
|
||||
nonStage0: []pkg.Artifact{
|
||||
musl,
|
||||
compilerRT,
|
||||
runtimes,
|
||||
|
||||
{"LLVM_ENABLE_ZLIB", "OFF"},
|
||||
{"LLVM_ENABLE_ZSTD", "OFF"},
|
||||
{"LLVM_ENABLE_LIBXML2", "OFF"},
|
||||
},
|
||||
script: `
|
||||
Script: `
|
||||
ln -s ld.lld /work/system/bin/ld
|
||||
|
||||
ln -s clang /work/system/bin/cc
|
||||
@@ -232,32 +256,30 @@ ln -s clang++ /work/system/bin/c++
|
||||
|
||||
ninja check-all
|
||||
`,
|
||||
})
|
||||
},
|
||||
Python,
|
||||
Perl,
|
||||
Diffutils,
|
||||
Bash,
|
||||
Gawk,
|
||||
Coreutils,
|
||||
Findutils,
|
||||
|
||||
return
|
||||
KernelHeaders,
|
||||
), llvmVersion
|
||||
}
|
||||
func init() {
|
||||
artifactsM[LLVMRuntimes] = Metadata{
|
||||
f: func(t Toolchain) (pkg.Artifact, string) {
|
||||
runtimes, _ := t.newLLVM()
|
||||
return runtimes, llvmVersion
|
||||
},
|
||||
|
||||
Name: "llvm-runtimes",
|
||||
Description: "LLVM runtimes: libunwind, libcxx, libcxxabi",
|
||||
Website: "https://llvm.org/",
|
||||
}
|
||||
|
||||
artifactsM[LLVMClang] = Metadata{
|
||||
f: func(t Toolchain) (pkg.Artifact, string) {
|
||||
_, clang := t.newLLVM()
|
||||
return clang, llvmVersion
|
||||
},
|
||||
f: Toolchain.newLLVMClang,
|
||||
|
||||
Name: "clang",
|
||||
Description: `an "LLVM native" C/C++/Objective-C compiler`,
|
||||
Website: "https://llvm.org/",
|
||||
|
||||
Dependencies: P{
|
||||
LLVMRuntimes,
|
||||
},
|
||||
|
||||
ID: 1830,
|
||||
}
|
||||
|
||||
@@ -282,18 +304,3 @@ func init() {
|
||||
Website: "https://libclc.llvm.org/",
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
// llvm stores the result of Toolchain.newLLVM.
|
||||
llvm [_toolchainEnd][2]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() (runtimes, clang pkg.Artifact) {
|
||||
llvmOnce[t].Do(func() {
|
||||
llvm[t][0], llvm[t][1] = t.newLLVM()
|
||||
})
|
||||
return llvm[t][0], llvm[t][1]
|
||||
}
|
||||
|
||||
@@ -328,24 +328,23 @@ mkdir -vp /work/system/bin
|
||||
name += "-std"
|
||||
}
|
||||
|
||||
boot := t - 1
|
||||
runtimes, clang := boot.NewLLVM()
|
||||
toybox := Toybox
|
||||
if flag&TEarly != 0 {
|
||||
toybox = toyboxEarly
|
||||
}
|
||||
std := []pkg.Artifact{cureEtc{newIANAEtc()}, boot.Load(Musl)}
|
||||
toolchain := []pkg.Artifact{boot.Load(LLVMCompilerRT), runtimes, clang}
|
||||
utils := []pkg.Artifact{
|
||||
boot.Load(Mksh),
|
||||
boot.Load(toybox),
|
||||
}
|
||||
|
||||
base := LLVMClang
|
||||
if flag&TNoToolchain != 0 {
|
||||
toolchain = nil
|
||||
base = Musl
|
||||
}
|
||||
|
||||
support = slices.Concat(extra, std, toolchain, utils)
|
||||
support = slices.Concat(extra, (t-1).AppendPresets([]pkg.Artifact{
|
||||
cureEtc{newIANAEtc()},
|
||||
},
|
||||
base,
|
||||
Mksh,
|
||||
toybox,
|
||||
))
|
||||
env = fixupEnviron(env, []string{
|
||||
EnvTriplet + "=" + triplet(),
|
||||
lcMessages,
|
||||
|
||||
@@ -7,12 +7,11 @@ import (
|
||||
)
|
||||
|
||||
func (t Toolchain) newStage0() (pkg.Artifact, string) {
|
||||
runtimes, clang := t.NewLLVM()
|
||||
return t.New("rosa-stage0", 0, []pkg.Artifact{
|
||||
t.Load(Musl),
|
||||
t.Load(LLVMCompilerRT),
|
||||
runtimes,
|
||||
clang,
|
||||
t.Load(LLVMRuntimes),
|
||||
t.Load(LLVMClang),
|
||||
|
||||
t.Load(Zlib),
|
||||
t.Load(Bzip2),
|
||||
|
||||
Reference in New Issue
Block a user