mrrl

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

musl-cross-make:old (6557B)


      1 #!/usr/bin/env pthbs-build
      2 #@pragma:nofail_digest
      3 #+musl-cross-make.cce5eef0be1758e36805fec680f21b424833d8022ad4893023bfa17cba5a6e19
      4 #+gnu-make.e7b478ac3eb957f5f9540109bd8867397a89075b683f449f06d5811eaa819c8e
      5 #+busybox.c3062ae43617ee3c723bf5c0e9b64411110c25e6e16b129626a0fc00c2570e11
      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 #@sha256:68140a82582ede938159630bca0fb13a93b4bf1cb2e85b08943c26242cf8f3a6:zpipe.c
     17 #@git:cf9b601eba1b8c4a3c0655ba25d7fc8cfa365cbc:musl-cross-make
     18 
     19 
     20 # - build script start -
     21 PATH="$pthbs_build_environment/command:$PATH"
     22 
     23 prefix=/versions/$pthbs_package
     24 dest=${pthbs_destdir%/}${prefix}
     25 cd '.'
     26 
     27 # For validating the compiler
     28 printf '%s\n' 'int main(void) { return 0; }' >true.c
     29 
     30 printf '%s\n' >musl-cross-make/config.mak \
     31 	"OUTPUT=${pthbs_destdir%/}/versions/$pthbs_package" \
     32 	"TARGET=x86_64-linux-musl" \
     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 	'st=-static --static' \
     41 	'fl=-g0 -O2' \
     42 	"command=$pthbs_build_environment/command" \
     43 	'COMMON_CONFIG += CFLAGS="${fl} ${st}" CXXFLAGS="${fl} ${st}" FFLAGS="${fl}" LDFLAGS="-s ${st}"' \
     44 	'COMMON_CONFIG += CC="${command}/x86_64-linux-musl-gcc ${st}" CXX="${command}/x86_64-linux-musl-g++ ${st}"'
     45 
     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 make -j${JOBS:-1} -l$((1+${JOBS:-1})) -C musl-cross-make || exit $?
     54 make -C musl-cross-make install || exit $?
     55 
     56 mv "$dest/x86_64-linux-musl/include" "$dest/"
     57 mv "$dest/bin" "$dest/command"
     58 mv "$dest/x86_64-linux-musl/bin"/* "$dest/command/"
     59 
     60 ln -s ../include "$dest/x86_64-linux-musl/include"
     61 ln -s ./command "$dest/bin"
     62 ln -s ../command "$dest/x86_64-linux-musl/bin"
     63 
     64 dd=$pthbs_destdir//versions/$pthbs_package
     65 
     66 # Override linker symlink
     67 for linkname in "$dd"'/x86_64-linux-musl/lib/'ld-musl-*so*; do
     68 	ln -s -f libc.so "$linkname"
     69 done
     70 
     71 # Validate the compiler
     72 "$dd"'/command/x86_64-linux-musl-gcc' --version
     73 "$dd"'/command/x86_64-linux-musl-gcc' -o true true.c
     74 "$dd"'/command/x86_64-linux-musl-readelf' --string-dump=.interp true >true.linker
     75 grep -F "$pthbs_package" true.linker
     76 
     77 pkgs="gmp mpc mpfr zlib"
     78 #pkgs="$pkgs libbacktrace libcc1 libcpp libdecnumber libiberty lto-plugin"
     79 
     80 for pkg in $pkgs; do
     81 	make -C musl-cross-make/build/local/x86_64-linux-musl/obj_gcc/$pkg prefix=/ DESTDIR="$dd" install
     82 done
     83 cp -va musl-cross-make/gcc-*.orig/zlib/zconf.h musl-cross-make/gcc-*.orig/zlib/zlib.h "$dd/include/"
     84 mkdir -p "$dd/library/pkgconfig"
     85 printf '%s\n' > "$dd/library/pkgconfig/zlib.pc" \
     86 	"prefix=/versions/$pthbs_package" \
     87 	'exec_prefix=${prefix}' \
     88 	'includedir=${prefix}/include' \
     89 	'libdir=${exec_prefix}/library' \
     90 	'' \
     91 	'Name: zlib' \
     92 	'Description: zlib compression library' \
     93 	'Version: 1.2.11' \
     94 	'' \
     95 	'Requires:' \
     96 	'Libs: -L${libdir} -lz' \
     97 	'Cflags: -I${includedir}'
     98 
     99 
    100 # validate zlib
    101 "$dd"'/command/x86_64-linux-musl-gcc' -I"$dd/include" -L"$dd/lib" -static -o zpipe zpipe.c -lz
    102 ./zpipe <true.c >true.c.gz
    103 ./zpipe -d <true.c.gz >true.c.2
    104 cmp -s true.c true.c.2
    105 
    106 
    107 
    108 cd "$pthbs_destdir/versions/$pthbs_package"
    109 find -type d -o -print | awk -F/ '
    110 BEGIN {
    111 	x["./command/x86_64-linux-musl-g++"]=1
    112 	x["./command/x86_64-linux-musl-gcc"]=1
    113 	x["./include/linux/landlock.h"]=1
    114 
    115 	x["./lib/libgmp.a"]=1
    116 	x["./lib/libmpc.a"]=1
    117 	x["./lib/libmpfr.a"]=1
    118 	x["./lib/libz.a"]=1
    119 
    120 	x["./include/gmp.h"]=1
    121 	x["./include/mpc.h"]=1
    122 	x["./include/mpf2mpfr.h"]=1
    123 	x["./include/mpfr.h"]=1
    124 	x["./include/zlib.h"]=1
    125 	x["./include/zconf.h"]=1
    126 }
    127 
    128 function r1(s) {
    129 	sub("^[.]/[^/]*", ".", s)
    130 	return s
    131 }
    132 function s1(repl, s) {
    133 	sub("^[.]/[^/]*", "./"repl, s)
    134 	return s
    135 }
    136 function link(src) {
    137 	x[$0]=0
    138 	printf "%s\t%s\n", $0, src
    139 	printf "genlinks >>%s\t%s<<\n", $0, src >>"/dev/stderr"
    140 }
    141 $1!="."{exit 1}
    142 
    143 $2 == "command" && $3 ~ /^x86_64-linux-musl-/ && ! (  \
    144 	$3 == "x86_64-linux-musl-ar" ||  \
    145 	$3 == "x86_64-linux-musl-as" ||  \
    146 	$3 == "x86_64-linux-musl-ld" ||  \
    147 	$3 == "x86_64-linux-musl-ld.bfd" ||  \
    148 	$3 == "x86_64-linux-musl-nm" ||  \
    149 	$3 == "x86_64-linux-musl-objcopy" ||  \
    150 	$3 == "x86_64-linux-musl-objdump" ||  \
    151 	$3 == "x86_64-linux-musl-ranlib" ||  \
    152 	$3 == "x86_64-linux-musl-readelf" ||  \
    153 	$3 == "x86_64-linux-musl-strip"  \
    154 ) {
    155 	target=$3
    156 	sub("x86_64-linux-musl-", "", target)
    157 	link("./command/" target)
    158 }
    159 $2 == "command" { link($0); next }
    160 
    161 $2 == "config" { link($0); next }
    162 $2 == "keys" { link($0); next }
    163 $2 == "zsh" { link($0); next }
    164 $2 == "env" { link($0); next }
    165 
    166 $2 == "library.so" { link($0); next }
    167 $2 == "library" { link($0); next }
    168 $2 == "lib" && $NF ~ /\.l?a$/ { link(s1("library", $0)); next }
    169 $2 == "lib" && $NF ~ /\.so(\..*)?$/ { link(s1("library.so", $0)); next }
    170 
    171 $2 == "share" && $3 ~ /^(info|man|doc|icons|terminfo)$/ { link(r1($0)); next }
    172 
    173 $2 == "man" { link($0); next }
    174 $2 == "info" { link($0); next }
    175 $2 == "doc" { link($0); next }
    176 $2 == "icons" { link($0); next }
    177 $2 == "terminfo" { link($0); next }
    178 $2 == "data" { link($0); next }
    179 $2 == "include" { link($0); next }
    180 
    181 { printf "genlinks ##%s## skipped\n", $0 >>"/dev/stderr" }
    182 
    183 END {
    184 	for(fname in x) { printf "DEBUG: x[\"%s\"]=\"%s\"\n", fname, x[fname] >"/dev/stderr" }
    185 	for(fname in x) {
    186 		if(x[fname]) {
    187 			printf "ERROR: missing expected file \"%s\"\n", fname >"/dev/stderr"
    188 			exit 3
    189 		}
    190 	}
    191 }' >.install-links.new
    192 mv .install-links.new .install-links
    193