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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
{ "toolchain":
{ "type": "configure"
, "arguments_config": ["ARCH", "BUILD_ARCH"]
, "config":
{ "type": "singleton_map"
, "key": "BUILD_ARCH"
, "value":
{ "type": "var"
, "name": "BUILD_ARCH"
, "default":
{ "type": "var"
, "name": "ARCH"
, "default":
{"type": "fail", "msg": "ARCH is required for cross-compiler."}
}
}
}
, "target": "toolchain_cross"
}
, "toolchain_cross":
{ "type": "export"
, "flexible_config":
["ARCH", "TARGET_ARCH", "BUILD_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
, "target": "gcc-musl-static"
}
, "runlibs":
{ "type": "export"
, "flexible_config": ["ARCH", "TARGET_ARCH", "TOOLCHAIN_CONFIG", "ENV"]
, "target": "libgcc_s"
}
, "strip_for_host":
{ "type": "configure"
, "arguments_config": ["ARCH"]
, "config":
{ "type": "singleton_map"
, "key": "TARGET_ARCH"
, "value": {"type": "var", "name": "ARCH"}
}
, "target": ["@", "binutils", "", "multi-target strip"]
}
, "gcc-musl-static":
{ "type": ["@", "rules", "CC/foreign/shell", "data"]
, "project": [["@", "gcc-musl", "", "combined_patched_sources"]]
, "localbase": ["strip_for_host"]
, "arguments_config": ["BUILD_ARCH"]
, "cmds":
{ "type": "let*"
, "bindings":
[ [ "TARGET"
, { "type": "case"
, "expr":
{ "type": "var"
, "name": "BUILD_ARCH"
, "default": {"type": "fail", "msg": "BUILD_ARCH is missing."}
}
, "case":
{ "x86": "i686"
, "x86_64": "x86_64"
, "arm": "arm"
, "arm64": "aarch64"
}
, "default":
{ "type": "fail"
, "msg":
["Unsupported BUILD_ARCH", {"type": "var", "name": "BUILD_ARCH"}]
}
}
]
]
, "body":
[ { "type": "join"
, "$1": ["TARGET=", {"type": "var", "name": "TARGET"}, "-linux-musl"]
}
, "export NJOBS=$(nproc --all 2>/dev/null || echo 1)"
, "export MAKEINFO=missing"
, "export BUILD_ROOT_DIR=${ACTION_DIR}"
, "unset CFLAGS CXXFLAGS LDFLAGS"
, "printf '#!/bin/sh\\nexec \"%s\" -static \"$@\"' \"${CC}\" >${TMPDIR}/cc"
, "printf '#!/bin/sh\\nexec \"%s\" -static \"$@\"' \"${CXX}\" >${TMPDIR}/c++"
, "chmod +x ${TMPDIR}/cc ${TMPDIR}/c++"
, "export CC=\"${TMPDIR}/cc\""
, "export CXX=\"${TMPDIR}/c++\""
, "mv musl-latest.orig musl.readonly"
, "cp -r musl.readonly musl-latest.orig && chmod -R +w musl-latest.orig"
, "export check_msgfmt=no # do not use system's msgfmt, if available"
, "${MAKE} -j${NJOBS} TARGET=${TARGET} LDFLAGS='-static' LDFLAGS_FOR_TARGET='-static' >build.log 2>&1 || (cat build.log && exit 1)"
, "${MAKE} -j${NJOBS} TARGET=${TARGET} LDFLAGS='-static' LDFLAGS_FOR_TARGET='-static' OUTPUT= DESTDIR=${DESTDIR} install >>build.log 2>&1 || (cat build.log && exit 1)"
, "cd ${DESTDIR}"
, "STRIP=${LOCALBASE}/bin/strip"
, "find ./bin/ ./${TARGET}/bin/ ./libexec/gcc/ -type f -exec sh -c \"${STRIP} {} 2>/dev/null\" \\;"
, "find . -type f -name '*.so*' -exec sh -c \"${STRIP} {} 2>/dev/null\" \\;"
, "find . -type f -name '*.a' -exec sh -c \"${STRIP} -g {} 2>/dev/null\" \\;"
, "find . -type f -name '*.o' -exec sh -c \"${STRIP} -g {} 2>/dev/null\" \\;"
, "for f in $(ls ./bin/${TARGET}-*); do"
, " ln -s $(basename $f) $(echo $f | sed 's|/'${TARGET}-'|/|g')"
, "done"
, "find . -type l -exec sh -c 'expr match \"$(readlink {})\" \"/\" >/dev/null' \\; -delete"
, "GCC_LIBDIR=\"lib/gcc/$(./bin/gcc -dumpmachine)/$(./bin/gcc -dumpfullversion -dumpversion)\""
, "mv ${GCC_LIBDIR}/include-fixed ${TMPDIR}/"
, "cp -rL ${TMPDIR}/include-fixed ${GCC_LIBDIR}/. # resolve symlinks"
]
}
, "out_dirs": ["."]
}
, "toolchain_for_target":
{ "type": "configure"
, "arguments_config": ["ARCH", "TARGET_ARCH"]
, "config":
{ "type": "singleton_map"
, "key": "BUILD_ARCH"
, "value":
{ "type": "var"
, "name": "TARGET_ARCH"
, "default":
{ "type": "var"
, "name": "ARCH"
, "default":
{"type": "fail", "msg": "ARCH is required for cross-compiler."}
}
}
}
, "target": "toolchain_cross"
}
, "libgcc_s":
{ "type": ["@", "rules", "CC/prebuilt", "library"]
, "name": ["libgcc"]
, "lib": ["libgcc_s_files"]
}
, "libgcc_s_files":
{ "type": "generic"
, "arguments_config": ["ENV"]
, "deps": ["toolchain_for_target"]
, "cmds": ["cp -L $(./bin/gcc -dumpmachine)/lib/libgcc_s.so.1 ."]
, "outs": ["libgcc_s.so.1"]
, "env": {"type": "var", "name": "ENV", "default": {"type": "empty_map"}}
}
}
|