galeb

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

чување 72a94bf58a111a8d7dc4c50ebda2954380e1695b
родитељ 2dd2433b66b8a6ee6ee4a3ad2ea4ba14b2673827
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Wed,  6 Jul 2022 22:22:49 +0200

Chroot up to binutils; further improvements

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

Diffstat:
M01-cross.sh | 49+++++++++++++++++++++++++++++++++++++++----------
M02-prep-chroot.sh | 3++-
M03-chroot.sh | 150++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Mlib/fun.sh | 20+++++++++++++-------
Apat-11.2.1/binutils-alpine/0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apat-11.2.1/binutils-alpine/binutils-ld-fix-static-linking.patch | 46++++++++++++++++++++++++++++++++++++++++++++++
измењених датотека: 6, додавања: 300(+), брисања: 23(-)

diff --git a/01-cross.sh b/01-cross.sh @@ -859,6 +859,36 @@ else remove_dir ${pkg} fi end_substep + +# begin_substep ncurses-6.2 +# if [ -e ${TL}/lib/libncurses.so ]; then +# msg info "%s exists, skipping %s" ${TL}/lib/libncurses.so ${pkg} +# else +# fetch_pkg https://ftp.gnu.org/gnu/ncurses/${pkg}.tar.gz +# extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.gz +# ( +# cd_or_fail ${G_SRC}/${pkg} +# +# sed -i s/mawk// configure +# +# TIC_PATH=/${TLD}/bin +# +# run_configure . \ +# --prefix=/${TLD} \ +# --build=${G_HOST} \ +# --host=${G_TARGET} \ +# --with-shared \ +# --without-debug \ +# --without-ada \ +# --enable-widec \ +# --enable-overwrite +# +# run_make ${JN} +# run_make install +# ) || exit 1 +# remove_dir ${G_SRC}/${pkg} +# fi +# end_substep begin_substep bash-5.1 if [ -x ${TL}/bin/bash ]; then @@ -1038,8 +1068,8 @@ end_substep # cd_or_fail ${G_SRC}/${pkg} # /bin/sed -i -e 's,/usr/local,/'${TLD}',g;s, \<cc\>, '${CC}',g' \ # -e 's, \<ar\>, '${AR}',g' \ -# -e 's,CFLAGS\s\+= ,&-static -fcommon ,g' \ -# -e 's,LDFLAGS\s\+= ,&-static -fcommon ,g' config.mk +# -e 's,^CFLAGS\s\+= ,&-static -fcommon ,g' \ +# -e 's,^LDFLAGS\s\+= ,&-static -fcommon ,g' config.mk # run_make ${JN} CC=${CC} # run_make install # #remove_dir ${G_SRC}/${pkg} @@ -1063,9 +1093,9 @@ end_substep # /bin/sed -i -e 's,/usr/local,/'${TLD}',g' \ # -e 's, \<cc\>, '${CC}',g' \ # -e 's, \<ar\>, '${AR}',g' \ -# -e 's,CFLAGS\s\+= ,&-static -fcommon ,g' \ -# -e 's,LDFLAGS\s\+= ,&-static -fcommon ,g' \ -# -e 's,LDLIBS\s\+= ,&-lc ,g' \ +# -e 's,^CFLAGS\s\+= ,&-static -fcommon ,g' \ +# -e 's,^LDFLAGS\s\+= ,&-static -fcommon ,g' \ +# -e 's,^LDLIBS\s\+= ,&-lc ,g' \ # config.mk # run_make ${JN} CC=${CC} # run_make install @@ -1083,15 +1113,12 @@ else extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz ( cd_or_fail ${G_SRC}/${pkg} - FORCE_UNSAFE_CONFIGURE=1 - gl_cv_struct_dirent_d_ino=yes - export FORCE_UNSAFE_CONFIGURE gl_cv_struct_dirent_d_ino run_configure . \ --prefix=/${TLD} \ - --bindir=/${TLD}/bin + --build=${G_HOST} \ + --host=${G_TARGET} run_make ${JN} run_make install - unset FORCE_UNSAFE_CONFIGURE gl_cv_struct_dirent_d_ino ) || exit 1 remove_dir ${G_SRC}/${pkg} fi @@ -1232,7 +1259,9 @@ fetch_pkg https://www.iana.org/time-zones/repository/releases/tzcode2022a.tar.gz fetch_pkg https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.0.6.tar.gz \ zlib-ng-2.0.6.tar.gz fetch_pkg https://ftp.gnu.org/gnu/readline/readline-8.1.tar.gz +git_clone 9base-20220706 git://git.suckless.org/9base +fetch_pkg https://ftp.gnu.org/gnu/texinfo/texinfo-6.8.tar.xz fetch_pkg https://distfiles.dereferenced.org/pkgconf/pkgconf-1.8.0.tar.xz fetch_pkg https://github.com/ericonr/argp-standalone/archive/refs/tags/\ 1.4.1.tar.gz argp-standalone-1.4.1.tar.gz diff --git a/02-prep-chroot.sh b/02-prep-chroot.sh @@ -92,7 +92,7 @@ if [ -e ${GR}/etc/profile ]; then else msg info "Generating %s" "${GR}/etc/profile" cat <<! >${GR}/etc/profile -PATH=/${TLD}/bin:/bin:/sbin:/sucks/bin:/sucks/sbin +PATH=/${TLD}/bin:/bin:/sbin:/sucks/bin:/sucks/sbin:/plan9/bin export PATH # A more familiar ls @@ -130,6 +130,7 @@ set -U fi link_if_ne /${TLD}/bin/lksh ${GR}/bin/sh +link_if_ne /${TLD}/bin/bash ${GR}/bin/bash cp_or_fail ${WD}/03-chroot.sh ${GR}/bin/ check_dir ${GR}/galeb cp_or_fail ${WD}/lib/env.sh ${GR}/galeb/env.sh diff --git a/03-chroot.sh b/03-chroot.sh @@ -84,6 +84,29 @@ else fi end_substep +begin_substep texinfo-6.8 +if [ -x ${TL}/bin/texi2dvi ]; then + msg info "%s exists, skipping %s" ${TL}/bin/texi2dvi ${pkg} +else + fetch_pkg https://ftp.gnu.org/gnu/texinfo/${pkg}.tar.xz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz + ( + cd_or_fail ${G_SRC}/${pkg} +CC="${G_TARGET}-gcc" +CXX="${G_TARGET}-g++" +AR="${G_TARGET}-ar" +AS="${G_TARGET}-as" +RANLIB="${G_TARGET}-ranlib" +LD="${G_TARGET}-ld" +STRIP="${G_TARGET}-strip" + run_configure . --prefix=/${TLD} + run_make + run_make install + ) || exit 1 + remove_dir ${G_SRC}/${pkg} +fi +end_substep + begin_substep man-pages-5.13 if [ -e /share/man/man2/fork.2 ]; then msg info "%s exists, skipping %s" /share/man/man2/fork.2 ${pkg} @@ -196,7 +219,7 @@ fi end_substep msg info "Cleaning up environment" -PATH=/bin:/sbin:/tools/bin +PATH=/bin:/sbin:/tools/bin:/plan9/bin export PATH unset CC CXX AR AS RANLIB LD STRIP @@ -238,14 +261,16 @@ mkpk_name() mkpk_install() { + CFLAGS='-O3 -march=native' + export CFLAGS ./configure --prefix=/ \\ --libdir=/lib \\ --zlib-compat \\ --sharedlibdir=/lib - make ${JN} + make ${JN} || exit 1 make DESTDIR=/build install - ln -s libz.so.1.2.11.zlib-ng /build/lib/libz.so.1.2.11 + ln -s libz.so.1.2.11.zlib-ng ../build/lib/libz.so.1.2.11 } ! mkpk ${pkg} @@ -469,6 +494,120 @@ mkpk_install() fi end_substep +begin_substep 9base-20220706 +if [ -x /9base/bin/bc ]; then + msg info "%s exists, skipping %s" /9base/bin/bc ${pkg} +elif [ -e ${G_SPKG}/${pkg}.tar.xz ]; then + unpack_pkg ${pkg} / +else + git_clone ${pkg} git://git.suckless.org/9base + ( + cd_or_fail ${G_SRC}/${pkg} + + if [ ! -e config.mk.orig ]; then + cp config.mk config.mk.orig + /tools/bin/sed -i -e 's,/usr/local\(/plan9\),\1,g' \ + -e 's,^CFLAGS\s\++= ,&-static --static -fcommon ,g' \ + -e 's,^LDFLAGS\s\++= ,&-static --static -fcommon ,g' \ + -e 's,^OBJTYPE\s\+= 386,#&,g' \ + -e 's,^#\(OBJTYPE\s\+= '${G_ARCH_EXT_ALT}'\),\1,' \ + config.mk + fi + if [ ! -e std.mk.orig ]; then + cp std.mk std.mk.orig + /tools/bin/sed -i -e 's,^#\(\s\+@strip.*\),\1,' std.mk + fi + cat <<! >MKPK +mkpk_name() +{ + printf "%s" "${pkg}" +} + +mkpk_install() +{ + make DESTDIR=/build ${JN} install +} +! + mkpk ${pkg} + unpack_pkg ${pkg} / + ) || exit 1 +fi +end_substep + +begin_substep binutils-2.38 +if [ -x /bin/ar ]; then + msg info "%s exists, skipping %s" /bin/ar ${pkg} +elif [ -e ${G_SPKG}/${pkg}.tar.xz ]; then + unpack_pkg ${pkg} / +else + fetch_pkg https://ftp.gnu.org/gnu/binutils/binutils-2.38.tar.xz + extract_pkg ${G_SRC} ${pkg} ${pkg}.tar.xz + ( + cd_or_fail ${G_SRC}/${pkg} + for patch in 0001-Revert-PR25882-.gnu.attributes-are-not-\ +checked-for-s.patch \ + binutils-ld-fix-static-linking.patch + do + apply_patch final-system -Np1 -i \ + ${G_PAT}/binutils-alpine/${patch} + done + + msg info "Cleaning empty man pages" + /tools/bin/find . -name '[a-z]*\.[0-9]*' -empty -exec rm -f {} \; + + cat <<! >MKPK +mkpk_name() +{ + printf "%s" "${pkg}" +} + +mkpk_install() +{ + CFLAGS='-O3 -march=native' + DESTDIR=/build + EXTRA_CONFIG=' --enable-targets=x86_64-pep ' + export CFLAGS DESTDIR EXTRA_CONFIG + + ./configure \\ + --prefix=/sucks \\ + --enable-gold \\ + --enable-ld=default \\ + --enable-plugins \\ + --enable-shared \\ + --disable-werror \\ + --with-system-zlib \\ + --enable-relro \\ + --enable-lto \\ + --disable-nls \\ + --enable-deterministic-archives \\ + --enable-default-hash-style=gnu \\ + --enable-threads \\ + --disable-multilib \\ + --with-mmap \\ + --enable-64-bit-bfd \\ + --with-pic $EXTRA_CONFIG + + make ${JN} tooldir=/sucks + make tooldir=/sucks install-strip + + ln -sf ld.bfd ../build/sucks/bin/ld + mkdir -p ../build/include + install -m 644 include/libiberty.h ../build/include/ + install -m 644 include/demangle.h ../build/include/ + + for m in dlltool nlmconv windres windmc + do + rm -f ../build/share/man/man1/$m.1 + done +} +! + mkpk ${pkg} + unpack_pkg ${pkg} / + ) || exit 1 + #remove_dir ${G_SRC}/${pkg} +fi +end_substep + # Move after autotools if false; then begin_substep argp-standalone-1.4.1 @@ -487,7 +626,6 @@ tags/1.4.1.tar.gz argp-standalone-1.4.1.tar.gz apply_patch final-system -Np1 -i \ ${G_PAT}/argp-standalone-mlfs/\ generate_configure_script.patch - chmod +x configure cat <<! >MKPK mkpk_name() { @@ -496,7 +634,9 @@ mkpk_name() mkpk_install() { - CFLAGS='-O3 -march=native -fPIC' \ + chmod +x configure + + CFLAGS='-O3 -march=native -fPIC' \\ ./configure --prefix=/ \\ --sysconfdir=/etc \\ --localstatedir=/var diff --git a/lib/fun.sh b/lib/fun.sh @@ -33,6 +33,7 @@ apply_patch() : > ${G_PAT}/${pat##*/}.${substepid}.applied else msg err "Patch %s failed" "$*" + sh exit 1 fi rm ${G_FIFO} @@ -211,9 +212,11 @@ fetch_pkg() git_clone() { - local dir=$1 + local dir=$1 repo shift + repo=${1##*/} + cd_or_fail ${G_SRC} if [ -d "${dir}" ]; then msg info "Directory %s exists" "${dir}" return @@ -224,6 +227,7 @@ git_clone() msg err "git clone %s failed" "$*" exit 1 fi + mv_or_fail "${repo}" "${dir}" rm ${G_FIFO} } @@ -300,11 +304,12 @@ mkpk() if [ ${fail} -ne 1 ]; then msg info "mkpk packing..." cd ../build - find . -newer ../timestamp | \ - sort | uniq | \ - xargs tar -cf ${G_SPKG}/$(mkpk_name).tar && \ - xz -9f ${G_SPKG}/$(mkpk_name).tar && \ - md5sum ${G_SPKG}/$(mkpk_name).tar.xz >${G_SPKG}/$(mkpk_name).md5 + tar -c $(find . \( -type b -o -type c -o -type f -o -type l \) \ + -newer ../timestamp | sort | uniq) | \ + xz -9 > ${G_SPKG}/$(mkpk_name).tar.xz && \ + cd ${G_SPKG} && \ + md5sum $(mkpk_name).tar.xz >$(mkpk_name).md5 && \ + { cd - >/dev/null 2>&1; } rm ../timestamp fi @@ -441,7 +446,8 @@ unpack_pkg() { local pkg=$1 shift - if ! md5sum -c ${G_SPKG}/${pkg}.md5 >/dev/null 2>&1; then + cd_or_fail ${G_SPKG} + if ! md5sum -c ${pkg}.md5 >/dev/null 2>&1; then msg err "md5sum -c %s failed" ${G_SPKG}/${pkg}.tar.xz exit 1 fi diff --git a/pat-11.2.1/binutils-alpine/0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch b/pat-11.2.1/binutils-alpine/0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch @@ -0,0 +1,55 @@ +From bbf05b742fde518fb97c789b043fe0d3aaf549f0 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill <ariadne@dereferenced.org> +Date: Tue, 21 Sep 2021 14:53:13 +0000 +Subject: [PATCH] Revert "PR25882, .gnu.attributes are not checked for shared + libraries" + +This revert is needed to avoid wrongly tagging objects with the incompatible +IBM long double ABI, which is not supported by musl and will result in +linking errors if used. + +This reverts commit a8acd6eeb6dc2cc5460ece90f90ebe36b56b20ba. +--- + bfd/elf32-tic6x.c | 3 --- + ld/ldlang.c | 10 ++++------ + 2 files changed, 4 insertions(+), 9 deletions(-) + +diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c +index 5754f3cb860..3ad1d612749 100644 +--- a/bfd/elf32-tic6x.c ++++ b/bfd/elf32-tic6x.c +@@ -3735,9 +3735,6 @@ elf32_tic6x_merge_attributes (bfd *ibfd, struct bfd_link_info *info) + + case Tag_ABI_PIC: + case Tag_ABI_PID: +- /* Don't transfer these tags from dynamic objects. */ +- if ((ibfd->flags & DYNAMIC) != 0) +- continue; + if (out_attr[i].i > in_attr[i].i) + out_attr[i].i = in_attr[i].i; + break; +diff --git a/ld/ldlang.c b/ld/ldlang.c +index 37b64c89ee1..f13beaef9d9 100644 +--- a/ld/ldlang.c ++++ b/ld/ldlang.c +@@ -7071,13 +7071,11 @@ lang_check (void) + bfd_printable_name (input_bfd), input_bfd, + bfd_printable_name (link_info.output_bfd)); + } +- +- /* If the input bfd has no contents, it shouldn't set the +- private data of the output bfd. */ +- else if (!file->flags.just_syms +- && ((input_bfd->flags & DYNAMIC) != 0 +- || bfd_count_sections (input_bfd) != 0)) ++ else if (bfd_count_sections (input_bfd)) + { ++ /* If the input bfd has no contents, it shouldn't set the ++ private data of the output bfd. */ ++ + bfd_error_handler_type pfn = NULL; + + /* If we aren't supposed to warn about mismatched input +-- +2.33.0 + diff --git a/pat-11.2.1/binutils-alpine/binutils-ld-fix-static-linking.patch b/pat-11.2.1/binutils-alpine/binutils-ld-fix-static-linking.patch @@ -0,0 +1,46 @@ +This fixes static linking for our hardened toolchain +diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc +index e8126cb..9532bfb 100644 +--- a/ld/scripttempl/elf.sc ++++ b/ld/scripttempl/elf.sc +@@ -235,8 +235,8 @@ test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS=" + if test "${ENABLE_INITFINI_ARRAY}" = "yes"; then + SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))" + SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))" +- CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors" +- DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors" ++ CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin*.o *crtend*.o $OTHER_EXCLUDE_FILES) .ctors" ++ DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin*.o *crtend*.o $OTHER_EXCLUDE_FILES) .dtors" + else + SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))" + SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))" +@@ -270,15 +270,14 @@ CTOR=".ctors ${CONSTRUCTING-0} : + doesn't matter which directory crtbegin.o + is in. */ + +- KEEP (*crtbegin.o(.ctors)) +- KEEP (*crtbegin?.o(.ctors)) ++ KEEP (*crtbegin*.o(.ctors)) + + /* We don't want to include the .ctor section from + the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + +- KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors)) ++ KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + ${CONSTRUCTING+${CTOR_END}} +@@ -286,9 +285,8 @@ CTOR=".ctors ${CONSTRUCTING-0} : + DTOR=".dtors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+${DTOR_START}} +- KEEP (*crtbegin.o(.dtors)) +- KEEP (*crtbegin?.o(.dtors)) +- KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors)) ++ KEEP (*crtbegin*.o(.dtors)) ++ KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ${CONSTRUCTING+${DTOR_END}}