musl-cross-make:bootstrap-0 (5691B)
1 #!/usr/bin/env pthbs-build 2 #@pragma:nofail_digest 3 #@pragma:nosandbox 4 #@pragma:nopath 5 #@sha256:0cdd76777a0dfd3dd3a63f215f030208ddb91c2361d2bcc02acec0f1c16b6a2e:musl-cross-make/sources/binutils-2.44.tar.gz 6 #@sha256:a3c2b80201b89e68616f4ad30bc66aee4927c3ce50e33929ca819d5c43538898:musl-cross-make/sources/gmp-6.3.0.tar.xz 7 #@sha256:b67ba0383ef7e8a8563734e2e889ef5ec3c3b898a01d00fa0a6869ad81c6ce01:musl-cross-make/sources/mpfr-4.2.2.tar.xz 8 #@sha256:dc7abf734487553644258a3822cfd429d74656749e309f2b25f09f4282e05588:musl-cross-make/sources/linux-headers-4.19.88-2.tar.xz 9 #@sha256:ab642492f5cf882b74aa0cb730cd410a81edcdbec895183ce930e706c1c759b8:musl-cross-make/sources/mpc-1.3.1.tar.gz 10 #@sha256:c95da32f440378d7751dd95533186f7fc05ceb4fb65eb5b85234e6299eb9838e:musl-cross-make/sources/gcc-9.4.0.tar.xz 11 #@sha256:a9a118bbe84d8764da0ea0d28b3ab3fae8477fc7e4085d90102b8596fc7c75e4:musl-cross-make/sources/musl-1.2.5.tar.gz 12 #@sha256:75d5d255a2a273b6e651f82eecfabf6cbcd8eaeae70e86b417384c8f4a58d8d3:musl-cross-make/sources/config.sub 13 #@git:cf9b601eba1b8c4a3c0655ba25d7fc8cfa365cbc:musl-cross-make 14 15 16 # - build script start - 17 18 prefix=/versions/$pthbs_package 19 dest=${pthbs_destdir%/}${prefix} 20 cd 'musl-cross-make' 21 22 # silence unpacking of tarballs 23 sed -i -e 's|tar \([zjJ]\)xvf |tar \1xf |' ./Makefile 24 25 cat >./config.mak <<EOF 26 OUTPUT=${pthbs_destdir%/}/versions/$pthbs_package 27 TARGET=x86_64-linux-musl 28 GCC_VER=9.4.0 29 EOF 30 31 printf '%s\n' >>config.mak ' 32 fl=-g0 -O2 33 COMMON_CONFIG += CFLAGS="-std=gnu17 ${fl}" 34 COMMON_CONFIG += CXXFLAGS="-std=gnu++11 ${fl}" 35 COMMON_CONFIG += FFLAGS="${fl}" LDFLAGS="-s" 36 ' 37 38 39 # make sure sources are considered fresh by make 40 touch ./sources/* 41 42 ${CC:-gcc} --version 43 ${CC:-gcc} -dumpmachine 44 cat -n config.mak 45 46 # Patch linker path for dynamic executables 47 make gcc-'9.4.0' 48 sed -i -e 's|/lib/ld-musl-|/versions/'"$pthbs_package"'/x86_64-linux-musl/lib/ld-musl-|' ./gcc-'9.4.0'/gcc/config/*/linux*.h 49 make -j${JOBS:-1} -l$((1+${JOBS:-1})) || make -d || exit $? 50 make install || exit $? 51 52 # Override linker symlink 53 for linkname in "$dest"'/x86_64-linux-musl/lib/'ld-musl-*so*; do 54 ln -s -f libc.so "$linkname" 55 done 56 57 # Validate the C compiler 58 "$dest"/bin/x86_64-linux-musl-gcc --version 59 printf '%s\n' 'int main(void) { return 0; }' >true.c 60 "$dest"/bin/x86_64-linux-musl-gcc -o true-dl true.c 61 "$dest"/bin/x86_64-linux-musl-readelf --string-dump=.interp true-dl >true.linker 62 grep -F "$pthbs_package" true.linker 63 "$dest"/bin/x86_64-linux-musl-gcc -static -o true-sl true.c 64 ./true-sl 65 66 # Validate the C++ compiler 67 "$dest"/bin/x86_64-linux-musl-g++ --version 68 printf '%s\n' >sort.cpp ' 69 #include <iostream> 70 #include <vector> 71 #include <algorithm> 72 #include <iterator> 73 int main() { 74 using namespace std; 75 istream_iterator<int> first(cin); 76 istream_iterator<int> last; 77 vector<int> vec(first, last); 78 sort(vec.begin(), vec.end()); 79 cout << "Sorted:" << endl; 80 copy(vec.begin(), vec.end(), ostream_iterator<int>(cout, "\n")); 81 return 0; 82 } 83 ' 84 "$dest"/bin/x86_64-linux-musl-g++ -o sort-dl sort.cpp 85 "$dest"/bin/x86_64-linux-musl-readelf --string-dump=.interp sort-dl >sort.linker 86 grep -F "$pthbs_package" sort.linker 87 "$dest"/bin/x86_64-linux-musl-g++ -static -o sort-sl sort.cpp 88 ./sort-sl >sort.out <<EOF 89 5 90 3 91 1 92 2 93 4 94 EOF 95 printf '%s\n' >sort.expected Sorted: 1 2 3 4 5 96 cmp sort.out sort.expected 97 98 if which dejagnu 2>/dev/null; then 99 make -j${JOBS:-1} -l$((1+${JOBS:-1})) -C build/local/x86_64-linux-musl/obj_gcc -k check-gcc 100 mkdir "$dest/test-results" 101 find build/local/x86_64-linux-musl/obj_gcc \ 102 -name '*.sum' -exec mv -v '{}' "$dest/test-results/" \; 103 fi 104 105 106 107 108 cd "$pthbs_destdir/versions/$pthbs_package" 109 find -type d -o -print | awk -F/ ' 110 BEGIN { 111 x["./bin/x86_64-linux-musl-g++"]=1 112 x["./bin/x86_64-linux-musl-gcc"]=1 113 } 114 115 function r1(s) { 116 sub("^[.]/[^/]*", ".", s) 117 return s 118 } 119 function s1(repl, s) { 120 sub("^[.]/[^/]*", "./"repl, s) 121 return s 122 } 123 function link(src) { 124 x[$0]=0 125 printf "%s\t%s\n", $0, src 126 printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr" 127 } 128 $1!="."{exit 1} 129 $2 == "bin" && $3 ~ /^x86_64-linux-musl-/ { target=$3; sub("x86_64-linux-musl-", "", target); link("./command/" target) } 130 $2 == "x86_64-linux-musl" && $3 == "include" { link(s1("include", r1($0))) } 131 132 $2 == "env" { link($0); next } 133 $2 == ".env-template" { link($0); next } 134 135 $2 == "command" { link($0); next } 136 $2 == "command" { link($0); next } 137 $2 == "bin" { link(s1("command", $0)); next } 138 $2 == "sbin" { link(s1("command", $0)); next } 139 140 $2 == "library.so" { link($0); next } 141 $2 == "library" { link($0); next } 142 $2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next } 143 $2 == "lib" && $NF ~ /\.so(\..*)?$/ { link(s1("library.so", $0)); next } 144 145 $2 == "share" && $3 == "info" { link(s1("info", r1($0))); next } 146 $2 == "share" && $3 == "man" { link(s1("man", r1($0))); next } 147 $2 == "share" && $3 == "doc" { link(s1("doc", r1($0))); next } 148 149 $2 == "config" { link($0); next } 150 $2 == "man" { link($0); next } 151 $2 == "info" { link($0); next } 152 $2 == "doc" { link($0); next } 153 $2 == "data" { link($0); next } 154 $2 == "include" { link($0); next } 155 156 $2 == "share" && $3 ~ /^(icons|terminfo)$/ { link(r1($0)); next } 157 158 $2 == "library.ocaml" { link($0); next } 159 160 $2 == "keys" { link($0); next } 161 $2 == "zsh" { link($0); next } 162 $2 == "vimfiles" { link($0); next } 163 $2 == "icons" { link($0); next } 164 $2 == "terminfo" { link($0); next } 165 166 167 { printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" } 168 169 END { 170 for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" } 171 retcode = 0 172 for(fname in x) { 173 if(x[fname]) { 174 printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr" 175 retcode = 3 176 } 177 } 178 exit retcode 179 }' >.install-links.new 180 mv .install-links.new .install-links 181