diff --git a/internal/rosa/musl.go b/internal/rosa/musl.go deleted file mode 100644 index 191a63e5..00000000 --- a/internal/rosa/musl.go +++ /dev/null @@ -1,94 +0,0 @@ -package rosa - -import "hakurei.app/internal/pkg" - -func (t Toolchain) newMusl(headers bool) (pkg.Artifact, string) { - const ( - version = "1.2.6" - checksum = "WtWb_OV_XxLDAB5NerOL9loLlHVadV00MmGk65PPBU1evaolagoMHfvpZp_vxEzS" - ) - - name := "musl" - helper := MakeHelper{ - OmitDefaults: true, - SkipCheck: true, - Script: ` -mkdir -p /work/system/bin -COMPAT_LINKER_NAME="ld-musl-` + t.linuxArch() + `.so.1" -ln -vs ../lib/libc.so /work/system/bin/linker -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 headers { - name += "-headers" - helper.Make = []string{ - "DESTDIR=/work", - "install-headers", - } - helper.Install = "# headers installed during make" - helper.Script = "" - } - - env := []string{ - "LDFLAGS=" + t.earlyLDFLAGS(false), - } - if t.stage.isStage0() { - env = append(env, - "CC=clang", - "AR=ar", - "RANLIB=ranlib", - ) - } - - return t.NewPackage(name, version, newTar( - "https://musl.libc.org/releases/musl-"+version+".tar.gz", - checksum, - pkg.TarGzip, - ), &PackageAttr{ - // expected to be writable in copies - Chmod: true, - - Env: env, - - Patches: []KV{ - {"ldso-rosa", `diff --git a/ldso/dynlink.c b/ldso/dynlink.c -index 715948f4..c2fece68 100644 ---- a/ldso/dynlink.c -+++ b/ldso/dynlink.c -@@ -1157,7 +1157,7 @@ static struct dso *load_library(const char *name, struct dso *needed_by) - sys_path = ""; - } - } -- if (!sys_path) sys_path = "/lib:/usr/local/lib:/usr/lib"; -+ if (!sys_path) sys_path = "/system/lib:/system/lib/" LDSO_ARCH "-rosa-linux-musl:/lib:/usr/local/lib:/usr/lib"; - fd = path_open(name, sys_path, buf, sizeof buf); - } - pathname = buf; -`}, - }, - }, &helper, - Coreutils, - ), version -} -func init() { - native.mustRegister(func(t Toolchain) (pkg.Artifact, string) { - return t.newMusl(false) - }, &Metadata{ - Name: "musl", - Description: "an implementation of the C standard library", - Website: "https://musl.libc.org/", - - ID: 11688, - }) - - native.mustRegister(func(t Toolchain) (pkg.Artifact, string) { - return t.newMusl(true) - }, &Metadata{ - Name: "musl-headers", - Description: "system installation of musl headers", - }) -} diff --git a/internal/rosa/package/musl/ldso-rosa.patch b/internal/rosa/package/musl/ldso-rosa.patch new file mode 100644 index 00000000..4ca3f01b --- /dev/null +++ b/internal/rosa/package/musl/ldso-rosa.patch @@ -0,0 +1,13 @@ +diff --git a/ldso/dynlink.c b/ldso/dynlink.c +index 715948f4..c2fece68 100644 +--- a/ldso/dynlink.c ++++ b/ldso/dynlink.c +@@ -1157,7 +1157,7 @@ static struct dso *load_library(const char *name, struct dso *needed_by) + sys_path = ""; + } + } +- if (!sys_path) sys_path = "/lib:/usr/local/lib:/usr/lib"; ++ if (!sys_path) sys_path = "/system/lib:/system/lib/" LDSO_ARCH "-rosa-linux-musl:/lib:/usr/local/lib:/usr/lib"; + fd = path_open(name, sys_path, buf, sizeof buf); + } + pathname = buf; diff --git a/internal/rosa/package/musl/package.az b/internal/rosa/package/musl/package.az new file mode 100644 index 00000000..893567e8 --- /dev/null +++ b/internal/rosa/package/musl/package.az @@ -0,0 +1,70 @@ +package musl-source { + description = "an implementation of the C standard library - source code"; + + version* = "1.2.6"; + output = remoteTar { + url = "https://musl.libc.org/releases/musl-"+version+".tar.gz"; + checksum = "WtWb_OV_XxLDAB5NerOL9loLlHVadV00MmGk65PPBU1evaolagoMHfvpZp_vxEzS"; + compress = gzip; + }; +} + +package musl-headers { + description = "system installation of musl headers"; + + source = musl-source; + + // expected to be writable in copies + chmod = true; + + env = [ + "LDFLAGS=" + earlyLDFLAGS, + ]; + + exec = make { + omitDefaults = true; + skipCheck = true; + + make = [ + "DESTDIR=/work", + "install-headers", + ]; + + install = "# headers installed during make"; + }; + + inputs = [ coreutils ]; +} + +package musl { + description = "an implementation of the C standard library"; + website = "https://musl.libc.org"; + anitya = 11688; + + source = musl-source; + patches = [ "ldso-rosa.patch" ]; + + // expected to be writable in copies + chmod = true; + + env = [ + "LDFLAGS=" + earlyLDFLAGS, + ]; + + exec = make { + omitDefaults = true; + skipCheck = true; + + postInstall = ` +mkdir -p /work/system/bin +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/ldd +ln -vs libc.so "/work/system/lib/${COMPAT_LINKER_NAME}" +rm -v "/work/lib/${COMPAT_LINKER_NAME}" +rmdir -v /work/lib +`; + }; + + inputs = [ coreutils ]; +} diff --git a/internal/rosa/state.go b/internal/rosa/state.go index 0f32ab55..a6149d46 100644 --- a/internal/rosa/state.go +++ b/internal/rosa/state.go @@ -434,7 +434,8 @@ func (s *S) getFrame() azalea.Frame { } s.frame.Val = map[unique.Handle[azalea.Ident]]any{ - k("linuxArch"): s.linuxArch(), + k("linuxArch"): s.linuxArch(), + k("earlyLDFLAGS"): s.earlyLDFLAGS(false), k("jobsE"): jobsE, k("jobsFlagE"): jobsFlagE,