internal/rosa: configurable architecture
All checks were successful
Test / Create distribution (push) Successful in 1m6s
Test / Sandbox (push) Successful in 2m48s
Test / ShareFS (push) Successful in 3m40s
Test / Hakurei (push) Successful in 3m57s
Test / Sandbox (race detector) (push) Successful in 5m22s
Test / Hakurei (race detector) (push) Successful in 6m33s
Test / Flake checks (push) Successful in 1m29s

This enables curing via binfmt.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-05-07 19:45:36 +09:00
parent 8d72b9e5bd
commit 65b7dd8b37
8 changed files with 39 additions and 53 deletions

View File

@@ -183,7 +183,8 @@ const (
// PresetUnexportedStart is the first unexported preset.
PresetUnexportedStart
llvmSource = iota - 1
stage0Dist = iota - 1
llvmSource
// earlyCompilerRT is an early, standalone compiler-rt installation for the
// standalone runtimes build.
//

View File

@@ -5,7 +5,6 @@ import (
"io"
"net/http"
"os"
"runtime"
"time"
"hakurei.app/fhs"
@@ -88,7 +87,7 @@ func (a busyboxBin) Cure(t *pkg.TContext) (err error) {
// the https://busybox.net/downloads/binaries/ binary release.
func newBusyboxBin() pkg.Artifact {
var version, url, checksum string
switch runtime.GOARCH {
switch arch {
case "amd64":
version = "1.35.0"
url = "https://busybox.net/downloads/binaries/" +
@@ -101,7 +100,7 @@ func newBusyboxBin() pkg.Artifact {
checksum = "npJjBO7iwhjW6Kx2aXeSxf8kXhVgTCDChOZTTsI8ZfFfa3tbsklxRiidZQdrVERg"
default:
panic("unsupported target " + runtime.GOARCH)
panic("unsupported target " + arch)
}
return pkg.NewExec(

View File

@@ -1,7 +1,6 @@
package rosa
import (
"runtime"
"slices"
"strconv"
"strings"
@@ -843,7 +842,7 @@ func (t Toolchain) newGnuTLS() (pkg.Artifact, string) {
)
var configureExtra []KV
switch runtime.GOARCH {
switch arch {
case "arm64":
configureExtra = []KV{
{"disable-hardware-acceleration"},
@@ -1148,7 +1147,7 @@ func (t Toolchain) newGCC() (pkg.Artifact, string) {
)
var configureExtra []KV
switch runtime.GOARCH {
switch arch {
case "amd64", "arm64":
configureExtra = append(configureExtra, KV{"with-multilib-list", "''"})
}

View File

@@ -1,7 +1,6 @@
package rosa
import (
"runtime"
"slices"
"hakurei.app/internal/pkg"
@@ -69,7 +68,7 @@ func (t Toolchain) newGoLatest() (pkg.Artifact, string) {
finalEnv []string
)
switch runtime.GOARCH {
switch arch {
case "amd64":
bootstrapExtra = append(bootstrapExtra, t.newGoBootstrap())
@@ -79,7 +78,7 @@ func (t Toolchain) newGoLatest() (pkg.Artifact, string) {
finalEnv = append(finalEnv, "CGO_ENABLED=0")
default:
panic("unsupported target " + runtime.GOARCH)
panic("unsupported target " + arch)
}
go119 := t.newGo(
@@ -104,7 +103,7 @@ echo \
[]string{"CGO_ENABLED=0"}, `
sed -i \
's,/lib/ld-musl-`+linuxArch()+`.so.1,/system/bin/linker,' \
cmd/link/internal/`+runtime.GOARCH+`/obj.go
cmd/link/internal/`+arch+`/obj.go
rm \
crypto/tls/handshake_client_test.go \
@@ -122,7 +121,7 @@ echo \
[]string{"CGO_ENABLED=0"}, `
sed -i \
's,/lib/ld-musl-`+linuxArch()+`.so.1,/system/bin/linker,' \
cmd/link/internal/`+runtime.GOARCH+`/obj.go
cmd/link/internal/`+arch+`/obj.go
`, go121,
)
@@ -132,7 +131,7 @@ sed -i \
[]string{"CGO_ENABLED=0"}, `
sed -i \
's,/lib/ld-musl-`+linuxArch()+`.so.1,/system/bin/linker,' \
cmd/link/internal/`+runtime.GOARCH+`/obj.go
cmd/link/internal/`+arch+`/obj.go
rm \
os/root_unix_test.go \
@@ -150,7 +149,7 @@ rm \
finalEnv, `
sed -i \
's,/lib/ld-musl-`+linuxArch()+`.so.1,/system/bin/linker,' \
cmd/link/internal/`+runtime.GOARCH+`/obj.go
cmd/link/internal/`+arch+`/obj.go
sed -i \
's/cpu.X86.HasAVX512VBMI/& \&\& cpu.X86.HasPOPCNT/' \
internal/runtime/gc/scan/scan_amd64.go

View File

@@ -2,7 +2,6 @@ package rosa
import (
"regexp"
"runtime"
"slices"
"strings"
@@ -248,7 +247,7 @@ func (t Toolchain) newLLVM() (pkg.Artifact, string) {
// unwind: fails on musl
"eh_frame_fde_pc_range",
}
switch runtime.GOARCH {
switch arch {
case "arm64":
skipChecks = append(skipChecks,
// LLVM: intermittently crashes

View File

@@ -4,7 +4,6 @@ package rosa
import (
"errors"
"path"
"runtime"
"slices"
"strconv"
"strings"
@@ -54,10 +53,9 @@ var (
AbsSystem = fhs.AbsRoot.Append("system")
)
// linuxArch returns the architecture name used by linux corresponding to
// [runtime.GOARCH].
// linuxArch returns the architecture name used by linux corresponding to arch.
func linuxArch() string {
switch runtime.GOARCH {
switch arch {
case "amd64":
return "x86_64"
case "arm64":
@@ -66,11 +64,11 @@ func linuxArch() string {
return "riscv64"
default:
panic("unsupported target " + runtime.GOARCH)
panic("unsupported target " + arch)
}
}
// triplet returns the Rosa OS host triple corresponding to [runtime.GOARCH].
// triplet returns the Rosa OS host triple corresponding to arch.
func triplet() string {
return linuxArch() + "-rosa-linux-musl"
}
@@ -80,9 +78,9 @@ type perArch[T any] map[string]T
// unwrap returns the value for the current architecture.
func (p perArch[T]) unwrap() T {
v, ok := p[runtime.GOARCH]
v, ok := p[arch]
if !ok {
panic("unsupported target " + runtime.GOARCH)
panic("unsupported target " + arch)
}
return v
}
@@ -268,7 +266,7 @@ func (t Toolchain) New(
support = append(support, extra...)
support = append(support, cureEtc{})
if t == toolchainStage0 {
support = append(support, NewStage0())
support = append(support, t.Load(stage0Dist))
} else {
support = append(support, _toolchainBusybox.New("gentoo", 0, nil, nil, nil, `
tar -C /work -xf /usr/src/stage3.tar.xz

View File

@@ -1,8 +1,6 @@
package rosa
import (
"sync"
"hakurei.app/fhs"
"hakurei.app/internal/pkg"
)
@@ -32,25 +30,22 @@ func init() {
}
}
var (
// stage0 stores the tarball unpack artifact.
stage0 pkg.Artifact
// stage0Once is for lazy initialisation of stage0.
stage0Once sync.Once
)
func init() {
const version = "20260504"
artifactsM[stage0Dist] = Metadata{
f: func(Toolchain) (pkg.Artifact, string) {
return newTar(
"https://hakurei.app/seed/"+version+"/"+
"stage0-"+triplet()+".tar.bz2",
perArch[string]{
"amd64": "IQjFDkiAVLo1XzflgMMiLP3gnVY2hhDMTzl-QqJDCQhcLQ3lLtRzjI5WCxGyW_lk",
"arm64": "6fmwl2Umx2QssKQvxxb1JOGkAjzfA_MXKku0jVdGjYGb35OvwEVA5NYtd0HIy3yH",
}.unwrap(),
pkg.TarBzip2,
), version
},
// NewStage0 returns a stage0 distribution created from curing [Stage0].
func NewStage0() pkg.Artifact {
stage0Once.Do(func() {
stage0 = newTar(
"https://hakurei.app/seed/20260504/"+
"stage0-"+triplet()+".tar.bz2",
perArch[string]{
"amd64": "IQjFDkiAVLo1XzflgMMiLP3gnVY2hhDMTzl-QqJDCQhcLQ3lLtRzjI5WCxGyW_lk",
"arm64": "6fmwl2Umx2QssKQvxxb1JOGkAjzfA_MXKku0jVdGjYGb35OvwEVA5NYtd0HIy3yH",
}.unwrap(),
pkg.TarBzip2,
)
})
return stage0
Name: "stage0-dist",
Description: "Rosa OS stage0 bootstrap seed",
}
}

View File

@@ -1,10 +1,6 @@
package rosa
import (
"runtime"
"hakurei.app/internal/pkg"
)
import "hakurei.app/internal/pkg"
func (t Toolchain) newTamaGo() (pkg.Artifact, string) {
const (
@@ -26,7 +22,7 @@ chmod -R +w ..
sed -i \
's,/lib/ld-musl-`+linuxArch()+`.so.1,/system/bin/linker,' \
cmd/link/internal/`+runtime.GOARCH+`/obj.go
cmd/link/internal/`+arch+`/obj.go
sed -i \
's/cpu.X86.HasAVX512VBMI/& \&\& cpu.X86.HasPOPCNT/' \
internal/runtime/gc/scan/scan_amd64.go