mrrl

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

musl-cross-make:oldbootstrap-1 (5318B)


      1 #!/usr/bin/env pthbs-build
      2 #@pragma:nofail_digest
      3 #@pragma:nosandbox
      4 #@pragma:nopath
      5 #+musl-cross-make.3a5a0f4bb8b0eff01ede6b59f9eb4a8933caf3df331acf45879025d27e5f0bab
      6 #+nawk.596c1948e96cbcabfe3954a70deb947de0c73be1ddde41fafe8291bfec04bdd4
      7 #@sha256:0cdd76777a0dfd3dd3a63f215f030208ddb91c2361d2bcc02acec0f1c16b6a2e:musl-cross-make/sources/binutils-2.44.tar.gz
      8 #@sha256:a3c2b80201b89e68616f4ad30bc66aee4927c3ce50e33929ca819d5c43538898:musl-cross-make/sources/gmp-6.3.0.tar.xz
      9 #@sha256:b67ba0383ef7e8a8563734e2e889ef5ec3c3b898a01d00fa0a6869ad81c6ce01:musl-cross-make/sources/mpfr-4.2.2.tar.xz
     10 #@sha256:3507dd105b0a0e1101bd43d294472fccf853429a259a5fa7c67467bba318f8e9:musl-cross-make/sources/linux-6.15.7.tar.xz
     11 #@sha256:ab642492f5cf882b74aa0cb730cd410a81edcdbec895183ce930e706c1c759b8:musl-cross-make/sources/mpc-1.3.1.tar.gz
     12 #@sha256:e0dc77297625631ac8e50fa92fffefe899a4eb702592da5c32ef04e2293aca3a:musl-cross-make/sources/gcc-14.3.0.tar.xz
     13 #@sha256:a9a118bbe84d8764da0ea0d28b3ab3fae8477fc7e4085d90102b8596fc7c75e4:musl-cross-make/sources/musl-1.2.5.tar.gz
     14 #@sha256:75d5d255a2a273b6e651f82eecfabf6cbcd8eaeae70e86b417384c8f4a58d8d3:musl-cross-make/sources/config.sub
     15 #@sha256:4213e75809588e3f32ae0fde8fb11df2dfd6e0e013762ff5ee951c3aadb7ffc0:musl-cross-make/patches/linux-6.15.7/0001-no-rsync-headers.diff
     16 #@git:cf9b601eba1b8c4a3c0655ba25d7fc8cfa365cbc:musl-cross-make
     17 
     18 
     19 # - build script start -
     20 
     21 prefix=/versions/$pthbs_package
     22 dest=${pthbs_destdir%/}${prefix}
     23 cd '.'
     24 
     25 bootstrap=/versions/musl-cross-make.3a5a0f4bb8b0eff01ede6b59f9eb4a8933caf3df331acf45879025d27e5f0bab
     26 "$bootstrap/bin/x86_64-linux-musl-gcc" --version
     27 
     28 # For validating the compiler
     29 printf '%s\n' 'int main(void) { return 0; }' >true.c
     30 
     31 printf '%s\n' >musl-cross-make/config.mak \
     32 	"OUTPUT=${pthbs_destdir%/}/versions/$pthbs_package" \
     33 	'GCC_VER=14.3.0' \
     34 	'LINUX_VER=6.15.7' \
     35 	'MUSL_VER=1.2.5' \
     36 	'BINUTILS_VER=2.44' \
     37 	'GMP_VER=6.3.0' \
     38 	'MPC_VER=1.3.1' \
     39 	'MPFR_VER=4.2.2' \
     40 	"TARGET=x86_64-linux-musl" \
     41 	'st=-static --static' \
     42 	'fl=-g0 -O2' \
     43 	"bbin=$bootstrap/bin" \
     44 	'COMMON_CONFIG += CFLAGS="${fl}" CXXFLAGS="${fl}" FFLAGS="${fl}" LDFLAGS="-s ${st}"' \
     45 	'COMMON_CONFIG += CC="${bbin}/x86_64-linux-musl-gcc ${st}" CXX="${bbin}/x86_64-linux-musl-g++ ${st}"'
     46 
     47 touch musl-cross-make/sources/*
     48 
     49 
     50 # Patch linker path for dynamic executables
     51 make -C musl-cross-make gcc-14.3.0
     52 sed -i -e 's|/lib/ld-musl-|/versions/'"$pthbs_package"'/x86_64-linux-musl/lib/ld-musl-|' musl-cross-make/gcc-14.3.0/gcc/config/*/linux*.h
     53 
     54 export PATH="$pthbs_build_environment/command:$PATH"
     55 make -j${JOBS:-1} -l$((1+${JOBS:-1})) -C musl-cross-make
     56 make -C musl-cross-make install
     57 
     58 mv "$dest/x86_64-linux-musl/include" "$dest/"
     59 mv "$dest/bin" "$dest/command"
     60 mv "$dest/x86_64-linux-musl/bin"/* "$dest/command/"
     61 
     62 ln -s ../include "$dest/x86_64-linux-musl/include"
     63 ln -s ./command "$dest/bin"
     64 ln -s ../command "$dest/x86_64-linux-musl/bin"
     65 
     66 # Override linker symlink
     67 for linkname in "${pthbs_destdir%/}"'/versions/'"$pthbs_package"'/x86_64-linux-musl/lib/'ld-musl-*so*; do
     68 	ln -s -f libc.so "$linkname"
     69 done
     70 
     71 # Validate the compiler
     72 "$dest/command/"'x86_64-linux-musl-gcc' --version
     73 "$dest/command/"'x86_64-linux-musl-gcc' -o true true.c
     74 "$dest/command/"'x86_64-linux-musl-readelf' --string-dump=.interp true >true.linker
     75 grep -F "$pthbs_package" true.linker
     76 
     77 
     78 
     79 
     80 cd "$pthbs_destdir/versions/$pthbs_package"
     81 
     82 find -type d -o -print | awk -F/ '
     83 BEGIN {
     84 	x["./command/x86_64-linux-musl-g++"]=1
     85 	x["./command/x86_64-linux-musl-gcc"]=1
     86 	x["./include/linux/landlock.h"]=1
     87 }
     88 
     89 function r1(s) {
     90 	sub("^[.]/[^/]*", ".", s)
     91 	return s
     92 }
     93 function s1(repl, s) {
     94 	sub("^[.]/[^/]*", "./"repl, s)
     95 	return s
     96 }
     97 function link(src) {
     98 	x[$0]=0
     99 	printf "%s\t%s\n", $0, src
    100 	printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr"
    101 }
    102 $1!="."{exit 1}
    103 
    104 
    105 $2 == "command" && $3 ~ /^x86_64-linux-musl-/ && ! (  \
    106 	$3 == "x86_64-linux-musl-ar" ||  \
    107 	$3 == "x86_64-linux-musl-as" ||  \
    108 	$3 == "x86_64-linux-musl-ld" ||  \
    109 	$3 == "x86_64-linux-musl-ld.bfd" ||  \
    110 	$3 == "x86_64-linux-musl-nm" ||  \
    111 	$3 == "x86_64-linux-musl-objcopy" ||  \
    112 	$3 == "x86_64-linux-musl-objdump" ||  \
    113 	$3 == "x86_64-linux-musl-ranlib" ||  \
    114 	$3 == "x86_64-linux-musl-readelf" ||  \
    115 	$3 == "x86_64-linux-musl-strip"  \
    116 ) {
    117 	target=$3
    118 	sub("x86_64-linux-musl-", "", target)
    119 	link("./command/" target)
    120 }
    121 $2 == "command" { link($0); next }
    122 
    123 $2 == "config" { link($0); next }
    124 $2 == "keys" { link($0); next }
    125 $2 == "zsh" { link($0); next }
    126 $2 == "env" { link($0); next }
    127 
    128 $2 == "library.so" { link($0); next }
    129 $2 == "library" { link($0); next }
    130 $2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next }
    131 $2 == "lib" && $NF ~ /\.so(\..*)?$/ { link(s1("library.so", $0)); next }
    132 
    133 $2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next }
    134 
    135 $2 == "man" { link($0); next }
    136 $2 == "info" { link($0); next }
    137 $2 == "doc" { link($0); next }
    138 $2 == "icons" { link($0); next }
    139 $2 == "terminfo" { link($0); next }
    140 $2 == "data" { link($0); next }
    141 $2 == "include" { link($0); next }
    142 
    143 { printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" }
    144 
    145 END {
    146 	for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" }
    147 	for(fname in x) {
    148 		if(x[fname]) {
    149 			printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr"
    150 			exit 3
    151 		}
    152 	}
    153 }' >.install-links.new
    154 mv .install-links.new .install-links
    155