internal/rosa/musl: migrate to make helper
All checks were successful
Test / Create distribution (push) Successful in 1m1s
Test / Sandbox (push) Successful in 2m44s
Test / Hakurei (push) Successful in 3m57s
Test / ShareFS (push) Successful in 4m4s
Test / Hpkg (push) Successful in 4m38s
Test / Sandbox (race detector) (push) Successful in 5m0s
Test / Hakurei (race detector) (push) Successful in 6m12s
Test / Flake checks (push) Successful in 1m40s
All checks were successful
Test / Create distribution (push) Successful in 1m1s
Test / Sandbox (push) Successful in 2m44s
Test / Hakurei (push) Successful in 3m57s
Test / ShareFS (push) Successful in 4m4s
Test / Hpkg (push) Successful in 4m38s
Test / Sandbox (race detector) (push) Successful in 5m0s
Test / Hakurei (race detector) (push) Successful in 6m12s
Test / Flake checks (push) Successful in 1m40s
This is much cleaner and eliminates the early ugliness. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -246,11 +246,8 @@ func (t Toolchain) newLLVM() (musl, compilerRT, runtimes, clang pkg.Artifact) {
|
||||
{"COMPILER_RT_BUILD_XRAY", "OFF"},
|
||||
},
|
||||
append: []string{"compiler-rt"},
|
||||
extra: []pkg.Artifact{t.NewMusl(&MuslAttr{
|
||||
Headers: true,
|
||||
Env: []string{
|
||||
extra: []pkg.Artifact{t.newMusl(true, []string{
|
||||
"CC=clang",
|
||||
},
|
||||
})},
|
||||
script: `
|
||||
mkdir -p "${ROSA_INSTALL_PREFIX}/lib/clang/21/lib/"
|
||||
@@ -267,9 +264,7 @@ ln -s \
|
||||
`,
|
||||
})
|
||||
|
||||
musl = t.NewMusl(&MuslAttr{
|
||||
Extra: []pkg.Artifact{compilerRT},
|
||||
Env: stage0ExclConcat(t, []string{
|
||||
musl = t.newMusl(false, stage0ExclConcat(t, []string{
|
||||
"CC=clang",
|
||||
"LIBCC=/system/lib/clang/21/lib/" +
|
||||
triplet() + "/libclang_rt.builtins.a",
|
||||
@@ -277,8 +272,7 @@ ln -s \
|
||||
"RANLIB=ranlib",
|
||||
},
|
||||
"LDFLAGS="+earlyLDFLAGS(false),
|
||||
),
|
||||
})
|
||||
), compilerRT)
|
||||
|
||||
runtimes = t.newLLVMVariant("runtimes", &llvmAttr{
|
||||
env: stage0ExclConcat(t, []string{},
|
||||
|
||||
@@ -1,34 +1,24 @@
|
||||
package rosa
|
||||
|
||||
import (
|
||||
"slices"
|
||||
import "hakurei.app/internal/pkg"
|
||||
|
||||
"hakurei.app/internal/pkg"
|
||||
)
|
||||
|
||||
// MuslAttr holds the attributes that will be applied to musl.
|
||||
type MuslAttr struct {
|
||||
// Install headers only.
|
||||
Headers bool
|
||||
// Environment variables concatenated with defaults.
|
||||
Env []string
|
||||
// Dependencies concatenated with defaults.
|
||||
Extra []pkg.Artifact
|
||||
}
|
||||
|
||||
// NewMusl returns a [pkg.Artifact] containing an installation of musl libc.
|
||||
func (t Toolchain) NewMusl(attr *MuslAttr) pkg.Artifact {
|
||||
func (t Toolchain) newMusl(
|
||||
headers bool,
|
||||
env []string,
|
||||
extra ...pkg.Artifact,
|
||||
) pkg.Artifact {
|
||||
const (
|
||||
version = "1.2.5"
|
||||
checksum = "y6USdIeSdHER_Fw2eT2CNjqShEye85oEg2jnOur96D073ukmIpIqDOLmECQroyDb"
|
||||
)
|
||||
|
||||
if attr == nil {
|
||||
attr = new(MuslAttr)
|
||||
}
|
||||
name := "musl"
|
||||
attr := MakeAttr{
|
||||
OmitDefaults: true,
|
||||
SkipCheck: true,
|
||||
|
||||
target := "install"
|
||||
script := `
|
||||
Env: env,
|
||||
Script: `
|
||||
mkdir -p /work/system/bin
|
||||
COMPAT_LINKER_NAME="ld-musl-` + linuxArch() + `.so.1"
|
||||
ln -vs ../lib/libc.so /work/system/bin/linker
|
||||
@@ -36,29 +26,23 @@ ln -vs ../lib/libc.so /work/system/bin/ldd
|
||||
ln -vs libc.so "/work/system/lib/${COMPAT_LINKER_NAME}"
|
||||
rm -v "/work/lib/${COMPAT_LINKER_NAME}"
|
||||
rmdir -v /work/lib
|
||||
`
|
||||
if attr.Headers {
|
||||
target = "install-headers"
|
||||
script = ""
|
||||
`,
|
||||
}
|
||||
|
||||
return t.New("musl-"+version, 0, stage0Concat(t, attr.Extra,
|
||||
t.Load(Make),
|
||||
t.Load(Coreutils),
|
||||
), nil, slices.Concat([]string{
|
||||
"ROSA_MUSL_TARGET=" + target,
|
||||
}, attr.Env), `
|
||||
cd "$(mktemp -d)"
|
||||
/usr/src/musl/configure \
|
||||
--prefix=/system \
|
||||
--target="${ROSA_TRIPLE}"
|
||||
make "-j$(nproc)" DESTDIR=/work "${ROSA_MUSL_TARGET}"
|
||||
`+script, pkg.Path(AbsUsrSrc.Append("musl"), false, t.NewPatchedSource(
|
||||
if headers {
|
||||
name += "-headers"
|
||||
attr.ScriptInstall = "make DESTDIR=/work install-headers"
|
||||
attr.Script = ""
|
||||
}
|
||||
|
||||
return t.NewViaMake(name, version, t.NewPatchedSource(
|
||||
// expected to be writable in copies
|
||||
"musl", version, pkg.NewHTTPGetTar(
|
||||
nil, "https://musl.libc.org/releases/musl-"+version+".tar.gz",
|
||||
mustDecode(checksum),
|
||||
pkg.TarGzip,
|
||||
), false,
|
||||
)))
|
||||
), &attr, stage0Concat(t, extra,
|
||||
t.Load(Coreutils),
|
||||
)...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user