aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa/rosa.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-05-01 03:09:49 +0900
committerOphestra <cat@gensokyo.uk>2026-05-01 03:36:58 +0900
commitfc66f0bb47dd4634f81aa67bf8fc092945643520 (patch)
treeca4664af315dc0929f7f4034aba29de769197d5a /internal/rosa/rosa.go
parent2cd6b35beeb655ae2a69d17d223063ee5a3e00bb (diff)
internal/rosa/llvm: use llvm build system
This removes the multistep bootstrap hack. Stage0 exceptions are also eliminated for a later change to bring the stage0 distribution down to just a bare toolchain, toybox and shell. This change also enables dynamic linking and ThinLTO. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/rosa/rosa.go')
-rw-r--r--internal/rosa/rosa.go57
1 files changed, 5 insertions, 52 deletions
diff --git a/internal/rosa/rosa.go b/internal/rosa/rosa.go
index c60e4568..e1d20407 100644
--- a/internal/rosa/rosa.go
+++ b/internal/rosa/rosa.go
@@ -107,21 +107,6 @@ func earlyLDFLAGS(static bool) string {
return s
}
-// earlyCFLAGS is reference CFLAGS for the stage0 toolchain.
-const earlyCFLAGS = "-Qunused-arguments " +
- "-isystem/system/include"
-
-// earlyCXXFLAGS returns reference CXXFLAGS for the stage0 toolchain
-// corresponding to [runtime.GOARCH].
-func earlyCXXFLAGS() string {
- return "--start-no-unused-arguments " +
- "-stdlib=libc++ " +
- "--end-no-unused-arguments " +
- "-isystem/system/include/c++/v1 " +
- "-isystem/system/include/" + triplet() + "/c++/v1 " +
- "-isystem/system/include "
-}
-
// Toolchain denotes the infrastructure to compile a [pkg.Artifact] on.
type Toolchain uint32
@@ -191,24 +176,6 @@ func (t Toolchain) isStd() bool {
}
}
-// stage0Concat concatenates s and values. If the current toolchain is
-// toolchainStage0, stage0Concat returns s as is.
-func stage0Concat[S ~[]E, E any](t Toolchain, s S, values ...E) S {
- if t.isStage0() {
- return s
- }
- return slices.Concat(s, values)
-}
-
-// stage0ExclConcat concatenates s and values. If the current toolchain is not
-// toolchainStage0, stage0ExclConcat returns s as is.
-func stage0ExclConcat[S ~[]E, E any](t Toolchain, s S, values ...E) S {
- if t.isStage0() {
- return slices.Concat(s, values)
- }
- return s
-}
-
// lastIndexFunc is like [strings.LastIndexFunc] but for [slices].
func lastIndexFunc[S ~[]E, E any](s S, f func(E) bool) (i int) {
if i = slices.IndexFunc(s, f); i < 0 {
@@ -338,7 +305,7 @@ mkdir -vp /work/system/bin
toybox = toyboxEarly
}
- base := Clang
+ base := LLVM
if flag&TNoToolchain != 0 {
base = Musl
}
@@ -353,11 +320,6 @@ mkdir -vp /work/system/bin
env = fixupEnviron(env, []string{
EnvTriplet + "=" + triplet(),
lcMessages,
-
- "AR=ar",
- "RANLIB=ranlib",
- "LIBCC=/system/lib/clang/" + llvmVersionMajor + "/lib/" + triplet() +
- "/libclang_rt.builtins.a",
}, "/system/bin", "/bin")
default:
@@ -415,8 +377,8 @@ cat /usr/src/` + name + `-patches/* | \
`
aname += "-patched"
}
- return t.New(aname, 0, stage0Concat(t, []pkg.Artifact{},
- t.Load(Patch),
+ return t.New(aname, 0, t.AppendPresets(nil,
+ Patch,
), nil, nil, script, paths...)
}
@@ -463,9 +425,6 @@ type PackageAttr struct {
// Passed to [Toolchain.NewPatchedSource].
Patches []KV
- // Dependencies not provided by stage0.
- NonStage0 []pkg.Artifact
-
// Passed through to [Toolchain.New], before source.
Paths []pkg.ExecPath
// Passed through to [Toolchain.New].
@@ -533,14 +492,8 @@ func (t Toolchain) NewPackage(
panic("source must be non-nil")
}
wantsChmod, wantsWrite := helper.wantsChmod(), helper.wantsWrite()
- dc := len(attr.NonStage0)
- if !t.isStage0() {
- dc += 1<<3 + len(extra)
- }
-
- extraRes := make([]pkg.Artifact, 0, dc)
- extraRes = append(extraRes, attr.NonStage0...)
- if !t.isStage0() {
+ extraRes := make([]pkg.Artifact, 0, 1<<3+len(extra))
+ {
pv := paGet()
for _, p := range helper.extra(attr.Flag) {
extraRes = t.appendPreset(extraRes, pv, p)