musl-cross-make (5497B)
1 #!/usr/bin/env pthbs-build 2 #+musl-cross-make.03e06250b7acd3aad4222be3e3eded91886c4a605ad2712f46f9359dd99a8646 3 #+gnu-make.e7ff1e81614b0d3c152cd2b39eb961289d08617e45a0a749932d053bba398337 4 #+busybox.8e33d8022cc1ea565c75884e2ede0ec1cc7a7fa0b741a3e0c909c4963a4af081 5 #@git:fd6be58297ee21fcba89216ccd0d4aca1e3f1c5c: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:bdf76c15229b241e578046b8486106f09534d754ea4cbf105e0660e551fb1669:musl-cross-make/sources/linux-6.5.4.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:a9a118bbe84d8764da0ea0d28b3ab3fae8477fc7e4085d90102b8596fc7c75e4:musl-cross-make/sources/musl-1.2.5.tar.gz 14 #@sha256:4213e75809588e3f32ae0fde8fb11df2dfd6e0e013762ff5ee951c3aadb7ffc0:musl-cross-make/patches/linux-6.5.4/0001-no-rsync-headers.diff 15 #@sha256:68140a82582ede938159630bca0fb13a93b4bf1cb2e85b08943c26242cf8f3a6:zpipe.c 16 17 : ${JOBS:=1} 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 "TARGET=x86_64-linux-musl" \ 25 'GCC_VER=11.2.0' \ 26 'LINUX_VER=6.5.4' \ 27 'st=-static --static' \ 28 'fl=-g0 -O2' \ 29 'COMMON_CONFIG += CFLAGS="${fl} ${st}" CXXFLAGS="${fl} ${st}" FFLAGS="${fl}" LDFLAGS="-s ${st}"' \ 30 'COMMON_CONFIG += CC="x86_64-linux-musl-gcc ${st}" CXX="x86_64-linux-musl-g++ ${st}"' 31 32 printf '%s %s\n' >musl-cross-make/hashes/linux-6.5.4.tar.xz.sha1 \ 33 24ffca128d47b6c8e5c15efaa2b1c9ebe546c13c linux-6.5.4.tar.xz 34 35 touch musl-cross-make/sources/* 36 37 # Patch linker path for dynamic executables 38 make -C musl-cross-make gcc-11.2.0 39 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 40 41 42 make -j${JOBS:-1} -l$((1+${JOBS:-1})) -C musl-cross-make || exit $? 43 make -C musl-cross-make install || exit $? 44 45 dd=$pthbs_destdir//versions/$pthbs_package 46 47 # Override linker symlink 48 for linkname in "$dd"'/x86_64-linux-musl/lib/'ld-musl-*so*; do 49 ln -s -f libc.so "$linkname" 50 done 51 52 # Validate the compiler 53 "$dd"'/bin/x86_64-linux-musl-gcc' --version 54 "$dd"'/bin/x86_64-linux-musl-gcc' -o true true.c 55 "$dd"'/bin/x86_64-linux-musl-readelf' --string-dump=.interp true >true.linker 56 grep -F "$pthbs_package" true.linker 57 58 pkgs="gmp intl mpc mpfr zlib" 59 #pkgs="$pkgs libbacktrace libcc1 libcpp libdecnumber libiberty lto-plugin" 60 61 for pkg in $pkgs; do 62 make -C musl-cross-make/build/local/x86_64-linux-musl/obj_gcc/$pkg prefix=/ DESTDIR="$dd" install 63 done 64 cp -va musl-cross-make/gcc-*.orig/zlib/zconf.h musl-cross-make/gcc-*.orig/zlib/zlib.h "$dd/include/" 65 mkdir -p "$dd/library/pkgconfig" 66 printf '%s\n' > "$dd/library/pkgconfig/zlib.pc" \ 67 "prefix=/versions/$pthbs_package" \ 68 'exec_prefix=${prefix}' \ 69 'includedir=${prefix}/include' \ 70 'libdir=${exec_prefix}/library' \ 71 '' \ 72 'Name: zlib' \ 73 'Description: zlib compression library' \ 74 'Version: 1.2.11' \ 75 '' \ 76 'Requires:' \ 77 'Libs: -L${libdir} -lz' \ 78 'Cflags: -I${includedir}' 79 80 # validate zlib 81 "$dd"'/bin/x86_64-linux-musl-gcc' -I"$dd/include" -L"$dd/lib" -static -o zpipe zpipe.c -lz 82 ./zpipe <true.c >true.c.gz 83 ./zpipe -d <true.c.gz >true.c.2 84 cmp -s true.c true.c.2 85 86 87 cd "$pthbs_destdir/versions/$pthbs_package" 88 find -type d -o -print | awk -F/ ' 89 BEGIN { 90 x["./bin/x86_64-linux-musl-g++"]=1 91 x["./bin/x86_64-linux-musl-gcc"]=1 92 x["./lib/libgmp.a"]=1 93 x["./lib/libmpc.a"]=1 94 x["./lib/libmpfr.a"]=1 95 x["./lib/libz.a"]=1 96 97 x["./include/gmp.h"]=1 98 x["./include/mpc.h"]=1 99 x["./include/mpf2mpfr.h"]=1 100 x["./include/mpfr.h"]=1 101 x["./include/zlib.h"]=1 102 x["./include/zconf.h"]=1 103 104 } 105 106 function r1(s) { 107 sub("^[.]/[^/]*", ".", s) 108 return s 109 } 110 function s1(repl, s) { 111 sub("^[.]/[^/]*", "./"repl, s) 112 return s 113 } 114 function link(src) { 115 x[$0]=0 116 printf "%s\t%s\n", $0, src 117 printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr" 118 } 119 $1!="."{exit 1} 120 121 122 $2 == "bin" && $3 ~ /^x86_64-linux-musl-/ { target=$3; sub("x86_64-linux-musl-", "", target); link("./command/" target) } 123 $2 == "command" { link($0); next } 124 $2 == "bin" { link(s1("command", $0)); next } 125 126 $2 == "library.so" { link($0); next } 127 $2 == "library" { link($0); next } 128 $2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next } 129 $2 == "lib" && $NF ~ /\.so(|\..*)$/ { link(s1("library.so", $0)); next } 130 131 $2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next } 132 133 $2 == "man" { link($0); next } 134 $2 == "info" { link($0); next } 135 $2 == "doc" { link($0); next } 136 $2 == "icons" { link($0); next } 137 $2 == "terminfo" { link($0); next } 138 $2 == "data" { link($0); next } 139 $2 == "include" { link($0); next } 140 141 { printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" } 142 143 END { 144 for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" } 145 for(fname in x) { 146 if(x[fname]) { 147 printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr" 148 exit 3 149 } 150 } 151 }' >.install-links.new 152 mv .install-links.new .install-links