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