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"},
|
{"COMPILER_RT_BUILD_XRAY", "OFF"},
|
||||||
},
|
},
|
||||||
append: []string{"compiler-rt"},
|
append: []string{"compiler-rt"},
|
||||||
extra: []pkg.Artifact{t.NewMusl(&MuslAttr{
|
extra: []pkg.Artifact{t.newMusl(true, []string{
|
||||||
Headers: true,
|
"CC=clang",
|
||||||
Env: []string{
|
|
||||||
"CC=clang",
|
|
||||||
},
|
|
||||||
})},
|
})},
|
||||||
script: `
|
script: `
|
||||||
mkdir -p "${ROSA_INSTALL_PREFIX}/lib/clang/21/lib/"
|
mkdir -p "${ROSA_INSTALL_PREFIX}/lib/clang/21/lib/"
|
||||||
@@ -267,18 +264,15 @@ ln -s \
|
|||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
|
|
||||||
musl = t.NewMusl(&MuslAttr{
|
musl = t.newMusl(false, stage0ExclConcat(t, []string{
|
||||||
Extra: []pkg.Artifact{compilerRT},
|
"CC=clang",
|
||||||
Env: stage0ExclConcat(t, []string{
|
"LIBCC=/system/lib/clang/21/lib/" +
|
||||||
"CC=clang",
|
triplet() + "/libclang_rt.builtins.a",
|
||||||
"LIBCC=/system/lib/clang/21/lib/" +
|
"AR=ar",
|
||||||
triplet() + "/libclang_rt.builtins.a",
|
"RANLIB=ranlib",
|
||||||
"AR=ar",
|
},
|
||||||
"RANLIB=ranlib",
|
"LDFLAGS="+earlyLDFLAGS(false),
|
||||||
},
|
), compilerRT)
|
||||||
"LDFLAGS="+earlyLDFLAGS(false),
|
|
||||||
),
|
|
||||||
})
|
|
||||||
|
|
||||||
runtimes = t.newLLVMVariant("runtimes", &llvmAttr{
|
runtimes = t.newLLVMVariant("runtimes", &llvmAttr{
|
||||||
env: stage0ExclConcat(t, []string{},
|
env: stage0ExclConcat(t, []string{},
|
||||||
|
|||||||
@@ -1,34 +1,24 @@
|
|||||||
package rosa
|
package rosa
|
||||||
|
|
||||||
import (
|
import "hakurei.app/internal/pkg"
|
||||||
"slices"
|
|
||||||
|
|
||||||
"hakurei.app/internal/pkg"
|
func (t Toolchain) newMusl(
|
||||||
)
|
headers bool,
|
||||||
|
env []string,
|
||||||
// MuslAttr holds the attributes that will be applied to musl.
|
extra ...pkg.Artifact,
|
||||||
type MuslAttr struct {
|
) pkg.Artifact {
|
||||||
// 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 {
|
|
||||||
const (
|
const (
|
||||||
version = "1.2.5"
|
version = "1.2.5"
|
||||||
checksum = "y6USdIeSdHER_Fw2eT2CNjqShEye85oEg2jnOur96D073ukmIpIqDOLmECQroyDb"
|
checksum = "y6USdIeSdHER_Fw2eT2CNjqShEye85oEg2jnOur96D073ukmIpIqDOLmECQroyDb"
|
||||||
)
|
)
|
||||||
|
|
||||||
if attr == nil {
|
name := "musl"
|
||||||
attr = new(MuslAttr)
|
attr := MakeAttr{
|
||||||
}
|
OmitDefaults: true,
|
||||||
|
SkipCheck: true,
|
||||||
|
|
||||||
target := "install"
|
Env: env,
|
||||||
script := `
|
Script: `
|
||||||
mkdir -p /work/system/bin
|
mkdir -p /work/system/bin
|
||||||
COMPAT_LINKER_NAME="ld-musl-` + linuxArch() + `.so.1"
|
COMPAT_LINKER_NAME="ld-musl-` + linuxArch() + `.so.1"
|
||||||
ln -vs ../lib/libc.so /work/system/bin/linker
|
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}"
|
ln -vs libc.so "/work/system/lib/${COMPAT_LINKER_NAME}"
|
||||||
rm -v "/work/lib/${COMPAT_LINKER_NAME}"
|
rm -v "/work/lib/${COMPAT_LINKER_NAME}"
|
||||||
rmdir -v /work/lib
|
rmdir -v /work/lib
|
||||||
`
|
`,
|
||||||
if attr.Headers {
|
|
||||||
target = "install-headers"
|
|
||||||
script = ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return t.New("musl-"+version, 0, stage0Concat(t, attr.Extra,
|
if headers {
|
||||||
t.Load(Make),
|
name += "-headers"
|
||||||
t.Load(Coreutils),
|
attr.ScriptInstall = "make DESTDIR=/work install-headers"
|
||||||
), nil, slices.Concat([]string{
|
attr.Script = ""
|
||||||
"ROSA_MUSL_TARGET=" + target,
|
}
|
||||||
}, attr.Env), `
|
|
||||||
cd "$(mktemp -d)"
|
return t.NewViaMake(name, version, t.NewPatchedSource(
|
||||||
/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(
|
|
||||||
// expected to be writable in copies
|
// expected to be writable in copies
|
||||||
"musl", version, pkg.NewHTTPGetTar(
|
"musl", version, pkg.NewHTTPGetTar(
|
||||||
nil, "https://musl.libc.org/releases/musl-"+version+".tar.gz",
|
nil, "https://musl.libc.org/releases/musl-"+version+".tar.gz",
|
||||||
mustDecode(checksum),
|
mustDecode(checksum),
|
||||||
pkg.TarGzip,
|
pkg.TarGzip,
|
||||||
), false,
|
), false,
|
||||||
)))
|
), &attr, stage0Concat(t, extra,
|
||||||
|
t.Load(Coreutils),
|
||||||
|
)...)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user