mrrl

Minimal Reliable Reproducible Linux
git clone https://ccx.te2000.cz/git/mrrl
Log | Files | Refs | Submodules | README

musl-cross-make:oldbootstrap-0 (3406B)


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