1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
package rosa
import "hakurei.app/internal/pkg"
func (s *S) newMusl(t Toolchain, 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-` + s.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=" + s.earlyLDFLAGS(false),
}
if t.isStage0() {
env = append(env,
"CC=clang",
"AR=ar",
"RANLIB=ranlib",
)
}
return s.NewPackage(t, 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(&Artifact{
f: func(t Toolchain, s *S) (pkg.Artifact, string) {
return s.newMusl(t, false)
},
Name: "musl",
Description: "an implementation of the C standard library",
Website: "https://musl.libc.org/",
ID: 11688,
})
native.MustRegister(&Artifact{
f: func(t Toolchain, s *S) (pkg.Artifact, string) {
return s.newMusl(t, true)
},
Name: "musl-headers",
Description: "system installation of musl headers",
})
}
|