galeb

Једноставна статичка дистрибуција заснована на musl-у
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување ed371700ec85e4a92ecfcd1c54b7c6f9f8edaf06
родитељ 9fb711bda1f3f45bc1e4c8e1dc22646719c65b58
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Sun,  3 Jul 2022 19:42:36 +0200

Move up to tools->tcl

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
M.gitignore | 1+
M01-cross.sh | 781+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------
A02-prep-chroot.sh | 50++++++++++++++++++++++++++++++++++++++++++++++++++
A03-chroot.sh | 0
Agaleb.session | 533+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mlib/env.sh | 38++++++++++++++++++++++++--------------
Mlib/fun.sh | 132++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------
Mpat | 4++--
Mpat-11.2.1/gcc-alpine/0003-Turn-on-Wl-z-relro-z-now-by-default.patch | 8++++----
Mpat-11.2.1/gcc-alpine/0004-Turn-on-D_FORTIFY_SOURCE-2-by-default-for-C-C-ObjC-O.patch | 8++++----
Mpat-11.2.1/gcc-alpine/0013-libgcc_s.patch | 8++++----
Mpat-11.2.1/gcc-alpine/0022-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch | 8++++----
Mpat-11.2.1/gcc-alpine/0042-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch | 6+++---
измењених датотека: 13, додавања: 1347(+), брисања: 230(-)

diff --git a/.gitignore b/.gitignore @@ -8,3 +8,4 @@ *.orig *.rej *.swp +*.session diff --git a/01-cross.sh b/01-cross.sh @@ -5,11 +5,19 @@ WD=${PWD} -totalsteps=4 +trap exit_cleanup HUP PIPE INT QUIT TERM EXIT + +totalsteps=3 step=1 -msg info "${white}Galeb %s${green} bootstrap" "${G_VER}" -msg info "${white}[%d/%d]: cross-tools" ${step} ${totalsteps} +msg info "${bgwhite}${black}Galeb %s${norm}${bold}${faint}${green} bootstrap" \ + "${G_VER}" +remove_file ${G_FIFO} + +begin_step cross-tools + +totalsubsteps=6 +substep=1 check_dir ${CT} check_dir ${G_PAT} @@ -24,30 +32,345 @@ check_dir ${GR}/share check_dir ${GR}/sucks/bin check_dir ${GR}/sucks/lib +if [ ! -e /${CTD} ] && [ ! -e /${TLD} ]; then + msg info "Linking %s and %s to / (needs root)" ${CTD} ${TLD} + su -c 'ln -s '${CT}' /; ln -s '${TL}' /' +fi + cd_or_fail ${G_SRC} -begin_pkg musl-cross-make -msg info "Setting up musl-cross-make" +# begin_substep musl-cross-make +# msg info "Setting up musl-cross-make" +# if [ -x ${CT}/bin/${CT_TRI}-gcc ]; then +# msg info "%s exists" "${CT_TRI}-gcc" +# else +# git_clone ${pkg} https://github.com/richfelker/${pkg} +# ( +# cd_or_fail ${pkg} +# cat <<! > config.mak +# TARGET = ${CT_TRI} +# OUTPUT = ${CT} +# COMMON_CONFIG += CFLAGS="-g0 -Os" +# ! +# run_make +# run_make install +# ) +# fi +# end_substep + +begin_substep linux-5.17.13 "Linux headers" +if [ -e ${CT}/${G_TARGET}/include/linux/stddef.h ]; then + msg info "%s exists, skipping %s" \ + ${CT}/${G_TARGET}/include/linux/stddef.h "${substepname}" +else + fetch_pkg https://www.kernel.org/pub/linux/kernel/v5.x/linux-5.17.13.tar.xz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz + ( + cd_or_fail ${G_SRC}/${pkg} + run_make ARCH=${G_ARCH} headers + check_dir ${CT}/${G_TARGET}/include + cp_or_fail -r "usr/include/*" ${CT}/${G_TARGET}/include/ + msg info "Removing *.cmd" + find ${CT}/${G_TARGET}/include -name '.*.cmd' -exec rm -f {} \; + rm ${CT}/${G_TARGET}/include/Makefile + #remove_dir ${G_SRC}/${pkg} + ) || exit 1 +fi +end_substep + +begin_substep binutils-2.38 +if [ -x ${CT}/${G_TARGET}/bin/ar ]; then + msg info "%s exists, skipping %s" "${CT}/${G_TARGET}/bin/ar" ${pkg} +else + fetch_pkg https://ftp.gnu.org/gnu/binutils/binutils-2.38.tar.xz + remove_dir ${G_SRC}/${pkg} + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz + ( + cd_or_fail ${G_SRC}/${pkg} + remove_dir build + check_dir build + cd_or_fail build + run_configure .. \ + --prefix=${CT} \ + --target=${G_TARGET} \ + --with-sysroot=${CT}/${G_TARGET} \ + --disable-nls \ + --disable-multilib \ + --disable-werror \ + --enable-deterministic-archives \ + --disable-compressed-debug-sections + run_make + run_make install-strip + ) || exit 1 + #remove_dir ${G_SRC}/${pkg} +fi +end_substep + +begin_substep gcc-11-20220101 "static GCC" if [ -x ${CT}/bin/${G_TARGET}-gcc ]; then - msg info "%s exists" "${G_TARGET}-gcc" + msg info "%s exists, skipping %s" "${CT}/bin/${G_TARGET}-gcc" ${pkg} +else +fetch_pkg https://gcc.gnu.org/pub/gcc/snapshots/11-20220101/gcc-11-20220101.tar.xz +remove_dir ${G_SRC}/${pkg} +extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz +( + cd_or_fail ${G_SRC}/${pkg} + + subpkg=gmp-6.2.1 + if [ -d gmp ]; then + msg info "Subpackage %s exists" "${subpkg}" + else + fetch_pkg https://ftp.gnu.org/gnu/gmp/${subpkg}.tar.xz + extract_pkg ${G_SRC}/${pkg} ${subpkg} ${subpkg}.tar.xz + mv_or_fail ${subpkg} gmp + fi + + subpkg=mpc-1.2.1 + if [ -d mpc ]; then + msg info "Subpackage %s exists" "${subpkg}" + else + fetch_pkg https://ftp.gnu.org/gnu/mpc/${subpkg}.tar.gz + extract_pkg ${G_SRC}/${pkg} ${subpkg} ${subpkg}.tar.gz + mv_or_fail ${subpkg} mpc + fi + + subpkg=mpfr-4.1.0 + if [ -d mpfr ]; then + msg info "Subpackage %s exists" "${subpkg}" + else + fetch_pkg https://ftp.gnu.org/gnu/mpfr/${subpkg}.tar.xz + extract_pkg ${G_SRC}/${pkg} ${subpkg} ${subpkg}.tar.xz + mv_or_fail ${subpkg} mpfr + fi + + remove_dir build + check_dir build + cd_or_fail build + + CFLAGS='-g0 -O0' + CXXFLAGS=${CFLAGS} + export CFLAGS CXXFLAGS + + run_configure .. \ + --prefix=/${CTD} \ + --build=${G_HOST} \ + --host=${G_HOST} \ + --target=${G_TARGET} \ + --with-sysroot=/${CTD}/${G_TARGET} \ + --disable-nls \ + --with-newlib \ + --disable-libitm \ + --disable-libvtv \ + --disable-libssp \ + --disable-shared \ + --disable-libgomp \ + --without-headers \ + --disable-threads \ + --disable-multilib \ + --disable-libatomic \ + --disable-libstdcxx \ + --enable-languages=c \ + --disable-libquadmath \ + --disable-libsanitizer \ + --with-arch=${G_ARCH_EXT} \ + --disable-decimal-float \ + --enable-clocale-generic + + run_make all-gcc all-target-libgcc + run_make install-gcc install-target-libgcc + + unset CFLAGS CXXFLAGS +) || exit 1 +#remove_dir ${G_SRC}/${pkg} +fi +end_substep + +msg info "Setting environment" +OLDPATH=${PATH} +PATH=/${CTD}/bin:/${TLD}/bin:/bin:/usr/bin +export PATH + +begin_substep musl-1.2.3 +if [ -e ${CT}/lib/ld-musl-${G_ARCH_EXT_ALT}.so.1 ]; then + msg info "%s exists, skipping %s" \ + ${CT}/lib/ld-musl-${G_ARCH_EXT_ALT}.so.1 ${pkg} else - git_clone ${pkg} https://github.com/richfelker/${pkg} + fetch_pkg https://musl.libc.org/releases/${pkg}.tar.gz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.gz ( - cd_or_fail ${pkg} - cat <<! > config.mak -TARGET = ${G_TARGET} -OUTPUT = ${CT} -COMMON_CONFIG += CFLAGS="-g0 -Os" + cd_or_fail ${G_SRC}/${pkg} + run_configure . \ + CROSS_COMPILE=${G_TARGET}- \ + --prefix=/ \ + --target=${G_TARGET} + run_make + DESTDIR=/${CTD} + export DESTDIR + run_make install + unset DESTDIR + + check_dir ${CT}/usr + link_if_ne ../include ${CT}/usr/include + + remove_file ${CT}/lib/ld-musl-${G_ARCH_EXT_ALT}.so.1 + link_if_ne libc.so ${CT}/lib/ld-musl-${G_ARCH_EXT_ALT}.so.1 + + link_if_ne ../lib/ld-musl-${G_ARCH_EXT_ALT}.so.1 ${CT}/bin/ldd + + check_dir ${CT}/etc + msg info "Generating %s" \ + ${CT}/etc/ld-musl-${G_ARCH_EXT_ALT}.path + cat <<! >${CT}/etc/ld-musl-${G_ARCH_EXT_ALT}.path +/${CTD}/lib +/${TLD}/lib ! + ) || exit 1 +fi +end_substep + +begin_substep gcc-11-20220101 "final GCC" +( + msg info "(Skipping)" + exit 0 + + skip_remove=0 + if [ ${skip_remove} -eq 0 ]; then + remove_dir ${G_SRC}/${pkg} + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz + fi + cd_or_fail ${G_SRC}/${pkg} + + if [ ${skip_remove} -eq 0 ]; then + msg info "Applying patches" + for n in 1 3 4 6 7 9 10 11 12 14 17 18 19 20 23 24 25 27 28 29 \ + 32 35 36 37 41 42 43 + do + apply_patch gcc-final -Np1 -i \ + ${WD}/pat/gcc-alpine/$(printf "%04d" $n)-*.patch + done + fi + + check_dir build + cd_or_fail build + + + printf "PATH=%s\n" "${PATH}" + printf "gcc=%s\n" $(which gcc) + + AR=ar + LDFLAGS='-Wl,-rpath,/'${CTD}'/lib' + export AR LDFLAGS + + run_configure .. \ + --prefix=/${CTD} \ + --build=${G_HOST} \ + --host=${G_HOST} \ + --target=${G_TARGET} \ + --disable-multilib \ + --with-sysroot=/${CTD} \ + --disable-nls \ + --enable-shared \ + --enable-languages=c,c++ \ + --enable-threads=posix \ + --enable-clocale=generic \ + --enable-libstdcxx-time \ + --enable-fully-dynamic-string \ + --disable-symvers \ + --disable-libsanitizer \ + --disable-lto-plugin \ + --disable-libssp + + run_make AS_FOR_TARGET=${G_TARGET}-as \ + LD_FOR_TARGET=${G_TARGET}-ld + run_make install + + unset AR LDFLAGS +) || exit 1 +end_substep + +begin_substep file-5.41 +if [ -x ${CT}/bin/file ]; then + msg info "%s exists, skipping %s" ${CT}/bin/file ${pkg} +else + fetch_pkg https://astron.com/pub/file/${pkg}.tar.gz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.gz + ( + cd_or_fail ${G_SRC}/${pkg} + + run_configure . \ + --prefix=/${CTD} --disable-libseccomp + run_make run_make install - ) + ) || exit 1 fi -end_pkg +end_substep -msg info "Setting environment" -OLDPATH=${PATH} -PATH=${CT}/bin:${OLDPATH} +end_step # cross-tools + +begin_step tools + +totalsubsteps=20 +substep=1 + +begin_substep musl-1.2.3 +if [ -e ${TL}/lib/ld-musl-${G_ARCH_EXT_ALT}.so.1 ]; then + msg info "%s exists, skipping %s" \ + ${TL}/lib/ld-musl-${G_ARCH_EXT_ALT}.so.1 ${pkg} +else + fetch_pkg https://musl.libc.org/releases/${pkg}.tar.gz + remove_dir ${G_SRC}/${pkg} + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.gz + ( + cd_or_fail ${G_SRC}/${pkg} + run_configure . \ + CROSS_COMPILE=${G_TARGET}- \ + --prefix=/ \ + --target=${G_TARGET} + run_make + run_make DESTDIR=/${TLD} install + + remove_file ${TL}/lib/ld-musl-${G_ARCH_EXT_ALT}.so.1 + link_if_ne libc.so ${TL}/lib/ld-musl-${G_ARCH_EXT_ALT}.so.1 + + #link_if_ne ../lib/ld-musl-${G_ARCH_EXT_ALT}.so.1 ${CT}/bin/ldd + + check_dir ${TL}/etc + msg info "Generating %s" \ + ${TL}/etc/ld-musl-${G_ARCH_EXT_ALT}.path + cat <<! >${TL}/etc/ld-musl-${G_ARCH_EXT_ALT}.path +/${TLD}/lib +! + ) || exit 1 +fi +end_substep + +msg info "Adjusting cross-tools" +SPECFILE=$(realpath $(dirname $(${G_TARGET}-gcc -print-libgcc-file-name)))/specs +msg info "Specfile at %s" "${SPECFILE}" +${G_TARGET}-gcc -dumpspecs > specs +sed -i 's,:\(/lib/ld-musl-'${G_ARCH_EXT_ALT}'.so.1\),:/'${TLD}'\1,g' specs +cat specs >>${G_LOG} +mv_or_fail specs ${SPECFILE} +unset SPECFILE + +msg info "Test specs" +echo 'int main(){}' > dummy.c +${G_TARGET}-gcc dummy.c +interp=$(${G_TARGET}-readelf -l a.out | grep interpreter) +remove_file a.out +remove_file dummy.c +if echo "${interp}" | grep "/${TLD}/lib/ld-musl-${G_ARCH_EXT_ALT}.so.1" \ + >/dev/null 2>&1 +then + msg info "Specs look OK" +else + msg err "Specs are not OK" + exit 1 +fi +unset interp + +msg info "Setting environment (%s)" "${stepname}" CC=${G_TARGET}-gcc CXX=${G_TARGET}-g++ AR=${G_TARGET}-ar @@ -55,172 +378,256 @@ AS=${G_TARGET}-as RANLIB=${G_TARGET}-ranlib LD=${G_TARGET}-ld STRIP=${G_TARGET}-strip -export PATH CC CXX AR AS RANLIB LD STRIP +export CC CXX AR AS RANLIB LD STRIP + +link_if_ne lib /${TLD}/lib64 -begin_pkg binutils-2.38 -if [ -x ${TL}/bin/ar ]; then - msg info "%s exists, skipping %s" "${TL}/bin/ar" ${pkg} +begin_substep binutils-2.38 +if [ -x ${TL}/${G_TARGET}/bin/ar ]; then + msg info "%s exists, skipping %s" ${TL}/${G_TARGET}/bin/ar ${pkg} else fetch_pkg https://ftp.gnu.org/gnu/binutils/binutils-2.38.tar.xz + remove_dir ${G_SRC}/${pkg} extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz ( cd_or_fail ${G_SRC}/${pkg} - remove_dir build check_dir build cd_or_fail build - CFLAGS='-static --static -fcommon' - LDFLAGS='-static --static -Bstatic -fcommon' - export CFLAGS LDFLAGS run_configure .. \ - --prefix=${TL} \ - --with-lib-path=${TL}/lib \ - --build=${G_TARGET} \ + --prefix=/${TLD} \ + --with-lib-path=/${TLD}/lib \ + --build=${G_HOST} \ --host=${G_TARGET} \ --target=${G_TARGET} \ --disable-nls \ --disable-werror \ - --with-static-standard-libraries \ --with-sysroot run_make run_make install-strip - unset CFLAGS LDFLAGS - ) - remove_dir ${G_SRC}/${pkg} + run_make -C ld clean + run_make -C ld LIB_PATH=/usr/lib:/lib + cp_or_fail ld/ld-new /${TLD}/bin + ) || exit 1 fi -end_pkg +end_substep -# ##pkg=gcc-12.1.0 -# pkg=gcc-11-20220101 -# if [ -x ${TL}/bin/gcc ]; then -# msg info "%s exists, skipping %s" "${TL}/bin/gcc" ${pkg} -# else -# #fetch_pkg https://ftp.gnu.org/gnu/gcc/${pkg}/${pkg}.tar.xz -# fetch_pkg https://gcc.gnu.org/pub/gcc/snapshots/11-20220101/gcc-11-20220101.tar.xz -# extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz -# ( -# cd_or_fail ${G_SRC}/${pkg} -# -# subpkg=gmp-6.2.1 -# if [ -d gmp ]; then -# msg info "Subpackage %s exists" "${subpkg}" -# else -# fetch_pkg https://ftp.gnu.org/gnu/gmp/${subpkg}.tar.xz -# extract_pkg ${G_SRC}/${pkg} ${subpkg} ${subpkg}.tar.xz -# mv_or_fail ${subpkg} gmp -# fi -# -# subpkg=mpc-1.2.1 -# if [ -d mpc ]; then -# msg info "Subpackage %s exists" "${subpkg}" -# else -# fetch_pkg https://ftp.gnu.org/gnu/mpc/${subpkg}.tar.gz -# extract_pkg ${G_SRC}/${pkg} ${subpkg} ${subpkg}.tar.gz -# mv_or_fail ${subpkg} mpc -# fi -# -# subpkg=mpfr-4.1.0 -# if [ -d mpfr ]; then -# msg info "Subpackage %s exists" "${subpkg}" -# else -# fetch_pkg https://ftp.gnu.org/gnu/mpfr/${subpkg}.tar.xz -# extract_pkg ${G_SRC}/${pkg} ${subpkg} ${subpkg}.tar.xz -# mv_or_fail ${subpkg} mpfr -# fi -# -# msg info "Applying patches" -# for n in 1 3 4 6 7 9 10 11 12 13 14 17 18 19 20 23 24 25 27 28 29 \ -# 32 35 36 37 41 42 43 -# do -# apply_patch -Np1 -i ${WD}/pat/gcc-alpine/$(printf "%04d" \ -# $n)-*.patch -# done -# -# apply_patch -Np1 -i ${WD}/pat/gcc-mlfs/fix_fenv_header.patch -# -# msg info "Generating include-fixed/limits.h" -# if ! cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \ -# $(realpath $(dirname $(${CT_TRI}-gcc \ -# -print-libgcc-file-name)))/include-fixed/limits.h -# then -# msg err "Generating include-fixed/limits.h failed" -# exit 1 -# fi -# -# msg info "Modifying linux*.h" -# for f in gcc/config/linux.h \ -# gcc/config/i386/linux.h \ -# gcc/config/i386/linux64.h -# do -# cp -u $f $f.orig -# sed -e 's,/lib\(64\)\?\(32\)\?/ld,/'${TLD}'&,g' \ -# -e 's,/usr,/'${TLD}',g' $f.orig > $f -# cat <<'!' >>$f -# #undef STANDARD_STARTFILE_PREFIX_1 -# #undef STANDARD_STARTFILE_PREFIX_2 -# ! -# printf "#define STANDARD_STARTFILE_PREFIX_1 \"/"${TLD}\ -# "/lib/\"\n" >>$f -# cat <<'!' >>$f -# #define STANDARD_STARTFILE_PREFIX_2 "" -# ! -# touch $f.orig -# done -# -# skip_conf=0 -# if [ ${skip_conf} != 1 ]; then -# remove_dir build -# fi -# check_dir build -# cd_or_fail build -# -# CFLAGS='-g0 -O0' -# CXXFLAGS=${CFLAGS} -# export CFLAGS CXXFLAGS -# -# if [ ! -e ${CT}/bin/${G_TARGET}-gcc ]; then -# ln -s ${CT_TRI}-gcc ${CT}/bin/${G_TARGET}-gcc -# fi -# for tool in cc cpp gcc g++; do -# if [ ! -e ${CT}/bin/${G_TARGET}-${tool} ]; then -# ln -s ${CT_TRI}-${tool} ${CT}/bin/${G_TARGET}-${tool} -# fi -# done -# -# if [ ${skip_conf} != 1 ]; then -# run_configure .. \ -# --target=${G_TARGET} \ -# --build=${CT_TRI} \ -# --host=${G_TARGET} \ -# --prefix=${TL} \ -# --with-local-prefix=${TL} \ -# --with-native-system-header-dir=/${TLD}/include \ -# --enable-languages=c,c++ \ -# --disable-libstdcxx-pch \ -# --disable-multilib \ -# --disable-bootstrap \ -# --disable-libgomp \ -# --disable-libquadmath \ -# --disable-libssp \ -# --disable-libvtv \ -# --disable-symvers \ -# --disable-libitm \ -# --disable-libsanitizer -# fi -# -# PATH=${CT}/bin:/bin:/usr/bin:${TL}/bin -# export PATH -# -# run_make -# run_make install -# -# unset CFLAGS CXXFLAGS -# } -# exit 0 -# remove_dir ${G_SRC}/${pkg} -# fi -# +begin_substep gcc-11-20220101 +if [ -x /${TLD}/bin/gcc ]; then + msg info "%s exists, skipping %s" "/${TLD}/bin/gcc" ${pkg} +else +fetch_pkg https://gcc.gnu.org/pub/gcc/snapshots/11-20220101/gcc-11-20220101.tar.xz +remove_dir ${G_SRC}/${pkg} +extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz +( + cd_or_fail ${G_SRC}/${pkg} + + subpkg=gmp-6.2.1 + if [ -d gmp ]; then + msg info "Subpackage %s exists" "${subpkg}" + else + fetch_pkg https://ftp.gnu.org/gnu/gmp/${subpkg}.tar.xz + extract_pkg ${G_SRC}/${pkg} ${subpkg} ${subpkg}.tar.xz + mv_or_fail ${subpkg} gmp + fi + + subpkg=mpc-1.2.1 + if [ -d mpc ]; then + msg info "Subpackage %s exists" "${subpkg}" + else + fetch_pkg https://ftp.gnu.org/gnu/mpc/${subpkg}.tar.gz + extract_pkg ${G_SRC}/${pkg} ${subpkg} ${subpkg}.tar.gz + mv_or_fail ${subpkg} mpc + fi + + subpkg=mpfr-4.1.0 + if [ -d mpfr ]; then + msg info "Subpackage %s exists" "${subpkg}" + else + fetch_pkg https://ftp.gnu.org/gnu/mpfr/${subpkg}.tar.xz + extract_pkg ${G_SRC}/${pkg} ${subpkg} ${subpkg}.tar.xz + mv_or_fail ${subpkg} mpfr + fi + + msg info "Applying patches" + for n in 1 3 4 6 7 9 10 11 12 14 17 18 19 20 23 24 25 27 28 29 \ + 32 35 36 37 41 42 43 + do + apply_patch gcc-tools -Np1 -i \ + ${WD}/pat/gcc-alpine/$(printf "%04d" $n)-*.patch + done + + apply_patch gcc-tools -Np1 -i ${WD}/pat/gcc-mlfs/fix_fenv_header.patch + + msg info "Generating include-fixed/limits.h" + if ! cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \ + $(realpath $(dirname $(${G_TARGET}-gcc \ + -print-libgcc-file-name)))/include-fixed/limits.h + then + msg err "Generating include-fixed/limits.h failed" + exit 1 + fi + + msg info "Modifying linux*.h" + for f in gcc/config/linux.h \ + gcc/config/i386/linux.h \ + gcc/config/i386/linux64.h + do + cp -u $f $f.orig + sed -e 's,/lib\(64\)\?\(32\)\?/ld,/'${TLD}'&,g' \ + -e 's,/usr,/'${TLD}',g' $f.orig > $f + cat <<'!' >>$f +#undef STANDARD_STARTFILE_PREFIX_1 +#undef STANDARD_STARTFILE_PREFIX_2 +#define STANDARD_STARTFILE_PREFIX_1 "/${TLD}/lib/" +#define STANDARD_STARTFILE_PREFIX_2 "" +! + touch $f.orig + done + + remove_dir build + check_dir build + cd_or_fail build + + CFLAGS='-g0 -O0' + CXXFLAGS=${CFLAGS} + export CFLAGS CXXFLAGS + + run_configure .. \ + --target=${G_TARGET} \ + --build=${G_HOST} \ + --host=${G_TARGET} \ + --prefix=/${TLD} \ + --with-local-prefix=/${TLD} \ + --with-native-system-header-dir=/${TLD}/include \ + --enable-languages=c,c++ \ + --disable-libstdcxx-pch \ + --disable-multilib \ + --disable-bootstrap \ + --disable-libgomp \ + --disable-libquadmath \ + --disable-libssp \ + --disable-libvtv \ + --disable-symvers \ + --disable-libitm \ + --disable-libsanitizer + + LOCALOLDPATH=${PATH} + PATH=/bin:/usr/bin:/${CTD}/bin:/${TLD}/bin + export PATH + run_make + run_make install-strip -begin_pkg mksh + link_if_ne gcc /${TLD}/bin/cc + + PATH=${LOCALOLDPATH} + export PATH + unset CFLAGS CXXFLAGS LOCALOLDPATH + + msg info "Testing interpreter" + echo 'int main(){}' > dummy.c + gcc dummy.c + interp=$(readelf -l a.out | grep ': /'${TLD}) + if echo "${interp}" | \ + grep "/${TLD}/lib/ld-musl-${G_ARCH_EXT_ALT}.so.1" \ + >/dev/null 2>&1 + then + msg info "Specs look OK" + else + msg err "Specs are not OK: %s" "${interp}" + exit 1 + fi + unset interp + remove_file a.out + remove_file dummy.c +) || exit 1 +#remove_dir ${G_SRC}/${pkg} +fi +end_substep + +begin_substep linux-5.17.13 "Linux headers" +if [ -e /${TLD}/include/linux/stddef.h ]; then + msg info "%s exists, skipping %s" \ + /${TLD}/include/linux/stddef.h "${substepname}" +else + fetch_pkg https://www.kernel.org/pub/linux/kernel/v5.x/linux-5.17.13.tar.xz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz + ( + cd_or_fail ${G_SRC}/${pkg} + run_make mrproper + run_make ARCH=${G_ARCH} headers + check_dir /${TLD}/include + cp_or_fail -r "usr/include/*" /${TLD}/include/ + msg info "Removing *.cmd" + find /${TLD}/include -name '.*.cmd' -exec rm -f {} \; + rm /${TLD}/include/Makefile + ) || exit 1 +fi +end_substep + +PATH=/${TLD}/bin:/${CT}/bin:/usr/bin:/bin +export PATH + +msg info "Adjusting tools" +SPECFILE=$(realpath $(dirname $(${G_TARGET}-gcc -print-libgcc-file-name)))/specs +msg info "Specfile at %s" "${SPECFILE}" +${G_TARGET}-gcc -dumpspecs > specs +sed -i 's,:\(/lib/ld-musl-'${G_ARCH_EXT_ALT}'.so.1\),:/'${TLD}'\1,g' specs +cat specs >>${G_LOG} +mv_or_fail specs ${SPECFILE} +unset SPECFILE + +msg info "Test specs" +echo 'int main(){}' > dummy.c +${G_TARGET}-gcc -B/tools/lib dummy.c +interp=$(${G_TARGET}-readelf -l a.out | grep interpreter) +remove_file a.out +remove_file dummy.c +if echo "${interp}" | grep "/${TLD}/lib/ld-musl-${G_ARCH_EXT_ALT}.so.1" \ + >/dev/null 2>&1 +then + msg info "Specs look OK" +else + msg err "Specs are not OK" + exit 1 +fi +unset interp + +begin_substep gcc-11-20220101 libstdcxx +if [ -e /${TLD}/share/gcc-11.2.1/python/libstdcxx ]; then + msg info "%s exists, skipping %s" \ + "/${TLD}/share/gcc-11.2.1/python/libstdcxx" "${substepname}" +else + ( + if ! tail -n1 /${TLD}/include/c++/11.2.1/fenv.h | \ + grep '^#endif //fix error$' 2>/dev/null + then + echo '#endif //fix error' \ + >>/${TLD}/include/c++/11.2.1/fenv.h + fi + + cd_or_fail ${G_SRC}/${pkg} + remove_dir build + check_dir build + cd_or_fail build + + run_configure ../libstdc++-v3 \ + --target=${G_TARGET} \ + --build=${G_HOST} \ + --host=${G_TARGET} \ + --prefix=/${TLD} \ + --disable-multilib \ + --disable-nls \ + --disable-libstdcxx-threads \ + --disable-libstdcxx-pch \ + --with-gxx-include-dir=/${TLD}/${G_TARGET}/include/c++/11.2.1 + + run_make + run_make install + ) || exit 1 +fi +end_substep + +begin_substep mksh if [ -x ${GR}/bin/mksh ]; then msg info "%s exists, skipping %s" ${GR}/bin/mksh ${pkg} else @@ -266,12 +673,39 @@ else install -c -s -m 555 lksh ${GR}/bin/lksh link_if_ne lksh ${GR}/bin/sh - unset CFLAGS LDSTATIC TARGET_OS + unset CFLAGS CPPFLAGS LDSTATIC TARGET_OS + ) || exit 1 +fi +end_substep + +end_step # tools + +msg info "Cleaning up environment" +export PATH=${OLDPATH} +unset OLDPATH CC CXX AR AS RANLIB LD STRIP +unset WD + +exit 1 + +#OLDPATH=${PATH} +#PATH=${CT}/bin:${OLDPATH} + +begin_substep sled +if [ -x ${GR}/bin/sled ]; then + msg info "%s exists, skipping %s" ${GR}/bin/sled ${pkg} +else + ( + git_clone ${pkg} https://git.sr.ht/~strahinja/sled + cd_or_fail ${G_SRC}/${pkg} + SLED_CC=${CC}' -O2 -Wall -static -fcommon' + PREFIX=${GR} + export SLED_CC PREFIX + run_do -c install ) || exit 1 fi -end_pkg +end_substep -begin_pkg sbase +begin_substep sbase if [ -x ${GR}/bin/ls ]; then msg info "%s exists, skipping %s" ${GR}/bin/ls ${pkg} else @@ -287,9 +721,9 @@ else #remove_dir ${G_SRC}/${pkg} ) || exit 1 fi -end_pkg +end_substep -begin_pkg ubase +begin_substep ubase if [ -x ${GR}/bin/id ]; then msg info "%s exists, skipping %s" ${GR}/bin/id ${pkg} else @@ -312,7 +746,7 @@ else #remove_dir ${G_SRC}/${pkg} ) || exit 1 fi -end_pkg +end_substep # msg info "${white}[%d/%d]: tinycc" ${step} ${totalsteps} # git_clone tinycc git://repo.or.cz/tinycc.git @@ -327,6 +761,11 @@ end_pkg # export CFLAGS LDFLAGS # run_configure . \ # --prefix=/ \ +# --bindir=/bin \ +# --libdir=/lib \ +# --tccdir=/lib/tcc \ +# --includedir=/include \ +# --sharedir=/share \ # --config-musl \ # --sysincludepaths=/include \ # --crtprefix=/lib \ @@ -345,7 +784,7 @@ export PATH=${OLDPATH} unset OLDPATH CC CXX AR AS RANLIB STRIP unset WD -msf info "Next: chroot %s /bin/mksh" ${GR} +msg info "Next run 02-prep-chroot.sh as root" # exit 0 # diff --git a/02-prep-chroot.sh b/02-prep-chroot.sh @@ -0,0 +1,50 @@ +#!/bin/sh + +. ./lib/env.sh +. ./lib/fun.sh + +trap exit_cleanup HUP PIPE INT QUIT TERM EXIT + +if [ "$(id -u)" -ne 0 ]; then + msg err "You must run this script as root" + exit 1 +fi + +check_dir ${GR}/dev +check_dir ${GR}/etc +check_dir ${GR}/proc +check_dir ${GR}/sys +check_dir ${GR}/run +check_dir ${GR}/tmp +chmod +t ${GR}/tmp +check_dir ${GR}/var/run + +check_mknod ${GR}/dev/console c 5 1 -m 600 +check_mknod ${GR}/dev/null c 1 3 -m 666 + +mount_or_fail -B /dev ${GR}/dev +mount_or_fail -t devpts devpts ${GR}/dev/pts -o gid=5,mode=620 +mount_or_fail -t proc proc ${GR}/proc +mount_or_fail -t sysfs sysfs ${GR}/sys +mount_or_fail -t tmpfs tmpfs ${GR}/run +#mount_or_fail -t tmpfs tmpfs ${GR}/tmp + +if [ -h ${GR}/dev/shm ]; then + check_dir ${GR}/$(readlink ${GR}/dev/shm) +fi + +cat <<! >${GR}/etc/passwd +root:x:0:0::/root:/bin/mksh +galeb:x:${GUID}:${GGID}::/src:/bin/mksh +! + +msg info "Next run 03-chroot.sh" + +PATH=/cross-tools/bin:/bin:/sbin:/sucks/bin \ +chroot ${GR} /bin/mksh -l +h + +#umount ${GR}/tmp +umount ${GR}/run +umount ${GR}/sys +umount ${GR}/proc +umount -R ${GR}/dev diff --git a/03-chroot.sh b/03-chroot.sh diff --git a/galeb.session b/galeb.session @@ -0,0 +1,533 @@ +let SessionLoad = 1 +if &cp | set nocp | endif +nmap  :bnext +nmap  :lclose|bp|bd # +nmap ; i :9 "6i +nmap - i -N +nnoremap <silent>  :copen:cn +nnoremap <silent>  :copen:cp +noremap <silent> [18;5~ :cclose +nnoremap \ :nohlsearch +let s:cpo_save=&cpo +set cpo&vim +xmap gx <Plug>NetrwBrowseXVis +nmap gx <Plug>NetrwBrowseX +xnoremap <silent> <Plug>NetrwBrowseXVis :call netrw#BrowseXVis() +nnoremap <silent> <Plug>NetrwBrowseX :call netrw#BrowseX(netrw#GX(),netrw#CheckIfRemote(netrw#GX())) +tnoremap <silent> <Plug>(fzf-normal)  +tnoremap <silent> <Plug>(fzf-insert) i +nnoremap <silent> <Plug>(fzf-normal) <Nop> +nnoremap <silent> <Plug>(fzf-insert) i +nmap <C-@> :buffers +nmap <Nul> :buffers +nmap <C-Q> :lclose|bp|bd # +nmap <S-Tab> :bprevious +noremap <silent> <F7> :copen +imap ;  :9 "6i +imap -  -N +cabbr h only | vertical botright help +let &cpo=s:cpo_save +unlet s:cpo_save +set background=dark +set backspace=indent,eol,start +set backupdir=~/.cache/vim/backup// +set cinoptions=:0,l1,g0,t0,U1,Ws,ks +set directory=~/.cache/vim/swap// +set fileencodings=ucs-bom,utf-8,default,latin1 +set helplang=sr +set hidden +set ruler +set shiftwidth=0 +set showcmd +set suffixes=.bak,~,.o,.info,.swp,.aux,.bbl,.blg,.brf,.cb,.dvi,.idx,.ilg,.ind,.inx,.jpg,.log,.out,.png,.toc +set switchbuf=usetab +set tags=./tags,./TAGS,tags,TAGS,~/.cache/ctags/ctags +set termencoding=utf-8 +set termguicolors +set textwidth=80 +set undodir=~/.cache/vim/undo// +let s:so_save = &g:so | let s:siso_save = &g:siso | setg so=0 siso=0 | setl so=-1 siso=-1 +let v:this_session=expand("<sfile>:p") +silent only +silent tabonly +cd ~/src/galeb +if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == '' + let s:wipebuf = bufnr('%') +endif +if &shortmess =~ 'A' + set shortmess=aoOA +else + set shortmess=aoO +endif +badd +45 01-cross.sh +badd +99 lib/fun.sh +badd +38 02-prep-chroot.sh +badd +27 lib/env.sh +badd +1 02-chroot.sh +argglobal +%argdel +$argadd 02-chroot.sh +edit 01-cross.sh +let s:save_splitbelow = &splitbelow +let s:save_splitright = &splitright +set splitbelow splitright +wincmd _ | wincmd | +vsplit +1wincmd h +wincmd w +wincmd _ | wincmd | +split +1wincmd k +wincmd w +let &splitbelow = s:save_splitbelow +let &splitright = s:save_splitright +wincmd t +let s:save_winminheight = &winminheight +let s:save_winminwidth = &winminwidth +set winminheight=0 +set winheight=1 +set winminwidth=0 +set winwidth=1 +exe 'vert 1resize ' . ((&columns * 95 + 95) / 191) +exe '2resize ' . ((&lines * 25 + 26) / 52) +exe 'vert 2resize ' . ((&columns * 95 + 95) / 191) +exe '3resize ' . ((&lines * 24 + 26) / 52) +exe 'vert 3resize ' . ((&columns * 95 + 95) / 191) +argglobal +balt 02-chroot.sh +setlocal keymap= +setlocal noarabic +setlocal noautoindent +setlocal backupcopy= +setlocal balloonexpr= +setlocal nobinary +setlocal nobreakindent +setlocal breakindentopt= +setlocal bufhidden= +setlocal buflisted +setlocal buftype= +setlocal nocindent +setlocal cinkeys=0{,0},0),0],:,0#,!^F,o,O,e +setlocal cinoptions=:0,l1,g0,t0,U1,Ws,ks +setlocal cinscopedecls=public,protected,private +setlocal cinwords=if,else,while,do,for,switch +set colorcolumn=80 +setlocal colorcolumn=80 +setlocal comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:- +setlocal commentstring=/*%s*/ +setlocal complete=.,w,b,u,t,i +setlocal concealcursor= +setlocal conceallevel=0 +setlocal completefunc= +setlocal nocopyindent +setlocal cryptmethod= +setlocal nocursorbind +setlocal nocursorcolumn +setlocal nocursorline +setlocal cursorlineopt=both +setlocal define= +setlocal dictionary= +setlocal nodiff +setlocal equalprg= +setlocal errorformat= +setlocal noexpandtab +if &filetype != 'sh' +setlocal filetype=sh +endif +setlocal fixendofline +setlocal foldcolumn=0 +setlocal foldenable +setlocal foldexpr=0 +setlocal foldignore=# +setlocal foldlevel=0 +setlocal foldmarker={{{,}}} +setlocal foldmethod=syntax +setlocal foldminlines=1 +setlocal foldnestmax=20 +setlocal foldtext=foldtext() +setlocal formatexpr= +setlocal formatoptions=tcq +setlocal formatlistpat=^\\s*\\d\\+[\\]:.)}\\t\ ]\\s* +setlocal formatprg= +setlocal grepprg= +setlocal iminsert=0 +setlocal imsearch=-1 +setlocal include= +setlocal includeexpr= +setlocal indentexpr= +setlocal indentkeys=0{,0},0),0],:,0#,!^F,o,O,e +setlocal noinfercase +setlocal iskeyword=@,48-57,_,192-255 +setlocal keywordprg= +setlocal nolinebreak +setlocal nolisp +setlocal lispwords= +setlocal nolist +setlocal listchars= +setlocal makeencoding= +setlocal makeprg= +setlocal matchpairs=(:),{:},[:] +setlocal modeline +setlocal modifiable +setlocal nrformats=bin,octal,hex +set number +setlocal number +setlocal numberwidth=4 +setlocal omnifunc= +setlocal path= +setlocal nopreserveindent +setlocal nopreviewwindow +setlocal quoteescape=\\ +setlocal noreadonly +set relativenumber +setlocal relativenumber +setlocal norightleft +setlocal rightleftcmd=search +setlocal noscrollbind +setlocal scrolloff=-1 +setlocal shiftwidth=0 +setlocal noshortname +setlocal showbreak= +setlocal sidescrolloff=-1 +setlocal signcolumn=auto +setlocal nosmartindent +setlocal softtabstop=0 +setlocal nospell +setlocal spellcapcheck=[.?!]\\_[\\])'\"\ \ ]\\+ +setlocal spellfile= +setlocal spelllang=en +setlocal spelloptions= +setlocal statusline= +setlocal suffixesadd= +setlocal swapfile +setlocal synmaxcol=3000 +if &syntax != 'sh' +setlocal syntax=sh +endif +setlocal tabstop=8 +setlocal tagcase= +setlocal tagfunc= +setlocal tags= +setlocal termwinkey= +setlocal termwinscroll=10000 +setlocal termwinsize= +setlocal textwidth=80 +setlocal thesaurus= +setlocal thesaurusfunc= +setlocal noundofile +setlocal undolevels=-123456 +setlocal varsofttabstop= +setlocal vartabstop= +setlocal virtualedit= +setlocal wincolor= +setlocal nowinfixheight +setlocal nowinfixwidth +setlocal wrap +setlocal wrapmargin=0 +let s:l = 179 - ((0 * winheight(0) + 25) / 50) +if s:l < 1 | let s:l = 1 | endif +keepjumps exe s:l +normal! zt +keepjumps 179 +normal! 0 +wincmd w +argglobal +if bufexists(fnamemodify("lib/env.sh", ":p")) | buffer lib/env.sh | else | edit lib/env.sh | endif +balt 02-prep-chroot.sh +setlocal keymap= +setlocal noarabic +setlocal noautoindent +setlocal backupcopy= +setlocal balloonexpr= +setlocal nobinary +setlocal nobreakindent +setlocal breakindentopt= +setlocal bufhidden= +setlocal buflisted +setlocal buftype= +setlocal nocindent +setlocal cinkeys=0{,0},0),0],:,0#,!^F,o,O,e +setlocal cinoptions=:0,l1,g0,t0,U1,Ws,ks +setlocal cinscopedecls=public,protected,private +setlocal cinwords=if,else,while,do,for,switch +set colorcolumn=80 +setlocal colorcolumn=80 +setlocal comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:- +setlocal commentstring=/*%s*/ +setlocal complete=.,w,b,u,t,i +setlocal concealcursor= +setlocal conceallevel=0 +setlocal completefunc= +setlocal nocopyindent +setlocal cryptmethod= +setlocal nocursorbind +setlocal nocursorcolumn +setlocal nocursorline +setlocal cursorlineopt=both +setlocal define= +setlocal dictionary= +setlocal nodiff +setlocal equalprg= +setlocal errorformat= +setlocal noexpandtab +if &filetype != 'sh' +setlocal filetype=sh +endif +setlocal fixendofline +setlocal foldcolumn=0 +setlocal foldenable +setlocal foldexpr=0 +setlocal foldignore=# +setlocal foldlevel=0 +setlocal foldmarker={{{,}}} +setlocal foldmethod=syntax +setlocal foldminlines=1 +setlocal foldnestmax=20 +setlocal foldtext=foldtext() +setlocal formatexpr= +setlocal formatoptions=tcq +setlocal formatlistpat=^\\s*\\d\\+[\\]:.)}\\t\ ]\\s* +setlocal formatprg= +setlocal grepprg= +setlocal iminsert=0 +setlocal imsearch=-1 +setlocal include= +setlocal includeexpr= +setlocal indentexpr= +setlocal indentkeys=0{,0},0),0],:,0#,!^F,o,O,e +setlocal noinfercase +setlocal iskeyword=@,48-57,_,192-255 +setlocal keywordprg= +setlocal nolinebreak +setlocal nolisp +setlocal lispwords= +setlocal nolist +setlocal listchars= +setlocal makeencoding= +setlocal makeprg= +setlocal matchpairs=(:),{:},[:] +setlocal modeline +setlocal modifiable +setlocal nrformats=bin,octal,hex +set number +setlocal number +setlocal numberwidth=4 +setlocal omnifunc= +setlocal path= +setlocal nopreserveindent +setlocal nopreviewwindow +setlocal quoteescape=\\ +setlocal noreadonly +set relativenumber +setlocal relativenumber +setlocal norightleft +setlocal rightleftcmd=search +setlocal noscrollbind +setlocal scrolloff=-1 +setlocal shiftwidth=0 +setlocal noshortname +setlocal showbreak= +setlocal sidescrolloff=-1 +setlocal signcolumn=auto +setlocal nosmartindent +setlocal softtabstop=0 +setlocal nospell +setlocal spellcapcheck=[.?!]\\_[\\])'\"\ \ ]\\+ +setlocal spellfile= +setlocal spelllang=en +setlocal spelloptions= +setlocal statusline= +setlocal suffixesadd= +setlocal swapfile +setlocal synmaxcol=3000 +if &syntax != 'sh' +setlocal syntax=sh +endif +setlocal tabstop=8 +setlocal tagcase= +setlocal tagfunc= +setlocal tags= +setlocal termwinkey= +setlocal termwinscroll=10000 +setlocal termwinsize= +setlocal textwidth=80 +setlocal thesaurus= +setlocal thesaurusfunc= +setlocal noundofile +setlocal undolevels=-123456 +setlocal varsofttabstop= +setlocal vartabstop= +setlocal virtualedit= +setlocal wincolor= +setlocal nowinfixheight +setlocal nowinfixwidth +setlocal wrap +setlocal wrapmargin=0 +let s:l = 11 - ((7 * winheight(0) + 12) / 25) +if s:l < 1 | let s:l = 1 | endif +keepjumps exe s:l +normal! zt +keepjumps 11 +normal! 020| +wincmd w +argglobal +if bufexists(fnamemodify("lib/fun.sh", ":p")) | buffer lib/fun.sh | else | edit lib/fun.sh | endif +balt 01-cross.sh +setlocal keymap= +setlocal noarabic +setlocal noautoindent +setlocal backupcopy= +setlocal balloonexpr= +setlocal nobinary +setlocal nobreakindent +setlocal breakindentopt= +setlocal bufhidden= +setlocal buflisted +setlocal buftype= +setlocal nocindent +setlocal cinkeys=0{,0},0),0],:,0#,!^F,o,O,e +setlocal cinoptions=:0,l1,g0,t0,U1,Ws,ks +setlocal cinscopedecls=public,protected,private +setlocal cinwords=if,else,while,do,for,switch +set colorcolumn=80 +setlocal colorcolumn=80 +setlocal comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:- +setlocal commentstring=/*%s*/ +setlocal complete=.,w,b,u,t,i +setlocal concealcursor= +setlocal conceallevel=0 +setlocal completefunc= +setlocal nocopyindent +setlocal cryptmethod= +setlocal nocursorbind +setlocal nocursorcolumn +setlocal nocursorline +setlocal cursorlineopt=both +setlocal define= +setlocal dictionary= +setlocal nodiff +setlocal equalprg= +setlocal errorformat= +setlocal noexpandtab +if &filetype != 'sh' +setlocal filetype=sh +endif +setlocal fixendofline +setlocal foldcolumn=0 +setlocal foldenable +setlocal foldexpr=0 +setlocal foldignore=# +setlocal foldlevel=0 +setlocal foldmarker={{{,}}} +setlocal foldmethod=syntax +setlocal foldminlines=1 +setlocal foldnestmax=20 +setlocal foldtext=foldtext() +setlocal formatexpr= +setlocal formatoptions=tcq +setlocal formatlistpat=^\\s*\\d\\+[\\]:.)}\\t\ ]\\s* +setlocal formatprg= +setlocal grepprg= +setlocal iminsert=0 +setlocal imsearch=-1 +setlocal include= +setlocal includeexpr= +setlocal indentexpr= +setlocal indentkeys=0{,0},0),0],:,0#,!^F,o,O,e +setlocal noinfercase +setlocal iskeyword=@,48-57,_,192-255 +setlocal keywordprg= +setlocal nolinebreak +setlocal nolisp +setlocal lispwords= +setlocal nolist +setlocal listchars= +setlocal makeencoding= +setlocal makeprg= +setlocal matchpairs=(:),{:},[:] +setlocal modeline +setlocal modifiable +setlocal nrformats=bin,octal,hex +set number +setlocal number +setlocal numberwidth=4 +setlocal omnifunc= +setlocal path= +setlocal nopreserveindent +setlocal nopreviewwindow +setlocal quoteescape=\\ +setlocal noreadonly +set relativenumber +setlocal relativenumber +setlocal norightleft +setlocal rightleftcmd=search +setlocal noscrollbind +setlocal scrolloff=-1 +setlocal shiftwidth=0 +setlocal noshortname +setlocal showbreak= +setlocal sidescrolloff=-1 +setlocal signcolumn=auto +setlocal nosmartindent +setlocal softtabstop=0 +setlocal nospell +setlocal spellcapcheck=[.?!]\\_[\\])'\"\ \ ]\\+ +setlocal spellfile= +setlocal spelllang=en +setlocal spelloptions= +setlocal statusline= +setlocal suffixesadd= +setlocal swapfile +setlocal synmaxcol=3000 +if &syntax != 'sh' +setlocal syntax=sh +endif +setlocal tabstop=8 +setlocal tagcase= +setlocal tagfunc= +setlocal tags= +setlocal termwinkey= +setlocal termwinscroll=10000 +setlocal termwinsize= +setlocal textwidth=80 +setlocal thesaurus= +setlocal thesaurusfunc= +setlocal noundofile +setlocal undolevels=-123456 +setlocal varsofttabstop= +setlocal vartabstop= +setlocal virtualedit= +setlocal wincolor= +setlocal nowinfixheight +setlocal nowinfixwidth +setlocal wrap +setlocal wrapmargin=0 +let s:l = 33 - ((21 * winheight(0) + 12) / 24) +if s:l < 1 | let s:l = 1 | endif +keepjumps exe s:l +normal! zt +keepjumps 33 +normal! 0 +wincmd w +exe 'vert 1resize ' . ((&columns * 95 + 95) / 191) +exe '2resize ' . ((&lines * 25 + 26) / 52) +exe 'vert 2resize ' . ((&columns * 95 + 95) / 191) +exe '3resize ' . ((&lines * 24 + 26) / 52) +exe 'vert 3resize ' . ((&columns * 95 + 95) / 191) +tabnext 1 +if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0 + silent exe 'bwipe ' . s:wipebuf +endif +unlet! s:wipebuf +set winheight=1 winwidth=20 +set shortmess=filnxtToOS +let &winminheight = s:save_winminheight +let &winminwidth = s:save_winminwidth +let s:sx = expand("<sfile>:p:r")."x.vim" +if filereadable(s:sx) + exe "source " . fnameescape(s:sx) +endif +let &g:so = s:so_save | let &g:siso = s:siso_save +doautoall SessionLoadPost +unlet SessionLoad +" vim: set ft=vim : diff --git a/lib/env.sh b/lib/env.sh @@ -1,22 +1,32 @@ #!/bin/sh -CT_TRI=x86_64-linux-musl -GSD=galeb-source -GRD=galeb-root -GS=${HOME}/${GSD} -GR=${HOME}/${GRD} -TL=${GR}/tools -CT=${GR}/cross-tools +# Edit this! Has to be hardcoded because of the +# necessity to run some scripts as root +GUSER=strajder + +GHOME=/home/${GUSER} +GUID=$(getent passwd ${GUSER} | cut -d : -f 3) +GGID=$(getent group ${GUSER} | cut -d : -f 3) + +CT_TRI=x86_64-cross-linux-musl +GR=${GHOME}/galeb-root +CTD=cross-tools +TLD=tools +CT=${GR}/${CTD} +TL=${GR}/${TLD} G_ARCH=x86 +G_ARCH_EXT=x86-64 +G_ARCH_EXT_ALT=x86_64 #G_HOST=$(gcc -dumpmachine) -G_FIFO=${GS}/fifo -G_LOG=${GS}/log -G_PAT=${GS}/pat -G_PKG=${GS}/pkg -G_SRC=${GS}/src +G_FIFO=${GR}/fifo +G_HOST=$(gcc -dumpmachine | sed 's/\([^-]\+-\)[^-]\+\(-.*\)/\1cross\2/g') +G_LOG=${GR}/log +G_PAT=${GR}/pat +G_PKG=${GR}/pkg +G_SRC=${GR}/src G_TARGET=x86_64-galeb-linux-musl G_VER=2.0 JN=-j$(($(nproc) * 3)) -export CT_TRI GSD GRD GS GR TL CT -export G_ARCH G_FIFO G_LOG G_PAT G_PKG G_SRC G_TARGET G_VER JN +export CT_TRI GHOME GUID GGID GR CTD TLD CT TL G_ARCH G_ARCH_EXT G_ARCH_EXT_ALT +export G_FIFO G_LOG G_PAT G_PKG G_SRC G_TARGET G_VER JN diff --git a/lib/fun.sh b/lib/fun.sh @@ -1,29 +1,35 @@ #!/bin/sh -norm=$(printf '\033[0m') -bold=$(printf '\033[1m') -faint=$(printf '\033[2m') -green=$(printf '\033[32m') -bgred=$(printf '\033[41m') -lred=$(printf '\033[91m') -yellow=$(printf '\033[93m') -lblue=$(printf '\033[94m') -white=$(printf '\033[97m') +norm=$(printf '\033[0m') +bold=$(printf '\033[1m') +faint=$(printf '\033[2m') +black=$(printf '\033[30m') +green=$(printf '\033[32m') +gray=$(printf '\033[37m') +bgred=$(printf '\033[41m') +lred=$(printf '\033[91m') +yellow=$(printf '\033[93m') +lblue=$(printf '\033[94m') +white=$(printf '\033[97m') +bgwhite=$(printf '\033[107m') apply_patch() { - local pat + local substepid pat + substepid=$1 + shift eval pat=\$$# - if [ -f "${G_PAT}/${pat##*/}.applied" ]; then + + if [ -f "${G_PAT}/${pat##*/}.${substepid}.applied" ]; then msg info "Patch %s applied" ${pat} return fi msg info "Patch %s" "$*" setup_fifo - if patch $* 2>&1 >${G_FIFO}; then - : > ${G_PAT}/${pat##*/}.applied + if patch $* >${G_FIFO} 2>&1; then + : > ${G_PAT}/${pat##*/}.${substepid}.applied else msg err "Patch %s failed" "$*" exit 1 @@ -31,10 +37,26 @@ apply_patch() rm ${G_FIFO} } -begin_pkg() +begin_step() +{ + stepname=$1 + msg info "${bgwhite}${black}[%d/%d]: %s" ${step} ${totalsteps} ${stepname} +} + +begin_substep() { pkg=$1 - msg info "${white}[%d/%d]: %s" ${step} ${totalsteps} ${pkg} + shift + substepname="$*" + if [ -n "${substepname}" ]; then + msg info "${white}[%d/%d]-[%d/%d]: %s" \ + ${step} ${totalsteps} \ + ${substep} ${totalsubsteps} "${substepname}" + else + msg info "${white}[%d/%d]-[%d/%d]: %s" \ + ${step} ${totalsteps} \ + ${substep} ${totalsubsteps} ${pkg} + fi } cd_or_fail() @@ -58,26 +80,61 @@ check_dir() mkdir -p "$1" } +check_mknod() +{ + local name type major minor + + name=$1 + shift + type=$1 + shift + major=$1 + shift + minor=$1 + shift + if [ -e "${name}" ]; then + msg info "Node %s exists" "${name}" + return + fi + msg info "Creating %s" "${name}" + mknod $* ${name} ${type} ${major} ${minor} +} + cp_or_fail() { - msg info "cp %s" "$@" + msg info "cp %s" "$*" if ! cp $*; then msg err "Cannot cp %s" "$*" exit 1 fi } -end_pkg() +end_step() { - msg info "${white}[%d/%d]: Done %s" ${step} ${totalsteps} ${pkg} + msg info "${bgwhite}${black}[%d/%d]: Done %s" ${step} ${totalsteps} ${stepname} step=$((step+1)) } +end_substep() +{ + if [ -n "${substepname}" ]; then + msg info "${white}[%d/%d]-[%d/%d]: Done %s" \ + ${step} ${totalsteps} \ + ${substep} ${totalsubsteps} "${substepname}" + unset substepname + else + msg info "${white}[%d/%d]-[%d/%d]: Done %s" \ + ${step} ${totalsteps} \ + ${substep} ${totalsubsteps} ${pkg} + fi + substep=$((substep+1)) +} + exit_cleanup() { [ -p ${G_FIFO} ] && rm ${G_FIFO} - unset CT_TRI GSD GRD GS GR TL CT - unset G_ARCH G_FIFO G_LOG G_PAT G_PKG G_SRC G_TARGET G_VER JN + unset CT_TRI GHOME GUID GGID GR CTD TLD CT TL G_ARCH G_ARCH_EXT + unset G_ARCH_EXT_ALT G_FIFO G_LOG G_PAT G_PKG G_SRC G_TARGET G_VER JN } extract_pkg() @@ -135,7 +192,7 @@ git_clone() fi msg info "git clone %s" "$*" setup_fifo - if ! git clone $* 2>&1 > ${G_FIFO}; then + if ! git clone $* >${G_FIFO} 2>&1; then msg err "git clone %s failed" "$*" exit 1 fi @@ -156,6 +213,15 @@ link_if_ne() fi } +mount_or_fail() +{ + msg info "mount %s" "$*" + if ! mount $*; then + msg err "mount %s failed" "$*" + exit 1 + fi +} + msg() { local fmt icon icon_plain kind tstamp @@ -201,24 +267,43 @@ remove_dir() fi } +remove_file() +{ + msg info "Removing %s" "$1" + if [ -e "$1" ]; then + rm -f "$1" + fi +} + run_configure() { local location=$1 shift msg info "configure %s" "$*" setup_fifo - if ! ${location}/configure $* 2>&1 > ${G_FIFO}; then + if ! ${location}/configure $* >${G_FIFO} 2>&1; then msg err "configure %s failed" "$*" exit 1 fi rm ${G_FIFO} } +run_do() +{ + msg info "do %s" "$*" + setup_fifo + if ! ./do $* >${G_FIFO} 2>&1; then + msg err "do %s failed" "$*" + exit 1 + fi + rm ${G_FIFO} +} + run_make() { msg info "make %s" "$*" setup_fifo - if ! make $* 2>&1 > ${G_FIFO}; then + if ! make $* >${G_FIFO} 2>&1; then msg err "make %s failed" "$*" exit 1 fi @@ -228,7 +313,6 @@ run_make() setup_fifo() { mkfifo ${G_FIFO} - trap exit_cleanup HUP PIPE INT QUIT TERM EXIT tee -a ${G_LOG} < ${G_FIFO} & } diff --git a/pat b/pat @@ -1 +1 @@ -pat-12.1.0 -\ No newline at end of file +pat-11.2.1 +\ No newline at end of file diff --git a/pat-11.2.1/gcc-alpine/0003-Turn-on-Wl-z-relro-z-now-by-default.patch b/pat-11.2.1/gcc-alpine/0003-Turn-on-Wl-z-relro-z-now-by-default.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Turn on -Wl,-z,relro,-z,now by default. --- gcc/doc/invoke.texi | 3 +++ - gcc/gcc.cc | 1 + + gcc/gcc.c | 1 + 2 files changed, 4 insertions(+) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi @@ -22,10 +22,10 @@ index cd31b522e42..17d371ef432 100644 @item -u @var{symbol} @opindex u Pretend the symbol @var{symbol} is undefined, to force linking of -diff --git a/gcc/gcc.cc b/gcc/gcc.cc +diff --git a/gcc/gcc.c b/gcc/gcc.c index b2200c5185a..625c9ab7902 100644 ---- a/gcc/gcc.cc -+++ b/gcc/gcc.cc +--- a/gcc/gcc.c ++++ b/gcc/gcc.c @@ -1039,6 +1039,7 @@ proper position among the other output files. */ "%{flto|flto=*:%<fcompare-debug*} \ %{flto} %{fno-lto} %{flto=*} %l " LINK_PIE_SPEC \ diff --git a/pat-11.2.1/gcc-alpine/0004-Turn-on-D_FORTIFY_SOURCE-2-by-default-for-C-C-ObjC-O.patch b/pat-11.2.1/gcc-alpine/0004-Turn-on-D_FORTIFY_SOURCE-2-by-default-for-C-C-ObjC-O.patch @@ -5,14 +5,14 @@ Subject: [PATCH] Turn on -D_FORTIFY_SOURCE=2 by default for C, C++, ObjC, ObjC++, if the optimization level is > 0 --- - gcc/c-family/c-cppbuiltin.cc | 4 ++++ + gcc/c-family/c-cppbuiltin.c | 4 ++++ gcc/doc/invoke.texi | 6 ++++++ 2 files changed, 10 insertions(+) -diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc +diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index db91a36794a..ed976c71404 100644 ---- a/gcc/c-family/c-cppbuiltin.cc -+++ b/gcc/c-family/c-cppbuiltin.cc +--- a/gcc/c-family/c-cppbuiltin.c ++++ b/gcc/c-family/c-cppbuiltin.c @@ -1385,6 +1385,10 @@ c_cpp_builtins (cpp_reader *pfile) builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0); builtin_define_with_value ("__USER_LABEL_PREFIX__", user_label_prefix, 0); diff --git a/pat-11.2.1/gcc-alpine/0013-libgcc_s.patch b/pat-11.2.1/gcc-alpine/0013-libgcc_s.patch @@ -4,15 +4,15 @@ Date: Sat, 24 Oct 2015 20:09:53 +0000 Subject: [PATCH] libgcc_s --- - gcc/config/i386/i386-expand.cc | 4 ++-- + gcc/config/i386/i386-expand.c | 4 ++-- libgcc/config/i386/cpuinfo.c | 6 +++--- libgcc/config/i386/t-linux | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) -diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc +diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c index 47d52550e5e..9cb8cc7950e 100644 ---- a/gcc/config/i386/i386-expand.cc -+++ b/gcc/config/i386/i386-expand.cc +--- a/gcc/config/i386/i386-expand.c ++++ b/gcc/config/i386/i386-expand.c @@ -12338,10 +12338,10 @@ { case IX86_BUILTIN_CPU_INIT: diff --git a/pat-11.2.1/gcc-alpine/0022-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch b/pat-11.2.1/gcc-alpine/0022-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch @@ -5,13 +5,13 @@ Subject: [PATCH] DP: Use --push-state/--pop-state for gold as well when linking libtsan. --- - gcc/gcc.cc | 16 ++++++++-------- + gcc/gcc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) -diff --git a/gcc/gcc.cc b/gcc/gcc.cc +diff --git a/gcc/gcc.c b/gcc/gcc.c index 6920bec0fa0..40e07354b3d 100644 ---- a/gcc/gcc.cc -+++ b/gcc/gcc.cc +--- a/gcc/gcc.c ++++ b/gcc/gcc.c @@ -696,10 +696,10 @@ proper position among the other output files. */ #define LIBASAN_SPEC STATIC_LIBASAN_LIBS #elif defined(HAVE_LD_STATIC_DYNAMIC) diff --git a/pat-11.2.1/gcc-alpine/0042-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch b/pat-11.2.1/gcc-alpine/0042-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch @@ -2,10 +2,10 @@ From: Alpine Linux community From: Olsken (updated patches) Date: Sat, 21 Aug 2021 08:51:52 +0000 -diff --git a/gcc/gcc.cc b/gcc/gcc.cc +diff --git a/gcc/gcc.c b/gcc/gcc.c index bc1bd1686..b5c83977f 100644 ---- a/gcc/gcc.cc -+++ b/gcc/gcc.cc +--- a/gcc/gcc.c ++++ b/gcc/gcc.c @@ -1005,6 +1005,12 @@ proper position among the other output files. */ #define NO_SSP_SPEC "" #endif