musl-cross-make:bootstrap-1 (4496B)
1 #!/usr/bin/env pthbs-build 2 #@pragma:nosandbox 3 #@pragma:nopath 4 #+musl-cross-make.d14cfd2214c9bc8f141df31e1bad9a34dd9ac123a2ba26bccfdf88597053da9b 5 #@sha256:ab66fc2d1c3ec0359b8e08843c9f33b63e8707efdff5e4cc5c200eae24722cbf:musl-cross-make/sources/binutils-2.33.1.tar.xz 6 #@sha256:75d5d255a2a273b6e651f82eecfabf6cbcd8eaeae70e86b417384c8f4a58d8d3:musl-cross-make/sources/config.sub 7 #@sha256:d08edc536b54c372a1010ff6619dd274c0f1603aa49212ba20f7aa2cda36fa8b:musl-cross-make/sources/gcc-11.2.0.tar.xz 8 #@sha256:5275bb04f4863a13516b2f39392ac5e272f5e1bb8057b18aec1c9b79d73d8fb2:musl-cross-make/sources/gmp-6.1.2.tar.bz2 9 #@sha256:dc7abf734487553644258a3822cfd429d74656749e309f2b25f09f4282e05588:musl-cross-make/sources/linux-headers-4.19.88-2.tar.xz 10 #@sha256:6985c538143c1208dcb1ac42cedad6ff52e267b47e5f970183a3e75125b43c2e:musl-cross-make/sources/mpc-1.1.0.tar.gz 11 #@sha256:c05e3f02d09e0e9019384cdd58e0f19c64e6db1fd6f5ecf77b4b1c61ca253acc:musl-cross-make/sources/mpfr-4.0.2.tar.bz2 12 #@sha256:a9a118bbe84d8764da0ea0d28b3ab3fae8477fc7e4085d90102b8596fc7c75e4:musl-cross-make/sources/musl-1.2.5.tar.gz 13 #@git:6f3701d08137496d5aac479e3a3977b5ae993c1f:musl-cross-make 14 15 16 # - build script start - 17 18 prefix=/home/ccx/versions/$pthbs_package 19 dest=${pthbs_destdir%/}${prefix} 20 cd '.' 21 22 bootstrap=/home/ccx/versions/musl-cross-make.d14cfd2214c9bc8f141df31e1bad9a34dd9ac123a2ba26bccfdf88597053da9b 23 "$bootstrap/bin/x86_64-linux-musl-gcc" --version 24 25 # For validating the compiler 26 printf '%s\n' 'int main(void) { return 0; }' >true.c 27 28 printf '%s\n' >musl-cross-make/config.mak \ 29 "OUTPUT=${pthbs_destdir%/}/home/ccx/versions/$pthbs_package" \ 30 'GCC_VER=11.2.0' \ 31 "TARGET=x86_64-linux-musl" \ 32 'st=-static --static' \ 33 'fl=-g0 -O2' \ 34 "bbin=$bootstrap/bin" \ 35 'COMMON_CONFIG += CFLAGS="${fl}" CXXFLAGS="${fl}" FFLAGS="${fl}" LDFLAGS="-s ${st}"' \ 36 'COMMON_CONFIG += CC="${bbin}/x86_64-linux-musl-gcc ${st}" CXX="${bbin}/x86_64-linux-musl-g++ ${st}"' 37 38 touch musl-cross-make/sources/* 39 40 41 # Patch linker path for dynamic executables 42 make -C musl-cross-make gcc-11.2.0 43 sed -i -e 's|/lib/ld-musl-|/home/ccx/versions/'"$pthbs_package"'/x86_64-linux-musl/lib/ld-musl-|' musl-cross-make/gcc-11.2.0/gcc/config/*/linux*.h 44 45 export PATH="$bootstrap/bin:$PATH" 46 make -j${JOBS:-1} -l$((1+${JOBS:-1})) -C musl-cross-make 47 make -C musl-cross-make install 48 49 # Override linker symlink 50 for linkname in "${pthbs_destdir%/}"'/home/ccx/versions/'"$pthbs_package"'/x86_64-linux-musl/lib/'ld-musl-*so*; do 51 ln -s -f libc.so "$linkname" 52 done 53 54 # Validate the compiler 55 "${pthbs_destdir%/}"'/home/ccx/versions'"/$pthbs_package/bin/"'x86_64-linux-musl-gcc' --version 56 "${pthbs_destdir%/}"'/home/ccx/versions'"/$pthbs_package/bin/"'x86_64-linux-musl-gcc' -o true true.c 57 "${pthbs_destdir%/}"'/home/ccx/versions'"/$pthbs_package/bin/"'x86_64-linux-musl-readelf' --string-dump=.interp true >true.linker 58 grep -F "$pthbs_package" true.linker 59 60 61 62 63 cd "$pthbs_destdir/home/ccx/versions/$pthbs_package" 64 find -type d -o -print | awk -F/ ' 65 BEGIN { 66 x["./bin/x86_64-linux-musl-g++"]=1 67 x["./bin/x86_64-linux-musl-gcc"]=1 68 } 69 70 function r1(s) { 71 sub("^[.]/[^/]*", ".", s) 72 return s 73 } 74 function s1(repl, s) { 75 sub("^[.]/[^/]*", "./"repl, s) 76 return s 77 } 78 function link(src) { 79 x[$0]=0 80 printf "%s\t%s\n", $0, src 81 printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr" 82 } 83 $1!="."{exit 1} 84 85 86 $2 == "bin" && $3 ~ /^x86_64-linux-musl-/ { target=$3; sub("x86_64-linux-musl-", "", target); link("./command/" target) } 87 88 $2 == "config" { link($0); next } 89 $2 == "keys" { link($0); next } 90 $2 == "zsh" { link($0); next } 91 $2 == "env" { link($0); next } 92 $2 == "command" { link($0); next } 93 $2 == "bin" { link(s1("command", $0)); next } 94 95 $2 == "library.so" { link($0); next } 96 $2 == "library" { link($0); next } 97 $2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next } 98 $2 == "lib" && $NF ~ /\.so(\..*)?$/ { link(s1("library.so", $0)); next } 99 100 $2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next } 101 102 $2 == "man" { link($0); next } 103 $2 == "info" { link($0); next } 104 $2 == "doc" { link($0); next } 105 $2 == "icons" { link($0); next } 106 $2 == "terminfo" { link($0); next } 107 $2 == "data" { link($0); next } 108 $2 == "include" { link($0); next } 109 110 { printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" } 111 112 END { 113 for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" } 114 for(fname in x) { 115 if(x[fname]) { 116 printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr" 117 exit 3 118 } 119 } 120 }' >.install-links.new 121 mv .install-links.new .install-links 122