diff --git a/cross-images/03_alpine_populate.sh b/cross-images/03_alpine_populate.sh index a0371bf..395bf22 100644 --- a/cross-images/03_alpine_populate.sh +++ b/cross-images/03_alpine_populate.sh @@ -15,6 +15,9 @@ else for fp in 4d07755e 524d27bb 58199dcc 58cbb476 58e4f17d ; do wget https://alpinelinux.org/keys/alpine-devel@lists.alpinelinux.org-$fp.rsa.pub done + for fp in 616a9724 ; do + wget https://git.alpinelinux.org/aports/plain/main/alpine-keys/alpine-devel@lists.alpinelinux.org-$fp.rsa.pub + done # Propagate the new keys into the sysroot and also tell it to start pulling in # packages from the internet. @@ -24,9 +27,13 @@ fi # g++ is needed to get libstdc++.a, annoyingly apk --root $root add --no-scripts \ + brotli-static \ bzip2-dev \ + bzip2-static \ expat-dev \ + expat-static \ fontconfig-dev \ + fontconfig-static \ freetype-dev \ freetype-static \ g++ \ @@ -40,7 +47,9 @@ apk --root $root add --no-scripts \ libpng-dev \ libpng-static \ openssl-dev \ - zlib-dev + openssl-libs-static \ + zlib-dev \ + zlib-static if [ $TARGET_ARCH != native ] ; then # Let's also install those cross-compilers! diff --git a/cross-images/06_setup_env.sh b/cross-images/06_setup_env.sh index 118ffeb..eb5579b 100644 --- a/cross-images/06_setup_env.sh +++ b/cross-images/06_setup_env.sh @@ -19,10 +19,13 @@ else sysroot=/alpine/home/rust/sysroot-$os_arch fi -RUSTFLAGS="-C target-feature=+crt-static -L ${sysroot}/usr/lib" +RUSTFLAGS="-C target-feature=+crt-static -C link-arg=-L${sysroot}/usr/lib" -for tectonic_implicit_dep in bz2 expat uuid stdc++ ; do - RUSTFLAGS="$RUSTFLAGS -l static=${tectonic_implicit_dep}" +for tectonic_implicit_dep in bz2 brotlidec brotlicommon expat uuid stdc++ ; do + # Thanks to a behavior change introduced in Rust 1.61, + # https://github.com/rust-lang/rust/pull/93901/ , we have to add these + # libraries using this approach rather than `-l static=...`. + RUSTFLAGS="$RUSTFLAGS -C link-arg=-l${tectonic_implicit_dep}" done if [ "$rust_platform" = aarch64-unknown-linux-musl ] ; then diff --git a/cross-images/Dockerfile.alpine-chroot b/cross-images/Dockerfile.alpine-chroot index 5739bb8..68060a7 100644 --- a/cross-images/Dockerfile.alpine-chroot +++ b/cross-images/Dockerfile.alpine-chroot @@ -1,4 +1,4 @@ -# Copyright 2019 The Tectonic Project +# Copyright 2019-2022 The Tectonic Project # Licensed under the MIT License. # We do some fancy Docker gymnastics to set up an Alpine instance that then @@ -6,16 +6,16 @@ # `Dockerfile.alpine-chroot-cross`, though, we don't need to install our own # cross-compiler or anything. -FROM alpine:3.10 AS chroot +FROM alpine:3.16 AS chroot ARG UID=1000 ARG rust_platform ARG alpine_platform # Privileged Alpine setup: make an unprivileged user to work inside the -# chroot. This script also sets up that user build packages, which we don't +# chroot. This script also sets up that user to build packages, which we don't # need but is quick so there's no point forking the script. -RUN apk update && apk add --update alpine-sdk +RUN apk update && apk add --update alpine-sdk sudo ADD 01_alpine_priv_setup.sh / RUN sh /01_alpine_priv_setup.sh "$UID" diff --git a/cross-images/Dockerfile.alpine-chroot-cross b/cross-images/Dockerfile.alpine-chroot-cross index 3f74914..71d0361 100644 --- a/cross-images/Dockerfile.alpine-chroot-cross +++ b/cross-images/Dockerfile.alpine-chroot-cross @@ -1,10 +1,10 @@ -# Copyright 2019 The Tectonic Project +# Copyright 2019-2022 The Tectonic Project # Licensed under the MIT License. # We do some fancy Docker gymnastics to set up an Alpine instance that then # becomes a chroot inside an Ubuntu install. -FROM alpine:3.10 AS chroot +FROM alpine:3.16 AS chroot ARG UID=1000 ARG rust_platform @@ -13,7 +13,7 @@ ARG alpine_arch ARG qemu_arch # Privileged Alpine setup: make a user that will build the desired cross compiler. -RUN apk update && apk add --update alpine-sdk +RUN apk update && apk add --update alpine-sdk sudo ADD 01_alpine_priv_setup.sh / RUN sh /01_alpine_priv_setup.sh "$UID" diff --git a/cross-images/mini-aports/main/binutils/0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch b/cross-images/mini-aports/main/binutils/0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch new file mode 100644 index 0000000..6e1fa77 --- /dev/null +++ b/cross-images/mini-aports/main/binutils/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 +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/cross-images/mini-aports/main/binutils/APKBUILD b/cross-images/mini-aports/main/binutils/APKBUILD index 91f5f4f..dc97c78 100644 --- a/cross-images/mini-aports/main/binutils/APKBUILD +++ b/cross-images/mini-aports/main/binutils/APKBUILD @@ -1,7 +1,8 @@ -# Maintainer: Natanael Copa +# Contributor: Natanael Copa +# Maintainer: Ariadne Conill pkgname=binutils -pkgver=2.32 -pkgrel=0 +pkgver=2.38 +pkgrel=2 pkgdesc="Tools necessary to build programs" url="https://www.gnu.org/software/binutils/" makedepends_build="bison flex texinfo" @@ -9,13 +10,23 @@ makedepends_host="zlib-dev" makedepends="$makedepends_build $makedepends_host" arch="all" license="GPL-2.0 GPL-3.0-or-later LGPL-2.0 BSD" -subpackages="$pkgname-dev $pkgname-doc $pkgname-gold" -source="https://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.bz2 +subpackages="$pkgname-dev $pkgname-doc" +source="https://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz binutils-ld-fix-static-linking.patch gold-mips.patch + ld-bfd-mips.patch + 0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch + binutils-mips-disable-assert.patch + binutils-ppc-fix-machine-options.patch + binutils-s390x-1.patch + binutils-s390x-2.patch " builddir="$srcdir/$pkgname-$pkgver" +if [ "$CHOST" = "$CBUILD" ] && [ "$CBUILD" = "$CTARGET" ] && [ "$CTARGET_ARCH" != "riscv64" ]; then + subpackages="$subpackages $pkgname-gold" +fi + if [ "$CHOST" != "$CTARGET" ]; then pkgname="$pkgname-$CTARGET_ARCH" subpackages="" @@ -23,34 +34,46 @@ if [ "$CHOST" != "$CTARGET" ]; then fi # secfixes: +# 2.35.2-r1: +# - CVE-2021-3487 # 2.32-r0: -# - CVE-2018-19931 -# - CVE-2018-19932 -# - CVE-2018-20002 -# - CVE-2018-20712 +# - CVE-2018-19931 +# - CVE-2018-19932 +# - CVE-2018-20002 +# - CVE-2018-20712 # 2.28-r1: -# - CVE-2017-7614 +# - CVE-2017-7614 build() { local _sysroot=/ local _cross_configure="--enable-install-libiberty --enable-shared" local _arch_configure="" + local _gold_configure="--disable-gold" + local _plugin_configure="--enable-plugins" if [ "$CHOST" != "$CTARGET" ]; then _sysroot="$CBUILDROOT" _cross_configure="--disable-install-libiberty" + _plugin_configure="--disable-plugins" + fi + + if [ "$CHOST" = "$CBUILD" ] && [ "$CBUILD" = "$CTARGET" ] && [ "$CTARGET_ARCH" != "riscv64" ]; then + _gold_configure="--enable-gold" fi if [ "$CTARGET_ARCH" = "x86_64" ]; then _arch_configure="--enable-targets=x86_64-pep" fi + if [ "$CTARGET_ARCH" = "riscv64" ]; then + _gold_configure="--disable-gold" + fi + case "$CTARGET_ARCH" in mips*) _hash_style_configure="--enable-default-hash-style=sysv" ;; *) _hash_style_configure="--enable-default-hash-style=gnu" ;; esac - cd "$builddir" ./configure \ --build=$CBUILD \ --host=$CHOST \ @@ -62,9 +85,9 @@ build() { --infodir=/usr/share/info \ --disable-multilib \ --enable-ld=default \ - --enable-gold=yes \ + $_gold_configure \ --enable-64-bit-bfd \ - --enable-plugins \ + $_plugin_configure \ --enable-relro \ --enable-deterministic-archives \ $_cross_configure \ @@ -79,7 +102,6 @@ build() { } package() { - cd "$builddir" make install DESTDIR="$pkgdir" if [ -d "$pkgdir"/usr/lib64 ]; then mv "$pkgdir"/usr/lib64/* "$pkgdir"/usr/lib/ @@ -88,8 +110,9 @@ package() { if [ "$CHOST" != "$CTARGET" ]; then # creating cross tools: remove any files that would conflict # with the native tools, or other cross tools - rm -r "$pkgdir"/usr/share + rm -r "${pkgdir:?}"/usr/share rm -f "$pkgdir"/usr/lib/libiberty.a + rm -r "${pkgdir:?}"/usr/lib/bfd-plugins fi } @@ -111,6 +134,14 @@ gold() { mv "$pkgdir"/usr/$CTARGET/bin/ld.gold "$subpkgdir"/usr/$CTARGET/bin/ld.gold } -sha512sums="99ec7ed2b5ebfd3ac16cecb1567ec4a72f81ac30717002d601708f7547b2f8122ffcce076c986f22894aede33c54c73012210a4e973ba9b6e2d87a242a2bee12 binutils-2.32.tar.bz2 +sha512sums=" +8bf0b0d193c9c010e0518ee2b2e5a830898af206510992483b427477ed178396cd210235e85fd7bd99a96fc6d5eedbeccbd48317a10f752b7336ada8b2bb826d binutils-2.38.tar.xz ecee33b0e435aa704af1c334e560f201638ff79e199aa11ed78a72f7c9b46f85fbb227af5748e735fd681d1965fcc42ac81b0c8824e540430ce0c706c81e8b49 binutils-ld-fix-static-linking.patch -f55cf2e0bf82f97583a1abe10710e4013ecf7d64f1da2ef8659a44a06d0dd8beaf58dab98a183488ea137f03e32d62efc878d95f018f836f8cec870bc448556f gold-mips.patch" +f55cf2e0bf82f97583a1abe10710e4013ecf7d64f1da2ef8659a44a06d0dd8beaf58dab98a183488ea137f03e32d62efc878d95f018f836f8cec870bc448556f gold-mips.patch +314d2ef9071c89940aa6c8118e8a1e2f191a5d0a4bf596da1ad9cc84f884d8bc7dea8bd7b9fc3f8f1bddd3fd41c6eb017e1e804044b3bf084df1ed9e6e095e2d ld-bfd-mips.patch +70ec22bd72ef6dddecfd970613387dd4a8cdc8730dd3cbf03d5a0c3a7c4d839383167bb06dad21bf7c235329fd44b5dc4aefe762f68544f17155cf002bf1be4a 0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch +609cd90d8b334eb309f586b17b9d335a08d3dbb6def7c3eb5c010028fcb681674031e5b9d853aa7a39a50304356a86afc184b85562b3f228f8197f4d29395c8f binutils-mips-disable-assert.patch +27ea91e0e406e2ed464fd692cf92a07e338781789f2d968c8b95d9d5545985056a6f7f500df3952e5ab42165db28b741aa33d6b717e880b11a2e41fe406b13c4 binutils-ppc-fix-machine-options.patch +a9efe2689624865f0ff33d4776a5bd295bcad6484bdd38d0ca490fea43691c4933ab33d17478851998eef12922dbf83d6c3225bb1f8faf92a1367d086390f7d3 binutils-s390x-1.patch +0e291df80ad279005265634014d0935d2c115a5ed708d25407094b7ad4ddf267d1fb7fcbcb2d9ad73bd305b4e3974628b820bd1f249f56c095e4896872434cc9 binutils-s390x-2.patch +" diff --git a/cross-images/mini-aports/main/binutils/binutils-mips-disable-assert.patch b/cross-images/mini-aports/main/binutils/binutils-mips-disable-assert.patch new file mode 100644 index 0000000..1a78858 --- /dev/null +++ b/cross-images/mini-aports/main/binutils/binutils-mips-disable-assert.patch @@ -0,0 +1,14 @@ +diff -urN binutils-2.35.2.orig/bfd/elfxx-mips.c binutils-2.35.2/bfd/elfxx-mips.c +--- binutils-2.35.2.orig/bfd/elfxx-mips.c 2021-01-30 01:38:03.000000000 -0700 ++++ binutils-2.35.2/bfd/elfxx-mips.c 2021-05-13 17:35:34.706913601 -0600 +@@ -6744,8 +6744,10 @@ + in the relocation. */ + if (h != NULL && ! SYMBOL_REFERENCES_LOCAL (info, &h->root)) + { ++#if 0 + BFD_ASSERT (htab->root.target_os == is_vxworks + || h->global_got_area != GGA_NONE); ++#endif + indx = h->root.dynindx; + if (SGI_COMPAT (output_bfd)) + defined_p = h->root.def_regular; diff --git a/cross-images/mini-aports/main/binutils/binutils-ppc-fix-machine-options.patch b/cross-images/mini-aports/main/binutils/binutils-ppc-fix-machine-options.patch new file mode 100644 index 0000000..703ecf9 --- /dev/null +++ b/cross-images/mini-aports/main/binutils/binutils-ppc-fix-machine-options.patch @@ -0,0 +1,41 @@ +Fix for DARN opcode error during ppc64le compilation of rng-tools which +occurs with binutils 2.38 but not with binutils 2.37.. + +https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=cebc89b9328;hp=9cbed90ee623d75e31994e7943960c997ba565f2 + + +diff -aur a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c +--- a/gas/config/tc-ppc.c ++++ b/gas/config/tc-ppc.c +@@ -5965,7 +5965,30 @@ + options do not count as a new machine, instead they add + to currently selected opcodes. */ + ppc_cpu_t machine_sticky = 0; +- new_cpu = ppc_parse_cpu (ppc_cpu, &machine_sticky, cpu_string); ++ /* Unfortunately, some versions of gcc emit a .machine ++ directive very near the start of the compiler's assembly ++ output file. This is bad because it overrides user -Wa ++ cpu selection. Worse, there are versions of gcc that ++ emit the *wrong* cpu, not even respecting the -mcpu given ++ to gcc. See gcc pr101393. And to compound the problem, ++ as of 20220222 gcc doesn't pass the correct cpu option to ++ gas on the command line. See gcc pr59828. Hack around ++ this by keeping sticky options for an early .machine. */ ++ asection *sec; ++ for (sec = stdoutput->sections; sec != NULL; sec = sec->next) ++ { ++ segment_info_type *info = seg_info (sec); ++ /* Are the frags for this section perturbed from their ++ initial state? Even .align will count here. */ ++ if (info != NULL ++ && (info->frchainP->frch_root != info->frchainP->frch_last ++ || info->frchainP->frch_root->fr_type != rs_fill ++ || info->frchainP->frch_root->fr_fix != 0)) ++ break; ++ } ++ new_cpu = ppc_parse_cpu (ppc_cpu, ++ sec == NULL ? &sticky : &machine_sticky, ++ cpu_string); + if (new_cpu != 0) + ppc_cpu = new_cpu; + else diff --git a/cross-images/mini-aports/main/binutils/binutils-s390x-1.patch b/cross-images/mini-aports/main/binutils/binutils-s390x-1.patch new file mode 100644 index 0000000..fab51a2 --- /dev/null +++ b/cross-images/mini-aports/main/binutils/binutils-s390x-1.patch @@ -0,0 +1,147 @@ +From 82a5bb730a16f8c7962568030268e784b4fb42c8 Mon Sep 17 00:00:00 2001 +From: Stefan Liebler +Date: Thu, 28 Apr 2022 14:29:58 +0200 +Subject: [PATCH] s390: Avoid dynamic TLS relocs in PIE + +No dynamic relocs are needed for TLS defined in an executable, the +TP relative offset is known at link time. + +Fixes +FAIL: Build pr22263-1 + +bfd/ + PR ld/22263 + * elf64-s390.c (elf_s390_tls_transition): Use bfd_link_dll + instead of bfd_link_pic for TLS. + (elf_s390_check_relocs): Likewise. + (allocate_dynrelocs): Likewise. + (elf_s390_relocate_section): Likewise. + +(cherry picked from commit 26b1426577b5dcb32d149c64cca3e603b81948a9) +--- + bfd/elf64-s390.c | 26 +++++++++++++------------- + 1 file changed, 13 insertions(+), 13 deletions(-) + +diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c +index e780efa7181..00ee386baab 100644 +--- a/bfd/elf64-s390.c ++++ b/bfd/elf64-s390.c +@@ -774,7 +774,7 @@ elf_s390_tls_transition (struct bfd_link_info *info, + int r_type, + int is_local) + { +- if (bfd_link_pic (info)) ++ if (bfd_link_dll (info)) + return r_type; + + switch (r_type) +@@ -1026,7 +1026,7 @@ elf_s390_check_relocs (bfd *abfd, + case R_390_TLS_GOTIE20: + case R_390_TLS_GOTIE64: + case R_390_TLS_IEENT: +- if (bfd_link_pic (info)) ++ if (bfd_link_dll (info)) + info->flags |= DF_STATIC_TLS; + /* Fall through */ + +@@ -1107,7 +1107,7 @@ elf_s390_check_relocs (bfd *abfd, + if (r_type == R_390_TLS_LE64 && bfd_link_pie (info)) + break; + +- if (!bfd_link_pic (info)) ++ if (!bfd_link_dll (info)) + break; + info->flags |= DF_STATIC_TLS; + /* Fall through */ +@@ -1571,7 +1571,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, + to R_390_TLS_LE64 requiring no TLS entry. For GOTIE12 and IEENT + we can save the dynamic TLS relocation. */ + if (h->got.refcount > 0 +- && !bfd_link_pic (info) ++ && !bfd_link_dll (info) + && h->dynindx == -1 + && elf_s390_hash_entry(h)->tls_type >= GOT_TLS_IE) + { +@@ -2662,7 +2662,7 @@ elf_s390_relocate_section (bfd *output_bfd, + + /* Relocations for tls literal pool entries. */ + case R_390_TLS_IE64: +- if (bfd_link_pic (info)) ++ if (bfd_link_dll (info)) + { + Elf_Internal_Rela outrel; + asection *sreloc; +@@ -2690,7 +2690,7 @@ elf_s390_relocate_section (bfd *output_bfd, + else if (h != NULL) + { + tls_type = elf_s390_hash_entry(h)->tls_type; +- if (!bfd_link_pic (info) && h->dynindx == -1 && tls_type >= GOT_TLS_IE) ++ if (!bfd_link_dll (info) && h->dynindx == -1 && tls_type >= GOT_TLS_IE) + r_type = R_390_TLS_LE64; + } + if (r_type == R_390_TLS_GD64 && tls_type >= GOT_TLS_IE) +@@ -2801,14 +2801,14 @@ elf_s390_relocate_section (bfd *output_bfd, + if (local_got_offsets == NULL) + abort(); + off = local_got_offsets[r_symndx]; +- if (bfd_link_pic (info)) ++ if (bfd_link_dll (info)) + goto emit_tls_relocs; + } + else + { + off = h->got.offset; + tls_type = elf_s390_hash_entry(h)->tls_type; +- if (bfd_link_pic (info) || h->dynindx != -1 || tls_type < GOT_TLS_IE) ++ if (bfd_link_dll (info) || h->dynindx != -1 || tls_type < GOT_TLS_IE) + goto emit_tls_relocs; + } + +@@ -2825,7 +2825,7 @@ elf_s390_relocate_section (bfd *output_bfd, + break; + + case R_390_TLS_LDM64: +- if (! bfd_link_pic (info)) ++ if (! bfd_link_dll (info)) + /* The literal pool entry this relocation refers to gets ignored + by the optimized code of the local exec model. Do nothing + and the value will turn out zero. */ +@@ -2900,7 +2900,7 @@ elf_s390_relocate_section (bfd *output_bfd, + continue; + + case R_390_TLS_LDO64: +- if (bfd_link_pic (info) || (input_section->flags & SEC_DEBUGGING)) ++ if (bfd_link_dll (info) || (input_section->flags & SEC_DEBUGGING)) + relocation -= dtpoff_base (info); + else + /* When converting LDO to LE, we must negate. */ +@@ -2922,7 +2922,7 @@ elf_s390_relocate_section (bfd *output_bfd, + + if (r_type == R_390_TLS_LOAD) + { +- if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1)) ++ if (!bfd_link_dll (info) && (h == NULL || h->dynindx == -1)) + { + /* IE->LE transition. Four valid cases: + lg %rx,(0,%ry) -> sllg %rx,%ry,0 +@@ -2972,7 +2972,7 @@ elf_s390_relocate_section (bfd *output_bfd, + invalid_tls_insn (input_bfd, input_section, rel); + return false; + } +- if (!bfd_link_pic (info) && (h == NULL || h->dynindx == -1)) ++ if (!bfd_link_dll (info) && (h == NULL || h->dynindx == -1)) + { + /* GD->LE transition. + brasl %r14,__tls_get_addr@plt -> brcl 0,. */ +@@ -2991,7 +2991,7 @@ elf_s390_relocate_section (bfd *output_bfd, + } + else if (r_type == R_390_TLS_LDCALL) + { +- if (!bfd_link_pic (info)) ++ if (!bfd_link_dll (info)) + { + unsigned int insn0, insn1; + +-- +2.27.0 + diff --git a/cross-images/mini-aports/main/binutils/binutils-s390x-2.patch b/cross-images/mini-aports/main/binutils/binutils-s390x-2.patch new file mode 100644 index 0000000..75d7a93 --- /dev/null +++ b/cross-images/mini-aports/main/binutils/binutils-s390x-2.patch @@ -0,0 +1,51 @@ +From 9a01457e02e7bb594ff9a9ac62a38c909e2e3083 Mon Sep 17 00:00:00 2001 +From: Stefan Liebler +Date: Thu, 28 Apr 2022 14:30:55 +0200 +Subject: [PATCH] s390: Add DT_JMPREL pointing to .rela.[i]plt with static-pie + +In static-pie case, there are IRELATIVE-relocs in +.rela.iplt (htab->irelplt), which will later be grouped +to .rela.plt. On s390, the IRELATIVE relocations are +always located in .rela.iplt - even for non-static case. +Ensure that DT_JMPREL, DT_PLTRELA, DT_PLTRELASZ is added +to the dynamic section even if htab->srelplt->size == 0. +See _bfd_elf_add_dynamic_tags in bfd/elflink.c. + +bfd/ + elf64-s390.c (elf_s390_size_dynamic_sections): + Enforce DT_JMPREL via htab->elf.dt_jmprel_required. + +(cherry picked from commit d942d8db12adf4c9e5c7d9ed6496a779ece7149e) +--- + bfd/elf64-s390.c | 15 ++++++++++++++- + 1 file changed, 14 insertions(+), 1 deletion(-) + +diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c +index 00ee386baab..0b851f7ac0e 100644 +--- a/bfd/elf64-s390.c ++++ b/bfd/elf64-s390.c +@@ -1876,7 +1876,20 @@ elf_s390_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, + else if (startswith (bfd_section_name (s), ".rela")) + { + if (s->size != 0 && s != htab->elf.srelplt) +- relocs = true; ++ { ++ relocs = true; ++ if (s == htab->elf.irelplt) ++ { ++ /* In static-pie case, there are IRELATIVE-relocs in ++ .rela.iplt (htab->irelplt), which will later be grouped ++ to .rela.plt. On s390, the IRELATIVE relocations are ++ always located in .rela.iplt - even for non-static case. ++ Ensure that DT_JMPREL, DT_PLTRELA, DT_PLTRELASZ is added ++ to the dynamic section even if htab->srelplt->size == 0. ++ See _bfd_elf_add_dynamic_tags in bfd/elflink.c. */ ++ htab->elf.dt_jmprel_required = true; ++ } ++ } + + /* We use the reloc_count field as a counter if we need + to copy relocs into the output file. */ +-- +2.27.0 + diff --git a/cross-images/mini-aports/main/binutils/ld-bfd-mips.patch b/cross-images/mini-aports/main/binutils/ld-bfd-mips.patch new file mode 100644 index 0000000..2991c88 --- /dev/null +++ b/cross-images/mini-aports/main/binutils/ld-bfd-mips.patch @@ -0,0 +1,19 @@ +--- ./ld/configure.tgt.orig ++++ ./ld/configure.tgt +@@ -541,12 +541,12 @@ + ;; + mips*-*-windiss) targ_emul=elf32mipswindiss + ;; +-mips64*el-*-linux-*) targ_emul=elf32ltsmipn32 +- targ_extra_emuls="elf32btsmipn32 elf32ltsmip elf32btsmip elf64ltsmip elf64btsmip" ++mips64*el-*-linux-*) targ_emul=elf64ltsmip ++ targ_extra_emuls="elf32ltsmipn32 elf32btsmipn32 elf32ltsmip elf32btsmip elf64btsmip" + targ_extra_libpath=$targ_extra_emuls + ;; +-mips64*-*-linux-*) targ_emul=elf32btsmipn32 +- targ_extra_emuls="elf32ltsmipn32 elf32btsmip elf32ltsmip elf64btsmip elf64ltsmip" ++mips64*-*-linux-*) targ_emul=elf64btsmip ++ targ_extra_emuls="elf32btsmipn32 elf32ltsmipn32 elf32btsmip elf32ltsmip elf64ltsmip" + targ_extra_libpath=$targ_extra_emuls + ;; + mips*el-*-linux-*) targ_emul=elf32ltsmip diff --git a/cross-images/mini-aports/main/build-base/APKBUILD b/cross-images/mini-aports/main/build-base/APKBUILD index 01b89d9..709b5ee 100644 --- a/cross-images/mini-aports/main/build-base/APKBUILD +++ b/cross-images/mini-aports/main/build-base/APKBUILD @@ -1,17 +1,17 @@ # Maintainer: Natanael Copa pkgname=build-base pkgver=0.5 -pkgrel=1 +pkgrel=3 url=http://dev.alpinelinux.org/cgit pkgdesc="Meta package for build base" -depends="binutils file gcc g++ make libc-dev fortify-headers" +depends="binutils file gcc g++ make libc-dev fortify-headers patch" if [ "$CHOST" != "$CTARGET" ]; then pkgname="$pkgname-$CTARGET_ARCH" pkgdesc="$pkgdesc ($CTARGET_ARCH)" depends="binutils-$CTARGET_ARCH gcc-$CTARGET_ARCH g++-$CTARGET_ARCH $depends" fi arch="noarch" -license=none +license="MIT" options="!check" build() { diff --git a/cross-images/mini-aports/main/fortify-headers/0000-do-not-mess-with-ppoll.patch b/cross-images/mini-aports/main/fortify-headers/0000-do-not-mess-with-ppoll.patch new file mode 100644 index 0000000..e9685ec --- /dev/null +++ b/cross-images/mini-aports/main/fortify-headers/0000-do-not-mess-with-ppoll.patch @@ -0,0 +1,34 @@ +diff -rNU3 fortify-headers-1.1.old/README fortify-headers-1.1/README +--- fortify-headers-1.1.old/README 2019-04-14 10:26:11.000000000 +0200 ++++ fortify-headers-1.1/README 2021-02-16 18:10:51.305259894 +0100 +@@ -67,7 +67,6 @@ + mempcpy + memset + poll +-ppoll + pread + read + readlink +diff -rNU3 fortify-headers-1.1.old/include/poll.h fortify-headers-1.1/include/poll.h +--- fortify-headers-1.1.old/include/poll.h 2019-04-14 10:26:11.000000000 +0200 ++++ fortify-headers-1.1/include/poll.h 2021-02-16 18:11:25.415259531 +0100 +@@ -39,19 +39,6 @@ + return __orig_poll(__f, __n, __s); + } + +-#ifdef _GNU_SOURCE +-#undef ppoll +-_FORTIFY_FN(ppoll) int ppoll(struct pollfd *__f, nfds_t __n, const struct timespec *__s, +- const sigset_t *__m) +-{ +- __typeof__(sizeof 0) __b = __builtin_object_size(__f, 0); +- +- if (__n > __b / sizeof(struct pollfd)) +- __builtin_trap(); +- return __orig_ppoll(__f, __n, __s, __m); +-} +-#endif +- + #ifdef __cplusplus + } + #endif diff --git a/cross-images/mini-aports/main/fortify-headers/APKBUILD b/cross-images/mini-aports/main/fortify-headers/APKBUILD index 2148b3b..8701f52 100644 --- a/cross-images/mini-aports/main/fortify-headers/APKBUILD +++ b/cross-images/mini-aports/main/fortify-headers/APKBUILD @@ -2,13 +2,14 @@ # Maintainer: Timo Teräs pkgname=fortify-headers pkgver=1.1 -pkgrel=0 +pkgrel=1 pkgdesc="standalone fortify source implementation" url="http://git.2f30.org/fortify-headers/" arch="noarch" options="!check" # No test suite. license="BSD-0" source="http://dl.2f30.org/releases/$pkgname-$pkgver.tar.gz + 0000-do-not-mess-with-ppoll.patch " builddir="$srcdir"/$pkgname-$pkgver @@ -22,4 +23,5 @@ package() { make DESTDIR="$pkgdir" PREFIX=/usr install } -sha512sums="a39d6e7c002bf91085f712aa46bc3f53ff934cc963694a229fa82d84ff4a7556105212a84a231ab5367c01c6a1e385172173f1f4a34d5eb4d2d9c58472c23dd0 fortify-headers-1.1.tar.gz" +sha512sums="a39d6e7c002bf91085f712aa46bc3f53ff934cc963694a229fa82d84ff4a7556105212a84a231ab5367c01c6a1e385172173f1f4a34d5eb4d2d9c58472c23dd0 fortify-headers-1.1.tar.gz +a48dca5f9e0ac301ae7c31e20af233e25709bc799be9a7fc97ebdff3b1f20d65fb6f8245d6b1b0d632a5661bc2c06144f9c2e97fb20122311da78fed8148c66b 0000-do-not-mess-with-ppoll.patch" diff --git a/cross-images/mini-aports/main/gcc/0002-posix_memalign.patch b/cross-images/mini-aports/main/gcc/0001-posix_memalign.patch similarity index 89% rename from cross-images/mini-aports/main/gcc/0002-posix_memalign.patch rename to cross-images/mini-aports/main/gcc/0001-posix_memalign.patch index 874f49b..f148bcc 100644 --- a/cross-images/mini-aports/main/gcc/0002-posix_memalign.patch +++ b/cross-images/mini-aports/main/gcc/0001-posix_memalign.patch @@ -1,14 +1,14 @@ -From 65eb86f3e110998d30489df009d44b4bc1043adc Mon Sep 17 00:00:00 2001 +From feb04e50d907683385cc4dc0163cf1d82258073a Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Fri, 26 Jan 2018 20:32:50 +0000 -Subject: [PATCH 02/12] posix_memalign +Subject: [PATCH] posix_memalign --- gcc/config/i386/pmm_malloc.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gcc/config/i386/pmm_malloc.h b/gcc/config/i386/pmm_malloc.h -index ffbb7f82cf5..b0b890d2403 100644 +index 1b0bfe37852..d7b2b19bb3c 100644 --- a/gcc/config/i386/pmm_malloc.h +++ b/gcc/config/i386/pmm_malloc.h @@ -27,12 +27,13 @@ @@ -38,5 +38,5 @@ index ffbb7f82cf5..b0b890d2403 100644 else return NULL; -- -2.17.1 +2.35.1 diff --git a/cross-images/mini-aports/main/gcc/0003-gcc-poison-system-directories.patch b/cross-images/mini-aports/main/gcc/0002-gcc-poison-system-directories.patch similarity index 73% rename from cross-images/mini-aports/main/gcc/0003-gcc-poison-system-directories.patch rename to cross-images/mini-aports/main/gcc/0002-gcc-poison-system-directories.patch index 0513897..223749d 100644 --- a/cross-images/mini-aports/main/gcc/0003-gcc-poison-system-directories.patch +++ b/cross-images/mini-aports/main/gcc/0002-gcc-poison-system-directories.patch @@ -1,11 +1,20 @@ -From 48c670d2678e0323d88eb72205e039f393cabe05 Mon Sep 17 00:00:00 2001 +From d64825212f807435a4b2f8e068c0f65195c8e2e6 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Fri, 29 Mar 2013 08:59:00 +0400 -Subject: [PATCH 03/39] gcc: poison-system-directories +Subject: [PATCH] gcc: poison-system-directories +Add /sw/include and /opt/include based on the original +zecke-no-host-includes.patch patch. The original patch checked for +/usr/include, /sw/include and /opt/include and then triggered a failure and +aborted. + +Instead, we add the two missing items to the current scan. If the user +wants this to be a failure, they can add "-Werror=poison-system-directories". + +Signed-off-by: Mark Hatle Signed-off-by: Khem Raj -Upstream-Status: Inappropriate [distribution: codesourcery] +Upstream-Status: Pending --- gcc/common.opt | 4 ++++ gcc/config.in | 6 ++++++ @@ -13,14 +22,14 @@ Upstream-Status: Inappropriate [distribution: codesourcery] gcc/configure.ac | 10 ++++++++++ gcc/doc/invoke.texi | 9 +++++++++ gcc/gcc.c | 2 ++ - gcc/incpath.c | 19 +++++++++++++++++++ - 7 files changed, 66 insertions(+) + gcc/incpath.c | 21 +++++++++++++++++++++ + 7 files changed, 68 insertions(+) diff --git a/gcc/common.opt b/gcc/common.opt -index d6ef85928f3..7b29efe3882 100644 +index a75b44ee47e..d15105a73f3 100644 --- a/gcc/common.opt +++ b/gcc/common.opt -@@ -679,6 +679,10 @@ Wreturn-local-addr +@@ -683,6 +683,10 @@ Wreturn-local-addr Common Var(warn_return_local_addr) Init(1) Warning Warn about returning a pointer/reference to a local or temporary variable. @@ -32,10 +41,10 @@ index d6ef85928f3..7b29efe3882 100644 Common Var(warn_shadow) Warning Warn when one variable shadows another. Same as -Wshadow=global. diff --git a/gcc/config.in b/gcc/config.in -index 5bccb408016..1c784a8276b 100644 +index 2de5a463315..059c818c895 100644 --- a/gcc/config.in +++ b/gcc/config.in -@@ -194,6 +194,12 @@ +@@ -218,6 +218,12 @@ #endif @@ -49,18 +58,18 @@ index 5bccb408016..1c784a8276b 100644 optimizer and back end) to be checked for dynamic type safety at runtime. This is quite expensive. */ diff --git a/gcc/configure b/gcc/configure -index 5c345ce0fd7..cafd05fd150 100755 +index 708328e1670..4b977e313b5 100755 --- a/gcc/configure +++ b/gcc/configure -@@ -953,6 +953,7 @@ with_system_zlib - enable_maintainer_mode +@@ -1020,6 +1020,7 @@ enable_maintainer_mode enable_link_mutex + enable_link_serialization enable_version_specific_runtime_libs +enable_poison_system_directories enable_plugin enable_host_shared enable_libquadmath_support -@@ -1696,6 +1697,8 @@ Optional Features: +@@ -1782,6 +1783,8 @@ Optional Features: --enable-version-specific-runtime-libs specify that runtime libraries should be installed in a compiler-specific directory @@ -69,7 +78,7 @@ index 5c345ce0fd7..cafd05fd150 100755 --enable-plugin enable plugin support --enable-host-shared build host code as shared libraries --disable-libquadmath-support -@@ -29715,6 +29718,19 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then : +@@ -31790,6 +31793,19 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then : fi @@ -90,10 +99,10 @@ index 5c345ce0fd7..cafd05fd150 100755 diff --git a/gcc/configure.ac b/gcc/configure.ac -index 65dbf1f2f80..dd5b38195ce 100644 +index df1c9cc3200..5461bab88a9 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac -@@ -6341,6 +6341,16 @@ AC_ARG_ENABLE(version-specific-runtime-libs, +@@ -7311,6 +7311,16 @@ AC_ARG_ENABLE(version-specific-runtime-libs, [specify that runtime libraries should be installed in a compiler-specific directory])]) @@ -111,18 +120,18 @@ index 65dbf1f2f80..dd5b38195ce 100644 AC_SUBST(subdirs) AC_SUBST(srcdir) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi -index 255149fcfb8..cb71b60fe3c 100644 +index cf536a15116..7d3f1ccddf3 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi -@@ -303,6 +303,7 @@ Objective-C and Objective-C++ Dialects}. - -Wpacked -Wpacked-bitfield-compat -Wpacked-not-aligned -Wpadded @gol +@@ -369,6 +369,7 @@ Objective-C and Objective-C++ Dialects}. + -Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded @gol -Wparentheses -Wno-pedantic-ms-format @gol - -Wplacement-new -Wplacement-new=@var{n} @gol + -Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast @gol +-Wno-poison-system-directories @gol - -Wpointer-arith -Wpointer-compare -Wno-pointer-to-int-cast @gol - -Wno-pragmas -Wredundant-decls -Wrestrict -Wno-return-local-addr @gol - -Wreturn-type -Wsequence-point -Wshadow -Wno-shadow-ivar @gol -@@ -5712,6 +5713,14 @@ made up of data only and thus requires no special treatment. But, for + -Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls @gol + -Wrestrict -Wno-return-local-addr -Wreturn-type @gol + -Wno-scalar-storage-order -Wsequence-point @gol +@@ -7728,6 +7729,14 @@ made up of data only and thus requires no special treatment. But, for most targets, it is made up of code and thus requires the stack to be made executable in order for the program to work properly. @@ -138,20 +147,20 @@ index 255149fcfb8..cb71b60fe3c 100644 @opindex Wfloat-equal @opindex Wno-float-equal diff --git a/gcc/gcc.c b/gcc/gcc.c -index a716f708259..02b3cd39fc2 100644 +index 8ba410c9e17..a83ba34ac4b 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c -@@ -1037,6 +1037,8 @@ proper position among the other output files. */ +@@ -1152,6 +1152,8 @@ proper position among the other output files. */ "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \ "%X %{o*} %{e*} %{N} %{n} %{r}\ - %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}} \ + %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \ + %{Wno-poison-system-directories:--no-poison-system-directories} \ + %{Werror=poison-system-directories:--error-poison-system-directories} \ - %{static|no-pie|static-pie:} %{L*} %(mfwrap) %(link_libgcc) " \ - VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o " CHKP_SPEC " \ + %{static|no-pie|static-pie:} %@{L*} %(mfwrap) %(link_libgcc) " \ + VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o "" \ %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\ diff --git a/gcc/incpath.c b/gcc/incpath.c -index b11c6a57939..e3b7a21966f 100644 +index 446d280321d..fbfc0ce03b8 100644 --- a/gcc/incpath.c +++ b/gcc/incpath.c @@ -26,6 +26,7 @@ @@ -162,7 +171,7 @@ index b11c6a57939..e3b7a21966f 100644 /* Microsoft Windows does not natively support inodes. VMS has non-numeric inodes. */ -@@ -393,6 +394,26 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose) +@@ -395,6 +396,26 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose) } fprintf (stderr, _("End of search list.\n")); } @@ -190,5 +199,5 @@ index b11c6a57939..e3b7a21966f 100644 /* Use given -I paths for #include "..." but not #include <...>, and -- -2.17.0 +2.35.1 diff --git a/cross-images/mini-aports/main/gcc/0003-specs-turn-on-Wl-z-now-by-default.patch b/cross-images/mini-aports/main/gcc/0003-specs-turn-on-Wl-z-now-by-default.patch new file mode 100644 index 0000000..f6d3774 --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0003-specs-turn-on-Wl-z-now-by-default.patch @@ -0,0 +1,44 @@ +From 9675297b3a46b65a54e9df97f26ea445d53c67c6 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:45:49 +0000 +Subject: [PATCH] specs: turn on -Wl,-z,now by default + +Previously, we also used to turn on -z relro here, but we now build +binutils with --enable-relro, which is functionally equivalent. + +Binutils does not appear to have a similar option for enabling -z +now by default. +--- + gcc/doc/invoke.texi | 3 +++ + gcc/gcc.c | 1 + + 2 files changed, 4 insertions(+) + +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index 7d3f1ccddf3..485d2d6b742 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -15921,6 +15921,9 @@ For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the + linker. When using the GNU linker, you can also get the same effect with + @option{-Wl,-Map=output.map}. + ++NOTE: In Alpine Linux, for LDFLAGS, the option ++@option{-Wl,-z,now} is used. To disable, use @option{-Wl,-z,nonow}. ++ + @item -u @var{symbol} + @opindex u + Pretend the symbol @var{symbol} is undefined, to force linking of +diff --git a/gcc/gcc.c b/gcc/gcc.c +index a83ba34ac4b..faf9ce76b3d 100644 +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -1150,6 +1150,7 @@ proper position among the other output files. */ + "%{flto|flto=*:% 0 +From 4eb1b3849325b77c4cb66b675119299de35125bb Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:46:22 +0000 +Subject: [PATCH] Turn on -D_FORTIFY_SOURCE=2 by default for C, C++, ObjC, + ObjC++, if the optimization level is > 0 --- - gcc/doc/invoke.texi | 6 ++++++ - gcc/c-family/c-cppbuiltin.c | 3 + - 2 files changed, 9 insertions(+), 0 deletions(-) + gcc/c-family/c-cppbuiltin.c | 4 ++++ + gcc/doc/invoke.texi | 6 ++++++ + 2 files changed, 10 insertions(+) -Index: b/gcc/doc/invoke.texi -=================================================================== +diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c +index 11e015bdb87..de8b7bf246f 100644 +--- a/gcc/c-family/c-cppbuiltin.c ++++ b/gcc/c-family/c-cppbuiltin.c +@@ -1427,6 +1427,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); + ++ /* Fortify Source enabled by default for optimization levels > 0 */ ++ if (optimize) ++ builtin_define_with_int_value ("_FORTIFY_SOURCE", 2); ++ + /* Misc. */ + if (flag_gnu89_inline) + cpp_define (pfile, "__GNUC_GNU_INLINE__"); +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index 485d2d6b742..164929f7583 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi -@@ -7840,6 +7840,12 @@ also turns on the following optimization +@@ -10225,6 +10225,12 @@ also turns on the following optimization flags: Please note the warning under @option{-fgcse} about invoking @option{-O2} on programs that use computed gotos. @@ -23,18 +41,6 @@ Index: b/gcc/doc/invoke.texi @item -O3 @opindex O3 Optimize yet more. @option{-O3} turns on all optimizations specified -Index: b/gcc/c-family/c-cppbuiltin.c -=================================================================== ---- a/gcc/c-family/c-cppbuiltin.c -+++ b/gcc/c-family/c-cppbuiltin.c -@@ -1176,6 +1176,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); - -+ /* Fortify Source enabled by default for optimization levels > 0 */ -+ if (optimize) -+ builtin_define_with_int_value ("_FORTIFY_SOURCE", 2); -+ - /* Misc. */ - if (flag_gnu89_inline) - cpp_define (pfile, "__GNUC_GNU_INLINE__"); +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/005_all_default-as-needed.patch b/cross-images/mini-aports/main/gcc/0005-On-linux-targets-pass-as-needed-by-default-to-the-li.patch similarity index 65% rename from cross-images/mini-aports/main/gcc/005_all_default-as-needed.patch rename to cross-images/mini-aports/main/gcc/0005-On-linux-targets-pass-as-needed-by-default-to-the-li.patch index 0085219..54d10b6 100644 --- a/cross-images/mini-aports/main/gcc/005_all_default-as-needed.patch +++ b/cross-images/mini-aports/main/gcc/0005-On-linux-targets-pass-as-needed-by-default-to-the-li.patch @@ -1,77 +1,77 @@ -# DP: On linux targets pass --as-needed by default to the linker, but always -# DP: link the sanitizer libraries with --no-as-needed. +From 8de5d46c530ceca9f4add46d5cae3cd52c38eba3 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:46:56 +0000 +Subject: [PATCH] On linux targets pass --as-needed by default to the linker, + but always link the sanitizer libraries with --no-as-needed. -Index: b/gcc/gcc.c -=================================================================== ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -692,8 +692,11 @@ proper position among the other output f - #ifdef LIBASAN_EARLY_SPEC - #define LIBASAN_SPEC STATIC_LIBASAN_LIBS - #elif defined(HAVE_LD_STATIC_DYNAMIC) --#define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION \ -- "} -lasan %{static-libasan:" LD_DYNAMIC_OPTION "}" \ -+#define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION "}" \ -+ " %{!static-libasan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ -+ " -lasan " \ -+ " %{static-libasan:" LD_DYNAMIC_OPTION "}" \ -+ " %{!static-libasan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ - STATIC_LIBASAN_LIBS - #else - #define LIBASAN_SPEC "-lasan" STATIC_LIBASAN_LIBS -@@ -710,8 +713,11 @@ proper position among the other output f - #ifdef LIBTSAN_EARLY_SPEC - #define LIBTSAN_SPEC STATIC_LIBTSAN_LIBS - #elif defined(HAVE_LD_STATIC_DYNAMIC) --#define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION \ -- "} -ltsan %{static-libtsan:" LD_DYNAMIC_OPTION "}" \ -+#define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION "}" \ -+ " %{!static-libtsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ -+ " -ltsan " \ -+ " %{static-libtsan:" LD_DYNAMIC_OPTION "}" \ -+ " %{!static-libtsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ - STATIC_LIBTSAN_LIBS - #else - #define LIBTSAN_SPEC "-ltsan" STATIC_LIBTSAN_LIBS -@@ -728,8 +734,11 @@ proper position among the other output f - #ifdef LIBLSAN_EARLY_SPEC - #define LIBLSAN_SPEC STATIC_LIBLSAN_LIBS - #elif defined(HAVE_LD_STATIC_DYNAMIC) --#define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION \ -- "} -llsan %{static-liblsan:" LD_DYNAMIC_OPTION "}" \ -+#define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION "}" \ -+ " %{!static-liblsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ -+ " -llsan " \ -+ " %{static-liblsan:" LD_DYNAMIC_OPTION "}" \ -+ " %{!static-liblsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ - STATIC_LIBLSAN_LIBS - #else - #define LIBLSAN_SPEC "-llsan" STATIC_LIBLSAN_LIBS -@@ -744,8 +753,11 @@ proper position among the other output f - #define STATIC_LIBUBSAN_LIBS \ - " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}" - #ifdef HAVE_LD_STATIC_DYNAMIC --#define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION \ -- "} -lubsan %{static-libubsan:" LD_DYNAMIC_OPTION "}" \ -+#define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION "}" \ -+ " %{!static-libubsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ -+ " -lubsan " \ -+ " %{static-libubsan:" LD_DYNAMIC_OPTION "}" \ -+ " %{!static-libubsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ - STATIC_LIBUBSAN_LIBS - #else - #define LIBUBSAN_SPEC "-lubsan" STATIC_LIBUBSAN_LIBS -Index: b/gcc/config/gnu-user.h -=================================================================== +--- + gcc/config/aarch64/aarch64-linux.h | 1 + + gcc/config/alpha/linux-elf.h | 2 +- + gcc/config/arm/linux-elf.h | 1 + + gcc/config/gnu-user.h | 6 +++--- + gcc/config/i386/gnu-user.h | 2 +- + gcc/config/i386/gnu-user64.h | 1 + + gcc/config/ia64/linux.h | 2 +- + gcc/config/mips/gnu-user.h | 1 + + gcc/config/riscv/linux.h | 1 + + gcc/config/rs6000/linux64.h | 4 ++-- + gcc/config/rs6000/sysv4.h | 2 +- + gcc/config/s390/linux.h | 2 +- + gcc/config/sparc/linux.h | 2 +- + gcc/gcc.c | 28 ++++++++++++++++++++-------- + 14 files changed, 36 insertions(+), 19 deletions(-) + +diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h +index 7f2529a2a1d..b097e1688aa 100644 +--- a/gcc/config/aarch64/aarch64-linux.h ++++ b/gcc/config/aarch64/aarch64-linux.h +@@ -35,6 +35,7 @@ + #define CPP_SPEC "%{pthread:-D_REENTRANT}" + + #define LINUX_TARGET_LINK_SPEC "%{h*} \ ++ --as-needed \ + %{static:-Bstatic} \ + %{shared:-shared} \ + %{symbolic:-Bsymbolic} \ +diff --git a/gcc/config/alpha/linux-elf.h b/gcc/config/alpha/linux-elf.h +index c1dae8ca2cf..a87dc740171 100644 +--- a/gcc/config/alpha/linux-elf.h ++++ b/gcc/config/alpha/linux-elf.h +@@ -37,7 +37,7 @@ along with GCC; see the file COPYING3. If not see + + #define ELF_DYNAMIC_LINKER GNU_USER_DYNAMIC_LINKER + +-#define LINK_SPEC "-m elf64alpha %{G*} %{relax:-relax} \ ++#define LINK_SPEC "-m elf64alpha --as-needed %{G*} %{relax:-relax} \ + %{O*:-O3} %{!O*:-O1} \ + %{shared:-shared} \ + %{!shared: \ +diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h +index 0c1c4e70b6b..8b581afacdd 100644 +--- a/gcc/config/arm/linux-elf.h ++++ b/gcc/config/arm/linux-elf.h +@@ -70,6 +70,7 @@ + %{rdynamic:-export-dynamic} \ + %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \ + -X \ ++ --as-needed \ + %{mbig-endian:-EB} %{mlittle-endian:-EL}" \ + SUBTARGET_EXTRA_LINK_SPEC + +diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h +index 5ebbf42a13d..902378e1bad 100644 --- a/gcc/config/gnu-user.h +++ b/gcc/config/gnu-user.h -@@ -161,15 +161,15 @@ see the files COPYING3 and COPYING.RUNTI +@@ -136,7 +136,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define LIBASAN_EARLY_SPEC "%{!shared:libasan_preinit%O%s} " \ "%{static-libasan:%{!shared:" \ LD_STATIC_OPTION " --whole-archive -lasan --no-whole-archive " \ - LD_DYNAMIC_OPTION "}}%{!static-libasan:-lasan}" + LD_DYNAMIC_OPTION "}}%{!static-libasan:%{!fuse-ld=gold:--push-state} --no-as-needed -lasan %{fuse-ld=gold:--as-needed;:--pop-state}}" - #undef LIBTSAN_EARLY_SPEC + #undef LIBHWASAN_EARLY_SPEC + #define LIBHWASAN_EARLY_SPEC "%{static-libhwasan:%{!shared:" \ + LD_STATIC_OPTION " --whole-archive -lhwasan --no-whole-archive " \ +@@ -145,12 +145,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define LIBTSAN_EARLY_SPEC "%{!shared:libtsan_preinit%O%s} " \ "%{static-libtsan:%{!shared:" \ LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \ @@ -84,20 +84,35 @@ Index: b/gcc/config/gnu-user.h - LD_DYNAMIC_OPTION "}}%{!static-liblsan:-llsan}" + LD_DYNAMIC_OPTION "}}%{!static-liblsan:%{!fuse-ld=gold:--push-state} --no-as-needed -llsan %{fuse-ld=gold:--as-needed;:--pop-state}}" #endif -Index: b/gcc/config/aarch64/aarch64-linux.h -=================================================================== ---- a/gcc/config/aarch64/aarch64-linux.h -+++ b/gcc/config/aarch64/aarch64-linux.h -@@ -35,6 +35,7 @@ - #define CPP_SPEC "%{pthread:-D_REENTRANT}" - #define LINUX_TARGET_LINK_SPEC "%{h*} \ -+ --as-needed \ - %{static:-Bstatic} \ - %{shared:-shared} \ - %{symbolic:-Bsymbolic} \ -Index: b/gcc/config/ia64/linux.h -=================================================================== + #undef TARGET_F951_OPTIONS +diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h +index a23e7ab3eb7..12ac8cb93a9 100644 +--- a/gcc/config/i386/gnu-user.h ++++ b/gcc/config/i386/gnu-user.h +@@ -68,7 +68,7 @@ along with GCC; see the file COPYING3. If not see + { "link_emulation", GNU_USER_LINK_EMULATION },\ + { "dynamic_linker", GNU_USER_DYNAMIC_LINKER } + +-#define GNU_USER_TARGET_LINK_SPEC "-m %(link_emulation) %{shared:-shared} \ ++#define GNU_USER_TARGET_LINK_SPEC "-m %(link_emulation) --as-needed %{shared:-shared} \ + %{!shared: \ + %{!static: \ + %{!static-pie: \ +diff --git a/gcc/config/i386/gnu-user64.h b/gcc/config/i386/gnu-user64.h +index f3e25b1412a..712b0f1c30e 100644 +--- a/gcc/config/i386/gnu-user64.h ++++ b/gcc/config/i386/gnu-user64.h +@@ -56,6 +56,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + "%{" SPEC_64 ":-m " GNU_USER_LINK_EMULATION64 "} \ + %{" SPEC_32 ":-m " GNU_USER_LINK_EMULATION32 "} \ + %{" SPEC_X32 ":-m " GNU_USER_LINK_EMULATIONX32 "} \ ++ --as-needed \ + %{shared:-shared} \ + %{!shared: \ + %{!static: \ +diff --git a/gcc/config/ia64/linux.h b/gcc/config/ia64/linux.h +index ac40c3dfd3f..6e19e25c35a 100644 --- a/gcc/config/ia64/linux.h +++ b/gcc/config/ia64/linux.h @@ -58,7 +58,7 @@ do { \ @@ -109,37 +124,35 @@ Index: b/gcc/config/ia64/linux.h %{shared:-shared} \ %{!shared: \ %{!static: \ -Index: b/gcc/config/sparc/linux.h -=================================================================== ---- a/gcc/config/sparc/linux.h -+++ b/gcc/config/sparc/linux.h -@@ -86,7 +86,7 @@ extern const char *host_detect_local_cpu - #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" - - #undef LINK_SPEC --#define LINK_SPEC "-m elf32_sparc %{shared:-shared} \ -+#define LINK_SPEC "-m elf32_sparc --as-needed %{shared:-shared} \ - %{!mno-relax:%{!r:-relax}} \ +diff --git a/gcc/config/mips/gnu-user.h b/gcc/config/mips/gnu-user.h +index a390bcece83..be0ee289367 100644 +--- a/gcc/config/mips/gnu-user.h ++++ b/gcc/config/mips/gnu-user.h +@@ -55,6 +55,7 @@ along with GCC; see the file COPYING3. If not see + #undef GNU_USER_TARGET_LINK_SPEC + #define GNU_USER_TARGET_LINK_SPEC "\ + %{G*} %{EB} %{EL} %{mips*} %{shared} \ ++ -as-needed \ %{!shared: \ %{!static: \ -Index: b/gcc/config/s390/linux.h -=================================================================== ---- a/gcc/config/s390/linux.h -+++ b/gcc/config/s390/linux.h -@@ -78,7 +78,7 @@ along with GCC; see the file COPYING3. + %{rdynamic:-export-dynamic} \ +diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h +index fce5b896e6e..ee29979dd34 100644 +--- a/gcc/config/riscv/linux.h ++++ b/gcc/config/riscv/linux.h +@@ -58,6 +58,7 @@ along with GCC; see the file COPYING3. If not see + "%{mabi=ilp32:_ilp32}" - #undef LINK_SPEC - #define LINK_SPEC \ -- "%{m31:-m elf_s390}%{m64:-m elf64_s390} \ -+ "%{m31:-m elf_s390}%{m64:-m elf64_s390} --as-needed \ - %{shared:-shared} \ - %{!shared: \ - %{static:-static} \ -Index: b/gcc/config/rs6000/linux64.h -=================================================================== + #define LINK_SPEC "\ ++-as-needed \ + -melf" XLEN_SPEC DEFAULT_ENDIAN_SPEC "riscv" LD_EMUL_SUFFIX " \ + %{mno-relax:--no-relax} \ + %{mbig-endian:-EB} \ +diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h +index e3f2cd254f6..43499ed29cf 100644 --- a/gcc/config/rs6000/linux64.h +++ b/gcc/config/rs6000/linux64.h -@@ -490,13 +490,13 @@ extern int dot_symbols; +@@ -374,13 +374,13 @@ extern int dot_symbols; " -m elf64ppc") #endif @@ -155,90 +168,105 @@ Index: b/gcc/config/rs6000/linux64.h %{!static-pie: \ %{rdynamic:-export-dynamic} \ -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}}} \ -Index: b/gcc/config/rs6000/sysv4.h -=================================================================== +diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h +index 510abe169c5..3c1f3a8ec5d 100644 --- a/gcc/config/rs6000/sysv4.h +++ b/gcc/config/rs6000/sysv4.h -@@ -811,7 +811,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF - CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \ - MUSL_DYNAMIC_LINKER) +@@ -789,7 +789,7 @@ GNU_USER_TARGET_CC1_SPEC + #define GNU_USER_DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER + #endif -#define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \ +#define LINK_OS_LINUX_SPEC "-m elf32ppclinux --as-needed %{!shared: %{!static: \ %{rdynamic:-export-dynamic} \ -dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}" -Index: b/gcc/config/i386/gnu-user64.h -=================================================================== ---- a/gcc/config/i386/gnu-user64.h -+++ b/gcc/config/i386/gnu-user64.h -@@ -56,6 +56,7 @@ - "%{" SPEC_64 ":-m " GNU_USER_LINK_EMULATION64 "} \ - %{" SPEC_32 ":-m " GNU_USER_LINK_EMULATION32 "} \ - %{" SPEC_X32 ":-m " GNU_USER_LINK_EMULATIONX32 "} \ -+ --as-needed \ - %{shared:-shared} \ - %{!shared: \ - %{!static: \ -Index: b/gcc/config/i386/gnu-user.h -=================================================================== ---- a/gcc/config/i386/gnu-user.h -+++ b/gcc/config/i386/gnu-user.h -@@ -74,7 +74,7 @@ along with GCC; see the file COPYING3. - { "link_emulation", GNU_USER_LINK_EMULATION },\ - { "dynamic_linker", GNU_USER_DYNAMIC_LINKER } - --#define GNU_USER_TARGET_LINK_SPEC "-m %(link_emulation) %{shared:-shared} \ -+#define GNU_USER_TARGET_LINK_SPEC "-m %(link_emulation) --as-needed %{shared:-shared} \ - %{!shared: \ - %{!static: \ - %{!static-pie: \ -Index: b/gcc/config/alpha/linux-elf.h -=================================================================== ---- a/gcc/config/alpha/linux-elf.h -+++ b/gcc/config/alpha/linux-elf.h -@@ -37,7 +37,7 @@ along with GCC; see the file COPYING3. - - #define ELF_DYNAMIC_LINKER GNU_USER_DYNAMIC_LINKER +diff --git a/gcc/config/s390/linux.h b/gcc/config/s390/linux.h +index daa48fdfc2b..2fcfc5d770f 100644 +--- a/gcc/config/s390/linux.h ++++ b/gcc/config/s390/linux.h +@@ -82,7 +82,7 @@ along with GCC; see the file COPYING3. If not see --#define LINK_SPEC "-m elf64alpha %{G*} %{relax:-relax} \ -+#define LINK_SPEC "-m elf64alpha --as-needed %{G*} %{relax:-relax} \ - %{O*:-O3} %{!O*:-O1} \ - %{shared:-shared} \ - %{!shared: \ -Index: b/gcc/config/arm/linux-elf.h -=================================================================== ---- a/gcc/config/arm/linux-elf.h -+++ b/gcc/config/arm/linux-elf.h -@@ -70,6 +70,7 @@ - %{rdynamic:-export-dynamic} \ - %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \ - -X \ -+ --as-needed \ - %{mbig-endian:-EB} %{mlittle-endian:-EL}" \ - SUBTARGET_EXTRA_LINK_SPEC + #undef LINK_SPEC + #define LINK_SPEC \ +- "%{m31:-m elf_s390}%{m64:-m elf64_s390} \ ++ "%{m31:-m elf_s390}%{m64:-m elf64_s390} --as-needed \ + %{shared:-shared} \ + %{!shared: \ + %{static:-static} \ +diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h +index 2550d7ee8f0..7596d0b2757 100644 +--- a/gcc/config/sparc/linux.h ++++ b/gcc/config/sparc/linux.h +@@ -81,7 +81,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); + #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" -Index: b/gcc/config/mips/gnu-user.h -=================================================================== ---- a/gcc/config/mips/gnu-user.h -+++ b/gcc/config/mips/gnu-user.h -@@ -55,6 +55,7 @@ along with GCC; see the file COPYING3. - #undef GNU_USER_TARGET_LINK_SPEC - #define GNU_USER_TARGET_LINK_SPEC "\ - %{G*} %{EB} %{EL} %{mips*} %{shared} \ -+ -as-needed \ + #undef LINK_SPEC +-#define LINK_SPEC "-m elf32_sparc %{shared:-shared} \ ++#define LINK_SPEC "-m elf32_sparc --as-needed %{shared:-shared} \ + %{!mno-relax:%{!r:-relax}} \ %{!shared: \ %{!static: \ - %{rdynamic:-export-dynamic} \ -Index: b/gcc/config/riscv/linux.h -=================================================================== ---- a/gcc/config/riscv/linux.h -+++ b/gcc/config/riscv/linux.h -@@ -50,6 +50,7 @@ - #define CPP_SPEC "%{pthread:-D_REENTRANT}" - - #define LINK_SPEC "\ -+-as-needed \ - -melf" XLEN_SPEC "lriscv \ - %{mno-relax:--no-relax} \ - %{shared} \ +diff --git a/gcc/gcc.c b/gcc/gcc.c +index faf9ce76b3d..1ad5da6d769 100644 +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -737,8 +737,11 @@ proper position among the other output files. */ + #ifdef LIBASAN_EARLY_SPEC + #define LIBASAN_SPEC STATIC_LIBASAN_LIBS + #elif defined(HAVE_LD_STATIC_DYNAMIC) +-#define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION \ +- "} -lasan %{static-libasan:" LD_DYNAMIC_OPTION "}" \ ++#define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION "}" \ ++ " %{!static-libasan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ ++ " -lasan " \ ++ " %{static-libasan:" LD_DYNAMIC_OPTION "}" \ ++ " %{!static-libasan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ + STATIC_LIBASAN_LIBS + #else + #define LIBASAN_SPEC "-lasan" STATIC_LIBASAN_LIBS +@@ -773,8 +776,11 @@ proper position among the other output files. */ + #ifdef LIBTSAN_EARLY_SPEC + #define LIBTSAN_SPEC STATIC_LIBTSAN_LIBS + #elif defined(HAVE_LD_STATIC_DYNAMIC) +-#define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION \ +- "} -ltsan %{static-libtsan:" LD_DYNAMIC_OPTION "}" \ ++#define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION "}" \ ++ " %{!static-libtsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ ++ " -ltsan " \ ++ " %{static-libtsan:" LD_DYNAMIC_OPTION "}" \ ++ " %{!static-libtsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ + STATIC_LIBTSAN_LIBS + #else + #define LIBTSAN_SPEC "-ltsan" STATIC_LIBTSAN_LIBS +@@ -791,8 +797,11 @@ proper position among the other output files. */ + #ifdef LIBLSAN_EARLY_SPEC + #define LIBLSAN_SPEC STATIC_LIBLSAN_LIBS + #elif defined(HAVE_LD_STATIC_DYNAMIC) +-#define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION \ +- "} -llsan %{static-liblsan:" LD_DYNAMIC_OPTION "}" \ ++#define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION "}" \ ++ " %{!static-liblsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ ++ " -llsan " \ ++ " %{static-liblsan:" LD_DYNAMIC_OPTION "}" \ ++ " %{!static-liblsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ + STATIC_LIBLSAN_LIBS + #else + #define LIBLSAN_SPEC "-llsan" STATIC_LIBLSAN_LIBS +@@ -807,8 +816,11 @@ proper position among the other output files. */ + #define STATIC_LIBUBSAN_LIBS \ + " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}" + #ifdef HAVE_LD_STATIC_DYNAMIC +-#define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION \ +- "} -lubsan %{static-libubsan:" LD_DYNAMIC_OPTION "}" \ ++#define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION "}" \ ++ " %{!static-libubsan:%{!fuse-ld=gold:--push-state }--no-as-needed}" \ ++ " -lubsan " \ ++ " %{static-libubsan:" LD_DYNAMIC_OPTION "}" \ ++ " %{!static-libubsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \ + STATIC_LIBUBSAN_LIBS + #else + #define LIBUBSAN_SPEC "-lubsan" STATIC_LIBUBSAN_LIBS +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/011_all_default-warn-format-security.patch b/cross-images/mini-aports/main/gcc/0006-Enable-Wformat-and-Wformat-security-by-default.patch similarity index 50% rename from cross-images/mini-aports/main/gcc/011_all_default-warn-format-security.patch rename to cross-images/mini-aports/main/gcc/0006-Enable-Wformat-and-Wformat-security-by-default.patch index f809abd..7a1a71f 100644 --- a/cross-images/mini-aports/main/gcc/011_all_default-warn-format-security.patch +++ b/cross-images/mini-aports/main/gcc/0006-Enable-Wformat-and-Wformat-security-by-default.patch @@ -1,9 +1,18 @@ -Enable -Wformat and -Wformat-security by default. +From 85e12e3d32a44c3fd10b5327edd542972a179eec Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:47:43 +0000 +Subject: [PATCH] Enable -Wformat and -Wformat-security by default. ---- a/gcc/c-family/c.opt 2016-03-23 18:51:56.000000000 +0100 -+++ b/gcc/c-family/c.opt 2016-04-28 23:45:54.063351272 +0200 -@@ -459,7 +459,7 @@ C ObjC C++ ObjC++ Var(warn_format_nonlit - Warn about format strings that are not literals. +--- + gcc/c-family/c.opt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt +index 2005b783c68..c5c6af427cc 100644 +--- a/gcc/c-family/c.opt ++++ b/gcc/c-family/c.opt +@@ -637,7 +637,7 @@ Warn about function calls with format strings that write past the end + of the destination region. Same as -Wformat-overflow=1. Wformat-security -C ObjC C++ ObjC++ Var(warn_format_security) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 2, 0) @@ -11,7 +20,7 @@ Enable -Wformat and -Wformat-security by default. Warn about possible security problems with format functions. Wformat-signedness -@@ -475,7 +475,7 @@ C ObjC C++ ObjC++ Var(warn_format_zero_l +@@ -658,7 +658,7 @@ C ObjC C++ ObjC++ Var(warn_format_zero_length) Warning LangEnabledBy(C ObjC C++ Warn about zero-length formats. Wformat= @@ -19,4 +28,7 @@ Enable -Wformat and -Wformat-security by default. +C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format) Init(1) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0) IntegerRange(0, 2) Warn about printf/scanf/strftime/strfmon format string anomalies. - Wignored-qualifiers + Wformat-overflow= +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0007-Enable-Wtrampolines-by-default.patch b/cross-images/mini-aports/main/gcc/0007-Enable-Wtrampolines-by-default.patch new file mode 100644 index 0000000..98397fa --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0007-Enable-Wtrampolines-by-default.patch @@ -0,0 +1,25 @@ +From f1e92f5f3576779776c9f3d6aeef76e1569e719a Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:48:24 +0000 +Subject: [PATCH] Enable -Wtrampolines by default. + +--- + gcc/common.opt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gcc/common.opt b/gcc/common.opt +index d15105a73f3..29f9504cb68 100644 +--- a/gcc/common.opt ++++ b/gcc/common.opt +@@ -775,7 +775,7 @@ Common Var(warn_system_headers) Warning + Do not suppress warnings from system headers. + + Wtrampolines +-Common Var(warn_trampolines) Warning ++Common Var(warn_trampolines) Init(1) Warning + Warn whenever a trampoline is generated. + + Wtype-limits +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch b/cross-images/mini-aports/main/gcc/0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch new file mode 100644 index 0000000..cfd18dc --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch @@ -0,0 +1,53 @@ +From 3503fd734a33b67ec6a9fdc2c52bb8310864b119 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:49:40 +0000 +Subject: [PATCH] Disable ssp on -nostdlib, -nodefaultlibs and -ffreestanding + Change the buffer size. + +--- + gcc/gcc.c | 8 +++++++- + gcc/params.opt | 2 +- + 2 files changed, 8 insertions(+), 2 deletions(-) + +diff --git a/gcc/gcc.c b/gcc/gcc.c +index 1ad5da6d769..99314032ec2 100644 +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -989,6 +989,12 @@ proper position among the other output files. */ + #define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}" + #endif + ++#ifdef ENABLE_DEFAULT_SSP ++#define NO_SSP_SPEC "%{nostdlib|nodefaultlibs|ffreestanding:-fno-stack-protector} " ++#else ++#define NO_SSP_SPEC "" ++#endif ++ + #ifndef LINK_SSP_SPEC + #ifdef TARGET_LIBC_PROVIDES_SSP + #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ +@@ -1288,7 +1294,7 @@ static const char *cc1_options = + %{-version:--version}\ + %{-help=*:--help=%*}\ + %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\ +- %{fsyntax-only:-o %j} %{-param*}\ ++ %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\ + %{coverage:-fprofile-arcs -ftest-coverage}\ + %{fprofile-arcs|fprofile-generate*|coverage:\ + %{!fprofile-update=single:\ +diff --git a/gcc/params.opt b/gcc/params.opt +index 8ba281b4cfa..bab39cdf8a2 100644 +--- a/gcc/params.opt ++++ b/gcc/params.opt +@@ -946,7 +946,7 @@ Common Joined UInteger Var(param_ssa_name_def_chain_limit) Init(512) Param Optim + The maximum number of SSA_NAME assignments to follow in determining a value. + + -param=ssp-buffer-size= +-Common Joined UInteger Var(param_ssp_buffer_size) Init(8) IntegerRange(1, 65536) Param Optimization ++Common Joined UInteger Var(param_ssp_buffer_size) Init(4) IntegerRange(1, 65536) Param Optimization + The lower bound for a buffer to be considered for stack smashing protection. + + -param=stack-clash-protection-guard-size= +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0008-s390x-muslldso.patch b/cross-images/mini-aports/main/gcc/0008-s390x-muslldso.patch deleted file mode 100644 index 64833f3..0000000 --- a/cross-images/mini-aports/main/gcc/0008-s390x-muslldso.patch +++ /dev/null @@ -1,26 +0,0 @@ -From b693804c8dba92fea7beee98f0aa520853a0532b Mon Sep 17 00:00:00 2001 -From: Szabolcs Nagy -Date: Thu, 22 Dec 2016 11:22:28 +0000 -Subject: [PATCH 08/12] s390x muslldso - ---- - gcc/config/s390/linux.h | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/gcc/config/s390/linux.h b/gcc/config/s390/linux.h -index 525c17c2c9f..2d4f4a0654e 100644 ---- a/gcc/config/s390/linux.h -+++ b/gcc/config/s390/linux.h -@@ -76,6 +76,9 @@ along with GCC; see the file COPYING3. If not see - #define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1" - #define GLIBC_DYNAMIC_LINKER64 "/lib/ld64.so.1" - -+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-s390.so.1" -+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-s390x.so.1" -+ - #undef LINK_SPEC - #define LINK_SPEC \ - "%{m31:-m elf_s390}%{m64:-m elf64_s390} \ --- -2.17.1 - diff --git a/cross-images/mini-aports/main/gcc/020_all_msgfmt-libstdc++-link.patch b/cross-images/mini-aports/main/gcc/0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch similarity index 55% rename from cross-images/mini-aports/main/gcc/020_all_msgfmt-libstdc++-link.patch rename to cross-images/mini-aports/main/gcc/0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch index a70ea50..390598e 100644 --- a/cross-images/mini-aports/main/gcc/020_all_msgfmt-libstdc++-link.patch +++ b/cross-images/mini-aports/main/gcc/0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch @@ -1,4 +1,8 @@ -Ensure that msgfmt doesn't encounter problems during gcc bootstrapping. +From c4dd51fe15a938fdd76d781a4eede2a9205eacbc Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:50:33 +0000 +Subject: [PATCH] Ensure that msgfmt doesn't encounter problems during gcc + bootstrapping. Solves error messages like the following: @@ -16,10 +20,16 @@ library path, will make it work as expected here. References: https://bugs.gentoo.org/372377 https://bugs.gentoo.org/295480 +--- + libstdc++-v3/po/Makefile.am | 1 + + libstdc++-v3/po/Makefile.in | 1 + + 2 files changed, 2 insertions(+) ---- gcc-4.1.2.orig/libstdc++-v3/po/Makefile.am -+++ gcc-4.1.2/libstdc++-v3/po/Makefile.am -@@ -39,6 +39,7 @@ MSGFMT = msgfmt +diff --git a/libstdc++-v3/po/Makefile.am b/libstdc++-v3/po/Makefile.am +index ab716ff04ea..e595268d9fc 100644 +--- a/libstdc++-v3/po/Makefile.am ++++ b/libstdc++-v3/po/Makefile.am +@@ -38,6 +38,7 @@ MSGFMT = msgfmt EXTRA_DIST = string_literals.cc POTFILES.in $(PACKAGE).pot $(LOCALE_IN) .po.mo: @@ -27,9 +37,11 @@ https://bugs.gentoo.org/295480 $(MSGFMT) -o $@ $< all-local: all-local-$(USE_NLS) ---- gcc-4.1.2.orig/libstdc++-v3/po/Makefile.in -+++ gcc-4.1.2/libstdc++-v3/po/Makefile.in -@@ -419,6 +419,7 @@ uninstall-am: uninstall-info-am +diff --git a/libstdc++-v3/po/Makefile.in b/libstdc++-v3/po/Makefile.in +index 8edd2e05639..63f61fcf96f 100644 +--- a/libstdc++-v3/po/Makefile.in ++++ b/libstdc++-v3/po/Makefile.in +@@ -553,6 +553,7 @@ uninstall-am: .po.mo: @@ -37,3 +49,6 @@ https://bugs.gentoo.org/295480 $(MSGFMT) -o $@ $< all-local: all-local-$(USE_NLS) +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch b/cross-images/mini-aports/main/gcc/0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch new file mode 100644 index 0000000..ba0b8ca --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch @@ -0,0 +1,28 @@ +From 0a1fd78184f00fb77dac00dabe98eb025620efc2 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:52:07 +0000 +Subject: [PATCH] Don't declare asprintf if defined as a macro. + +--- + include/libiberty.h | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/include/libiberty.h b/include/libiberty.h +index f4c0fe11d6f..cf4b1043e4d 100644 +--- a/include/libiberty.h ++++ b/include/libiberty.h +@@ -652,8 +652,11 @@ extern void *bsearch_r (const void *, const void *, + /* Like sprintf but provides a pointer to malloc'd storage, which must + be freed by the caller. */ + ++/* asprintf may be declared as a macro by glibc with __USE_FORTIFY_LEVEL. */ ++#ifndef asprintf + extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2; + #endif ++#endif + + /* Like asprintf but allocates memory without fail. This works like + xmalloc. */ +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0010-ldbl128-config.patch b/cross-images/mini-aports/main/gcc/0010-ldbl128-config.patch deleted file mode 100644 index b5a1010..0000000 --- a/cross-images/mini-aports/main/gcc/0010-ldbl128-config.patch +++ /dev/null @@ -1,76 +0,0 @@ -From 47467f3ab0fb2f2fcede81060fe8bb339d0909eb Mon Sep 17 00:00:00 2001 -From: Szabolcs Nagy -Date: Wed, 28 Feb 2018 00:54:05 +0000 -Subject: [PATCH 10/12] ldbl128 config - ---- - gcc/configure | 13 +++++++++++++ - gcc/configure.ac | 16 ++++++++++++++-- - 2 files changed, 27 insertions(+), 2 deletions(-) - -diff --git a/gcc/configure b/gcc/configure -index 6121e163259..07ff8597d48 100755 ---- a/gcc/configure -+++ b/gcc/configure -@@ -29309,6 +29309,15 @@ if test "${with_long_double_128+set}" = set; then : - withval=$with_long_double_128; gcc_cv_target_ldbl128="$with_long_double_128" - else - -+ case "$target" in -+ s390*-*-linux-musl*) -+ gcc_cv_target_ldbl128=yes -+ ;; -+ powerpc*-*-linux-musl*) -+ gcc_cv_target_ldbl128=no -+ ;; -+ *) -+ - if test $glibc_version_major -gt 2 \ - || ( test $glibc_version_major -eq 2 && test $glibc_version_minor -ge 4 ); then : - gcc_cv_target_ldbl128=yes -@@ -29320,6 +29329,10 @@ else - && gcc_cv_target_ldbl128=yes - - fi -+ -+ ;; -+ esac -+ - fi - - ;; -diff --git a/gcc/configure.ac b/gcc/configure.ac -index b066cc609e1..6c15ed898c0 100644 ---- a/gcc/configure.ac -+++ b/gcc/configure.ac -@@ -5971,13 +5971,25 @@ case "$target" in - AC_ARG_WITH(long-double-128, - [AS_HELP_STRING([--with-long-double-128], - [use 128-bit long double by default])], -- gcc_cv_target_ldbl128="$with_long_double_128", -+ gcc_cv_target_ldbl128="$with_long_double_128", [ -+ case "$target" in -+ s390*-*-linux-musl*) -+ gcc_cv_target_ldbl128=yes -+ ;; -+ powerpc*-*-linux-musl*) -+ gcc_cv_target_ldbl128=no -+ ;; -+ *)] - [GCC_GLIBC_VERSION_GTE_IFELSE([2], [4], [gcc_cv_target_ldbl128=yes], [ - [gcc_cv_target_ldbl128=no - grep '^[ ]*#[ ]*define[ ][ ]*__LONG_DOUBLE_MATH_OPTIONAL' \ - $target_header_dir/bits/wordsize.h > /dev/null 2>&1 \ - && gcc_cv_target_ldbl128=yes -- ]])]) -+ ]])] -+ [ -+ ;; -+ esac -+ ]) - ;; - esac - if test x$gcc_cv_target_ldbl128 = xyes; then --- -2.17.1 - diff --git a/cross-images/mini-aports/main/gcc/0011-libiberty-copy-PIC-objects-during-build-process.patch b/cross-images/mini-aports/main/gcc/0011-libiberty-copy-PIC-objects-during-build-process.patch new file mode 100644 index 0000000..a8e5cd3 --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0011-libiberty-copy-PIC-objects-during-build-process.patch @@ -0,0 +1,24 @@ +From f81d67f6fe1f1066642606209c882b333d937cb7 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:53:00 +0000 +Subject: [PATCH] libiberty: copy PIC objects during build process + +--- + libiberty/Makefile.in | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in +index 4f1213b983b..d0224649d30 100644 +--- a/libiberty/Makefile.in ++++ b/libiberty/Makefile.in +@@ -264,6 +264,7 @@ $(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS) + $(AR) $(AR_FLAGS) $(TARGETLIB) \ + $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS); \ + $(RANLIB) $(TARGETLIB); \ ++ cp $(TARGETLIB) ../ ; \ + cd ..; \ + else true; fi + +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/053_all_libitm-no-fortify-source.patch b/cross-images/mini-aports/main/gcc/0012-libitm-disable-FORTIFY.patch similarity index 54% rename from cross-images/mini-aports/main/gcc/053_all_libitm-no-fortify-source.patch rename to cross-images/mini-aports/main/gcc/0012-libitm-disable-FORTIFY.patch index 5ab15af..ba14aa4 100644 --- a/cross-images/mini-aports/main/gcc/053_all_libitm-no-fortify-source.patch +++ b/cross-images/mini-aports/main/gcc/0012-libitm-disable-FORTIFY.patch @@ -1,14 +1,17 @@ -https://bugs.gentoo.org/508852 -https://gcc.gnu.org/PR61164 +From 3b732288ce771348cbcc9fb633a36b7aff2b4ad4 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:53:36 +0000 +Subject: [PATCH] libitm: disable FORTIFY -2014-04-27 Magnus Granberg - - #508852 - * libitm/configure.tgt: Disable FORTIFY +--- + libitm/configure.tgt | 10 ++++++++++ + 1 file changed, 10 insertions(+) +diff --git a/libitm/configure.tgt b/libitm/configure.tgt +index a3d84896cc5..ecb281d5919 100644 --- a/libitm/configure.tgt +++ b/libitm/configure.tgt -@@ -43,6 +43,16 @@ if test "$gcc_cv_have_tls" = yes ; then +@@ -47,6 +47,16 @@ if test "$gcc_cv_have_tls" = yes ; then esac fi @@ -25,3 +28,6 @@ https://gcc.gnu.org/PR61164 # Map the target cpu to an ARCH sub-directory. At the same time, # work out any special compilation flags as necessary. case "${target_cpu}" in +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0012-static-pie.patch b/cross-images/mini-aports/main/gcc/0012-static-pie.patch deleted file mode 100644 index 03a4f68..0000000 --- a/cross-images/mini-aports/main/gcc/0012-static-pie.patch +++ /dev/null @@ -1,138 +0,0 @@ -From a4aa319f7c19e564dced3daeb7222c9315af936c Mon Sep 17 00:00:00 2001 -From: Szabolcs Nagy -Date: Sat, 18 Aug 2018 23:58:45 +0000 -Subject: [PATCH 12/12] static-pie - -in gcc-8 -static means static non-pie, even if -pie or -static-pie -are specified, -static-pie can be used to build static pie. - -in musl toolchains -static -pie always meant static pie, so this -patch fixes the link specs accordingly, the new -static-pie is just -an alias to -static -pie. ---- - gcc/common.opt | 4 ++-- - gcc/config/gnu-user.h | 12 +++++------- - gcc/config/rs6000/sysv4.h | 11 +++++------ - gcc/gcc.c | 6 +++--- - 4 files changed, 15 insertions(+), 18 deletions(-) - -diff --git a/gcc/common.opt b/gcc/common.opt -index b52ef0b38c8..0ce5857e01d 100644 ---- a/gcc/common.opt -+++ b/gcc/common.opt -@@ -3197,11 +3197,11 @@ Driver - - no-pie - Driver RejectNegative Negative(shared) --Don't create a dynamically linked position independent executable. -+Don't create a position independent executable. - - pie - Driver RejectNegative Negative(no-pie) --Create a dynamically linked position independent executable. -+Create a position independent executable. - - static-pie - Driver RejectNegative Negative(pie) -diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h -index 8620de3e42d..235328a2642 100644 ---- a/gcc/config/gnu-user.h -+++ b/gcc/config/gnu-user.h -@@ -52,13 +52,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see - #define GNU_USER_TARGET_STARTFILE_SPEC \ - "%{shared:; \ - pg|p|profile:%{static-pie:grcrt1.o%s;:gcrt1.o%s}; \ -- static:crt1.o%s; \ -- static-pie:rcrt1.o%s; \ -+ static|static-pie:%{" PIE_SPEC ":rcrt1.o%s;:crt1.o%s}; \ - " PIE_SPEC ":Scrt1.o%s; \ - :crt1.o%s} \ - crti.o%s \ -- %{static:crtbeginT.o%s; \ -- shared|static-pie|" PIE_SPEC ":crtbeginS.o%s; \ -+ %{shared|" PIE_SPEC ":crtbeginS.o%s; \ -+ static:crtbeginT.o%s; \ - :crtbegin.o%s} \ - %{fvtable-verify=none:%s; \ - fvtable-verify=preinit:vtv_start_preinit.o%s; \ -@@ -92,8 +91,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see - "%{fvtable-verify=none:%s; \ - fvtable-verify=preinit:vtv_end_preinit.o%s; \ - fvtable-verify=std:vtv_end.o%s} \ -- %{static:crtend.o%s; \ -- shared|static-pie|" PIE_SPEC ":crtendS.o%s; \ -+ %{shared|" PIE_SPEC ":crtendS.o%s; \ - :crtend.o%s} \ - crtn.o%s \ - " CRTOFFLOADEND -@@ -133,7 +131,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see - #define LIB_SPEC GNU_USER_TARGET_LIB_SPEC - - #if defined(HAVE_LD_EH_FRAME_HDR) --#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} " -+#define LINK_EH_SPEC "%{!static|" PIE_SPEC ":--eh-frame-hdr} " - #endif - - #undef LINK_GCC_C_SEQUENCE_SPEC -diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h -index bb19d0dcd41..bb2a2324eb0 100644 ---- a/gcc/config/rs6000/sysv4.h -+++ b/gcc/config/rs6000/sysv4.h -@@ -763,12 +763,12 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN) - #define STARTFILE_LINUX_SPEC \ - "%{shared:; \ - pg|p|profile:gcrt1.o%s; \ -- static:crt1.o%s; \ -- static-pie|" PIE_SPEC ":Scrt1.o%s; \ -+ static|static-pie:%{" PIE_SPEC ":rcrt1.o%s;:crt1.o%s}; \ -+ " PIE_SPEC ":Scrt1.o%s; \ - :crt1.o%s} \ - %{mnewlib:ecrti.o%s;:crti.o%s} \ -- %{static:crtbeginT.o%s; \ -- shared|static-pie|" PIE_SPEC ":crtbeginS.o%s; \ -+ %{shared|" PIE_SPEC ":crtbeginS.o%s; \ -+ static:crtbeginT.o%s; \ - :crtbegin.o%s} \ - %{fvtable-verify=none:%s; \ - fvtable-verify=preinit:vtv_start_preinit.o%s; \ -@@ -781,8 +781,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN) - "%{fvtable-verify=none:%s; \ - fvtable-verify=preinit:vtv_end_preinit.o%s; \ - fvtable-verify=std:vtv_end.o%s} \ -- %{static:crtend.o%s; \ -- shared|static-pie|" PIE_SPEC ":crtendS.o%s; \ -+ %{shared|" PIE_SPEC ":crtendS.o%s; \ - :crtend.o%s} \ - %{mnewlib:ecrtn.o%s;:crtn.o%s} \ - " CRTOFFLOADEND -diff --git a/gcc/gcc.c b/gcc/gcc.c -index eb1610ba8b0..87560afb03c 100644 ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -900,7 +900,7 @@ proper position among the other output files. */ - #define NO_FPIE_AND_FPIC_SPEC NO_FPIE_SPEC "|" NO_FPIC_SPEC - #define FPIE_OR_FPIC_SPEC NO_FPIE_AND_FPIC_SPEC ":;" - #else --#define PIE_SPEC "pie" -+#define PIE_SPEC "pie|static-pie" - #define FPIE1_SPEC "fpie" - #define NO_FPIE1_SPEC FPIE1_SPEC ":;" - #define FPIE2_SPEC "fPIE" -@@ -924,12 +924,12 @@ proper position among the other output files. */ - #ifndef LINK_PIE_SPEC - #ifdef HAVE_LD_PIE - #ifndef LD_PIE_SPEC --#define LD_PIE_SPEC "-pie" -+#define LD_PIE_SPEC "-pie %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic}" - #endif - #else - #define LD_PIE_SPEC "" - #endif --#define LINK_PIE_SPEC "%{static|shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} " -+#define LINK_PIE_SPEC "%{shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} " - #endif - - #ifndef LINK_BUILDID_SPEC --- -2.17.1 - diff --git a/cross-images/mini-aports/main/gcc/203-libgcc_s.patch b/cross-images/mini-aports/main/gcc/0013-libgcc_s.patch similarity index 71% rename from cross-images/mini-aports/main/gcc/203-libgcc_s.patch rename to cross-images/mini-aports/main/gcc/0013-libgcc_s.patch index f8cab7d..54de72b 100644 --- a/cross-images/mini-aports/main/gcc/203-libgcc_s.patch +++ b/cross-images/mini-aports/main/gcc/0013-libgcc_s.patch @@ -1,19 +1,19 @@ -From 9e3eab51e518018d9d99b3123598b1e2322a6af3 Mon Sep 17 00:00:00 2001 +From a3e556187d0a8e9d39544f023960eca0f07d3e83 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Sat, 24 Oct 2015 20:09:53 +0000 -Subject: [PATCH 3/6] libgcc_s +Subject: [PATCH] libgcc_s --- - gcc/config/i386/i386.c | 4 ++-- - libgcc/config/i386/cpuinfo.c | 6 +++--- - libgcc/config/i386/t-linux | 2 +- + 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.c b/gcc/config/i386/i386.c -index 3d044e8..82523e1 100644 ---- a/gcc/config/i386/i386.c -+++ b/gcc/config/i386/i386.c -@@ -40269,10 +40269,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget, +diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c +index 1772fb16c9a..77e04b0c2df 100644 +--- a/gcc/config/i386/i386-expand.c ++++ b/gcc/config/i386/i386-expand.c +@@ -11066,10 +11066,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget, { case IX86_BUILTIN_CPU_INIT: { @@ -27,11 +27,11 @@ index 3d044e8..82523e1 100644 return expand_expr (call_expr, target, mode, EXPAND_NORMAL); } diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c -index 8c2248d..6c82f15 100644 +index ef463848f9d..1a3de052c80 100644 --- a/libgcc/config/i386/cpuinfo.c +++ b/libgcc/config/i386/cpuinfo.c -@@ -485,7 +485,7 @@ __cpu_indicator_init (void) - return 0; +@@ -63,7 +63,7 @@ __cpu_indicator_init (void) + __cpu_features2); } -#if defined SHARED && defined USE_ELF_SYMVER @@ -42,7 +42,7 @@ index 8c2248d..6c82f15 100644 + __attribute__ ((weak, alias ("__cpu_indicator_init"))); #endif diff --git a/libgcc/config/i386/t-linux b/libgcc/config/i386/t-linux -index 11bb46e..4f47f7b 100644 +index 8506a635790..564296f788e 100644 --- a/libgcc/config/i386/t-linux +++ b/libgcc/config/i386/t-linux @@ -3,5 +3,5 @@ @@ -53,5 +53,5 @@ index 11bb46e..4f47f7b 100644 +HOST_LIBGCC2_CFLAGS += -mlong-double-80 $(CET_FLAGS) CRTSTUFF_T_CFLAGS += $(CET_FLAGS) -- -2.8.1 +2.35.1 diff --git a/cross-images/mini-aports/main/gcc/205-nopie.patch b/cross-images/mini-aports/main/gcc/0014-nopie.patch similarity index 87% rename from cross-images/mini-aports/main/gcc/205-nopie.patch rename to cross-images/mini-aports/main/gcc/0014-nopie.patch index e3da94d..eafc9e0 100644 --- a/cross-images/mini-aports/main/gcc/205-nopie.patch +++ b/cross-images/mini-aports/main/gcc/0014-nopie.patch @@ -1,7 +1,7 @@ -From b6015aca9c9cc83739fd0ed637a835119b2c4e34 Mon Sep 17 00:00:00 2001 +From f520e67fba621f213146271408ff3210b3527176 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Sat, 7 Nov 2015 02:08:05 +0000 -Subject: [PATCH 5/6] nopie +Subject: [PATCH] nopie --- gcc/configure | 27 +++++++++++++++++++++++++++ @@ -9,10 +9,10 @@ Subject: [PATCH 5/6] nopie 2 files changed, 40 insertions(+) diff --git a/gcc/configure b/gcc/configure -index 1c6e340..7e8b5d6 100755 +index 4b977e313b5..592e81e40f6 100755 --- a/gcc/configure +++ b/gcc/configure -@@ -29390,6 +29390,33 @@ fi +@@ -32300,6 +32300,33 @@ fi $as_echo "$gcc_cv_no_pie" >&6; } if test "$gcc_cv_no_pie" = "yes"; then NO_PIE_FLAG="-no-pie" @@ -47,10 +47,10 @@ index 1c6e340..7e8b5d6 100755 diff --git a/gcc/configure.ac b/gcc/configure.ac -index 6c1dcd9..0ca7647 100644 +index 5461bab88a9..1577529ffb7 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac -@@ -6098,6 +6098,19 @@ AC_CACHE_CHECK([for -no-pie option], +@@ -7571,6 +7571,19 @@ AC_CACHE_CHECK([for -no-pie option], LDFLAGS="$saved_LDFLAGS"]) if test "$gcc_cv_no_pie" = "yes"; then NO_PIE_FLAG="-no-pie" @@ -71,5 +71,5 @@ index 6c1dcd9..0ca7647 100644 AC_SUBST([NO_PIE_FLAG]) -- -2.8.1 +2.35.1 diff --git a/cross-images/mini-aports/main/gcc/0015-libffi-use-__linux__-instead-of-__gnu_linux__-for-mu.patch b/cross-images/mini-aports/main/gcc/0015-libffi-use-__linux__-instead-of-__gnu_linux__-for-mu.patch new file mode 100644 index 0000000..992058d --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0015-libffi-use-__linux__-instead-of-__gnu_linux__-for-mu.patch @@ -0,0 +1,25 @@ +From 37310cabb8bc7256899c4d45cc68a47ca2a3232b Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:57:09 +0000 +Subject: [PATCH] libffi: use __linux__ instead of __gnu_linux__ for musl + +--- + libffi/src/closures.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libffi/src/closures.c b/libffi/src/closures.c +index 721ff00ea43..22a699c6340 100644 +--- a/libffi/src/closures.c ++++ b/libffi/src/closures.c +@@ -34,7 +34,7 @@ + #include + + #if !FFI_MMAP_EXEC_WRIT && !FFI_EXEC_TRAMPOLINE_TABLE +-# if __gnu_linux__ && !defined(__ANDROID__) ++# if __linux__ && !defined(__ANDROID__) + /* This macro indicates it may be forbidden to map anonymous memory + with both write and execute permission. Code compiled when this + option is defined will attempt to map such pages once, but if it +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0016-dlang-update-zlib-binding.patch b/cross-images/mini-aports/main/gcc/0016-dlang-update-zlib-binding.patch new file mode 100644 index 0000000..77d02b2 --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0016-dlang-update-zlib-binding.patch @@ -0,0 +1,425 @@ +From 586e82425a024d85d1bd9952ca51d8a671aa9b5d Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:57:51 +0000 +Subject: [PATCH] dlang: update zlib binding + +--- + libphobos/src/std/zlib.d | 266 ++++++++++++++++++++++++++++----------- + 1 file changed, 196 insertions(+), 70 deletions(-) + +diff --git a/libphobos/src/std/zlib.d b/libphobos/src/std/zlib.d +index e6cce240fd5..bd2fe37ebec 100644 +--- a/libphobos/src/std/zlib.d ++++ b/libphobos/src/std/zlib.d +@@ -1,7 +1,7 @@ + // Written in the D programming language. + + /** +- * Compress/decompress data using the $(HTTP www._zlib.net, _zlib library). ++ * Compress/decompress data using the $(HTTP www.zlib.net, zlib library). + * + * Examples: + * +@@ -43,12 +43,12 @@ + * References: + * $(HTTP en.wikipedia.org/wiki/Zlib, Wikipedia) + * +- * Copyright: Copyright Digital Mars 2000 - 2011. ++ * Copyright: Copyright The D Language Foundation 2000 - 2011. + * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). + * Authors: $(HTTP digitalmars.com, Walter Bright) +- * Source: $(PHOBOSSRC std/_zlib.d) ++ * Source: $(PHOBOSSRC std/zlib.d) + */ +-/* Copyright Digital Mars 2000 - 2011. ++/* Copyright The D Language Foundation 2000 - 2011. + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) +@@ -75,9 +75,9 @@ enum + + class ZlibException : Exception + { +- this(int errnum) +- { string msg; +- ++ private static string getmsg(int errnum) nothrow @nogc pure @safe ++ { ++ string msg; + switch (errnum) + { + case Z_STREAM_END: msg = "stream end"; break; +@@ -90,7 +90,12 @@ class ZlibException : Exception + case Z_VERSION_ERROR: msg = "version error"; break; + default: msg = "unknown error"; break; + } +- super(msg); ++ return msg; ++ } ++ ++ this(int errnum) ++ { ++ super(getmsg(errnum)); + } + } + +@@ -104,7 +109,7 @@ class ZlibException : Exception + * buf = buffer containing input data + * + * Returns: +- * A $(D uint) checksum for the provided input data and starting checksum ++ * A `uint` checksum for the provided input data and starting checksum + * + * See_Also: + * $(LINK http://en.wikipedia.org/wiki/Adler-32) +@@ -147,7 +152,7 @@ uint adler32(uint adler, const(void)[] buf) + * buf = buffer containing input data + * + * Returns: +- * A $(D uint) checksum for the provided input data and starting checksum ++ * A `uint` checksum for the provided input data and starting checksum + * + * See_Also: + * $(LINK http://en.wikipedia.org/wiki/Cyclic_redundancy_check) +@@ -191,13 +196,14 @@ uint crc32(uint crc, const(void)[] buf) + ubyte[] compress(const(void)[] srcbuf, int level) + in + { +- assert(-1 <= level && level <= 9); ++ assert(-1 <= level && level <= 9, "Compression level needs to be within [-1, 9]."); + } +-body ++do + { + import core.memory : GC; ++ import std.array : uninitializedArray; + auto destlen = srcbuf.length + ((srcbuf.length + 1023) / 1024) + 12; +- auto destbuf = new ubyte[destlen]; ++ auto destbuf = uninitializedArray!(ubyte[])(destlen); + auto err = etc.c.zlib.compress2(destbuf.ptr, &destlen, cast(ubyte *) srcbuf.ptr, srcbuf.length, level); + if (err) + { +@@ -276,7 +282,7 @@ void[] uncompress(const(void)[] srcbuf, size_t destlen = 0u, int winbits = 15) + throw new ZlibException(err); + } + } +- assert(0); ++ assert(0, "Unreachable code"); + } + + @system unittest +@@ -370,9 +376,9 @@ class Compress + this(int level, HeaderFormat header = HeaderFormat.deflate) + in + { +- assert(1 <= level && level <= 9); ++ assert(1 <= level && level <= 9, "Legal compression level are in [1, 9]."); + } +- body ++ do + { + this.level = level; + this.gzip = header == HeaderFormat.gzip; +@@ -406,6 +412,7 @@ class Compress + const(void)[] compress(const(void)[] buf) + { + import core.memory : GC; ++ import std.array : uninitializedArray; + int err; + ubyte[] destbuf; + +@@ -420,7 +427,7 @@ class Compress + inited = 1; + } + +- destbuf = new ubyte[zs.avail_in + buf.length]; ++ destbuf = uninitializedArray!(ubyte[])(zs.avail_in + buf.length); + zs.next_out = destbuf.ptr; + zs.avail_out = to!uint(destbuf.length); + +@@ -461,9 +468,10 @@ class Compress + void[] flush(int mode = Z_FINISH) + in + { +- assert(mode == Z_FINISH || mode == Z_SYNC_FLUSH || mode == Z_FULL_FLUSH); ++ assert(mode == Z_FINISH || mode == Z_SYNC_FLUSH || mode == Z_FULL_FLUSH, ++ "Mode must be either Z_FINISH, Z_SYNC_FLUSH or Z_FULL_FLUSH."); + } +- body ++ do + { + import core.memory : GC; + ubyte[] destbuf; +@@ -523,6 +531,7 @@ class UnCompress + z_stream zs; + int inited; + int done; ++ bool inputEnded; + size_t destbufsize; + + HeaderFormat format; +@@ -571,16 +580,16 @@ class UnCompress + const(void)[] uncompress(const(void)[] buf) + in + { +- assert(!done); ++ assert(!done, "Buffer has been flushed."); + } +- body ++ do + { ++ if (inputEnded || !buf.length) ++ return null; ++ + import core.memory : GC; ++ import std.array : uninitializedArray; + int err; +- ubyte[] destbuf; +- +- if (buf.length == 0) +- return null; + + if (!inited) + { +@@ -598,26 +607,152 @@ class UnCompress + + if (!destbufsize) + destbufsize = to!uint(buf.length) * 2; +- destbuf = new ubyte[zs.avail_in * 2 + destbufsize]; +- zs.next_out = destbuf.ptr; +- zs.avail_out = to!uint(destbuf.length); +- +- if (zs.avail_in) +- buf = zs.next_in[0 .. zs.avail_in] ~ cast(ubyte[]) buf; ++ auto destbuf = uninitializedArray!(ubyte[])(destbufsize); ++ size_t destFill; + + zs.next_in = cast(ubyte*) buf.ptr; + zs.avail_in = to!uint(buf.length); + +- err = inflate(&zs, Z_NO_FLUSH); +- if (err != Z_STREAM_END && err != Z_OK) ++ while (true) + { +- GC.free(destbuf.ptr); +- error(err); ++ auto oldAvailIn = zs.avail_in; ++ ++ zs.next_out = destbuf[destFill .. $].ptr; ++ zs.avail_out = to!uint(destbuf.length - destFill); ++ ++ err = inflate(&zs, Z_NO_FLUSH); ++ if (err == Z_STREAM_END) ++ { ++ inputEnded = true; ++ break; ++ } ++ else if (err != Z_OK) ++ { ++ GC.free(destbuf.ptr); ++ error(err); ++ } ++ else if (!zs.avail_in) ++ break; ++ ++ /* ++ According to the zlib manual inflate() stops when either there's ++ no more data to uncompress or the output buffer is full ++ So at this point, the output buffer is too full ++ */ ++ ++ destFill = destbuf.length; ++ ++ if (destbuf.capacity) ++ { ++ if (destbuf.length < destbuf.capacity) ++ destbuf.length = destbuf.capacity; ++ else ++ { ++ auto newLength = GC.extend(destbuf.ptr, destbufsize, destbufsize); ++ ++ if (newLength && destbuf.length < destbuf.capacity) ++ destbuf.length = destbuf.capacity; ++ else ++ destbuf.length += destbufsize; ++ } ++ } ++ else ++ destbuf.length += destbufsize; + } ++ + destbuf.length = destbuf.length - zs.avail_out; + return destbuf; + } + ++ // Test for issues 3191 and 9505 ++ @system unittest ++ { ++ import std.algorithm.comparison; ++ import std.array; ++ import std.file; ++ import std.zlib; ++ ++ // Data that can be easily compressed ++ ubyte[1024] originalData; ++ ++ // This should yield a compression ratio of at least 1/2 ++ auto compressedData = compress(originalData, 9); ++ assert(compressedData.length < originalData.length / 2, ++ "The compression ratio is too low to accurately test this situation"); ++ ++ auto chunkSize = compressedData.length / 4; ++ assert(chunkSize < compressedData.length, ++ "The length of the compressed data is too small to accurately test this situation"); ++ ++ auto decompressor = new UnCompress(); ++ ubyte[originalData.length] uncompressedData; ++ ubyte[] reusedBuf; ++ int progress; ++ ++ reusedBuf.length = chunkSize; ++ ++ for (int i = 0; i < compressedData.length; i += chunkSize) ++ { ++ auto len = min(chunkSize, compressedData.length - i); ++ // simulate reading from a stream in small chunks ++ reusedBuf[0 .. len] = compressedData[i .. i + len]; ++ ++ // decompress using same input buffer ++ auto chunk = decompressor.uncompress(reusedBuf); ++ assert(progress + chunk.length <= originalData.length, ++ "The uncompressed result is bigger than the original data"); ++ ++ uncompressedData[progress .. progress + chunk.length] = cast(const ubyte[]) chunk[]; ++ progress += chunk.length; ++ } ++ ++ auto chunk = decompressor.flush(); ++ assert(progress + chunk.length <= originalData.length, ++ "The uncompressed result is bigger than the original data"); ++ ++ uncompressedData[progress .. progress + chunk.length] = cast(const ubyte[]) chunk[]; ++ progress += chunk.length; ++ ++ assert(progress == originalData.length, ++ "The uncompressed and the original data sizes differ"); ++ assert(originalData[] == uncompressedData[], ++ "The uncompressed and the original data differ"); ++ } ++ ++ @system unittest ++ { ++ ubyte[1024] invalidData; ++ auto decompressor = new UnCompress(); ++ ++ try ++ { ++ auto uncompressedData = decompressor.uncompress(invalidData); ++ } ++ catch (ZlibException e) ++ { ++ assert(e.msg == "data error"); ++ return; ++ } ++ ++ assert(false, "Corrupted data didn't result in an error"); ++ } ++ ++ @system unittest ++ { ++ ubyte[2014] originalData = void; ++ auto compressedData = compress(originalData, 9); ++ ++ auto decompressor = new UnCompress(); ++ auto uncompressedData = decompressor.uncompress(compressedData ~ cast(ubyte[]) "whatever"); ++ ++ assert(originalData.length == uncompressedData.length, ++ "The uncompressed and the original data sizes differ"); ++ assert(originalData[] == uncompressedData[], ++ "The uncompressed and the original data differ"); ++ assert(!decompressor.uncompress("whatever").length, ++ "Compression continued after the end"); ++ } ++ + /** + * Decompress and return any remaining data. + * The returned data should be appended to that returned by uncompress(). +@@ -626,49 +761,40 @@ class UnCompress + void[] flush() + in + { +- assert(!done); ++ assert(!done, "Buffer has been flushed before."); + } + out + { +- assert(done); ++ assert(done, "Flushing failed."); + } +- body ++ do + { +- import core.memory : GC; +- ubyte[] extra; +- ubyte[] destbuf; +- int err; +- + done = 1; +- if (!inited) +- return null; ++ return null; ++ } + +- L1: +- destbuf = new ubyte[zs.avail_in * 2 + 100]; +- zs.next_out = destbuf.ptr; +- zs.avail_out = to!uint(destbuf.length); ++ /// Returns true if all input data has been decompressed and no further data ++ /// can be decompressed (inflate() returned Z_STREAM_END) ++ @property bool empty() const ++ { ++ return inputEnded; ++ } + +- err = etc.c.zlib.inflate(&zs, Z_NO_FLUSH); +- if (err == Z_OK && zs.avail_out == 0) +- { +- extra ~= destbuf; +- goto L1; +- } +- if (err != Z_STREAM_END) +- { +- GC.free(destbuf.ptr); +- if (err == Z_OK) +- err = Z_BUF_ERROR; +- error(err); +- } +- destbuf = destbuf.ptr[0 .. zs.next_out - destbuf.ptr]; +- err = etc.c.zlib.inflateEnd(&zs); +- inited = 0; +- if (err) +- error(err); +- if (extra.length) +- destbuf = extra ~ destbuf; +- return destbuf; ++ /// ++ @system unittest ++ { ++ // some random data ++ ubyte[1024] originalData = void; ++ ++ // append garbage data (or don't, this works in both cases) ++ auto compressedData = cast(ubyte[]) compress(originalData) ~ cast(ubyte[]) "whatever"; ++ ++ auto decompressor = new UnCompress(); ++ auto uncompressedData = decompressor.uncompress(compressedData); ++ ++ assert(uncompressedData[] == originalData[], ++ "The uncompressed and the original data differ"); ++ assert(decompressor.empty, "The UnCompressor reports not being done"); + } + } + +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0016-invalid_tls_model.patch b/cross-images/mini-aports/main/gcc/0016-invalid_tls_model.patch deleted file mode 100644 index 93dd7dd..0000000 --- a/cross-images/mini-aports/main/gcc/0016-invalid_tls_model.patch +++ /dev/null @@ -1,25 +0,0 @@ ---- ./libgomp/configure.tgt.orig 2018-09-25 13:44:16.654561098 -0400 -+++ ./libgomp/configure.tgt 2018-09-25 13:44:50.452688100 -0400 -@@ -10,23 +10,6 @@ - # XCFLAGS Add extra compile flags to use. - # XLDFLAGS Add extra link flags to use. - --# Optimize TLS usage by avoiding the overhead of dynamic allocation. --if test $gcc_cv_have_tls = yes ; then -- case "${target}" in -- -- *-*-k*bsd*-gnu*) -- ;; -- -- *-*-linux* | *-*-gnu*) -- XCFLAGS="${XCFLAGS} -ftls-model=initial-exec" -- ;; -- -- *-*-rtems*) -- XCFLAGS="${XCFLAGS} -ftls-model=local-exec" -- ;; -- esac --fi -- - # Since we require POSIX threads, assume a POSIX system by default. - config_path="posix" diff --git a/cross-images/mini-aports/main/gcc/0017-dlang-use-libucontext-on-mips64.patch b/cross-images/mini-aports/main/gcc/0017-dlang-use-libucontext-on-mips64.patch new file mode 100644 index 0000000..ddb8131 --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0017-dlang-use-libucontext-on-mips64.patch @@ -0,0 +1,24 @@ +From 26daa73d678b87a6950df1d79d171ba40ecbce15 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Thu, 6 Jan 2022 03:18:32 +0000 +Subject: [PATCH] dlang: use libucontext on mips64 + +--- + libphobos/configure.tgt | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libphobos/configure.tgt b/libphobos/configure.tgt +index 0643daeb613..b74d9fb3f25 100644 +--- a/libphobos/configure.tgt ++++ b/libphobos/configure.tgt +@@ -38,6 +38,7 @@ case "${target}" in + ;; + mips*-*-linux*) + LIBPHOBOS_SUPPORTED=yes ++ LIBDRUNTIME_NEEDS_UCONTEXT=yes + ;; + power*-*-freebsd*) + LIBPHOBOS_SUPPORTED=yes +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0018-dlang-libdruntime-define-fcntl.h-constants-for-mips6.patch b/cross-images/mini-aports/main/gcc/0018-dlang-libdruntime-define-fcntl.h-constants-for-mips6.patch new file mode 100644 index 0000000..2ac4cda --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0018-dlang-libdruntime-define-fcntl.h-constants-for-mips6.patch @@ -0,0 +1,38 @@ +From caeae8288593dbd5a1a6d93508d875eb0d8fdf49 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Thu, 6 Jan 2022 03:19:12 +0000 +Subject: [PATCH] dlang: libdruntime: define fcntl.h constants for mips64 + +--- + libphobos/libdruntime/core/sys/posix/fcntl.d | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +diff --git a/libphobos/libdruntime/core/sys/posix/fcntl.d b/libphobos/libdruntime/core/sys/posix/fcntl.d +index 59df921ba41..9ee9f943948 100644 +--- a/libphobos/libdruntime/core/sys/posix/fcntl.d ++++ b/libphobos/libdruntime/core/sys/posix/fcntl.d +@@ -871,6 +871,21 @@ else version (CRuntime_Musl) + F_SETLKW = 7, + } + } ++ else version (MIPS_Any) ++ { ++ enum ++ { ++ O_DIRECTORY = 0x010000, // octal 0200000 ++ O_NOFOLLOW = 0x020000, // octal 0400000 ++ O_DIRECT = 0x008000, // octal 0100000 ++ O_LARGEFILE = 0x002000, // octal 0020000 ++ O_TMPFILE = 0x410000, // octal 020200000 ++ ++ F_GETLK = 33, ++ F_SETLK = 34, ++ F_SETLKW = 35, ++ } ++ } + else + static assert(0, "Platform not supported"); + +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/ada-shared.patch b/cross-images/mini-aports/main/gcc/0019-ada-fix-shared-linking.patch similarity index 59% rename from cross-images/mini-aports/main/gcc/ada-shared.patch rename to cross-images/mini-aports/main/gcc/0019-ada-fix-shared-linking.patch index 6f1c16a..bae33ac 100644 --- a/cross-images/mini-aports/main/gcc/ada-shared.patch +++ b/cross-images/mini-aports/main/gcc/0019-ada-fix-shared-linking.patch @@ -1,10 +1,19 @@ -Index: b/gcc/ada/link.c -=================================================================== +From 374a19de60fcd5c31321c3f4d26dcc4b631e8c3f Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:59:16 +0000 +Subject: [PATCH] ada: fix shared linking + +--- + gcc/ada/link.c | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/gcc/ada/link.c b/gcc/ada/link.c +index 5cd5ef64f56..1c611a82cab 100644 --- a/gcc/ada/link.c +++ b/gcc/ada/link.c -@@ -105,9 +105,9 @@ - - #elif defined (__FreeBSD__) +@@ -107,9 +107,9 @@ const char *__gnat_default_libgcc_subdir = "lib"; + || defined (__NetBSD__) || defined (__OpenBSD__) \ + || defined (__QNX__) const char *__gnat_object_file_option = "-Wl,@"; -const char *__gnat_run_path_option = "-Wl,-rpath,"; -char __gnat_shared_libgnat_default = STATIC; @@ -15,9 +24,9 @@ Index: b/gcc/ada/link.c int __gnat_link_max = 8192; unsigned char __gnat_objlist_file_supported = 1; const char *__gnat_object_library_extension = ".a"; -@@ -127,9 +127,9 @@ +@@ -129,9 +129,9 @@ const char *__gnat_default_libgcc_subdir = "lib"; - #elif defined (linux) || defined(__GLIBC__) + #elif defined (__linux__) || defined (__GLIBC__) const char *__gnat_object_file_option = "-Wl,@"; -const char *__gnat_run_path_option = "-Wl,-rpath,"; -char __gnat_shared_libgnat_default = STATIC; @@ -28,3 +37,6 @@ Index: b/gcc/ada/link.c int __gnat_link_max = 8192; unsigned char __gnat_objlist_file_supported = 1; const char *__gnat_object_library_extension = ".a"; +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0020-build-fix-CXXFLAGS_FOR_BUILD-passing.patch b/cross-images/mini-aports/main/gcc/0020-build-fix-CXXFLAGS_FOR_BUILD-passing.patch new file mode 100644 index 0000000..6ffdb0a --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0020-build-fix-CXXFLAGS_FOR_BUILD-passing.patch @@ -0,0 +1,24 @@ +From ad053bc46b535e78397f992e3c2c1d28c1ebd1f4 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 06:59:43 +0000 +Subject: [PATCH] build: fix CXXFLAGS_FOR_BUILD passing + +--- + Makefile.in | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/Makefile.in b/Makefile.in +index 047be0255e2..426949aa91c 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -170,6 +170,7 @@ BUILD_EXPORTS = \ + # built for the build system to override those in BASE_FLAGS_TO_PASS. + EXTRA_BUILD_FLAGS = \ + CFLAGS="$(CFLAGS_FOR_BUILD)" \ ++ CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \ + LDFLAGS="$(LDFLAGS_FOR_BUILD)" + + # This is the list of directories to built for the host system. +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0021-add-fortify-headers-paths.patch b/cross-images/mini-aports/main/gcc/0021-add-fortify-headers-paths.patch new file mode 100644 index 0000000..0e93b16 --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0021-add-fortify-headers-paths.patch @@ -0,0 +1,25 @@ +From 18d44a7f8d801cc6926a73e2dda2f0ce859dc561 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 07:01:06 +0000 +Subject: [PATCH] add fortify-headers paths + +--- + gcc/config/linux.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/gcc/config/linux.h b/gcc/config/linux.h +index 4e1db60fced..7fcf402b416 100644 +--- a/gcc/config/linux.h ++++ b/gcc/config/linux.h +@@ -167,6 +167,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + + #ifdef NATIVE_SYSTEM_HEADER_DIR + #define INCLUDE_DEFAULTS_MUSL_NATIVE \ ++ { NATIVE_SYSTEM_HEADER_DIR "/fortify", 0, 0, 0, 1, 2 }, \ ++ { NATIVE_SYSTEM_HEADER_DIR "/fortify", 0, 0, 0, 1, 0 }, \ + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \ + { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 }, + #else +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0022-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch b/cross-images/mini-aports/main/gcc/0022-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch new file mode 100644 index 0000000..ff4c489 --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0022-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch @@ -0,0 +1,31 @@ +From 38d27ebdcc5a8bea0807b5d56203f0ea5e16868f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Timo=20Ter=C3=A4s?= +Date: Fri, 21 Aug 2020 07:03:00 +0000 +Subject: [PATCH] Alpine musl package provides libssp_nonshared.a. We link to + it unconditionally, as otherwise we get link failures if some objects are + -fstack-protector built and final link happens with -fno-stack-protector. + This seems to be the common case when bootstrapping gcc, the piepatches do + not seem to fully fix the crosstoolchain and bootstrap sequence wrt. + stack-protector flag usage. + +--- + gcc/gcc.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/gcc/gcc.c b/gcc/gcc.c +index 99314032ec2..6e91767efe8 100644 +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -997,8 +997,7 @@ proper position among the other output files. */ + + #ifndef LINK_SSP_SPEC + #ifdef TARGET_LIBC_PROVIDES_SSP +-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ +- "|fstack-protector-strong|fstack-protector-explicit:}" ++#define LINK_SSP_SPEC "-lssp_nonshared" + #else + #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ + "|fstack-protector-strong|fstack-protector-explicit" \ +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/gcc-as-needed-gold.patch b/cross-images/mini-aports/main/gcc/0023-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch similarity index 76% rename from cross-images/mini-aports/main/gcc/gcc-as-needed-gold.patch rename to cross-images/mini-aports/main/gcc/0023-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch index e22e59b..784729e 100644 --- a/cross-images/mini-aports/main/gcc/gcc-as-needed-gold.patch +++ b/cross-images/mini-aports/main/gcc/0023-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch @@ -1,10 +1,18 @@ -# DP: Use --push-state/--pop-state for gold as well when linking libtsan. +From 0cc2a1befaf343e5ce1cbc15bd247eee812bdf33 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 07:03:42 +0000 +Subject: [PATCH] DP: Use --push-state/--pop-state for gold as well when + linking libtsan. -Index: b/gcc/gcc.c -=================================================================== +--- + gcc/gcc.c | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/gcc/gcc.c b/gcc/gcc.c +index 6e91767efe8..22dbbf85850 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c -@@ -693,10 +693,10 @@ proper position among the other output f +@@ -738,10 +738,10 @@ proper position among the other output files. */ #define LIBASAN_SPEC STATIC_LIBASAN_LIBS #elif defined(HAVE_LD_STATIC_DYNAMIC) #define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION "}" \ @@ -17,7 +25,7 @@ Index: b/gcc/gcc.c STATIC_LIBASAN_LIBS #else #define LIBASAN_SPEC "-lasan" STATIC_LIBASAN_LIBS -@@ -714,10 +714,10 @@ proper position among the other output f +@@ -777,10 +777,10 @@ proper position among the other output files. */ #define LIBTSAN_SPEC STATIC_LIBTSAN_LIBS #elif defined(HAVE_LD_STATIC_DYNAMIC) #define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION "}" \ @@ -30,7 +38,7 @@ Index: b/gcc/gcc.c STATIC_LIBTSAN_LIBS #else #define LIBTSAN_SPEC "-ltsan" STATIC_LIBTSAN_LIBS -@@ -735,10 +735,10 @@ proper position among the other output f +@@ -798,10 +798,10 @@ proper position among the other output files. */ #define LIBLSAN_SPEC STATIC_LIBLSAN_LIBS #elif defined(HAVE_LD_STATIC_DYNAMIC) #define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION "}" \ @@ -43,7 +51,7 @@ Index: b/gcc/gcc.c STATIC_LIBLSAN_LIBS #else #define LIBLSAN_SPEC "-llsan" STATIC_LIBLSAN_LIBS -@@ -754,10 +754,10 @@ proper position among the other output f +@@ -817,10 +817,10 @@ proper position among the other output files. */ " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}" #ifdef HAVE_LD_STATIC_DYNAMIC #define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION "}" \ @@ -56,3 +64,6 @@ Index: b/gcc/gcc.c STATIC_LIBUBSAN_LIBS #else #define LIBUBSAN_SPEC "-lubsan" STATIC_LIBUBSAN_LIBS +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/gcc-pure64-mips.patch b/cross-images/mini-aports/main/gcc/0024-mips64-disable-multilib-support.patch similarity index 84% rename from cross-images/mini-aports/main/gcc/gcc-pure64-mips.patch rename to cross-images/mini-aports/main/gcc/0024-mips64-disable-multilib-support.patch index d78f283..1beb3e0 100644 --- a/cross-images/mini-aports/main/gcc/gcc-pure64-mips.patch +++ b/cross-images/mini-aports/main/gcc/0024-mips64-disable-multilib-support.patch @@ -1,18 +1,19 @@ -From b8c4e45d052adc247341066f748421743704b481 Mon Sep 17 00:00:00 2001 +From feea6f782e83a53487ad633608484dfa3483be1b Mon Sep 17 00:00:00 2001 From: Nils Andreas Svee Date: Thu, 21 Dec 2017 03:14:33 +0100 -Subject: [PATCH] Pure 64-bit MIPS +Subject: [PATCH] mips64: disable multilib support +multilib is not supported by Alpine GCC --- gcc/config/mips/mips.h | 8 ++++---- gcc/config/mips/t-linux64 | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h -index 803ab98e7..afd74752f 100644 +index 47aac9d3d61..4ad81059a86 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h -@@ -3330,11 +3330,11 @@ struct GTY(()) machine_function { +@@ -3425,11 +3425,11 @@ struct GTY(()) machine_function { /* If we are *not* using multilibs and the default ABI is not ABI_32 we need to change these from /lib and /usr/lib. */ #if MIPS_ABI_DEFAULT == ABI_N32 @@ -29,7 +30,7 @@ index 803ab98e7..afd74752f 100644 /* Load store bonding is not supported by micromips and fix_24k. The diff --git a/gcc/config/mips/t-linux64 b/gcc/config/mips/t-linux64 -index 16c8adf85..bb46204db 100644 +index 130e1f04707..a64ac2bbb5b 100644 --- a/gcc/config/mips/t-linux64 +++ b/gcc/config/mips/t-linux64 @@ -21,6 +21,6 @@ MULTILIB_DIRNAMES = n32 32 64 @@ -43,5 +44,5 @@ index 16c8adf85..bb46204db 100644 + ../lib32 \ + ../lib -- -2.15.1 +2.35.1 diff --git a/cross-images/mini-aports/main/gcc/0025-aarch64-disable-multilib-support.patch b/cross-images/mini-aports/main/gcc/0025-aarch64-disable-multilib-support.patch new file mode 100644 index 0000000..cc388e9 --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0025-aarch64-disable-multilib-support.patch @@ -0,0 +1,26 @@ +From cbd96a32dc2aaa61f6adcb3643e1da21f185f80e Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Thu, 6 Jan 2022 03:12:55 +0000 +Subject: [PATCH] aarch64: disable multilib support + +multilib is unsupported on Alpine GCC +--- + gcc/config/aarch64/t-aarch64-linux | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gcc/config/aarch64/t-aarch64-linux b/gcc/config/aarch64/t-aarch64-linux +index 241b0ef20b6..18e63b34d8b 100644 +--- a/gcc/config/aarch64/t-aarch64-linux ++++ b/gcc/config/aarch64/t-aarch64-linux +@@ -22,7 +22,7 @@ LIB1ASMSRC = aarch64/lib1funcs.asm + LIB1ASMFUNCS = _aarch64_sync_cache_range + + AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be) +-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu) ++MULTILIB_OSDIRNAMES = mabi.lp64=../lib + MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu) + + MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32) +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0026-s390x-disable-multilib-support.patch b/cross-images/mini-aports/main/gcc/0026-s390x-disable-multilib-support.patch new file mode 100644 index 0000000..4f9fe34 --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0026-s390x-disable-multilib-support.patch @@ -0,0 +1,25 @@ +From e87e415e9a88dbce68ed7b9d8386c3c2d0c0d6b6 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Thu, 6 Jan 2022 03:13:59 +0000 +Subject: [PATCH] s390x: disable multilib support + +multilib is not supported on Alpine GCC at present +--- + gcc/config/s390/t-linux64 | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/gcc/config/s390/t-linux64 b/gcc/config/s390/t-linux64 +index cc6ab367072..7f498ee1cdc 100644 +--- a/gcc/config/s390/t-linux64 ++++ b/gcc/config/s390/t-linux64 +@@ -7,5 +7,5 @@ + + MULTILIB_OPTIONS = m64/m31 + MULTILIB_DIRNAMES = 64 32 +-MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu) +-MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu) ++MULTILIB_OSDIRNAMES = m64=../lib ++MULTILIB_OSDIRNAMES+= m32=../lib32 +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/gcc-pure64.patch b/cross-images/mini-aports/main/gcc/0027-ppc64-le-disable-multilib-support.patch similarity index 51% rename from cross-images/mini-aports/main/gcc/gcc-pure64.patch rename to cross-images/mini-aports/main/gcc/0027-ppc64-le-disable-multilib-support.patch index 2c350fe..c76ff5f 100644 --- a/cross-images/mini-aports/main/gcc/gcc-pure64.patch +++ b/cross-images/mini-aports/main/gcc/0027-ppc64-le-disable-multilib-support.patch @@ -1,37 +1,20 @@ ---- ./gcc/config/i386/t-linux64.orig 2013-01-14 16:32:37.000000000 +0000 -+++ ./gcc/config/i386/t-linux64 2013-04-22 06:12:32.984439677 +0000 -@@ -34,6 +34,6 @@ - comma=, - MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG)) - MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS))) --MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu) --MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu) -+MULTILIB_OSDIRNAMES = m64=../lib -+MULTILIB_OSDIRNAMES+= m32=../lib32 - MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32) ---- ./gcc/config/aarch64/t-aarch64-linux.orig -+++ ./gcc/config/aarch64/t-aarch64-linux -@@ -22,7 +22,7 @@ - LIB1ASMFUNCS = _aarch64_sync_cache_range - - AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be) --MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu) -+MULTILIB_OSDIRNAMES = mabi.lp64=../lib - MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu) - - MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32 ---- ./gcc/config/s390/t-linux64.orig -+++ ./gcc/config/s390/t-linux64 -@@ -7,5 +7,5 @@ - MULTILIB_OPTIONS = m64/m31 - MULTILIB_DIRNAMES = 64 32 --MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu) --MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu) -+MULTILIB_OSDIRNAMES = m64=../lib -+MULTILIB_OSDIRNAMES+= m32=../lib32 +From 5c24869c9bc1a552f8bb5c32a8538c6e065a4db8 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Thu, 6 Jan 2022 03:14:33 +0000 +Subject: [PATCH] ppc64[le]: disable multilib support + +multilib is not presently supported on Alpine GCC +--- + gcc/config/rs6000/t-linux | 6 ++++-- + gcc/config/rs6000/t-linux64 | 4 ++-- + gcc/config/rs6000/t-linux64bele | 4 ++-- + gcc/config/rs6000/t-linux64lebe | 4 ++-- + 4 files changed, 10 insertions(+), 8 deletions(-) ---- ./gcc/config/rs6000/t-linux.orig -+++ ./gcc/config/rs6000/t-linux +diff --git a/gcc/config/rs6000/t-linux b/gcc/config/rs6000/t-linux +index aeb7440c492..ab14c455d8d 100644 +--- a/gcc/config/rs6000/t-linux ++++ b/gcc/config/rs6000/t-linux @@ -2,7 +2,8 @@ # or soft-float. ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float))) @@ -40,9 +23,9 @@ +MULTILIB_OSDIRNAMES := m64=../lib +MULTILIB_OSDIRNAMES += m32=../lib32 else - ifneq (,$(findstring spe,$(target))) - MULTIARCH_DIRNAME := powerpc-linux-gnuspe$(if $(findstring 8548,$(with_cpu)),,v1) -@@ -14,7 +15,8 @@ + MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu) + endif +@@ -10,7 +11,8 @@ ifneq (,$(findstring powerpcle,$(target))) MULTIARCH_DIRNAME := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME)) endif ifneq (,$(findstring powerpc64le,$(target))) @@ -52,8 +35,10 @@ endif endif ---- ./gcc/config/rs6000/t-linux64.orig -+++ ./gcc/config/rs6000/t-linux64 +diff --git a/gcc/config/rs6000/t-linux64 b/gcc/config/rs6000/t-linux64 +index e11a118cb5f..df81dc04a32 100644 +--- a/gcc/config/rs6000/t-linux64 ++++ b/gcc/config/rs6000/t-linux64 @@ -28,8 +28,8 @@ MULTILIB_OPTIONS := m64/m32 MULTILIB_DIRNAMES := 64 32 @@ -65,8 +50,10 @@ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c $(COMPILE) $< ---- ./gcc/config/rs6000/t-linux64bele.orig -+++ ./gcc/config/rs6000/t-linux64bele +diff --git a/gcc/config/rs6000/t-linux64bele b/gcc/config/rs6000/t-linux64bele +index 97c1ee6fb4d..08d72639cb6 100644 +--- a/gcc/config/rs6000/t-linux64bele ++++ b/gcc/config/rs6000/t-linux64bele @@ -2,6 +2,6 @@ MULTILIB_OPTIONS += mlittle @@ -76,8 +63,10 @@ +MULTILIB_OSDIRNAMES = m64=../lib +MULTILIB_OSDIRNAMES+= m32=../lib32 MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN} ---- ./gcc/config/rs6000/t-linux64lebe.orig -+++ ./gcc/config/rs6000/t-linux64lebe +diff --git a/gcc/config/rs6000/t-linux64lebe b/gcc/config/rs6000/t-linux64lebe +index 2e63bdb9fc9..c6e1c5db65d 100644 +--- a/gcc/config/rs6000/t-linux64lebe ++++ b/gcc/config/rs6000/t-linux64lebe @@ -2,6 +2,6 @@ MULTILIB_OPTIONS += mbig @@ -87,3 +76,6 @@ +MULTILIB_OSDIRNAMES := m64=../lib +MULTILIB_OSDIRNAMES += m32=../lib32 MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN} +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0028-x86_64-disable-multilib-support.patch b/cross-images/mini-aports/main/gcc/0028-x86_64-disable-multilib-support.patch new file mode 100644 index 0000000..868e18f --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0028-x86_64-disable-multilib-support.patch @@ -0,0 +1,26 @@ +From 25927f8106583ee594e7bcdf92dd1387e0fd024c Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Thu, 6 Jan 2022 03:14:54 +0000 +Subject: [PATCH] x86_64: disable multilib support + +multilib is not presently supported on Alpine GCC +--- + gcc/config/i386/t-linux64 | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/gcc/config/i386/t-linux64 b/gcc/config/i386/t-linux64 +index d288b093522..2949033aa04 100644 +--- a/gcc/config/i386/t-linux64 ++++ b/gcc/config/i386/t-linux64 +@@ -33,6 +33,6 @@ + comma=, + MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG)) + MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS))) +-MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu) +-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu) ++MULTILIB_OSDIRNAMES = m64=../lib ++MULTILIB_OSDIRNAMES+= m32=../lib32 + MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32) +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0029-riscv-disable-multilib-support.patch b/cross-images/mini-aports/main/gcc/0029-riscv-disable-multilib-support.patch new file mode 100644 index 0000000..228f66f --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0029-riscv-disable-multilib-support.patch @@ -0,0 +1,74 @@ +From 18bcf23cae4069ffe9d9f64e851193d29dd4814f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Mon, 3 Jan 2022 07:14:48 +0100 +Subject: [PATCH] riscv: disable multilib support +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From the musl wiki [1]: + + musl does not support sharing an include directory between archs + […], and thus is not compatible with GCC-style multilib. It is + recommended that distributions build GCC with multilib disabled, + and use library directories named lib, not lib64 or lib32. + +For this reason, we patch existing GCC configuration files (gcc/config) +to pin MULTILIB_OSDIRNAMES to lib, there is also a corresponding GCC +upstream bug about this issue [2]. Avoiding the use of lib64 and lib32 +directories is a bit more difficult on the RISC-V architecture. This is +due to the fact that the default RISC-V configuration does not only use +the lib64 and lib32 directories but also subdirectories within these +directories for different RISC-V ABIs (e.g. lp64d, lp64, …) [3]. + +This patch aligns the RISC-V configuration with other architectures by +pinning MULTILIB_OSDIRNAMES to lib for rv64gc (our default RISC-V +-march). Furthermore, this patch removes the ABI-specific startfile +prefix spec. Since both of these impact the default LIBRARY_PATH [4] +this patch thereby aligns the default RISC-V LIBRARY_PATH with that from +other Alpine architectures and thereby fixes #13369 [5]. + +Incidentally, this also fixes gccgo on riscv64, as without this patch +gccgo is otherwise not able to find the *.gox files for the Go standard +library. + +[1]: https://wiki.musl-libc.org/guidelines-for-distributions.html#Multilib/multi_arch +[2]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90077 +[3]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103889#c14 +[4]: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/gcc.c;h=d4c8746b0aa322286decf92aa72a12f0a393b655;hb=HEAD#l9122 +[5]: https://gitlab.alpinelinux.org/alpine/aports/-/issues/13369 +--- + gcc/config/riscv/linux.h | 6 ------ + gcc/config/riscv/t-linux | 7 +++++-- + 2 files changed, 5 insertions(+), 8 deletions(-) + +diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h +index ee29979dd34..fe8a82d6702 100644 +--- a/gcc/config/riscv/linux.h ++++ b/gcc/config/riscv/linux.h +@@ -71,9 +71,3 @@ along with GCC; see the file COPYING3. If not see + %{static:-static}}" + + #define TARGET_ASM_FILE_END file_end_indicate_exec_stack +- +-#define STARTFILE_PREFIX_SPEC \ +- "/lib" XLEN_SPEC "/" ABI_SPEC "/ " \ +- "/usr/lib" XLEN_SPEC "/" ABI_SPEC "/ " \ +- "/lib/ " \ +- "/usr/lib/ " +diff --git a/gcc/config/riscv/t-linux b/gcc/config/riscv/t-linux +index 216d2776a18..1a8a863853e 100644 +--- a/gcc/config/riscv/t-linux ++++ b/gcc/config/riscv/t-linux +@@ -1,3 +1,6 @@ +-# Only XLEN and ABI affect Linux multilib dir names, e.g. /lib32/ilp32d/ +-MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES))) ++MULTILIB_OPTIONS := march=rv64gc ++MULTILIB_DIRNAMES := rv64gc ++ ++MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib,$(MULTILIB_DIRNAMES))) + MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES)) ++MULTILIB_MATCHES := march?rv64gc=march?rv64imafdc +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/002_all_default-relro.patch b/cross-images/mini-aports/main/gcc/002_all_default-relro.patch deleted file mode 100644 index c461017..0000000 --- a/cross-images/mini-aports/main/gcc/002_all_default-relro.patch +++ /dev/null @@ -1,33 +0,0 @@ -# Turn on -Wl,-z,relro,-z,now by default. - ---- - gcc/doc/invoke.texi | 3 +++ - gcc/gcc.c | 1 + - 2 files changed, 4 insertions(+), 0 deletions(-) - -Index: b/gcc/doc/invoke.texi -=================================================================== ---- a/gcc/doc/invoke.texi -+++ b/gcc/doc/invoke.texi -@@ -11424,6 +11424,9 @@ For example, @option{-Wl,-Map,output.map - linker. When using the GNU linker, you can also get the same effect with - @option{-Wl,-Map=output.map}. - -+NOTE: In Alpine Linux, for LDFLAGS, the option -+@option{-Wl,-z,relro,now} is used. To disable, use @option{-Wl,-z,norelro}. -+ - @item -u @var{symbol} - @opindex u - Pretend the symbol @var{symbol} is undefined, to force linking of -Index: b/gcc/gcc.c -=================================================================== ---- a/gcc/gcc.c -+++ b/gcc/gcc.c -@@ -890,6 +890,7 @@ proper position among the other output f - "%{flto|flto=*:% +Date: Fri, 21 Aug 2020 07:05:41 +0000 +Subject: [PATCH] always build libgcc_eh.a + +highly inspired by: http://landley.net/hg/aboriginal/file/7e0747a665ab/sources/patches/gcc-core-libgcceh.patch +--- + libgcc/Makefile.in | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) -diff -durN gcc-4.6.0.orig/libgcc/Makefile.in gcc-4.6.0/libgcc/Makefile.in ---- gcc-4.6.0.orig/libgcc/Makefile.in 2011-01-26 05:19:58.000000000 +0100 -+++ gcc-4.6.0/libgcc/Makefile.in 2011-09-12 18:17:12.743718974 +0200 -@@ -772,8 +772,9 @@ - libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_EXT) +diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in +index 2c8be561eb5..c557750b1b3 100644 +--- a/libgcc/Makefile.in ++++ b/libgcc/Makefile.in +@@ -957,8 +957,9 @@ ifneq ($(LIBUNWIND),) + all: libunwind.a endif +all: libgcc_eh.a @@ -14,8 +23,8 @@ diff -durN gcc-4.6.0.orig/libgcc/Makefile.in gcc-4.6.0/libgcc/Makefile.in +all: libgcc_s$(SHLIB_EXT) ifneq ($(LIBUNWIND),) all: libunwind$(SHLIB_EXT) - endif -@@ -950,10 +951,6 @@ + libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_EXT) +@@ -1160,10 +1161,6 @@ install-libunwind: install-shared: $(mkinstalldirs) $(DESTDIR)$(inst_libdir) @@ -26,9 +35,9 @@ diff -durN gcc-4.6.0.orig/libgcc/Makefile.in gcc-4.6.0/libgcc/Makefile.in $(subst @multilib_dir@,$(MULTIDIR),$(subst \ @shlib_base_name@,libgcc_s,$(subst \ @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(SHLIB_INSTALL)))) -@@ -968,6 +965,10 @@ - chmod 644 $(DESTDIR)$(inst_libdir)/libgcov.a +@@ -1180,6 +1177,10 @@ ifeq ($(enable_gcov),yes) $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcov.a + endif + $(INSTALL_DATA) libgcc_eh.a $(DESTDIR)$(inst_libdir)/ + chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a @@ -37,3 +46,6 @@ diff -durN gcc-4.6.0.orig/libgcc/Makefile.in gcc-4.6.0/libgcc/Makefile.in parts="$(INSTALL_PARTS)"; \ for file in $$parts; do \ rm -f $(DESTDIR)$(inst_libdir)/$$file; \ +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/libgnarl-musl.patch b/cross-images/mini-aports/main/gcc/0031-ada-libgnarl-compatibility-for-musl.patch similarity index 74% rename from cross-images/mini-aports/main/gcc/libgnarl-musl.patch rename to cross-images/mini-aports/main/gcc/0031-ada-libgnarl-compatibility-for-musl.patch index 7e35cda..7878583 100644 --- a/cross-images/mini-aports/main/gcc/libgnarl-musl.patch +++ b/cross-images/mini-aports/main/gcc/0031-ada-libgnarl-compatibility-for-musl.patch @@ -1,7 +1,18 @@ -diff -rup gcc-8.2.0/gcc/ada/libgnarl/s-osinte__linux.ads gcc-8.2.0-new/gcc/ada/libgnarl/s-osinte__linux.ads ---- gcc-8.2.0/gcc/ada/libgnarl/s-osinte__linux.ads 2018-01-11 00:55:25.000000000 -0800 -+++ gcc-8.2.0-new/gcc/ada/libgnarl/s-osinte__linux.ads 2018-11-01 16:16:23.372452951 -0700 -@@ -394,12 +394,6 @@ package System.OS_Interface is +From d7064ab25a561bb99c3d0b35663154656013aed2 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 07:06:30 +0000 +Subject: [PATCH] ada: libgnarl compatibility for musl + +--- + gcc/ada/libgnarl/s-osinte__linux.ads | 11 ------ + gcc/ada/libgnarl/s-taprop__linux.adb | 53 ++-------------------------- + 2 files changed, 3 insertions(+), 61 deletions(-) + +diff --git a/gcc/ada/libgnarl/s-osinte__linux.ads b/gcc/ada/libgnarl/s-osinte__linux.ads +index 2272f83d68d..1d78456544a 100644 +--- a/gcc/ada/libgnarl/s-osinte__linux.ads ++++ b/gcc/ada/libgnarl/s-osinte__linux.ads +@@ -401,12 +401,6 @@ package System.OS_Interface is PTHREAD_RWLOCK_PREFER_WRITER_NP : constant := 1; PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP : constant := 2; @@ -14,7 +25,7 @@ diff -rup gcc-8.2.0/gcc/ada/libgnarl/s-osinte__linux.ads gcc-8.2.0-new/gcc/ada/l function pthread_rwlock_init (mutex : access pthread_rwlock_t; attr : access pthread_rwlockattr_t) return int; -@@ -464,11 +458,6 @@ package System.OS_Interface is +@@ -468,11 +462,6 @@ package System.OS_Interface is protocol : int) return int; pragma Import (C, pthread_mutexattr_setprotocol); @@ -26,10 +37,11 @@ diff -rup gcc-8.2.0/gcc/ada/libgnarl/s-osinte__linux.ads gcc-8.2.0-new/gcc/ada/l type struct_sched_param is record sched_priority : int; -- scheduling priority end record; -diff -rup gcc-8.2.0/gcc/ada/libgnarl/s-taprop__linux.adb gcc-8.2.0-new/gcc/ada/libgnarl/s-taprop__linux.adb ---- gcc-8.2.0/gcc/ada/libgnarl/s-taprop__linux.adb 2018-01-11 00:55:25.000000000 -0800 -+++ gcc-8.2.0-new/gcc/ada/libgnarl/s-taprop__linux.adb 2018-11-13 11:28:36.433964449 -0800 -@@ -202,9 +202,6 @@ package body System.Task_Primitives.Oper +diff --git a/gcc/ada/libgnarl/s-taprop__linux.adb b/gcc/ada/libgnarl/s-taprop__linux.adb +index 757a6cdfdad..82df94f6a00 100644 +--- a/gcc/ada/libgnarl/s-taprop__linux.adb ++++ b/gcc/ada/libgnarl/s-taprop__linux.adb +@@ -198,9 +198,6 @@ package body System.Task_Primitives.Operations is pragma Import (C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup"); @@ -39,7 +51,7 @@ diff -rup gcc-8.2.0/gcc/ada/libgnarl/s-taprop__linux.adb gcc-8.2.0-new/gcc/ada/l -- We do not have pragma Linker_Options ("-lcap"); here, because this -- library is not present on many Linux systems. 'libcap' is the Linux -- "capabilities" library, called by __gnat_has_cap_sys_nice. -@@ -214,38 +211,6 @@ package body System.Task_Primitives.Oper +@@ -210,38 +207,6 @@ package body System.Task_Primitives.Operations is -- Convert Ada priority to Linux priority. Priorities are 1 .. 99 on -- GNU/Linux, so we map 0 .. 98 to 1 .. 99. @@ -72,13 +84,13 @@ diff -rup gcc-8.2.0/gcc/ada/libgnarl/s-taprop__linux.adb gcc-8.2.0-new/gcc/ada/l - return Ceiling_Support; - end Get_Ceiling_Support; - -- pragma Warnings (Off, "non-static call not allowed in preelaborated unit"); +- pragma Warnings (Off, "non-preelaborable call not allowed*"); - Ceiling_Support : constant Boolean := Get_Ceiling_Support; -- pragma Warnings (On, "non-static call not allowed in preelaborated unit"); +- pragma Warnings (On, "non-preelaborable call not allowed*"); -- True if the locking policy is Ceiling_Locking, and the current process -- has permission to use this policy. The process has permission if it is -- running as 'root', or if the capability was set by the setcap command, -@@ -348,7 +313,9 @@ package body System.Task_Primitives.Oper +@@ -344,7 +309,9 @@ package body System.Task_Primitives.Operations is -- Init_Mutex -- ---------------- @@ -88,7 +100,7 @@ diff -rup gcc-8.2.0/gcc/ada/libgnarl/s-taprop__linux.adb gcc-8.2.0-new/gcc/ada/l Mutex_Attr : aliased pthread_mutexattr_t; Result, Result_2 : C.int; -@@ -360,16 +327,7 @@ package body System.Task_Primitives.Oper +@@ -356,16 +323,7 @@ package body System.Task_Primitives.Operations is return Result; end if; @@ -106,7 +118,7 @@ diff -rup gcc-8.2.0/gcc/ada/libgnarl/s-taprop__linux.adb gcc-8.2.0-new/gcc/ada/l Result := pthread_mutexattr_setprotocol (Mutex_Attr'Access, PTHREAD_PRIO_INHERIT); pragma Assert (Result = 0); -@@ -409,11 +367,6 @@ package body System.Task_Primitives.Oper +@@ -405,11 +363,6 @@ package body System.Task_Primitives.Operations is Result := pthread_rwlockattr_init (RWlock_Attr'Access); pragma Assert (Result = 0); @@ -118,3 +130,6 @@ diff -rup gcc-8.2.0/gcc/ada/libgnarl/s-taprop__linux.adb gcc-8.2.0-new/gcc/ada/l Result := pthread_rwlock_init (L.RW'Access, RWlock_Attr'Access); pragma Assert (Result in 0 | ENOMEM); +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/ada-musl.patch b/cross-images/mini-aports/main/gcc/0032-ada-musl-support-fixes.patch similarity index 69% rename from cross-images/mini-aports/main/gcc/ada-musl.patch rename to cross-images/mini-aports/main/gcc/0032-ada-musl-support-fixes.patch index 7a86ae4..1035c95 100644 --- a/cross-images/mini-aports/main/gcc/ada-musl.patch +++ b/cross-images/mini-aports/main/gcc/0032-ada-musl-support-fixes.patch @@ -1,20 +1,81 @@ +From 5193de0a6c96fefe0c46fc9a6b8c27623ad85640 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Fri, 21 Aug 2020 07:07:48 +0000 +Subject: [PATCH] ada: musl support fixes + +--- + gcc/ada/Makefile.rtl | 10 +++++----- + gcc/ada/adaint.c | 34 +++++++++++++++++++--------------- + gcc/ada/adaint.h | 10 ++++------ + gcc/ada/terminals.c | 8 ++++---- + 4 files changed, 32 insertions(+), 30 deletions(-) + +diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl +index b5b8b573ea4..6fce40d1e98 100644 +--- a/gcc/ada/Makefile.rtl ++++ b/gcc/ada/Makefile.rtl +@@ -1748,7 +1748,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(target_cpu) $(target_os))),) + s-intman.adb #include #endif + -+#if defined (linux) ++#if defined (linux) || defined(__linux__) +#define _GNU_SOURCE 1 +#include +#endif #ifdef __PikeOS__ #define __BSD_VISIBLE 1 -@@ -3255,7 +3260,6 @@ __gnat_lwp_self (void) +@@ -3442,7 +3447,6 @@ __gnat_lwp_self (void) #endif #if defined (__linux__) @@ -22,7 +83,7 @@ index 3b0aea9..ee0bb69 100644 /* glibc versions earlier than 2.7 do not define the routines to handle dynamically allocated CPU sets. For these targets, we use the static -@@ -3265,7 +3269,7 @@ __gnat_lwp_self (void) +@@ -3452,7 +3456,7 @@ __gnat_lwp_self (void) /* Dynamic cpu sets */ @@ -31,7 +92,7 @@ index 3b0aea9..ee0bb69 100644 __gnat_cpu_alloc (size_t count) { return CPU_ALLOC (count); -@@ -3278,33 +3282,33 @@ __gnat_cpu_alloc_size (size_t count) +@@ -3465,33 +3469,33 @@ __gnat_cpu_alloc_size (size_t count) } void @@ -73,7 +134,7 @@ index 3b0aea9..ee0bb69 100644 } size_t -@@ -3314,23 +3318,23 @@ __gnat_cpu_alloc_size (size_t count ATTRIBUTE_UNUSED) +@@ -3501,23 +3505,23 @@ __gnat_cpu_alloc_size (size_t count ATTRIBUTE_UNUSED) } void @@ -103,10 +164,10 @@ index 3b0aea9..ee0bb69 100644 #endif /* !CPU_ALLOC */ #endif /* __linux__ */ diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h -index 0d12f7e..a063b47 100644 +index 85997b9ba68..fd10e5b5589 100644 --- a/gcc/ada/adaint.h +++ b/gcc/ada/adaint.h -@@ -316,13 +316,11 @@ extern void *__gnat_lwp_self (void); +@@ -325,13 +325,11 @@ extern void *__gnat_lwp_self (void); /* Routines for interface to required CPU set primitives */ @@ -125,77 +186,19 @@ index 0d12f7e..a063b47 100644 #if defined (_WIN32) diff --git a/gcc/ada/terminals.c b/gcc/ada/terminals.c -index 7025f57..207b50d 100644 ---- a/gcc/ada/terminals.c -+++ b/gcc/ada/terminals.c -@@ -1108,13 +1108,6 @@ __gnat_setup_winsize (void *desc, int rows, int columns) - #include - #include - --/* On some system termio is either absent or including it will disable termios -- (HP-UX) */ --#if !defined (__hpux__) && !defined (BSD) && !defined (__APPLE__) \ -- && !defined (__rtems__) && !defined (__QNXNTO__) --# include --#endif -- - #include - #include - #include -diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in -index ebb955e..08cfbee 100644 ---- a/gcc/ada/gcc-interface/Makefile.in -+++ b/gcc/ada/gcc-interface/Makefile.in -@@ -1028,7 +1028,7 @@ ifeq ($(strip $(filter-out %86 linux%,$(target_cpu) $(target_os))),) - s-tpopsp.adb +Date: Sun, 30 Aug 2020 17:59:45 +0200 +Subject: [PATCH] gcc-go: Fix handling of signal 34 on musl +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Taken from Adélie Linux. +--- + libgo/mksigtab.sh | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/libgo/mksigtab.sh b/libgo/mksigtab.sh +index 11e4ec436bd..fe866eacb27 100644 +--- a/libgo/mksigtab.sh ++++ b/libgo/mksigtab.sh +@@ -82,7 +82,7 @@ checksig _SIGPWR '{_SigNotify, "SIGPWR: power failure restart"}' + checksig _SIGEMT '{_SigThrow, "SIGEMT: emulate instruction executed"}' + checksig _SIGINFO '{_SigNotify, "SIGINFO: status request from keyboard"}' + checksig _SIGTHR '{_SigNotify, "SIGTHR: reserved"}' +-checksig _SIGPOLL '{_SigNotify, "SIGPOLL: pollable event occurred"}' ++#checksig _SIGPOLL '{_SigNotify, "SIGPOLL: pollable event occurred"}' + checksig _SIGWAITING '{_SigNotify, "SIGWAITING: reserved signal no longer used by"}' + checksig _SIGLWP '{_SigNotify, "SIGLWP: reserved signal no longer used by"}' + checksig _SIGFREEZE '{_SigNotify, "SIGFREEZE: special signal used by CPR"}' +@@ -95,10 +95,12 @@ checksig _SIGLOST ' {_SigNotify, "SIGLOST: resource lost (Sun); server died (G + + # Special handling of signals 32 and 33 on GNU/Linux systems, + # because they are special to glibc. ++# Signal 34 is additionally special to Linux systems with musl. + if test "${GOOS}" = "linux"; then +- SIGLIST=$SIGLIST"_32__33_" ++ SIGLIST=$SIGLIST"_32__33__34_" + echo ' 32: {_SigSetStack + _SigUnblock, "signal 32"}, /* SIGCANCEL; see issue 6997 */' + echo ' 33: {_SigSetStack + _SigUnblock, "signal 33"}, /* SIGSETXID; see issues 3871, 9400, 12498 */' ++ echo ' 34: {_SigSetStack + _SigUnblock, "signal 34"}, /* see issue 30062 */' + fi + + if test "${GOOS}" = "aix"; then +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0034-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch b/cross-images/mini-aports/main/gcc/0034-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch new file mode 100644 index 0000000..7ee6c7c --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0034-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch @@ -0,0 +1,27 @@ +From c205f79c18add13247a06cfd843f5eb44c4c3cb4 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Thu, 25 Nov 2021 01:47:03 +0000 +Subject: [PATCH] There are more than one st_{a,m,c}tim fields in struct stat + on time64 machines. + +Run the Go-isation on all of them. +--- + libgo/mksysinfo.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh +index 0c52ea5d71a..6fef104cc1c 100755 +--- a/libgo/mksysinfo.sh ++++ b/libgo/mksysinfo.sh +@@ -510,7 +510,7 @@ fi + + # For historical reasons Go uses the suffix "timespec" instead of "tim" for + # stat_t's time fields on NetBSD. +-st_times='-e s/st_atim/Atim/ -e s/st_mtim/Mtim/ -e s/st_ctim/Ctim/' ++st_times='-e s/st_atim/Atim/g -e s/st_mtim/Mtim/g -e s/st_ctim/Ctim/g' + if test "${GOOS}" = "netbsd"; then + st_times='-e s/st_atim/Atimespec/ -e s/st_mtim/Mtimespec/ -e s/st_ctim/Ctimespec/' + fi +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0035-gcc-go-signal-34-is-special-on-musl-libc.patch b/cross-images/mini-aports/main/gcc/0035-gcc-go-signal-34-is-special-on-musl-libc.patch new file mode 100644 index 0000000..0b38bcd --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0035-gcc-go-signal-34-is-special-on-musl-libc.patch @@ -0,0 +1,29 @@ +From af64f915a4717036a7f1fe637308b455c94e0f1e Mon Sep 17 00:00:00 2001 +From: "A. Wilcox" +Date: Sun, 30 Aug 2020 18:03:03 +0200 +Subject: [PATCH] gcc-go: signal 34 is special on musl libc +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Taken from Adélie Linux. +--- + libgo/go/runtime/signal_gccgo.go | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libgo/go/runtime/signal_gccgo.go b/libgo/go/runtime/signal_gccgo.go +index 2eece687e35..e86490ce203 100644 +--- a/libgo/go/runtime/signal_gccgo.go ++++ b/libgo/go/runtime/signal_gccgo.go +@@ -106,7 +106,7 @@ func getsig(i uint32) uintptr { + if sigaction(i, nil, &sa) < 0 { + // On GNU/Linux glibc rejects attempts to call + // sigaction with signal 32 (SIGCANCEL) or 33 (SIGSETXID). +- if GOOS == "linux" && (i == 32 || i == 33) { ++ if GOOS == "linux" && (i == 32 || i == 33 || i == 34) { + return _SIG_DFL + } + throw("sigaction read failure") +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0036-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch b/cross-images/mini-aports/main/gcc/0036-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch new file mode 100644 index 0000000..ed3ee4a --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0036-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch @@ -0,0 +1,27 @@ +From 6e41b6753af412388e9259fe791904146695e84e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Sun, 30 Aug 2020 19:27:51 +0200 +Subject: [PATCH] gcc-go: undef SETCONTEXT_CLOBBERS_TLS in proc.c + +--- + libgo/runtime/proc.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c +index 38bf7a6b255..e50403b5a75 100644 +--- a/libgo/runtime/proc.c ++++ b/libgo/runtime/proc.c +@@ -66,6 +66,10 @@ static void gscanstack(G*); + + __thread G *g __asm__(GOSYM_PREFIX "runtime.g"); + ++/* libucontext does not seem to support tlsbase, undef the macro ++ * here to make sure we define initcontext and fixcontext as dummies. */ ++#undef SETCONTEXT_CLOBBERS_TLS ++ + #ifndef SETCONTEXT_CLOBBERS_TLS + + static inline void +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0037-gcc-go-link-to-libucontext.patch b/cross-images/mini-aports/main/gcc/0037-gcc-go-link-to-libucontext.patch new file mode 100644 index 0000000..8ffdfc7 --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0037-gcc-go-link-to-libucontext.patch @@ -0,0 +1,25 @@ +From cc89c078ffc58a7f6675a60fbca24224effcb7e3 Mon Sep 17 00:00:00 2001 +From: "A. Wilcox" +Date: Mon, 31 Aug 2020 08:59:40 +0200 +Subject: [PATCH] gcc-go: link to libucontext + +--- + Makefile.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile.in b/Makefile.in +index 426949aa91c..f97db1ef569 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -50331,7 +50331,7 @@ configure-target-libgo: + esac; \ + module_srcdir=libgo; \ + rm -f no-such-file || : ; \ +- CONFIG_SITE=no-such-file $(SHELL) \ ++ CONFIG_SITE=no-such-file LIBS="-lucontext $$LIBS" $(SHELL) \ + $$s/$$module_srcdir/configure \ + --srcdir=$${topdir}/$$module_srcdir \ + $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0038-Use-generic-errstr.go-implementation-on-musl.patch b/cross-images/mini-aports/main/gcc/0038-Use-generic-errstr.go-implementation-on-musl.patch new file mode 100644 index 0000000..6a05b5f --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0038-Use-generic-errstr.go-implementation-on-musl.patch @@ -0,0 +1,48 @@ +From 3fb914ca83ac18287ee24aa75aba9149e35487ad Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Mon, 19 Apr 2021 07:21:41 +0200 +Subject: [PATCH] Use generic errstr.go implementation on musl + +glibc provides two version of strerror_r() depending on a feature test +macro. The first is the XSI-compliant version which returns an int, the +second is GNU-specific and returns a char pointer. + +Similarity, gcc's libgo provides two implementations of Errstr() both of +which use strerror_r(). On Linux, it is assumed that the GNU-specific +strerror_r version is used. However, musl only provides the +XSI-compliant version of strerror_r. This patch enables the generic +Errstr() implementation which also uses the XSI-compliant version of +strerror_r. +--- + libgo/go/syscall/errstr.go | 1 - + libgo/go/syscall/errstr_glibc.go | 2 +- + 2 files changed, 1 insertion(+), 2 deletions(-) + +diff --git a/libgo/go/syscall/errstr.go b/libgo/go/syscall/errstr.go +index 6c2441d364d..8f7c5538163 100644 +--- a/libgo/go/syscall/errstr.go ++++ b/libgo/go/syscall/errstr.go +@@ -5,7 +5,6 @@ + // license that can be found in the LICENSE file. + + // +build !hurd +-// +build !linux + + package syscall + +diff --git a/libgo/go/syscall/errstr_glibc.go b/libgo/go/syscall/errstr_glibc.go +index 5b19e6f202d..8dc60172186 100644 +--- a/libgo/go/syscall/errstr_glibc.go ++++ b/libgo/go/syscall/errstr_glibc.go +@@ -7,7 +7,7 @@ + // We use this rather than errstr.go because on GNU/Linux sterror_r + // returns a pointer to the error message, and may not use buf at all. + +-// +build hurd linux ++// +build hurd !linux + + package syscall + +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0039-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch b/cross-images/mini-aports/main/gcc/0039-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch new file mode 100644 index 0000000..495fcec --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0039-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch @@ -0,0 +1,275 @@ +From 52ce9c86c0c89ae45e0d08cc232682e1811aa8f2 Mon Sep 17 00:00:00 2001 +From: Drew DeVault +Date: Wed, 9 Dec 2020 16:07:26 +0000 +Subject: [PATCH] configure: Add --enable-autolink-libatomic, use in + LINK_GCC_C_SEQUENCE_SPEC [PR81358] + +This fixes issues with RISC-V. +--- + Makefile.in | 1 + + gcc/config.in | 6 ++++++ + gcc/config/gnu-user.h | 12 +++++++++++- + gcc/configure | 34 +++++++++++++++++++++++++++++++--- + gcc/configure.ac | 22 +++++++++++++++++++++- + gcc/doc/install.texi | 8 ++++++++ + gcc/doc/tm.texi | 8 +++++++- + gcc/doc/tm.texi.in | 8 +++++++- + gcc/gcc.c | 12 +++++++++++- + 9 files changed, 103 insertions(+), 8 deletions(-) + +diff --git a/Makefile.in b/Makefile.in +index f97db1ef569..7e577ed3dbb 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -222,6 +222,7 @@ HOST_EXPORTS = \ + RANLIB_FOR_TARGET="$(RANLIB_FOR_TARGET)"; export RANLIB_FOR_TARGET; \ + READELF_FOR_TARGET="$(READELF_FOR_TARGET)"; export READELF_FOR_TARGET; \ + TOPLEVEL_CONFIGURE_ARGUMENTS="$(TOPLEVEL_CONFIGURE_ARGUMENTS)"; export TOPLEVEL_CONFIGURE_ARGUMENTS; \ ++ TARGET_CONFIGDIRS="$(TARGET_CONFIGDIRS)"; export TARGET_CONFIGDIRS; \ + HOST_LIBS="$(STAGE1_LIBS)"; export HOST_LIBS; \ + GMPLIBS="$(HOST_GMPLIBS)"; export GMPLIBS; \ + GMPINC="$(HOST_GMPINC)"; export GMPINC; \ +diff --git a/gcc/config.in b/gcc/config.in +index 059c818c895..2a560417440 100644 +--- a/gcc/config.in ++++ b/gcc/config.in +@@ -106,6 +106,12 @@ + #endif + + ++/* Define if libatomic should always be linked. */ ++#ifndef USED_FOR_TARGET ++#undef ENABLE_AUTOLINK_LIBATOMIC ++#endif ++ ++ + /* Define to 1 to specify that we are using the BID decimal floating point + format instead of DPD */ + #ifndef USED_FOR_TARGET +diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h +index 902378e1bad..daf7727a01a 100644 +--- a/gcc/config/gnu-user.h ++++ b/gcc/config/gnu-user.h +@@ -109,8 +109,18 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + #define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} " + #endif + ++#if !defined(LINK_LIBATOMIC_SPEC) && defined(ENABLE_AUTOLINK_LIBATOMIC) ++# ifdef LD_AS_NEEDED_OPTION ++# define LINK_LIBATOMIC_SPEC LD_AS_NEEDED_OPTION " -latomic " LD_NO_AS_NEEDED_OPTION ++# else ++# define LINK_LIBATOMIC_SPEC "-latomic" ++# endif ++#elif !defined(LINK_LIBATOMIC_SPEC) ++# define LINK_LIBATOMIC_SPEC "" ++#endif ++ + #define GNU_USER_TARGET_LINK_GCC_C_SEQUENCE_SPEC \ +- "%{static|static-pie:--start-group} %G %{!nolibc:%L} \ ++ "%{static|static-pie:--start-group} %G %{!nolibc:" LINK_LIBATOMIC_SPEC " %L} \ + %{static|static-pie:--end-group}%{!static:%{!static-pie:%G}}" + + #undef LINK_GCC_C_SEQUENCE_SPEC +diff --git a/gcc/configure b/gcc/configure +index 592e81e40f6..8672298f23f 100755 +--- a/gcc/configure ++++ b/gcc/configure +@@ -978,6 +978,7 @@ with_changes_root_url + enable_languages + with_multilib_list + with_multilib_generator ++enable_autolink_libatomic + with_zstd + with_zstd_include + with_zstd_lib +@@ -1707,6 +1708,9 @@ Optional Features: + --disable-shared don't provide a shared libgcc + --disable-gcov don't provide libgcov and related host tools + --enable-languages=LIST specify which front-ends to build ++ --enable-autolink-libatomic ++ enable automatic linking of libatomic (ignored if ++ not built) + --disable-rpath do not hardcode runtime library paths + --enable-sjlj-exceptions + arrange to use setjmp/longjmp exception handling +@@ -8070,7 +8074,6 @@ else + fi + + +- + # Check whether --with-multilib-generator was given. + if test "${with_multilib_generator+set}" = set; then : + withval=$with_multilib_generator; : +@@ -8078,6 +8081,32 @@ else + with_multilib_generator=default + fi + ++# If libatomic is available, whether it should be linked automatically ++# Check whether --enable-autolink-libatomic was given. ++if test "${enable_autolink_libatomic+set}" = set; then : ++ enableval=$enable_autolink_libatomic; ++ case $enable_autolink_libatomic in ++ yes | no) ;; ++ *) as_fn_error $? "'$enable_autolink_libatomic' is an invalid value for ++--enable-autolink-libatomic. Valid choices are 'yes' and 'no'." "$LINENO" 5 ;; ++ esac ++ ++else ++ enable_autolink_libatomic='' ++fi ++ ++ ++if test x$enable_autolink_libatomic = xyes; then ++ if echo " ${TARGET_CONFIGDIRS} " | grep " libatomic " > /dev/null 2>&1 ; then ++ ++$as_echo "#define ENABLE_AUTOLINK_LIBATOMIC 1" >>confdefs.h ++ ++ else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libatomic is not build for this target, --enable-autolink-libatomic ignored" >&5 ++$as_echo "$as_me: WARNING: libatomic is not build for this target, --enable-autolink-libatomic ignored" >&2;} ++ fi ++fi ++ + + # ------------------------- + # Checks for other programs +@@ -19501,7 +19530,7 @@ else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +-#line 19501 "configure" ++#line 19158 "configure" + #include "confdefs.h" + + #if HAVE_DLFCN_H +@@ -34068,4 +34097,3 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} + fi + +- +diff --git a/gcc/configure.ac b/gcc/configure.ac +index 1577529ffb7..e96691f69ba 100644 +--- a/gcc/configure.ac ++++ b/gcc/configure.ac +@@ -1149,6 +1149,27 @@ AC_ARG_WITH(multilib-generator, + :, + with_multilib_generator=default) + ++# If libatomic is available, whether it should be linked automatically ++AC_ARG_ENABLE(autolink-libatomic, ++[AS_HELP_STRING([--enable-autolink-libatomic], ++ [enable automatic linking of libatomic (ignored if not built)])], ++[ ++ case $enable_autolink_libatomic in ++ yes | no) ;; ++ *) AC_MSG_ERROR(['$enable_autolink_libatomic' is an invalid value for ++--enable-autolink-libatomic. Valid choices are 'yes' and 'no'.]) ;; ++ esac ++], [enable_autolink_libatomic='']) ++ ++if test x$enable_autolink_libatomic = xyes; then ++ if echo " ${TARGET_CONFIGDIRS} " | grep " libatomic " > /dev/null 2>&1 ; then ++ AC_DEFINE(ENABLE_AUTOLINK_LIBATOMIC, 1, ++ [Define if libatomic should always be linked.]) ++ else ++ AC_MSG_WARN([libatomic is not build for this target, --enable-autolink-libatomic ignored]) ++ fi ++fi ++ + # ------------------------- + # Checks for other programs + # ------------------------- +@@ -7729,4 +7750,3 @@ done + ], + [subdirs='$subdirs']) + AC_OUTPUT +- +diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi +index 4c38244ae58..4a544e6a4ee 100644 +--- a/gcc/doc/install.texi ++++ b/gcc/doc/install.texi +@@ -2213,6 +2213,14 @@ files, but these changed header paths may conflict with some compilation + environments. Enabled by default, and may be disabled using + @option{--disable-canonical-system-headers}. + ++@item --enable-autolink-libatomic ++@itemx --disable-autolink-libatomic ++Tell GCC that it should automatically link libatomic; if supported by ++the linker, the file is only linked as needed. This flag is ignored ++when libatomic is not built. Note that this conigure flag is in particular ++useful when building an offloading-target compiler; as for those, a ++user had to specify @code{-foffload=target=-latomic} otherwise. ++ + @item --with-glibc-version=@var{major}.@var{minor} + Tell GCC that when the GNU C Library (glibc) is used on the target it + will be version @var{major}.@var{minor} or later. Normally this can +diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi +index b370bc76b25..acc78273983 100644 +--- a/gcc/doc/tm.texi ++++ b/gcc/doc/tm.texi +@@ -381,7 +381,13 @@ the argument @option{-lgcc} to tell the linker to do the search. + + @defmac LINK_GCC_C_SEQUENCE_SPEC + The sequence in which libgcc and libc are specified to the linker. +-By default this is @code{%G %L %G}. ++By default this is @code{%G LINK_LIBATOMIC_SPEC %L %G}. ++@end defmac ++ ++@defmac LINK_LIBATOMIC_SPEC ++This macro is used in the default @code{LINK_GCC_C_SEQUENCE_SPEC} to link ++libatomic. By default, it is unset unless @code{ENABLE_AUTOLINK_LIBATOMIC} ++is set. + @end defmac + + @defmac POST_LINK_SPEC +diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in +index 2974dae2701..80e003a38ce 100644 +--- a/gcc/doc/tm.texi.in ++++ b/gcc/doc/tm.texi.in +@@ -381,7 +381,13 @@ the argument @option{-lgcc} to tell the linker to do the search. + + @defmac LINK_GCC_C_SEQUENCE_SPEC + The sequence in which libgcc and libc are specified to the linker. +-By default this is @code{%G %L %G}. ++By default this is @code{%G LINK_LIBATOMIC_SPEC %L %G}. ++@end defmac ++ ++@defmac LINK_LIBATOMIC_SPEC ++This macro is used in the default @code{LINK_GCC_C_SEQUENCE_SPEC} to link ++libatomic. By default, it is unset unless @code{ENABLE_AUTOLINK_LIBATOMIC} ++is set. + @end defmac + + @defmac POST_LINK_SPEC +diff --git a/gcc/gcc.c b/gcc/gcc.c +index 22dbbf85850..90aa576037a 100644 +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -980,13 +980,23 @@ proper position among the other output files. */ + # define ASM_DEBUG_OPTION_SPEC "" + #endif + ++#if !defined(LINK_LIBATOMIC_SPEC) && defined(ENABLE_AUTOLINK_LIBATOMIC) ++# ifdef LD_AS_NEEDED_OPTION ++# define LINK_LIBATOMIC_SPEC LD_AS_NEEDED_OPTION " -latomic " LD_NO_AS_NEEDED_OPTION ++# else ++# define LINK_LIBATOMIC_SPEC "-latomic" ++# endif ++#elif !defined(LINK_LIBATOMIC_SPEC) ++# define LINK_LIBATOMIC_SPEC "" ++#endif ++ + /* Here is the spec for running the linker, after compiling all files. */ + + /* This is overridable by the target in case they need to specify the + -lgcc and -lc order specially, yet not require them to override all + of LINK_COMMAND_SPEC. */ + #ifndef LINK_GCC_C_SEQUENCE_SPEC +-#define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}" ++#define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:" LINK_LIBATOMIC_SPEC " %L %G}" + #endif + + #ifdef ENABLE_DEFAULT_SSP +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0040-configure-fix-detection-of-atomic-builtins-in-libato.patch b/cross-images/mini-aports/main/gcc/0040-configure-fix-detection-of-atomic-builtins-in-libato.patch new file mode 100644 index 0000000..c97f0b6 --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0040-configure-fix-detection-of-atomic-builtins-in-libato.patch @@ -0,0 +1,57 @@ +From 5010fa237897bca92291ba8835123125d4af933a Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Sun, 29 Aug 2021 09:45:27 +0200 +Subject: [PATCH] configure: fix detection of atomic builtins in libatomic + configure script + +Alpine's --enable-autolink-libatomic (which is enabled for riscv64 by +default) causes the libatomic configure script to incorrectly detect +which builtins are available on riscv64. This then causes incorrect code +generation for libatomic since it assumes compiler builtins to be +available which are not actually available on riscv64. + +This commit fixes this issue by disabling linking of libatomic configure +test code entirely, thereby preventing linking against libatomic. + +See: + +* https://gitlab.alpinelinux.org/alpine/aports/-/issues/12948 +* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101996#c6 +--- + libatomic/configure.tgt | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt +index 670b0d72cfe..38c2cd9345f 100644 +--- a/libatomic/configure.tgt ++++ b/libatomic/configure.tgt +@@ -30,6 +30,26 @@ + # on ${target_cpu}. For example to allow proper use of multilibs. + configure_tgt_pre_target_cpu_XCFLAGS="${XCFLAGS}" + ++# The libatomic configure script performs several checks to determine ++# whether builtins for atomic operations are available. When compiling ++# with --enable-autolink-libatomic the test code compiled by the ++# configure script is also linked against libatomic. This causes it ++# to think that builtins are available, even if there are not, since ++# the tested symbols are provided by libatomic. ++# ++# This is a hack to ensure that we don't link against libatomic by not ++# linking any configure test code at all when --enable-autolink-libatomic ++# is given. ++# ++# See: ++# ++# * https://gitlab.alpinelinux.org/alpine/aports/-/issues/12817 ++# * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101996#c4 ++# ++if test x$enable_autolink_libatomic = xyes; then ++ gcc_no_link=yes ++fi ++ + case "${target_cpu}" in + alpha*) + # fenv.c needs this option to generate inexact exceptions. +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0041-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch b/cross-images/mini-aports/main/gcc/0041-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch new file mode 100644 index 0000000..4eadde5 --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0041-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch @@ -0,0 +1,84 @@ +From 2d924c522dde7426afbb8096d9301b17d0e73121 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Sun, 28 Nov 2021 00:54:37 +0100 +Subject: [PATCH] libgo: Recognize off64_t and loff_t definitions of musl libc + +Without this patch, both off64_t and loff_t are not recognized by +-fdump-go-spec which causes a variety Go-related compilation errors on +musl libc since the gcc-go frontend expects both off64_t and loff_t to +be present. + +Also make sure that autoconf recognizes support for loff_t on musl, by +compiling the relevant feature test code with -D_GNU_SOURCE and making +it include fcntl.h which defines loff_t on musl. +--- + libgo/configure | 4 +++- + libgo/configure.ac | 4 +++- + libgo/sysinfo.c | 21 +++++++++++++++++++++ + 3 files changed, 27 insertions(+), 2 deletions(-) + +diff --git a/libgo/configure b/libgo/configure +index 70f64c974fd..69d15839e8c 100755 +--- a/libgo/configure ++++ b/libgo/configure +@@ -15546,7 +15546,9 @@ _ACEOF + + fi + +-ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "$ac_includes_default" ++CFLAGS_hold=$CFLAGS ++CFLAGS="$CFLAGS -D_GNU_SOURCE" ++ac_fn_c_check_type "$LINENO" "loff_t" "ac_cv_type_loff_t" "#include " + if test "x$ac_cv_type_loff_t" = xyes; then : + + cat >>confdefs.h <<_ACEOF +diff --git a/libgo/configure.ac b/libgo/configure.ac +index ebab9d9de3e..a3d9d309aba 100644 +--- a/libgo/configure.ac ++++ b/libgo/configure.ac +@@ -602,7 +602,9 @@ AC_STRUCT_DIRENT_D_TYPE + + AC_CHECK_FUNCS(accept4 dup3 epoll_create1 faccessat fallocate fchmodat fchownat futimesat getxattr inotify_add_watch inotify_init inotify_init1 inotify_rm_watch listxattr mkdirat mknodat open64 openat pipe2 removexattr renameat setxattr sync_file_range splice syscall tee unlinkat unshare utimensat) + AC_TYPE_OFF_T +-AC_CHECK_TYPES([loff_t]) ++CFLAGS_hold=$CFLAGS ++CFLAGS="$CFLAGS -D_GNU_SOURCE" # musl does not define loff_t without this ++AC_CHECK_TYPES([loff_t], [], [], [[#include ]]) + + LIBS_hold="$LIBS" + LIBS="$LIBS -lm" +diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c +index 8ce061e2f5f..b85add15a7b 100644 +--- a/libgo/sysinfo.c ++++ b/libgo/sysinfo.c +@@ -343,6 +343,27 @@ enum { + #endif + }; + ++// musl libc has both off64_t and loff_t. However, both of these types ++// are defined as CPP macros, not as C typedefs. Unfortunately, the GCC ++// -fdump-go-spec option, which is responsible for generating type ++// definitions for Go based on this file, only recognizes types defined ++// through typedefs. ++// ++// For this reason, we check here if either off64_t or loff_t are ++// defined as CPP macros and if so, we redefine them using a C typedef. ++#if defined(HAVE_OFF64_T) && defined(off64_t) ++typedef off64_t __musl_off64_t; ++#undef off64_t ++typedef __musl_off64_t off64_t; ++#endif ++ ++// See comment regarding musl libc above. ++#if defined(HAVE_LOFF_T) && defined(loff_t) ++typedef loff_t __musl_loff_t; ++#undef loff_t ++typedef __musl_loff_t loff_t; ++#endif ++ + // SIOCGIFMTU can't be added in the above enum as it might + // be signed in some OSes. + #ifdef SIOCGIFMTU +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch b/cross-images/mini-aports/main/gcc/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch new file mode 100644 index 0000000..7975e63 --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch @@ -0,0 +1,80 @@ +From 72f32e3383129ad139df76d9a063fac9b03079b1 Mon Sep 17 00:00:00 2001 +From: Alex McGrath +Date: Wed, 13 Oct 2021 23:24:27 +0100 +Subject: [PATCH] Fix attempt to use poisoned calloc error in libgccjit + +This moves usages of pthread.h to above any usage of system.h as it +included #pragma GCC poison calloc +--- + gcc/jit/jit-playback.c | 4 ++-- + gcc/jit/jit-recording.c | 4 ++-- + gcc/jit/libgccjit.c | 3 ++- + 3 files changed, 6 insertions(+), 5 deletions(-) + +diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c +index cee9daa8220..a5600084933 100644 +--- a/gcc/jit/jit-playback.c ++++ b/gcc/jit/jit-playback.c +@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + ++#include ++ + #include "config.h" + #include "system.h" + #include "coretypes.h" +@@ -41,8 +43,6 @@ along with GCC; see the file COPYING3. If not see + #include "diagnostic.h" + #include "stmt.h" + +-#include +- + #include "jit-playback.h" + #include "jit-result.h" + #include "jit-builtins.h" +diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c +index 117ff70114c..d2634a546b1 100644 +--- a/gcc/jit/jit-recording.c ++++ b/gcc/jit/jit-recording.c +@@ -18,6 +18,8 @@ You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + ++#include ++ + #include "config.h" + #include "system.h" + #include "coretypes.h" +@@ -25,8 +27,6 @@ along with GCC; see the file COPYING3. If not see + #include "pretty-print.h" + #include "toplev.h" + +-#include +- + #include "jit-builtins.h" + #include "jit-recording.h" + #include "jit-playback.h" +diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c +index 0cc650f9810..2f44481eeb0 100644 +--- a/gcc/jit/libgccjit.c ++++ b/gcc/jit/libgccjit.c +@@ -18,13 +18,14 @@ You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + ++#include ++ + #include "config.h" + #include "system.h" + #include "coretypes.h" + #include "timevar.h" + #include "typed-splay-tree.h" + #include "cppbuiltin.h" +-#include + + #include "libgccjit.h" + #include "jit-recording.h" +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0043-stddef.h-add-support-for-musl-typedef-macro-guards.patch b/cross-images/mini-aports/main/gcc/0043-stddef.h-add-support-for-musl-typedef-macro-guards.patch new file mode 100644 index 0000000..af77176 --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0043-stddef.h-add-support-for-musl-typedef-macro-guards.patch @@ -0,0 +1,106 @@ +From aeef0ee2aac43d89ae26c6a3559aae4f8a1d53da Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Thu, 25 Nov 2021 17:44:04 +0100 +Subject: [PATCH] stddef.h: add support for musl typedef macro guards + +The stddef.h header checks/sets various hardcoded toolchain/os specific +macro guards to prevent redefining types such as ptrdiff_t, wchar_t, or +size_t. However, without this patch, the file does not check/set the +typedef macro guards for musl libc. This causes types such as size_t to +be defined twice for files which include both musl's stddef.h as well as +GCC's ginclude/stddef.h. This is, for example, the case for +libgo/sysinfo.c. If libgo/sysinfo.c has multiple typedefs for size_t +this confuses -fdump-go-spec and causes size_t not to be included in the +generated type definitions thereby causing a gcc-go compilation failure +on musl with the following error message: + + sysinfo.go:7765:13: error: use of undefined type '_size_t' + 7765 | type Size_t _size_t + | ^ + libcall_posix.go:49:35: error: non-integer len argument in make + 49 | b := make([]byte, len) + | + +This commit fixes this issue by ensuring that ptrdiff_t, wchar_t, and size_t +are only defined once in the pre-processed libgo/sysinfo.c file by enhancing +gcc/ginclude/stddef.h with musl-specific typedef macro guards. +--- + gcc/ginclude/stddef.h | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/gcc/ginclude/stddef.h b/gcc/ginclude/stddef.h +index 66619fe43b1..50d710a5ab9 100644 +--- a/gcc/ginclude/stddef.h ++++ b/gcc/ginclude/stddef.h +@@ -128,6 +128,7 @@ _TYPE_wchar_t; + #ifndef ___int_ptrdiff_t_h + #ifndef _GCC_PTRDIFF_T + #ifndef _PTRDIFF_T_DECLARED /* DragonFly */ ++#ifndef __DEFINED_ptrdiff_t /* musl libc */ + #define _PTRDIFF_T + #define _T_PTRDIFF_ + #define _T_PTRDIFF +@@ -137,10 +138,12 @@ _TYPE_wchar_t; + #define ___int_ptrdiff_t_h + #define _GCC_PTRDIFF_T + #define _PTRDIFF_T_DECLARED ++#define __DEFINED_ptrdiff_t + #ifndef __PTRDIFF_TYPE__ + #define __PTRDIFF_TYPE__ long int + #endif + typedef __PTRDIFF_TYPE__ ptrdiff_t; ++#endif /* __DEFINED_ptrdiff_t */ + #endif /* _PTRDIFF_T_DECLARED */ + #endif /* _GCC_PTRDIFF_T */ + #endif /* ___int_ptrdiff_t_h */ +@@ -174,6 +177,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; + #ifndef _SIZE_T_DEFINED + #ifndef _BSD_SIZE_T_DEFINED_ /* Darwin */ + #ifndef _SIZE_T_DECLARED /* FreeBSD 5 */ ++#ifndef __DEFINED_size_t /* musl libc */ + #ifndef ___int_size_t_h + #ifndef _GCC_SIZE_T + #ifndef _SIZET_ +@@ -191,6 +195,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t; + #define _SIZE_T_DEFINED + #define _BSD_SIZE_T_DEFINED_ /* Darwin */ + #define _SIZE_T_DECLARED /* FreeBSD 5 */ ++#define __DEFINED_size_t /* musl libc */ + #define ___int_size_t_h + #define _GCC_SIZE_T + #define _SIZET_ +@@ -215,6 +220,7 @@ typedef long ssize_t; + #endif /* _SIZET_ */ + #endif /* _GCC_SIZE_T */ + #endif /* ___int_size_t_h */ ++#endif /* __DEFINED_size_t */ + #endif /* _SIZE_T_DECLARED */ + #endif /* _BSD_SIZE_T_DEFINED_ */ + #endif /* _SIZE_T_DEFINED */ +@@ -251,6 +257,7 @@ typedef long ssize_t; + #ifndef _BSD_WCHAR_T_DEFINED_ /* Darwin */ + #ifndef _BSD_RUNE_T_DEFINED_ /* Darwin */ + #ifndef _WCHAR_T_DECLARED /* FreeBSD 5 */ ++#ifndef __DEFINED_wchar_t /* musl libc */ + #ifndef _WCHAR_T_DEFINED_ + #ifndef _WCHAR_T_DEFINED + #ifndef _WCHAR_T_H +@@ -272,6 +279,7 @@ typedef long ssize_t; + #define __INT_WCHAR_T_H + #define _GCC_WCHAR_T + #define _WCHAR_T_DECLARED ++#define __DEFINED_wchar_t + + /* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_ + instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other +@@ -326,6 +334,7 @@ typedef __WCHAR_TYPE__ wchar_t; + #endif + #endif + #endif ++#endif /* __DEFINED_wchar_t */ + #endif /* _WCHAR_T_DECLARED */ + #endif /* _BSD_RUNE_T_DEFINED_ */ + #endif +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0044-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch b/cross-images/mini-aports/main/gcc/0044-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch new file mode 100644 index 0000000..140d3e8 --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0044-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch @@ -0,0 +1,63 @@ +From 36c79820c1085590f272ef1afcad4744125d96d0 Mon Sep 17 00:00:00 2001 +From: "A. Wilcox" +Date: Sun, 30 Aug 2020 18:33:49 +0200 +Subject: [PATCH] gcc-go: Use int64 type as offset argument for mmap +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Without this patch, Go run-time memory allocation fails on 32-bit architectures: + + fatal error: runtime: cannot allocate memory + runtime stack: + runtime.dopanic__m + :0 + runtime.throw + :0 + :0 + :0 + runtime.systemstack + :0 + runtime.addrRanges.init + :0 + runtime.pageAlloc.init + :0 + runtime.mheap.init + :0 + runtime.schedinit + :0 + :0 + :0 + +Taken from Adélie Linux [1]. + +[1]: https://git.adelielinux.org/adelie/packages/-/commit/63b5fb12c3d75e460799c672bbbdd5d29c3cc33c +--- + libgo/go/runtime/mem_gccgo.go | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/libgo/go/runtime/mem_gccgo.go b/libgo/go/runtime/mem_gccgo.go +index fa3389d857e..57bed97c710 100644 +--- a/libgo/go/runtime/mem_gccgo.go ++++ b/libgo/go/runtime/mem_gccgo.go +@@ -15,7 +15,7 @@ import ( + //go:linkname sysFree + + //extern mmap +-func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) unsafe.Pointer ++func sysMmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) unsafe.Pointer + + //extern munmap + func munmap(addr unsafe.Pointer, length uintptr) int32 +@@ -37,7 +37,7 @@ func init() { + } + } + +-func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uintptr) (unsafe.Pointer, int) { ++func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off int64) (unsafe.Pointer, int) { + p := sysMmap(addr, n, prot, flags, fd, off) + if uintptr(p) == _MAP_FAILED { + return nil, errno() +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0045-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch b/cross-images/mini-aports/main/gcc/0045-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch new file mode 100644 index 0000000..4823eef --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0045-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch @@ -0,0 +1,58 @@ +From 353c8abdc34a294c89c24423ef0c4182189117f6 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Sun, 2 Jan 2022 01:07:03 +0100 +Subject: [PATCH] libgo: include asm/ptrace.h for pt_regs definition on PowerPC +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Both glibc and musl libc declare pt_regs as an incomplete type. This +type has to be completed by inclusion of another header. On Linux, the +asm/ptrace.h header file provides this type definition. Without +including this header file, it is not possible to access the regs member +of the mcontext_t struct as done in libgo/runtime/go-signal.c. On glibc, +other headers (e.g. sys/user.h) include asm/ptrace.h but on musl +asm/ptrace.h is not included by other headers and thus the +aforementioned files do not compile without an explicit include of +asm/ptrace.h: + + libgo/runtime/go-signal.c: In function 'getSiginfo': + libgo/runtime/go-signal.c:227:63: error: invalid use of undefined type 'struct pt_regs' + 227 | ret.sigpc = ((ucontext_t*)(context))->uc_mcontext.regs->nip; + | + +Instead of including the asm/ptrace.h header conditionally on PowerPC +only it would alternatively also be possible to include it +unconditionally. + +See also: + +* https://git.musl-libc.org/cgit/musl/commit/?id=c2518a8efb6507f1b41c3b12e03b06f8f2317a1f +* https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d57cb31910ca5c200e4172276749a7f8bd17ae3c +* https://github.com/kaniini/libucontext/issues/36 + +Signed-off-by: Sören Tempel +--- + libgo/runtime/go-signal.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/libgo/runtime/go-signal.c b/libgo/runtime/go-signal.c +index d30d1603adc..fc01e04e4a1 100644 +--- a/libgo/runtime/go-signal.c ++++ b/libgo/runtime/go-signal.c +@@ -10,6 +10,12 @@ + #include + #include + ++// On PowerPC, ucontext.h uses a pt_regs struct as an incomplete ++// type. This type must be completed by including asm/ptrace.h. ++#ifdef __PPC__ ++#include ++#endif ++ + #include "runtime.h" + + #ifndef SA_RESTART +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0046-Disable-fsplit-stack-support-on-non-glibc-targets.patch b/cross-images/mini-aports/main/gcc/0046-Disable-fsplit-stack-support-on-non-glibc-targets.patch new file mode 100644 index 0000000..ffd7ab0 --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0046-Disable-fsplit-stack-support-on-non-glibc-targets.patch @@ -0,0 +1,115 @@ +From 2c6bf28619c9b3bf713f7f5319c5d750a6c297ae Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Fri, 21 Jan 2022 19:22:46 +0000 +Subject: [PATCH] Disable -fsplit-stack support on non-glibc targets +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The -fsplit-stack option requires the pthread_t TCB definition in the +libc to provide certain struct fields at specific hardcoded offsets. As +far as I know, only glibc provides these fields at the required offsets. +Most notably, musl libc does not have these fields. However, since gcc +accesses the fields using a fixed offset, this does not cause a +compile-time error, but instead results in a silent memory corruption at +run-time with musl libc. For example, on s390x libgcc's +__stack_split_initialize CTOR will overwrite the cancel field in the +pthread_t TCB on musl. + +The -fsplit-stack option is used within the gcc code base itself by +gcc-go (if available). On musl-based systems with split-stack support +(i.e. s390x or x86) this causes Go programs compiled with gcc-go to +misbehave at run-time. + +This patch fixes gcc-go on musl by disabling -fsplit-stack in gcc itself +since it is not supported on non-glibc targets anyhow. This is achieved +by checking if gcc targets a glibc-based system. This check has been +added for x86 and s390x, the rs6000 config already checks for +TARGET_GLIBC_MAJOR. Other architectures do not have split-stack +support. With this patch applied, the gcc-go configure script will +detect that -fsplit-stack support is not available and will not use it. + +See https://www.openwall.com/lists/musl/2012/10/16/12 + +This patch was written under the assumption that glibc is the only libc +implementation which supports the required fields at the required +offsets in the pthread_t TCB. The patch has been tested on Alpine Linux +Edge on the s390x and x86 architectures by bootstrapping Google's Go +implementation with gcc-go. + +Signed-off-by: Sören Tempel + +gcc/ChangeLog: + + * common/config/s390/s390-common.c (s390_supports_split_stack): + Only support split-stack on glibc targets. + * config/i386/gnu-user-common.h (STACK_CHECK_STATIC_BUILTIN): Ditto. + * config/i386/gnu.h (defined): Ditto. +--- + gcc/common/config/s390/s390-common.c | 14 ++++++++++---- + gcc/config/i386/gnu-user-common.h | 5 +++-- + gcc/config/i386/gnu.h | 5 ++++- + 3 files changed, 17 insertions(+), 7 deletions(-) + +diff --git a/gcc/common/config/s390/s390-common.c b/gcc/common/config/s390/s390-common.c +index b6bc8501742..8c1e590322d 100644 +--- a/gcc/common/config/s390/s390-common.c ++++ b/gcc/common/config/s390/s390-common.c +@@ -116,13 +116,19 @@ s390_handle_option (struct gcc_options *opts ATTRIBUTE_UNUSED, + + /* -fsplit-stack uses a field in the TCB, available with glibc-2.23. + We don't verify it, since earlier versions just have padding at +- its place, which works just as well. */ ++ its place, which works just as well. For other libc implementations ++ we disable the feature entirely to avoid corrupting the TCB. */ + + static bool +-s390_supports_split_stack (bool report ATTRIBUTE_UNUSED, +- struct gcc_options *opts ATTRIBUTE_UNUSED) ++s390_supports_split_stack (bool report, ++ struct gcc_options *opts) + { +- return true; ++ if (opts->x_linux_libc == LIBC_GLIBC) ++ return true; ++ ++ if (report) ++ error ("%<-fsplit-stack%> currently only supported on GNU/Linux"); ++ return false; + } + + #undef TARGET_DEFAULT_TARGET_FLAGS +diff --git a/gcc/config/i386/gnu-user-common.h b/gcc/config/i386/gnu-user-common.h +index 00226f5a455..6e13315b5a3 100644 +--- a/gcc/config/i386/gnu-user-common.h ++++ b/gcc/config/i386/gnu-user-common.h +@@ -66,7 +66,8 @@ along with GCC; see the file COPYING3. If not see + #define STACK_CHECK_STATIC_BUILTIN 1 + + /* We only build the -fsplit-stack support in libgcc if the +- assembler has full support for the CFI directives. */ +-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE ++ assembler has full support for the CFI directives and ++ targets glibc. */ ++#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE && OPTION_GLIBC + #define TARGET_CAN_SPLIT_STACK + #endif +diff --git a/gcc/config/i386/gnu.h b/gcc/config/i386/gnu.h +index 25fbc07f58c..afd3e8e8841 100644 +--- a/gcc/config/i386/gnu.h ++++ b/gcc/config/i386/gnu.h +@@ -35,7 +35,10 @@ along with GCC. If not, see . + crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}" + #endif + +-#ifdef TARGET_LIBC_PROVIDES_SSP ++/* -fsplit-stack uses a field in the TCB at a fixed offset. This ++ field is only available for glibc. Disable -fsplit-stack for ++ other libc implementations to avoid silent TCB corruptions. */ ++#if defined (TARGET_LIBC_PROVIDES_SSP) && OPTION_GLIBC + + /* i386 glibc provides __stack_chk_guard in %gs:0x14. */ + #define TARGET_THREAD_SSP_OFFSET 0x14 +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0047-x86-Properly-disable-fsplit-stack-support-on-non-gli.patch b/cross-images/mini-aports/main/gcc/0047-x86-Properly-disable-fsplit-stack-support-on-non-gli.patch new file mode 100644 index 0000000..0437fd4 --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0047-x86-Properly-disable-fsplit-stack-support-on-non-gli.patch @@ -0,0 +1,94 @@ +From 4ea687132408a7c662706c4a7eb3c61b7773d735 Mon Sep 17 00:00:00 2001 +From: "H.J. Lu" +Date: Fri, 21 Jan 2022 13:24:00 -0800 +Subject: [PATCH] x86: Properly disable -fsplit-stack support on non-glibc + targets + +Revert x86 changes in + +commit c163647ffbc9a20c8feb6e079dbecccfe016c82e +Author: Soren Tempel +Date: Fri Jan 21 19:22:46 2022 +0000 + + Disable -fsplit-stack support on non-glibc targets + +and change ix86_supports_split_stack to return true only on glibc. + + PR bootstrap/104170 + * common/config/i386/i386-common.c (ix86_supports_split_stack): + Return true only on glibc. + * config/i386/gnu-user-common.h (STACK_CHECK_STATIC_BUILTIN): + Revert commit c163647ffbc. + * config/i386/gnu.h (TARGET_LIBC_PROVIDES_SSP): Likewise. +--- + gcc/common/config/i386/i386-common.c | 17 +++++++++++------ + gcc/config/i386/gnu-user-common.h | 5 ++--- + gcc/config/i386/gnu.h | 5 +---- + 3 files changed, 14 insertions(+), 13 deletions(-) + +diff --git a/gcc/common/config/i386/i386-common.c b/gcc/common/config/i386/i386-common.c +index 96549aa7d7e..a3b5258e828 100644 +--- a/gcc/common/config/i386/i386-common.c ++++ b/gcc/common/config/i386/i386-common.c +@@ -1696,16 +1696,21 @@ ix86_option_init_struct (struct gcc_options *opts) + field in the TCB, so they cannot be used together. */ + + static bool +-ix86_supports_split_stack (bool report ATTRIBUTE_UNUSED, ++ix86_supports_split_stack (bool report, + struct gcc_options *opts ATTRIBUTE_UNUSED) + { ++#ifdef TARGET_THREAD_SPLIT_STACK_OFFSET ++ if (opts->x_linux_libc != LIBC_GLIBC) ++#endif ++ { ++ if (report) ++ error ("%<-fsplit-stack%> currently only supported on GNU/Linux"); ++ return false; ++ } ++ + bool ret = true; + +-#ifndef TARGET_THREAD_SPLIT_STACK_OFFSET +- if (report) +- error ("%<-fsplit-stack%> currently only supported on GNU/Linux"); +- ret = false; +-#else ++#ifdef TARGET_THREAD_SPLIT_STACK_OFFSET + if (!HAVE_GAS_CFI_PERSONALITY_DIRECTIVE) + { + if (report) +diff --git a/gcc/config/i386/gnu-user-common.h b/gcc/config/i386/gnu-user-common.h +index 6e13315b5a3..00226f5a455 100644 +--- a/gcc/config/i386/gnu-user-common.h ++++ b/gcc/config/i386/gnu-user-common.h +@@ -66,8 +66,7 @@ along with GCC; see the file COPYING3. If not see + #define STACK_CHECK_STATIC_BUILTIN 1 + + /* We only build the -fsplit-stack support in libgcc if the +- assembler has full support for the CFI directives and +- targets glibc. */ +-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE && OPTION_GLIBC ++ assembler has full support for the CFI directives. */ ++#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE + #define TARGET_CAN_SPLIT_STACK + #endif +diff --git a/gcc/config/i386/gnu.h b/gcc/config/i386/gnu.h +index afd3e8e8841..25fbc07f58c 100644 +--- a/gcc/config/i386/gnu.h ++++ b/gcc/config/i386/gnu.h +@@ -35,10 +35,7 @@ along with GCC. If not, see . + crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}" + #endif + +-/* -fsplit-stack uses a field in the TCB at a fixed offset. This +- field is only available for glibc. Disable -fsplit-stack for +- other libc implementations to avoid silent TCB corruptions. */ +-#if defined (TARGET_LIBC_PROVIDES_SSP) && OPTION_GLIBC ++#ifdef TARGET_LIBC_PROVIDES_SSP + + /* i386 glibc provides __stack_chk_guard in %gs:0x14. */ + #define TARGET_THREAD_SSP_OFFSET 0x14 +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0048-gdc-unconditionally-link-libgphobos-against-libucont.patch b/cross-images/mini-aports/main/gcc/0048-gdc-unconditionally-link-libgphobos-against-libucont.patch new file mode 100644 index 0000000..3853101 --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0048-gdc-unconditionally-link-libgphobos-against-libucont.patch @@ -0,0 +1,26 @@ +From e74e2946a534fbac7e8ec6c687c407761daef49a Mon Sep 17 00:00:00 2001 +From: Mathias LANG +Date: Mon, 17 Jan 2022 16:31:09 +0000 +Subject: [PATCH] gdc: unconditionally link libgphobos against libucontext + +ref: alpine/aports#13422 +--- + Makefile.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile.in b/Makefile.in +index 7e577ed3dbb..da40b61a8c5 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -51248,7 +51248,7 @@ configure-target-libphobos: + esac; \ + module_srcdir=libphobos; \ + rm -f no-such-file || : ; \ +- CONFIG_SITE=no-such-file $(SHELL) \ ++ CONFIG_SITE=no-such-file LIBS="-lucontext $$LIBS" $(SHELL) \ + $$s/$$module_srcdir/configure \ + --srcdir=$${topdir}/$$module_srcdir \ + $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0049-properly-disable-fsplit-stack-on-non-glibc-targets-P.patch b/cross-images/mini-aports/main/gcc/0049-properly-disable-fsplit-stack-on-non-glibc-targets-P.patch new file mode 100644 index 0000000..b228f24 --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0049-properly-disable-fsplit-stack-on-non-glibc-targets-P.patch @@ -0,0 +1,298 @@ +From 7b5108375bb67532af30d1e7f553ac5f3b1096fe Mon Sep 17 00:00:00 2001 +From: Jakub Jelinek +Date: Mon, 24 Jan 2022 11:13:39 +0100 +Subject: [PATCH] properly disable -fsplit-stack on non-glibc targets + [PR104170] +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +On Sat, Jan 22, 2022 at 10:32:21AM +0100, Martin Liška wrote: +> I've just noticed the patch broke a few cross compilers: +> +> s390x-ibm-tpf: +> +> /home/marxin/buildworker/zen2-cross-compilers/build/gcc/common/config/s390/s390-common.cc: In function ‘bool s390_supports_split_stack(bool, gcc_options*)’: +> /home/marxin/buildworker/zen2-cross-compilers/build/gcc/common/config/s390/s390-common.cc:126:13: error: ‘struct gcc_options’ has no member named ‘x_linux_libc’ +> 126 | if (opts->x_linux_libc == LIBC_GLIBC) +> | ^~~~~~~~~~~~ +> +> i686-kopensolaris-gnu, i686-symbolics-gnu +> +> /home/marxin/buildworker/zen2-cross-compilers/build/gcc/common/config/i386/i386-common.cc: In function ‘bool ix86_supports_split_stack(bool, gcc_options*)’: +> /home/marxin/buildworker/zen2-cross-compilers/build/gcc/common/config/i386/i386-common.cc:1721:13: error: ‘struct gcc_options’ has no member named ‘x_linux_libc’ +> 1721 | if (opts->x_linux_libc != LIBC_GLIBC) +> | ^~~~~~~~~~~~ +> make[1]: *** [Makefile:2418: i386-common.o] Error 1 +> +> Can you please take a look? Btw. do you have a bugzilla account? + +I bet instead of opts->x_linux_libc != LIBC_GLIBC it needs to use + #ifdef OPTION_GLIBC + if (!OPTION_GLIBC) + #endif +or so. I think the first committed patch actually used that +but used it in #if directive, which is wrong because it is something +that needs to be evaluated at runtime. + +That doesn't work well either, because the *supports_split_stack +hooks have opts argument and OPTION_GLIBC doesn't take that. + +So, here is a patch that introduces OPTION_*_P macros that take opts +as an argument and redefines OPTION_* using those (similarly to how +the option scripts create TARGET_*_P and TARGET_* macros). + +2022-01-24 Jakub Jelinek + + PR bootstrap/104170 + * config/linux.h (OPTION_GLIBC_P, OPTION_UCLIBC_P, + OPTION_BIONIC_P, OPTION_MUSL_P): Define. + (OPTION_GLIBC, OPTION_UCLIBC, OPTION_BIONIC, OPTION_MUSL): Redefine + using OPTION_*_P macros. + * config/alpha/linux.h (OPTION_GLIBC_P, OPTION_UCLIBC_P, + OPTION_BIONIC_P, OPTION_MUSL_P): Define. + (OPTION_GLIBC, OPTION_UCLIBC, OPTION_BIONIC, OPTION_MUSL): Redefine + using OPTION_*_P macros. + * config/rs6000/linux.h (OPTION_GLIBC_P, OPTION_UCLIBC_P, + OPTION_BIONIC_P, OPTION_MUSL_P): Define. + (OPTION_GLIBC, OPTION_UCLIBC, OPTION_BIONIC, OPTION_MUSL): Redefine + using OPTION_*_P macros. + * config/rs6000/linux64.h (OPTION_GLIBC_P, OPTION_UCLIBC_P, + OPTION_BIONIC_P, OPTION_MUSL_P): Define. + (OPTION_GLIBC, OPTION_UCLIBC, OPTION_BIONIC, OPTION_MUSL): Redefine + using OPTION_*_P macros. + * config/fuchsia.h (OPTION_MUSL_P): Redefine. + * config/glibc-stdint.h (OPTION_MUSL_P): Define if not defined. + * common/config/s390/s390-common.cc (s390_supports_split_stack): Re-add + ATTRIBUTE_UNUSED to opts parameter. If OPTION_GLIBC_P is defined, use + OPTION_GLIBC_P (opts) as condition, otherwise assume if (false). + * common/config/i386/i386-common.cc (ix86_supports_split_stack): If + OPTION_GLIBC_P is defined use !OPTION_GLIBC_P (opts) as condition, + otherwise assume if (true). +--- + gcc/common/config/i386/i386-common.c | 4 ++-- + gcc/common/config/s390/s390-common.c | 6 ++++-- + gcc/config/alpha/linux.h | 25 +++++++++++++++---------- + gcc/config/fuchsia.h | 2 ++ + gcc/config/glibc-stdint.h | 3 +++ + gcc/config/linux.h | 25 +++++++++++++++---------- + gcc/config/rs6000/linux.h | 25 +++++++++++++++---------- + gcc/config/rs6000/linux64.h | 25 +++++++++++++++---------- + 8 files changed, 71 insertions(+), 44 deletions(-) + +diff --git a/gcc/common/config/i386/i386-common.c b/gcc/common/config/i386/i386-common.c +index a3b5258e828..864e68ab985 100644 +--- a/gcc/common/config/i386/i386-common.c ++++ b/gcc/common/config/i386/i386-common.c +@@ -1699,8 +1699,8 @@ static bool + ix86_supports_split_stack (bool report, + struct gcc_options *opts ATTRIBUTE_UNUSED) + { +-#ifdef TARGET_THREAD_SPLIT_STACK_OFFSET +- if (opts->x_linux_libc != LIBC_GLIBC) ++#if defined(TARGET_THREAD_SPLIT_STACK_OFFSET) && defined(OPTION_GLIBC_P) ++ if (!OPTION_GLIBC_P (opts)) + #endif + { + if (report) +diff --git a/gcc/common/config/s390/s390-common.c b/gcc/common/config/s390/s390-common.c +index 8c1e590322d..11116f131cb 100644 +--- a/gcc/common/config/s390/s390-common.c ++++ b/gcc/common/config/s390/s390-common.c +@@ -121,10 +121,12 @@ s390_handle_option (struct gcc_options *opts ATTRIBUTE_UNUSED, + + static bool + s390_supports_split_stack (bool report, +- struct gcc_options *opts) ++ struct gcc_options *opts ATTRIBUTE_UNUSED) + { +- if (opts->x_linux_libc == LIBC_GLIBC) ++#ifdef OPTION_GLIBC_P ++ if (OPTION_GLIBC_P (opts)) + return true; ++#endif + + if (report) + error ("%<-fsplit-stack%> currently only supported on GNU/Linux"); +diff --git a/gcc/config/alpha/linux.h b/gcc/config/alpha/linux.h +index bde7fb0d292..812ec8ecb31 100644 +--- a/gcc/config/alpha/linux.h ++++ b/gcc/config/alpha/linux.h +@@ -58,18 +58,23 @@ along with GCC; see the file COPYING3. If not see + #define WCHAR_TYPE "int" + + #ifdef SINGLE_LIBC +-#define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC) +-#define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC) +-#define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC) +-#undef OPTION_MUSL +-#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL) ++#define OPTION_GLIBC_P(opts) (DEFAULT_LIBC == LIBC_GLIBC) ++#define OPTION_UCLIBC_P(opts) (DEFAULT_LIBC == LIBC_UCLIBC) ++#define OPTION_BIONIC_P(opts) (DEFAULT_LIBC == LIBC_BIONIC) ++#undef OPTION_MUSL_P ++#define OPTION_MUSL_P(opts) (DEFAULT_LIBC == LIBC_MUSL) + #else +-#define OPTION_GLIBC (linux_libc == LIBC_GLIBC) +-#define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC) +-#define OPTION_BIONIC (linux_libc == LIBC_BIONIC) +-#undef OPTION_MUSL +-#define OPTION_MUSL (linux_libc == LIBC_MUSL) ++#define OPTION_GLIBC_P(opts) ((opts)->x_linux_libc == LIBC_GLIBC) ++#define OPTION_UCLIBC_P(opts) ((opts)->x_linux_libc == LIBC_UCLIBC) ++#define OPTION_BIONIC_P(opts) ((opts)->x_linux_libc == LIBC_BIONIC) ++#undef OPTION_MUSL_P ++#define OPTION_MUSL_P(opts) ((opts)->x_linux_libc == LIBC_MUSL) + #endif ++#define OPTION_GLIBC OPTION_GLIBC_P (&global_options) ++#define OPTION_UCLIBC OPTION_UCLIBC_P (&global_options) ++#define OPTION_BIONIC OPTION_BIONIC_P (&global_options) ++#undef OPTION_MUSL ++#define OPTION_MUSL OPTION_MUSL_P (&global_options) + + /* Determine what functions are present at the runtime; + this includes full c99 runtime and sincos. */ +diff --git a/gcc/config/fuchsia.h b/gcc/config/fuchsia.h +index 54602dc300d..47c0dfd8b81 100644 +--- a/gcc/config/fuchsia.h ++++ b/gcc/config/fuchsia.h +@@ -52,6 +52,8 @@ along with GCC; see the file COPYING3. If not see + /* We are using MUSL as our libc. */ + #undef OPTION_MUSL + #define OPTION_MUSL 1 ++#undef OPTION_MUSL_P ++#define OPTION_MUSL_P(opts) 1 + + #ifndef TARGET_SUB_OS_CPP_BUILTINS + #define TARGET_SUB_OS_CPP_BUILTINS() +diff --git a/gcc/config/glibc-stdint.h b/gcc/config/glibc-stdint.h +index c8d7ba18d1c..f095197514f 100644 +--- a/gcc/config/glibc-stdint.h ++++ b/gcc/config/glibc-stdint.h +@@ -27,6 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + #ifndef OPTION_MUSL + #define OPTION_MUSL 0 + #endif ++#ifndef OPTION_MUSL_P ++#define OPTION_MUSL_P(opts) 0 ++#endif + + #define SIG_ATOMIC_TYPE "int" + +diff --git a/gcc/config/linux.h b/gcc/config/linux.h +index 7fcf402b416..ab62a1741f7 100644 +--- a/gcc/config/linux.h ++++ b/gcc/config/linux.h +@@ -29,18 +29,23 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + + /* C libraries supported on Linux. */ + #ifdef SINGLE_LIBC +-#define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC) +-#define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC) +-#define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC) +-#undef OPTION_MUSL +-#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL) ++#define OPTION_GLIBC_P(opts) (DEFAULT_LIBC == LIBC_GLIBC) ++#define OPTION_UCLIBC_P(opts) (DEFAULT_LIBC == LIBC_UCLIBC) ++#define OPTION_BIONIC_P(opts) (DEFAULT_LIBC == LIBC_BIONIC) ++#undef OPTION_MUSL_P ++#define OPTION_MUSL_P(opts) (DEFAULT_LIBC == LIBC_MUSL) + #else +-#define OPTION_GLIBC (linux_libc == LIBC_GLIBC) +-#define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC) +-#define OPTION_BIONIC (linux_libc == LIBC_BIONIC) +-#undef OPTION_MUSL +-#define OPTION_MUSL (linux_libc == LIBC_MUSL) ++#define OPTION_GLIBC_P(opts) ((opts)->x_linux_libc == LIBC_GLIBC) ++#define OPTION_UCLIBC_P(opts) ((opts)->x_linux_libc == LIBC_UCLIBC) ++#define OPTION_BIONIC_P(opts) ((opts)->x_linux_libc == LIBC_BIONIC) ++#undef OPTION_MUSL_P ++#define OPTION_MUSL_P(opts) ((opts)->x_linux_libc == LIBC_MUSL) + #endif ++#define OPTION_GLIBC OPTION_GLIBC_P (&global_options) ++#define OPTION_UCLIBC OPTION_UCLIBC_P (&global_options) ++#define OPTION_BIONIC OPTION_BIONIC_P (&global_options) ++#undef OPTION_MUSL ++#define OPTION_MUSL OPTION_MUSL_P (&global_options) + + #define GNU_USER_TARGET_OS_CPP_BUILTINS() \ + do { \ +diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h +index 47c9d9ac0b6..be04462d357 100644 +--- a/gcc/config/rs6000/linux.h ++++ b/gcc/config/rs6000/linux.h +@@ -27,18 +27,23 @@ + #define NO_PROFILE_COUNTERS 1 + + #ifdef SINGLE_LIBC +-#define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC) +-#define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC) +-#define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC) +-#undef OPTION_MUSL +-#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL) ++#define OPTION_GLIBC_P(opts) (DEFAULT_LIBC == LIBC_GLIBC) ++#define OPTION_UCLIBC_P(opts) (DEFAULT_LIBC == LIBC_UCLIBC) ++#define OPTION_BIONIC_P(opts) (DEFAULT_LIBC == LIBC_BIONIC) ++#undef OPTION_MUSL_P ++#define OPTION_MUSL_P(opts) (DEFAULT_LIBC == LIBC_MUSL) + #else +-#define OPTION_GLIBC (linux_libc == LIBC_GLIBC) +-#define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC) +-#define OPTION_BIONIC (linux_libc == LIBC_BIONIC) +-#undef OPTION_MUSL +-#define OPTION_MUSL (linux_libc == LIBC_MUSL) ++#define OPTION_GLIBC_P(opts) ((opts)->x_linux_libc == LIBC_GLIBC) ++#define OPTION_UCLIBC_P(opts) ((opts)->x_linux_libc == LIBC_UCLIBC) ++#define OPTION_BIONIC_P(opts) ((opts)->x_linux_libc == LIBC_BIONIC) ++#undef OPTION_MUSL_P ++#define OPTION_MUSL_P(opts) ((opts)->x_linux_libc == LIBC_MUSL) + #endif ++#define OPTION_GLIBC OPTION_GLIBC_P (&global_options) ++#define OPTION_UCLIBC OPTION_UCLIBC_P (&global_options) ++#define OPTION_BIONIC OPTION_BIONIC_P (&global_options) ++#undef OPTION_MUSL ++#define OPTION_MUSL OPTION_MUSL_P (&global_options) + + /* Determine what functions are present at the runtime; + this includes full c99 runtime and sincos. */ +diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h +index 43499ed29cf..1d73a09a476 100644 +--- a/gcc/config/rs6000/linux64.h ++++ b/gcc/config/rs6000/linux64.h +@@ -267,18 +267,23 @@ extern int dot_symbols; + #define OS_MISSING_POWERPC64 !TARGET_64BIT + + #ifdef SINGLE_LIBC +-#define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC) +-#define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC) +-#define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC) +-#undef OPTION_MUSL +-#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL) ++#define OPTION_GLIBC_P(opts) (DEFAULT_LIBC == LIBC_GLIBC) ++#define OPTION_UCLIBC_P(opts) (DEFAULT_LIBC == LIBC_UCLIBC) ++#define OPTION_BIONIC_P(opts) (DEFAULT_LIBC == LIBC_BIONIC) ++#undef OPTION_MUSL_P ++#define OPTION_MUSL_P(opts) (DEFAULT_LIBC == LIBC_MUSL) + #else +-#define OPTION_GLIBC (linux_libc == LIBC_GLIBC) +-#define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC) +-#define OPTION_BIONIC (linux_libc == LIBC_BIONIC) +-#undef OPTION_MUSL +-#define OPTION_MUSL (linux_libc == LIBC_MUSL) ++#define OPTION_GLIBC_P(opts) ((opts)->x_linux_libc == LIBC_GLIBC) ++#define OPTION_UCLIBC_P(opts) ((opts)->x_linux_libc == LIBC_UCLIBC) ++#define OPTION_BIONIC_P(opts) ((opts)->x_linux_libc == LIBC_BIONIC) ++#undef OPTION_MUSL_P ++#define OPTION_MUSL_P(opts) ((opts)->x_linux_libc == LIBC_MUSL) + #endif ++#define OPTION_GLIBC OPTION_GLIBC_P (&global_options) ++#define OPTION_UCLIBC OPTION_UCLIBC_P (&global_options) ++#define OPTION_BIONIC OPTION_BIONIC_P (&global_options) ++#undef OPTION_MUSL ++#define OPTION_MUSL OPTION_MUSL_P (&global_options) + + /* Determine what functions are present at the runtime; + this includes full c99 runtime and sincos. */ +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0050-x86-Fix-fsplit-stack-feature-detection-via-TARGET_CA.patch b/cross-images/mini-aports/main/gcc/0050-x86-Fix-fsplit-stack-feature-detection-via-TARGET_CA.patch new file mode 100644 index 0000000..8388196 --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0050-x86-Fix-fsplit-stack-feature-detection-via-TARGET_CA.patch @@ -0,0 +1,75 @@ +From 400bae077d11c3a2ee9f4c8b96c31bbf39416a4f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= +Date: Mon, 21 Feb 2022 04:13:47 +0100 +Subject: [PATCH] x86: Fix -fsplit-stack feature detection via + TARGET_CAN_SPLIT_STACK +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Since commit c163647ffbc9a20c8feb6e079dbecccfe016c82e -fsplit-stack +is only supported on glibc targets. However, this original commit +required some fixups. As part of the fixup, the changes to the +gnu-user-common.h and gnu.h where partially reverted in commit +60953a23d57b13a672f751bec0c6eefc059eb1ab thus causing TARGET_CAN_SPLIT_STACK +to be defined for non-glibc targets even though -fsplit-stack is +actually not supported and attempting to use it causes a runtime error. + +This causes gcc internal code, such as ./gcc/go/gospec.c to not +correctly detect that -fsplit-stack is not supported and thus causes +gccgo to fail compilation on non-glibc targets. + +This commit ensures that TARGET_CAN_SPLIT_STACK is set based on the +changes performed in 2c31a8be4a5db11a0a0e97c366dded6362421086, i.e. +the new OPTION_GLIBC_P macro is now used to detect if -fsplit-stack is +supported in the x86 header files. + +The proposed changes have been tested on x86_64 Alpine Linux (which uses +musl libc) and fix compilation of gccgo for this target. + +Signed-off-by: Sören Tempel + +gcc/ChangeLog: + + * config/i386/gnu-user-common.h (defined): Only define + TARGET_CAN_SPLIT_STACK for glibc targets. + * config/i386/gnu.h (defined): Ditto. +--- + gcc/config/i386/gnu-user-common.h | 5 +++-- + gcc/config/i386/gnu.h | 5 +++-- + 2 files changed, 6 insertions(+), 4 deletions(-) + +diff --git a/gcc/config/i386/gnu-user-common.h b/gcc/config/i386/gnu-user-common.h +index 00226f5a455..4e3fbb1de05 100644 +--- a/gcc/config/i386/gnu-user-common.h ++++ b/gcc/config/i386/gnu-user-common.h +@@ -66,7 +66,8 @@ along with GCC; see the file COPYING3. If not see + #define STACK_CHECK_STATIC_BUILTIN 1 + + /* We only build the -fsplit-stack support in libgcc if the +- assembler has full support for the CFI directives. */ +-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE ++ assembler has full support for the CFI directives. Also ++ we only support -fsplit-stack on glibc targets. */ ++#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE && defined(OPTION_GLIBC_P) + #define TARGET_CAN_SPLIT_STACK + #endif +diff --git a/gcc/config/i386/gnu.h b/gcc/config/i386/gnu.h +index 25fbc07f58c..41a6a37dfee 100644 +--- a/gcc/config/i386/gnu.h ++++ b/gcc/config/i386/gnu.h +@@ -41,8 +41,9 @@ along with GCC. If not, see . + #define TARGET_THREAD_SSP_OFFSET 0x14 + + /* We only build the -fsplit-stack support in libgcc if the +- assembler has full support for the CFI directives. */ +-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE ++ assembler has full support for the CFI directives. Also ++ we only support -fsplit-stack on glibc targets. */ ++#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE && defined(OPTION_GLIBC_P) + #define TARGET_CAN_SPLIT_STACK + #endif + /* We steal the last transactional memory word. */ +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/0051-go-gospec-forcibly-disable-fsplit-stack-support.patch b/cross-images/mini-aports/main/gcc/0051-go-gospec-forcibly-disable-fsplit-stack-support.patch new file mode 100644 index 0000000..319b1ef --- /dev/null +++ b/cross-images/mini-aports/main/gcc/0051-go-gospec-forcibly-disable-fsplit-stack-support.patch @@ -0,0 +1,33 @@ +From dba87d9796b61f4f3eea83c200a2d208564e2277 Mon Sep 17 00:00:00 2001 +From: Ariadne Conill +Date: Mon, 21 Feb 2022 10:04:47 +0000 +Subject: [PATCH] go/gospec: forcibly disable -fsplit-stack support + +for some reason, TARGET_CAN_SPLIT_STACK still gets defined on 32-bit x86, +so hackfix it for now +--- + gcc/go/gospec.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/gcc/go/gospec.c b/gcc/go/gospec.c +index cf8d0f2b60e..d5bfa57ea45 100644 +--- a/gcc/go/gospec.c ++++ b/gcc/go/gospec.c +@@ -269,11 +269,12 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, + /* Copy the 0th argument, i.e., the name of the program itself. */ + new_decoded_options[j++] = decoded_options[i++]; + +-#ifdef TARGET_CAN_SPLIT_STACK ++ /* Hackfix: we never support split stack on Alpine GCC */ ++#if 0 + supports_split_stack = 1; + #endif + +-#ifdef TARGET_CAN_SPLIT_STACK_64BIT ++#if 0 + if (is_m64) + supports_split_stack = 1; + #endif +-- +2.35.1 + diff --git a/cross-images/mini-aports/main/gcc/012_all_default-warn-trampolines.patch b/cross-images/mini-aports/main/gcc/012_all_default-warn-trampolines.patch deleted file mode 100644 index 7a644cb..0000000 --- a/cross-images/mini-aports/main/gcc/012_all_default-warn-trampolines.patch +++ /dev/null @@ -1,13 +0,0 @@ -Enable -Wtrampolines by default. - ---- a/gcc/common.opt -+++ b/gcc/common.opt -@@ -712,7 +712,7 @@ Common Var(warn_system_headers) Warning - Do not suppress warnings from system headers. - - Wtrampolines --Common Var(warn_trampolines) Warning -+Common Var(warn_trampolines) Init(1) Warning - Warn whenever a trampoline is generated. - - Wtype-limits diff --git a/cross-images/mini-aports/main/gcc/013_all_default-ssp-fix.patch b/cross-images/mini-aports/main/gcc/013_all_default-ssp-fix.patch deleted file mode 100644 index d2deac7..0000000 --- a/cross-images/mini-aports/main/gcc/013_all_default-ssp-fix.patch +++ /dev/null @@ -1,38 +0,0 @@ -Disable ssp on -nostdlib, -nodefaultlibs and -ffreestanding -Change the buffer size. - ---- a/gcc/gcc.c 2017-07-04 09:15:57.740793000 +0200 -+++ b/gcc/gcc.c 2018-03-02 13:58:44.387741114 +0100 -@@ -857,6 +857,12 @@ proper position among the other output f - #define LINK_GCC_C_SEQUENCE_SPEC "%G %L %G" - #endif - -+#ifdef ENABLE_DEFAULT_SSP -+#define NO_SSP_SPEC "%{nostdlib|nodefaultlibs|ffreestanding:-fno-stack-protector} " -+#else -+#define NO_SSP_SPEC "" -+#endif -+ - #ifndef LINK_SSP_SPEC - #ifdef TARGET_LIBC_PROVIDES_SSP - #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ -@@ -1131,7 +1148,7 @@ static const char *cc1_options = - %{-version:--version}\ - %{-help=*:--help=%*}\ - %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}}\ -- %{fsyntax-only:-o %j} %{-param*}\ -+ %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\ - %{coverage:-fprofile-arcs -ftest-coverage}\ - %{fprofile-arcs|fprofile-generate*|coverage:\ - %{!fprofile-update=singel:\ ---- a/gcc/params.def 2016-03-30 09:47:40.000000000 +0200 -+++ b/gcc/params.def 2016-09-19 12:56:58.443179039 +0200 -@@ -673,7 +673,7 @@ DEFPARAM (PARAM_INTEGER_SHARE_LIMIT, - DEFPARAM (PARAM_SSP_BUFFER_SIZE, - "ssp-buffer-size", - "The lower bound for a buffer to be considered for stack smashing protection.", -- 8, 1, 0) -+ 4, 1, 0) - - DEFPARAM (PARAM_MIN_SIZE_FOR_STACK_SHARING, - "min-size-for-stack-sharing", diff --git a/cross-images/mini-aports/main/gcc/050_all_libiberty-asprintf.patch b/cross-images/mini-aports/main/gcc/050_all_libiberty-asprintf.patch deleted file mode 100644 index bee0c4c..0000000 --- a/cross-images/mini-aports/main/gcc/050_all_libiberty-asprintf.patch +++ /dev/null @@ -1,18 +0,0 @@ -2008-07-25 Magnus Granberg - - * include/libiberty.h (asprintf): Don't declare if defined as a macro - ---- a/include/libiberty.h -+++ b/include/libiberty.h -@@ -609,8 +609,11 @@ extern int pwait (int, int *, int); - /* Like sprintf but provides a pointer to malloc'd storage, which must - be freed by the caller. */ - -+/* asprintf may be declared as a macro by glibc with __USE_FORTIFY_LEVEL. */ -+#ifndef asprintf - extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2; - #endif -+#endif - - #if !HAVE_DECL_VASPRINTF - /* Like vsprintf but provides a pointer to malloc'd storage, which diff --git a/cross-images/mini-aports/main/gcc/051_all_libiberty-pic.patch b/cross-images/mini-aports/main/gcc/051_all_libiberty-pic.patch deleted file mode 100644 index b6160a7..0000000 --- a/cross-images/mini-aports/main/gcc/051_all_libiberty-pic.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/libiberty/Makefile.in -+++ b/libiberty/Makefile.in -@@ -246,6 +246,7 @@ $(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS) - $(AR) $(AR_FLAGS) $(TARGETLIB) \ - $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS); \ - $(RANLIB) $(TARGETLIB); \ -+ cp $(TARGETLIB) ../ ; \ - cd ..; \ - else true; fi - diff --git a/cross-images/mini-aports/main/gcc/090_all_pr55930-dependency-tracking.patch b/cross-images/mini-aports/main/gcc/090_all_pr55930-dependency-tracking.patch deleted file mode 100644 index a8743e0..0000000 --- a/cross-images/mini-aports/main/gcc/090_all_pr55930-dependency-tracking.patch +++ /dev/null @@ -1,18 +0,0 @@ -libatomic build failure if configured with --disable-dependency-tracking -load_n.c:115:1: fatal error: opening dependency file .deps/load_1_.lo.Ppo: No such file or directory - -https://bugs.gentoo.org/463463 -http://gcc.gnu.org/PR55930 - ---- a/libatomic/Makefile.in -+++ b/libatomic/Makefile.in -@@ -298,7 +298,8 @@ PAT_N = $(word 2,$(PAT_SPLIT)) - PAT_S = $(word 3,$(PAT_SPLIT)) - IFUNC_DEF = -DIFUNC_ALT=$(PAT_S) - IFUNC_OPT = $(word $(PAT_S),$(IFUNC_OPTIONS)) --M_DEPS = -MT $@ -MD -MP -MF $(DEPDIR)/$(@F).Ppo -+@AMDEP_TRUE@M_DEPS = -MT $@ -MD -MP -MF $(DEPDIR)/$(@F).Ppo -+@AMDEP_FALSE@M_DEPS = - M_SIZE = -DN=$(PAT_N) - M_IFUNC = $(if $(PAT_S),$(IFUNC_DEF) $(IFUNC_OPT)) - M_FILE = $(PAT_BASE)_n.c diff --git a/cross-images/mini-aports/main/gcc/320-libffi-gnulinux.patch b/cross-images/mini-aports/main/gcc/320-libffi-gnulinux.patch deleted file mode 100644 index b3b4fc9..0000000 --- a/cross-images/mini-aports/main/gcc/320-libffi-gnulinux.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/libffi/closures.c.orig b/libffi/closures.c -index 721ff00..22a699c 100644 ---- a/libffi/src/closures.c.orig -+++ b/libffi/src/closures.c -@@ -34,7 +34,7 @@ - #include - - #if !FFI_MMAP_EXEC_WRIT && !FFI_EXEC_TRAMPOLINE_TABLE --# if __gnu_linux__ && !defined(__ANDROID__) -+# if __linux__ && !defined(__ANDROID__) - /* This macro indicates it may be forbidden to map anonymous memory - with both write and execute permission. Code compiled when this - option is defined will attempt to map such pages once, but if it diff --git a/cross-images/mini-aports/main/gcc/APKBUILD b/cross-images/mini-aports/main/gcc/APKBUILD index 91013ca..f0ec4ee 100644 --- a/cross-images/mini-aports/main/gcc/APKBUILD +++ b/cross-images/mini-aports/main/gcc/APKBUILD @@ -1,40 +1,45 @@ -# Maintainer: Natanael Copa +# Contributor: Natanael Copa +# Contributor: Sören Tempel +# Maintainer: Ariadne Conill pkgname=gcc -pkgver=8.3.0 +_pkgbase=11.2.1 +pkgver=11.2.1_git20220219 [ "$BOOTSTRAP" = "nolibc" ] && pkgname="gcc-pass2" [ "$CBUILD" != "$CHOST" ] && _cross="-$CARCH" || _cross="" [ "$CHOST" != "$CTARGET" ] && _target="-$CTARGET_ARCH" || _target="" pkgname="$pkgname$_target" -pkgrel=0 +pkgrel=2 pkgdesc="The GNU Compiler Collection" -url="http://gcc.gnu.org" +url="https://gcc.gnu.org" arch="all" -license="GPL LGPL" +license="GPL-2.0-or-later LGPL-2.1-or-later" _gccrel=$pkgver-r$pkgrel -depends="binutils$_target isl" -makedepends_build="gcc$_cross g++$_cross paxmark bison flex texinfo gawk zip gmp-dev mpfr-dev mpc1-dev zlib-dev" -makedepends_host="linux-headers gmp-dev mpfr-dev mpc1-dev isl-dev zlib-dev !gettext-dev" +depends="binutils$_target" +makedepends_build="gcc$_cross g++$_cross bison flex texinfo gawk zip gmp-dev mpfr-dev mpc1-dev zlib-dev" +makedepends_host="linux-headers gmp-dev mpfr-dev mpc1-dev isl-dev zlib-dev !gettext-dev libucontext-dev" subpackages=" " [ "$CHOST" = "$CTARGET" ] && subpackages="gcc-doc$_target" replaces="libstdc++ binutils" -: ${LANG_CXX:=true} -: ${LANG_OBJC:=true} -: ${LANG_GO:=true} -: ${LANG_FORTRAN:=true} -: ${LANG_ADA:=true} +: "${LANG_CXX:=true}" +: "${LANG_D:=true}" +: "${LANG_OBJC:=true}" +: "${LANG_GO:=true}" +: "${LANG_FORTRAN:=true}" +: "${LANG_ADA:=true}" +: "${LANG_JIT:=true}" -LIBGOMP=true -LIBGCC=true -LIBATOMIC=true -LIBITM=true +_libgomp=true +_libgcc=true +_libatomic=true +_libitm=true if [ "$CHOST" != "$CTARGET" ]; then if [ "$BOOTSTRAP" = nolibc ]; then LANG_CXX=false LANG_ADA=false - LIBGCC=false + _libgcc=false _builddir="$srcdir/build-cross-pass2" else _builddir="$srcdir/build-cross-final" @@ -42,9 +47,11 @@ if [ "$CHOST" != "$CTARGET" ]; then LANG_OBJC=false LANG_GO=false LANG_FORTRAN=false - LIBGOMP=false - LIBATOMIC=false - LIBITM=false + LANG_D=false + LANG_JIT=false + _libgomp=false + _libatomic=false + _libitm=false # reset target flags (should be set in crosscreate abuild) # fixup flags. seems gcc treats CPPFLAGS as global without @@ -78,6 +85,8 @@ elif [ "$CBUILD" != "$CHOST" ]; then LANG_OBJC=false LANG_GO=false LANG_FORTRAN=false + LANG_D=false + LANG_JIT=false STRIP_FOR_TARGET=${CROSS_COMPILE}strip _builddir="$srcdir/build-cross-native" @@ -86,37 +95,59 @@ else _builddir="$srcdir/build" fi -# Go needs {set,make,swap}context, unimplemented in musl -[ "$CTARGET_LIBC" = musl ] && LANG_GO=false +# GDC hasn't been ported to PowerPC +# See libphobos/configure.tgt in GCC sources for supported targets +# riscv fails with: error: static assert "unimplemented" +case "$CARCH" in +ppc64le|riscv64) LANG_D=false ;; +esac # libitm has TEXTRELs in ARM build, so disable for now case "$CTARGET_ARCH" in -arm*) LIBITM=false ;; -mips*) LIBITM=false ;; +arm*) _libitm=false ;; +mips*) _libitm=false ;; +riscv64) _libitm=false ;; +esac + +# Internal libffi fails to build on MIPS at the moment, need to +# investigate further. We disable LANG_GO on mips64 as it requires +# the internal libffi. +case "$CTARGET_ARCH" in +mips*) LANG_GO=false ;; esac # Fortran uses libquadmath if toolchain has __float128 # currently on x86, x86_64 and ia64 -LIBQUADMATH=$LANG_FORTRAN +_libquadmath=$LANG_FORTRAN case "$CTARGET_ARCH" in -x86 | x86_64) LIBQUADMATH=$LANG_FORTRAN ;; -*) LIBQUADMATH=false ;; +x86 | x86_64) _libquadmath=$LANG_FORTRAN ;; +*) _libquadmath=false ;; esac # libatomic is a dependency for openvswitch -$LIBATOMIC && subpackages="$subpackages libatomic::$CTARGET_ARCH" -$LIBGCC && subpackages="$subpackages libgcc::$CTARGET_ARCH" -$LIBQUADMATH && subpackages="$subpackages libquadmath::$CTARGET_ARCH" -if $LIBGOMP; then +$_libatomic && subpackages="$subpackages libatomic::$CTARGET_ARCH" +$_libgcc && subpackages="$subpackages libgcc::$CTARGET_ARCH" +$_libquadmath && subpackages="$subpackages libquadmath::$CTARGET_ARCH" +if $_libgomp; then depends="$depends libgomp=$_gccrel" subpackages="$subpackages libgomp::$CTARGET_ARCH" fi +case "$CARCH" in +riscv64) +LANG_ADA=false;; +esac + _languages=c if $LANG_CXX; then subpackages="$subpackages libstdc++:libcxx:$CTARGET_ARCH g++$_target:gpp" _languages="$_languages,c++" fi +if $LANG_D; then + subpackages="$subpackages libgphobos::$CTARGET_ARCH gcc-gdc$_target:gdc" + _languages="$_languages,d" + makedepends_build="$makedepends_build libucontext-dev" +fi if $LANG_OBJC; then subpackages="$subpackages libobjc::$CTARGET_ARCH gcc-objc$_target:objc" _languages="$_languages,objc" @@ -130,57 +161,83 @@ if $LANG_FORTRAN; then _languages="$_languages,fortran" fi if $LANG_ADA; then - subpackages="$subpackages libgnat::$CTARGET_ARCH gcc-gnat$_target:gnat" + subpackages="$subpackages libgnat-static:libgnatstatic:$CTARGET_ARCH libgnat::$CTARGET_ARCH gcc-gnat$_target:gnat" _languages="$_languages,ada" - makedepends_build="$makedepends_build gcc-gnat gcc-gnat$_cross" + [ "$CBUILD" = "$CTARGET" ] && makedepends_build="$makedepends_build gcc-gnat-bootstrap" + [ "$CBUILD" != "$CTARGET" ] && makedepends_build="$makedepends_build gcc-gnat gcc-gnat$_cross" +fi +if $LANG_JIT; then + subpackages="$subpackages libgccjit:jit libgccjit-dev:jitdev" + _languages="$_languages,jit" fi makedepends="$makedepends_build $makedepends_host" -source="https://gcc.gnu.org/pub/gcc/releases/gcc-${_pkgbase:-$pkgver}/gcc-${_pkgbase:-$pkgver}.tar.xz - 002_all_default-relro.patch - 003_all_default-fortify-source.patch - 005_all_default-as-needed.patch - gcc-as-needed-gold.patch - gcc-as-needed-push-pop.patch - 011_all_default-warn-format-security.patch - 012_all_default-warn-trampolines.patch - 013_all_default-ssp-fix.patch - 020_all_msgfmt-libstdc++-link.patch - 050_all_libiberty-asprintf.patch - 051_all_libiberty-pic.patch - 053_all_libitm-no-fortify-source.patch - 090_all_pr55930-dependency-tracking.patch - 0003-gcc-poison-system-directories.patch - - 203-libgcc_s.patch - 205-nopie.patch - 0002-posix_memalign.patch - 0008-s390x-muslldso.patch - 0010-ldbl128-config.patch - 0012-static-pie.patch - - libgcc-always-build-gcceh.a.patch - gcc-4.9-musl-fortify.patch - gcc-6.1-musl-libssp.patch - gcc-pure64.patch - - fix-cxxflags-passing.patch - ada-shared.patch - ada-musl.patch - libgnarl-musl.patch - - 320-libffi-gnulinux.patch - - gcc-pure64-mips.patch - 0016-invalid_tls_model.patch +# when using upstream releases, use this URI template +# https://gcc.gnu.org/pub/gcc/releases/gcc-${_pkgbase:-$pkgver}/gcc-${_pkgbase:-$pkgver}.tar.xz +# +# right now, we are using a git snapshot. +# +# PLEASE submit all patches to gcc to https://gitlab.alpinelinux.org/kaniini/alpine-gcc-patches, +# so that they can be properly tracked and easily rebased if needed. +source="https://dev.alpinelinux.org/~nenolod/gcc-${pkgver}.tar.xz + 0001-posix_memalign.patch + 0002-gcc-poison-system-directories.patch + 0003-specs-turn-on-Wl-z-now-by-default.patch + 0004-Turn-on-D_FORTIFY_SOURCE-2-by-default-for-C-C-ObjC-O.patch + 0005-On-linux-targets-pass-as-needed-by-default-to-the-li.patch + 0006-Enable-Wformat-and-Wformat-security-by-default.patch + 0007-Enable-Wtrampolines-by-default.patch + 0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch + 0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch + 0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch + 0011-libiberty-copy-PIC-objects-during-build-process.patch + 0012-libitm-disable-FORTIFY.patch + 0013-libgcc_s.patch + 0014-nopie.patch + 0015-libffi-use-__linux__-instead-of-__gnu_linux__-for-mu.patch + 0016-dlang-update-zlib-binding.patch + 0017-dlang-use-libucontext-on-mips64.patch + 0018-dlang-libdruntime-define-fcntl.h-constants-for-mips6.patch + 0019-ada-fix-shared-linking.patch + 0020-build-fix-CXXFLAGS_FOR_BUILD-passing.patch + 0021-add-fortify-headers-paths.patch + 0022-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch + 0023-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch + 0024-mips64-disable-multilib-support.patch + 0025-aarch64-disable-multilib-support.patch + 0026-s390x-disable-multilib-support.patch + 0027-ppc64-le-disable-multilib-support.patch + 0028-x86_64-disable-multilib-support.patch + 0029-riscv-disable-multilib-support.patch + 0030-always-build-libgcc_eh.a.patch + 0031-ada-libgnarl-compatibility-for-musl.patch + 0032-ada-musl-support-fixes.patch + 0033-gcc-go-Fix-handling-of-signal-34-on-musl.patch + 0034-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch + 0035-gcc-go-signal-34-is-special-on-musl-libc.patch + 0036-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch + 0037-gcc-go-link-to-libucontext.patch + 0038-Use-generic-errstr.go-implementation-on-musl.patch + 0039-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch + 0040-configure-fix-detection-of-atomic-builtins-in-libato.patch + 0041-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch + 0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch + 0043-stddef.h-add-support-for-musl-typedef-macro-guards.patch + 0044-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch + 0045-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch + 0046-Disable-fsplit-stack-support-on-non-glibc-targets.patch + 0047-x86-Properly-disable-fsplit-stack-support-on-non-gli.patch + 0048-gdc-unconditionally-link-libgphobos-against-libucont.patch + 0049-properly-disable-fsplit-stack-on-non-glibc-targets-P.patch + 0050-x86-Fix-fsplit-stack-feature-detection-via-TARGET_CA.patch + 0051-go-gospec-forcibly-disable-fsplit-stack-support.patch + libgo-musl-1.2.3.patch " -# gcc-4.8-build-args.patch - # we build out-of-tree -_gccdir="$srcdir"/gcc-${_pkgbase:-$pkgver} -_gcclibdir=/usr/lib/gcc/${CTARGET}/$pkgver -_gcclibexec=/usr/libexec/gcc/${CTARGET}/$pkgver +_gccdir="$srcdir"/gcc-$pkgver +_gcclibdir="/usr/lib/gcc/$CTARGET/${_pkgbase:-$pkgver}" +_gcclibexec="/usr/libexec/gcc/$CTARGET/${_pkgbase:-$pkgver}" prepare() { cd "$_gccdir" @@ -203,7 +260,7 @@ prepare() { return 1 fi - echo ${pkgver} > gcc/BASE-VER + echo ${_pkgbase:-$pkgver} > gcc/BASE-VER } build() { @@ -212,6 +269,7 @@ build() { local _cross_configure= local _bootstrap_configure= local _symvers= + local _jit_configure= cd "$_gccdir" @@ -229,6 +287,7 @@ build() { i486-*-*-*) _arch_configure="--with-arch=i486 --with-tune=generic --enable-cld";; i586-*-*-*) _arch_configure="--with-arch=i586 --with-tune=generic --enable-cld";; s390x-*-*-*) _arch_configure="--with-arch=z196 --with-tune=zEC12 --with-zarch --with-long-double-128 --enable-decimal-float";; + riscv64-*-*-*) _arch_configure="--with-arch=rv64gc --with-abi=lp64d --enable-autolink-libatomic";; esac case "$CTARGET_ARCH" in @@ -255,10 +314,12 @@ build() { *) _bootstrap_configure="--enable-shared --enable-threads --enable-tls" ;; esac - $LIBGOMP || _bootstrap_configure="$_bootstrap_configure --disable-libgomp" - $LIBATOMIC || _bootstrap_configure="$_bootstrap_configure --disable-libatomic" - $LIBITM || _bootstrap_configure="$_bootstrap_configure --disable-libitm" - $LIBQUADMATH || _arch_configure="$_arch_configure --disable-libquadmath" + $LANG_JIT && _jit_configure="--enable-host-shared" + + $_libgomp || _bootstrap_configure="$_bootstrap_configure --disable-libgomp" + $_libatomic || _bootstrap_configure="$_bootstrap_configure --disable-libatomic" + $_libitm || _bootstrap_configure="$_bootstrap_configure --disable-libitm" + $_libquadmath || _arch_configure="$_arch_configure --disable-libquadmath" msg "Building the following:" echo "" @@ -275,6 +336,8 @@ build() { echo " hash_style_configure=$_hash_style_configure" echo "" + export CFLAGS="$CFLAGS -O2" + mkdir -p "$_builddir" cd "$_builddir" "$_gccdir"/configure --prefix=/usr \ @@ -283,7 +346,7 @@ build() { --build=${CBUILD} \ --host=${CHOST} \ --target=${CTARGET} \ - --with-pkgversion="Alpine ${pkgver}" \ + --with-pkgversion="Alpine $pkgver" \ --enable-checking=release \ --disable-fixed-point \ --disable-libstdcxx-pch \ @@ -300,6 +363,7 @@ build() { $_libc_configure \ $_cross_configure \ $_bootstrap_configure \ + $_jit_configure \ --with-system-zlib \ $_hash_style_configure make @@ -307,43 +371,45 @@ build() { package() { cd "$_builddir" - make -j1 DESTDIR="${pkgdir}" install + make -j1 DESTDIR="$pkgdir" install ln -s gcc "$pkgdir"/usr/bin/cc # we dont support gcj -static # and saving 35MB is not bad. - find "$pkgdir" -name libgtkpeer.a \ - -o -name libgjsmalsa.a -o \ - -o -name libgij.a -o \ - | xargs rm -f + find "$pkgdir" \( -name libgtkpeer.a \ + -o -name libgjsmalsa.a \ + -o -name libgij.a \) \ + -delete # strip debug info from some static libs - ${STRIP_FOR_TARGET} -g `find "$pkgdir" \( -name libgfortran.a -o -name libobjc.a -o -name libgomp.a \ + find "$pkgdir" \( -name libgfortran.a -o -name libobjc.a -o -name libgomp.a \ + -o -name libgphobos.a -o -name libgdruntime.a \ -o -name libmudflap.a -o -name libmudflapth.a \ -o -name libgcc.a -o -name libgcov.a -o -name libquadmath.a \ -o -name libitm.a -o -name libgo.a -o -name libcaf\*.a \ -o -name libatomic.a -o -name libasan.a -o -name libtsan.a \) \ - -a -type f` + -a -type f \ + -exec ${STRIP_FOR_TARGET} -g {} + - if $LIBGOMP; then + if $_libgomp; then mv "$pkgdir"/usr/lib/libgomp.spec "$pkgdir"/$_gcclibdir fi - if $LIBITM; then + if $_libitm; then mv "$pkgdir"/usr/lib/libitm.spec "$pkgdir"/$_gcclibdir fi # remove ffi rm -f "$pkgdir"/usr/lib/libffi* "$pkgdir"/usr/share/man/man3/ffi* - find "$pkgdir" -name 'ffi*.h' | xargs rm -f + find "$pkgdir" -name 'ffi*.h' -delete local gdblib=${_target:+$CTARGET/}lib - for i in $(find "$pkgdir"/usr/$gdblib/ -type f -maxdepth 1 -name "*-gdb.py" ); do - mkdir -p "$pkgdir"/usr/share/gdb/python/auto-load/usr/$gdblib - mv "$i" "$pkgdir"/usr/share/gdb/python/auto-load/usr/$gdblib/ - done - - paxmark -pmrs "$pkgdir"/$_gcclibexec/cc1 + if [ -d "$pkgdir"/usr/$gdblib/ ]; then + for i in $(find "$pkgdir"/usr/$gdblib/ -type f -maxdepth 1 -name "*-gdb.py"); do + mkdir -p "$pkgdir"/usr/share/gdb/python/auto-load/usr/$gdblib + mv "$i" "$pkgdir"/usr/share/gdb/python/auto-load/usr/$gdblib/ + done + fi # move ada runtime libs if $LANG_ADA; then @@ -351,20 +417,24 @@ package() { mv "$i" "$pkgdir"/usr/lib/ ln -s ../../../../${i##*/} $i done + for i in $(find "$pkgdir"/$_gcclibdir/adalib/ -type f -maxdepth 1 -name "libgna*.a"); do + mv "$i" "$pkgdir"/usr/lib/ + ln -s ../../../../${i##*/} $i + done fi if [ "$CHOST" != "$CTARGET" ]; then # cross-gcc: remove any files that would conflict with the # native gcc package - rm -rf "$pkgdir"/usr/bin/cc "$pkgdir"/usr/include "$pkgdir"/usr/share + rm -rf "$pkgdir"/usr/bin/cc "$pkgdir"/usr/include "${pkgdir:?}"/usr/share # libcc1 does not depend on target, don't ship it rm -rf "$pkgdir"/usr/lib/libcc1.so* # fixup gcc library symlinks to be linker scripts so # linker finds the libs from relocated sysroot - for so in "$pkgdir"/usr/$CTARGET/lib/*.so; do + for so in "$pkgdir"/usr/"$CTARGET"/lib/*.so; do if [ -h "$so" ]; then - local _real=$(basename $(readlink "$so")) + local _real=$(basename "$(readlink "$so")") rm -f "$so" echo "GROUP ($_real)" > "$so" fi @@ -373,29 +443,33 @@ package() { # add c89/c99 wrapper scripts cat >"$pkgdir"/usr/bin/c89 <<'EOF' #!/bin/sh -fl="-std=c89" +_flavor="-std=c89" for opt; do case "$opt" in - -ansi|-std=c89|-std=iso9899:1990) fl="";; + -ansi|-std=c89|-std=iso9899:1990) _flavor="";; -std=*) echo "$(basename $0) called with non ANSI/ISO C option $opt" >&2 exit 1;; esac done -exec gcc $fl ${1+"$@"} +exec gcc $_flavor ${1+"$@"} EOF cat >"$pkgdir"/usr/bin/c99 <<'EOF' #!/bin/sh -fl="-std=c99" +_flavor="-std=c99" for opt; do case "$opt" in - -std=c99|-std=iso9899:1999) fl="";; + -std=c99|-std=iso9899:1999) _flavor="";; -std=*) echo "$(basename $0) called with non ISO C99 option $opt" >&2 exit 1;; esac done -exec gcc $fl ${1+"$@"} +exec gcc $_flavor ${1+"$@"} EOF chmod 755 "$pkgdir"/usr/bin/c?9 + + # install lto plugin so regular binutils may use it + mkdir -p "$pkgdir"/usr/lib/bfd-plugins + ln -s /$_gcclibexec/liblto_plugin.so "$pkgdir/usr/lib/bfd-plugins/" fi } @@ -412,6 +486,12 @@ libcxx() { pkgdesc="GNU C++ standard runtime library" depends= + if [ "$CHOST" = "$CTARGET" ]; then + # verify that we are using clock_gettime rather than doing direct syscalls + # so we dont break 32 bit arches due to time64. + nm -D "$pkgdir"/usr/lib/libstdc++.so.* | grep clock_gettime + fi + mkdir -p "$subpkgdir"/usr/lib mv "$pkgdir"/usr/${_target:+$CTARGET/}lib/libstdc++.so.* "$subpkgdir"/usr/lib/ } @@ -425,13 +505,24 @@ gpp() { "$subpkgdir"/usr/${_target:+$CTARGET/}lib \ mv "$pkgdir/$_gcclibexec/cc1plus" "$subpkgdir/$_gcclibexec/" - paxmark -pmrs "$subpkgdir/$_gcclibexec/cc1plus" mv "$pkgdir"/usr/${_target:+$CTARGET/}lib/*++* "$subpkgdir"/usr/${_target:+$CTARGET/}lib/ mv "$pkgdir"/usr/${_target:+$CTARGET/}include/c++ "$subpkgdir"/usr/${_target:+$CTARGET/}include/ mv "$pkgdir"/usr/bin/*++ "$subpkgdir"/usr/bin/ } +jit() { + pkgdesc="GCC JIT Library" + depends= + amove usr/lib/libgccjit.so* +} + +jitdev() { + pkgdesc="GCC JIT Library (development files)" + depends="libgccjit" + amove usr/include/libgccjit*.h +} + libobjc() { pkgdesc="GNU Objective-C runtime" replaces="objc" @@ -445,8 +536,10 @@ objc() { replaces="gcc" depends="libc-dev gcc=$_gccrel libobjc=$_gccrel" - mkdir -p "$subpkgdir"/$_gcclibdir/include \ + mkdir -p "$subpkgdir/$_gcclibexec" \ + "$subpkgdir"/$_gcclibdir/include \ "$subpkgdir"/usr/lib + mv "$pkgdir/$_gcclibexec/cc1obj" "$subpkgdir/$_gcclibexec/" mv "$pkgdir"/$_gcclibdir/include/objc "$subpkgdir"/$_gcclibdir/include/ mv "$pkgdir"/usr/lib/libobjc.so "$pkgdir"/usr/lib/libobjc.a \ "$subpkgdir"/usr/lib/ @@ -469,6 +562,39 @@ libgomp() { mv "$pkgdir"/usr/${_target:+$CTARGET/}lib/libgomp.so.* "$subpkgdir"/usr/lib/ } +libgphobos() { + pkgdesc="D programming language standard library for GCC" + depends= + + mkdir -p "$subpkgdir"/usr/lib + mv "$pkgdir"/usr/lib/libgdruntime.so.* "$subpkgdir"/usr/lib/ + mv "$pkgdir"/usr/lib/libgphobos.so.* "$subpkgdir"/usr/lib/ +} + +gdc() { + pkgdesc="GCC-based D language compiler" + depends="gcc=$_gccrel libgphobos=$_gccrel musl-dev" + depends="$depends libucontext-dev" + + mkdir -p "$subpkgdir/$_gcclibexec" \ + "$subpkgdir"/$_gcclibdir/include/d/ \ + "$subpkgdir"/usr/lib \ + "$subpkgdir"/usr/bin + # Copy: The installed '.d' files, the static lib, the binary itself + # The shared libs are part of 'libgphobos' so one can run program + # without installing the compiler + mv "$pkgdir/$_gcclibexec/d21" "$subpkgdir/$_gcclibexec/" + mv "$pkgdir"/$_gcclibdir/include/d/* "$subpkgdir"/$_gcclibdir/include/d/ + mv "$pkgdir"/usr/lib/libgdruntime.a "$subpkgdir"/usr/lib/ + mv "$pkgdir"/usr/lib/libgdruntime.so "$subpkgdir"/usr/lib/ + mv "$pkgdir"/usr/lib/libgphobos.a "$subpkgdir"/usr/lib/ + mv "$pkgdir"/usr/lib/libgphobos.so "$subpkgdir"/usr/lib/ + mv "$pkgdir"/usr/lib/libgphobos.spec "$subpkgdir"/usr/lib/ + mv "$pkgdir"/usr/bin/$CTARGET-gdc "$subpkgdir"/usr/bin/ + mv "$pkgdir"/usr/bin/gdc "$subpkgdir"/usr/bin/ +} + + libgo() { pkgdesc="Go runtime library for GCC" depends= @@ -479,17 +605,24 @@ libgo() { go() { pkgdesc="Go support for GCC" - depends="gcc=$_gccrel libgo=$_gccrel" + depends="gcc=$_gccrel libgo=$_gccrel !go" mkdir -p "$subpkgdir"/$_gcclibexec \ "$subpkgdir"/usr/lib \ "$subpkgdir"/usr/bin mv "$pkgdir"/usr/lib/go "$subpkgdir"/usr/lib/ mv "$pkgdir"/usr/bin/*gccgo "$subpkgdir"/usr/bin/ + mv "$pkgdir"/usr/bin/*go "$subpkgdir"/usr/bin + mv "$pkgdir"/usr/bin/*gofmt "$subpkgdir"/usr/bin mv "$pkgdir"/$_gcclibexec/go1 "$subpkgdir"/$_gcclibexec/ + mv "$pkgdir"/$_gcclibexec/cgo "$subpkgdir"/$_gcclibexec/ + mv "$pkgdir"/$_gcclibexec/buildid "$subpkgdir"/$_gcclibexec/ + mv "$pkgdir"/$_gcclibexec/test2json "$subpkgdir"/$_gcclibexec/ + mv "$pkgdir"/$_gcclibexec/vet "$subpkgdir"/$_gcclibexec/ mv "$pkgdir"/usr/lib/libgo.a \ "$pkgdir"/usr/lib/libgo.so \ "$pkgdir"/usr/lib/libgobegin.a \ + "$pkgdir"/usr/lib/libgolibbegin.a \ "$subpkgdir"/usr/lib/ } @@ -513,7 +646,7 @@ libquadmath() { gfortran() { pkgdesc="GNU Fortran Compiler" depends="gcc=$_gccrel libgfortran=$_gccrel" - $LIBQUADMATH && depends="$depends libquadmath=$_gccrel" + $_libquadmath && depends="$depends libquadmath=$_gccrel" replaces="gcc" mkdir -p "$subpkgdir"/$_gcclibexec \ @@ -524,11 +657,12 @@ gfortran() { mv "$pkgdir"/usr/lib/libgfortran.a \ "$pkgdir"/usr/lib/libgfortran.so \ "$subpkgdir"/usr/lib/ - if $LIBQUADMATH; then + if $_libquadmath; then mv "$pkgdir"/usr/lib/libquadmath.a \ "$pkgdir"/usr/lib/libquadmath.so \ "$subpkgdir"/usr/lib/ fi + mv "$pkgdir"/$_gcclibdir/finclude "$subpkgdir"/$_gcclibdir/ mv "$pkgdir"/$_gcclibexec/f951 "$subpkgdir"/$_gcclibexec mv "$pkgdir"/usr/lib/libgfortran.spec "$subpkgdir"/$_gcclibdir } @@ -541,9 +675,18 @@ libgnat() { mv "$pkgdir"/usr/lib/libgna*.so "$subpkgdir"/usr/lib/ } +libgnatstatic() { + pkgdesc="GNU Ada static libraries" + depends= + + mkdir -p "$subpkgdir"/usr/lib + mv "$pkgdir"/usr/lib/libgna*.a "$subpkgdir"/usr/lib/ +} + gnat() { pkgdesc="Ada support for GCC" depends="gcc=$_gccrel" + provides="$pkgname-gnat-bootstrap" [ "$CHOST" = "$CTARGET" ] && depends="$depends libgnat=$_gccrel" mkdir -p "$subpkgdir"/$_gcclibexec \ @@ -554,35 +697,58 @@ gnat() { mv "$pkgdir"/usr/bin/*gnat* "$subpkgdir"/usr/bin/ } -sha512sums="1811337ae3add9680cec64968a2509d085b6dc5b6783fc1e8c295e3e47416196fd1a3ad8dfe7e10be2276b4f62c357659ce2902f239f60a8648548231b4b5802 gcc-8.3.0.tar.xz -e36e95b81489163abd6fe9d58f7867bdca43e61143afacbfb17f4698c0b16ec5fd0061d8fab7b2ae615540bebd721c2e2227f80401b4e7fc253da9da62e6b513 002_all_default-relro.patch -f86466c62b8291fac46f9c250c7ad8fa5ab7b1cce2504442fd07ddc4543665b317ae28951f244e39aba29aeaf3fff252ec4f6a147aa16adb2b7aed747dd89188 003_all_default-fortify-source.patch -02b725b220e540077efef741e9d457f9e004fe53ae642a138e214875d076a60f7c2f27de0ed9a4225db2030fc9c3d2c5b0414c895b9eec0f5f48fad70e2fb029 005_all_default-as-needed.patch -6c9a5068f6eea8a85d297a3555b1d2333ffd4b9ddbfb7560a3e643f8577603871ca123373ef7f96e894225291d88f7bf575c7f8386bcfdd1dabcd7ba12598b65 gcc-as-needed-gold.patch -ab0df1862f1b645634e79b8101326ce53215eba39861a455cd145b81b5267a6a61bc6e76b32d53887a0a48873f7efc23e2c52cc04400c6afd89822f245cdbc77 gcc-as-needed-push-pop.patch -e026bf9f73ee254528423c6cabdfd7794960c567161581b7d4b7c61c45027e12a6efef79662d4288b9cbaecb4798f01af6a5b4a13b766c2d501444ac1846fd43 011_all_default-warn-format-security.patch -37de4cc9061bfe1963e6e6570e1a6bbfd58204bf90e0eef819882599a9a80ea28f3eb815c20c1f173dc25d4bd9971b7c7f7f9512d6f8f91f04de1e1175114d4d 012_all_default-warn-trampolines.patch -38a0fedeac3eebe4a6a957792ba520225cf42663c96a171cd168fdb6c91ffa9a56b80351f8238c5d03b78d3ae2a6539a54481fe4848b4a395e2c87f2ff7adc08 013_all_default-ssp-fix.patch -d35a3ac7e13a4446921a90e1ff3eec1079840c845f9d523c868e24ae21f94cf69ba041de5341ebef96432a6f57598e223381d4286e8fb8baaa25906707f29fbd 020_all_msgfmt-libstdc++-link.patch -840070a3c423e6206aaa6e63e1d9a0fcd6efd53626cd1240a193f0b60aa5d84216acc4a2a4fa8bce74549b07e6a316b01d638f20cea13dc62473491a302fb3d6 050_all_libiberty-asprintf.patch -0a0bc72b9366158f5d23fff1928e756fdd212433bac6ab1f00d632f241382820db8db5d475ddf11ea020eaf7e2e71b12fb9b1c3c870cf84adf6c2b16f15aabca 051_all_libiberty-pic.patch -e7a2eb1b1870e199d6fd753d065781575656fa12baa264f96c5d179689d88c31b8a3f92a5dae96088c05e96aa2bda138364ad7dbcc79e1819a102f192cbb7bab 053_all_libitm-no-fortify-source.patch -4a328d1e1a56c20166307edcfa322068915784d9c08025b7f81cf69714da48fc266b6d34f77b9135c2f10da830d9df408276a1b78d1fd218637c2823506593c2 090_all_pr55930-dependency-tracking.patch -3842bd2be3e53db34e59bfb2bd438b244fc3712055058b9e232e33345f0fab216256b79e364fbac335972dc599a1d74393704f0cd595f3f076dcc10883c85b28 0003-gcc-poison-system-directories.patch -d1c2d7ff7f673375dc7cd84ae9d8515853b5af6390c70bb763412c012101344e4ee1ce155151ce3fb6ba2b80af7ed42d697dbe1bf6fd6e7b2b9087a378c47c37 203-libgcc_s.patch -98473bcaa77903a223ca9b0d2087c0921b287a2816d308cc32c8fe009e6cbf5dd1ae7fba27794ab8d9c09e117fe534413d91a464d1218474fc123ce0adfdc2c1 205-nopie.patch -6d84354e6df96d5ea244eb3bb5f044781796b88040b11c78fb6ee509e5aac19d46e0e92ca836e98e6495d9751f52439833b748efc419e4f5d5301fb549c4dcc9 0002-posix_memalign.patch -7f434a7350c9b06d0ae7cc18a569d813238483afa34b0801d112844a0dfe6164ae36b0416955fd4da7a8caa54672247f319a8ec7ce4b6a97a5f4e17ec083112a 0008-s390x-muslldso.patch -66085c5555e6b91b6874d1782d5a1dc0ab1792889f9400f48cde9483f82b51b9e3a5de1efbba21a19fc5e664334f2188d0c2bc988d42335efa26118b3c85cc7f 0010-ldbl128-config.patch -45d5bc11a89e5af77503ca06eec52d6d84e6fea0be021aaee1bcc39f8dd3c7b4baa4200cfa2b0688faa0f207d005db89c029eff32f362207aa3d2365b2f2363e 0012-static-pie.patch -d08d7ead2de0429e5c9055d5b029ec2be9a8c821d22cecaf9b51f633652c493333f98963d9267fa2fa63850c50ae5eefd5f59e5910ec10d20044dac082182a8b libgcc-always-build-gcceh.a.patch -600fe5098dc54edaa9808fd5717af9dec058953f9ad37d49cfba1db4f7e9a7a8f02019342f75157fc575946fa693259422184de27b7ecc8386d9f3ecc0f7cc5d gcc-4.9-musl-fortify.patch -dbe0ee917fc7668571722364ab7c806731e3a31e8bfa30b4941b28b16b877d2a32b4a3897ef533399a28f82d43cac9b28e92de0493f0e779046db56584e07fa4 gcc-6.1-musl-libssp.patch -fa62556719449caec6b2b434355bfbcaa5ae55ffe017b3e1f827f66a2aae21b79c571ee7a4ce723ea69169bc3a6447e73650991a200cc372adf2f102677518d7 gcc-pure64.patch -35d6d59f0b7b968f282f56767c9e0823a7bdc5aa0d450aca50fbd802649a7ca608b47671244a3faa208a9b0d6832cabb5a22724157dc817b2c0ad63d09f93282 fix-cxxflags-passing.patch -3f5bc334d9f73d06f5f7c876738d02356acdd08958bea0e4d2095ebf15c2c2ec4e411abdae0297505ae9a1699ca01b17338e853184e84663203b192b0d35fc19 ada-shared.patch -50537add461714f44dc6a778e0c6d0e15d6a782591c8aff38d1fb559191ddac2b5ee14a43a3005b389fdf98d2e7468ff4e64c88ba024cf94f9fe0d9854b9e9c8 ada-musl.patch -a1f7750bc7b8b7d916a5dee34fcc736bd4fb249c96538b547d495794e6cfd49356aa3974506a15074b4cb58edd5d7e2868607c902dd003e8c464d5066fd4a575 libgnarl-musl.patch -f4ef08454e28c8732db69115e4998ec153399e8d229dd27f923dbdcf57b68128a65640d026cc7f45b58ba8764ab1eb575d4eb6d6dfc550a87a183f8b94e76181 320-libffi-gnulinux.patch -86be3338cc9c33089608bc4c5e3b7918c4e500a345c338f361b18c342119a6ed69af5495d72950de7106d760f003528b46ad14795e805f8a3331e206dcb234e3 gcc-pure64-mips.patch -8039d4081b77332694bc10f898d5e4da0ece4ce7b0e219fedb2aab965126b6b0537d03ba8652341c9c35af07eef33e96b42cc02388f36d8027b9475d44f6b420 0016-invalid_tls_model.patch" +sha512sums=" +94d4d2e31f5a84455055d34cfbbcc63d5bd63e60345c2a4e30aa404724e65e5d14868ef50b7fcf5537dd12dc6f1381a27cede269801050e193b4bdb8f2919971 gcc-11.2.1_git20220219.tar.xz +d46a87edb919697a37c15af99c9142c6ad8ec364fe9b5747f5808368e619766163d3d8b64e987b1155785ddc91b5b191b795857cd70118d64f978e46b476bfff 0001-posix_memalign.patch +59fa772417c1d1baf8bd8477ef4e30975fbd616d949fbd72fa88cc72d9662f2e28214305a188d75e30c54a95be111c7998784f7d1499562490acbe194a3c2116 0002-gcc-poison-system-directories.patch +556240f9888c24706694560ad3ba1a90d3ed6da1dd3d7eebb603f4e3551d5743908840d4b1f598d6d5dc3cc52bcfafbcd777282ec8864051c3c8aba623866d3e 0003-specs-turn-on-Wl-z-now-by-default.patch +747a2ba2c0227471dd8a327bddd4699aa6aad5ddce2e523816e43e04fd5a4d8c2f1a69f02980632263ab1c23334d01e27d5df737a0ba9f6bd16b9c85112de82a 0004-Turn-on-D_FORTIFY_SOURCE-2-by-default-for-C-C-ObjC-O.patch +0fe2b802ce0b9c986d7ea5378df49899b028baad419ccd4071fd1a2dad90736e0f04eef29056f6c74c1fa2482359629b5e3747d58fcbf3520c6ed10c66c7b87e 0005-On-linux-targets-pass-as-needed-by-default-to-the-li.patch +7d37f31108cddfeb25ebf7e462d999873dc184bb26f74c9d7d6d32534a15070291661ab58be41ccedb44af20de0568e704b4152668c6bd803cf88f1ddfb6e35c 0006-Enable-Wformat-and-Wformat-security-by-default.patch +698893670d00df1ddbaa7dd970b17049f94d0cc2fec3225925bbad606e44c29288e38a7afa4b4cae3c9c26be35646c52e9eadc67022b89d7b4ce97ce64a5a2ac 0007-Enable-Wtrampolines-by-default.patch +b549d45824d6b9f2ec830ed66ba192ebfe9d9c3db554bf0b51379e9b624de0f0a1a315520487a1a3bfbe9d65d41c41239b9461bc9f1b5059c51d5f4dc7581872 0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch +15089ea9465057f6897d5c570e79abd068b85f9fc77490668872397699025905aa065eaf7318ddb0847747da4397676242064f290b45e16f616bab86258be260 0009-Ensure-that-msgfmt-doesn-t-encounter-problems-during.patch +cc9aa31e3b4227f7887d9be470bb19cb3ccd8125155741721921b4c8f791710fabc279b492232454fda0a47bf98509bd2fd4bcdbf5a5aad8b8f476bc5aa74d07 0010-Don-t-declare-asprintf-if-defined-as-a-macro.patch +c2c74411717e5bf6e261bde4d5c50b12645de2d556b3eb898600e7629772f7d9d213e32f5a0b81d8ee2ba2e4bc55ea64ee60119d9d9a03045574016d94b76f61 0011-libiberty-copy-PIC-objects-during-build-process.patch +d92fe356d745fbc858cbb338b0027b814a2f7812fc7bb6147d641e7319d4ff09ac4ade766b419566e70e6250847ec56e95fd74617a82069dc93f669d827dd48e 0012-libitm-disable-FORTIFY.patch +2e5c0845581c92573fc2e60f7771d9f99e23fd32bf4da7c09bc1738f69174f8becfe9f0c9ee96fbc87b3264dcf2d4b801d051606bd528b43e76cd1fb9ddf6b40 0013-libgcc_s.patch +2a79fd03fe9b98cca3cdbed368969304f9ebcedb7701703740c30a1fe70bfdeceaddac4cbf796f60ee080f0d62a926da6c48042c563b081d9116691c4531a68c 0014-nopie.patch +4a1d53c120047702ea51df3c611af3e4ae82b9cf63dc8244ac38042de44b24afe98578e70aa964884b22ef76ee65d1d703355defc613637acf52d580ce86f17c 0015-libffi-use-__linux__-instead-of-__gnu_linux__-for-mu.patch +64065ec9243eb12424cb75822219376e7829f1e1d206d93c4b4cbe18eb4e538019361cc1b5b7d88da4d2d5c891d9e282d579902db534d09b7d58ec91bfada6b5 0016-dlang-update-zlib-binding.patch +35ffecaa8ec56b64c73df93530d858632f0429de007d70869432c183610d344711a1552b1bb00f2180ae952c66a66e1c6285139a8818d656691a121cd7abdba7 0017-dlang-use-libucontext-on-mips64.patch +f78fc1bc99669a90bd68051f9d17bfc25065e49c7d4e853cda293be3a9f17b08867de31e73b90a82b948005f5e17020ccf55dfa4a1b0b9b0cba707c0ed635a46 0018-dlang-libdruntime-define-fcntl.h-constants-for-mips6.patch +463ce54bb32d9ba52ed7f0d7df99011f17543e80f6aca9a61b747e074662b283c563434b96a0bc8ae4636e154f1033c5720f3c8113bc6ad095592a1d5584981c 0019-ada-fix-shared-linking.patch +194647e5a87fb7ebd7602eee9ffa5d3e713dc26baa5f8fa50ada513ca5d28898d1fcee5e9db0d3af6d5b774961426fc1e2f9b5155992ead9981412c627967219 0020-build-fix-CXXFLAGS_FOR_BUILD-passing.patch +d707e47a10c866c0e6d085f9a2bfa1b21eff8e6a1b222840abbbe1b2f21cc4a50f4fa45f7dbbb1ad86dc2eb7c88160c715e69039d3de7f7784de7d5f2a87d6e4 0021-add-fortify-headers-paths.patch +e746e250451eb76726a9de8f42de5eb1d23a228fd3d8961cd2a6c6f691a5418fcd32a817998e3a5aaf8d2d90cd03371aaf7912c9b834ed6c663c649f85f1d058 0022-Alpine-musl-package-provides-libssp_nonshared.a.-We-.patch +c6d3a4b5d541b52f44641e59556c6312d785c4e12d47fac11a530ae0746170e891c0ed64ce6e9856e5581debfae0d5216753afaf87df1a2d40d50bdfa24ea7dc 0023-DP-Use-push-state-pop-state-for-gold-as-well-when-li.patch +a29ad877662bbdbc6422456d32ed31aab3764edcc1eb3e1abe7be0f22d162da6d0f0d6565a25c7a43bf23151faba0492122ddcf832bdac57b3e47f89a6ab158d 0024-mips64-disable-multilib-support.patch +18be870ec68865f4661ac73f9bf50765164711582b497beb852928e1d993bc257a0d2b015f435e93461c35edc1811505d31f3a46147bccb4764dcf9b8319c93a 0025-aarch64-disable-multilib-support.patch +b2b830626396936be105361e87c82490b5cd3d26ce7b8dbccf156d53eb5d0db82a28167656aaa5e47b6a1315263abf070432db693c5ae10da892217ce2728728 0026-s390x-disable-multilib-support.patch +094ed675ff5512829bbf7f2bd2632498300b7f15cec6b4a397b145f378a41c17c99f05ea0b94ed1408773a3e8b1fd713ba302c64dba00269df270d401b0e6443 0027-ppc64-le-disable-multilib-support.patch +ee67238c66132f30fd00cc084d37012a927abe32ac48b4617779f22069d86384826c063b79626ab64f6adefdac0f00fcd5c18b95c8a2f11fb2cbee67babc9beb 0028-x86_64-disable-multilib-support.patch +2ddf60a03db15c9c3e847001e300a54dfd9b5435da630e18379313e516fccbb8ea5e26571bb4f88baa6756cdb5c8ba7d059249c46a2f56e67bfca368750431eb 0029-riscv-disable-multilib-support.patch +e7f9088809a4a4b87a6a5670227fb31766fb124ecdcea9936b00a7b98fdc06d7e7f27b6f67a575c434ba978623cb5f1183691dd63d6db98b180c4e08d62e5c5e 0030-always-build-libgcc_eh.a.patch +653b2dbdf43ad336e75aa33ee3e520edd4c8cdb486bf8f5a30dbd8496b96451aa508e12e6a81dd16d36119f22fb9b0c46bcc39d731c89443c435fa4d1ca6fa08 0031-ada-libgnarl-compatibility-for-musl.patch +9d46489087018366eea3b6537f6a86b0e183c7d49f8fecc2f50fbbcebf78727f5a1661ee6a50b5bddef0d54ebe47668ad61440784495194420b0896d5bd3f1aa 0032-ada-musl-support-fixes.patch +63a2f9a81f94826dfac05073d6b7cb599c5b1d026c460edfd329f770c72208e369af1e427904528351aa78bce6e9445af9c59ca73ef5302f7362027757fa5d46 0033-gcc-go-Fix-handling-of-signal-34-on-musl.patch +8d3a01d7e5e983eaabdf5c4a7e58ef33c55a794ed4cb5d438b41218ded367d3214b868a5c8d68f52ef74b0f83abb95d29b36ef8d0c7be68f7d1537a04e65d5c1 0034-There-are-more-than-one-st_-a-m-c-tim-fields-in-stru.patch +56c7c1911fef05beaecfa1b41703d46d18c5e967430c79c719f8685f4c4971bb177f2de35b0a1631d5d3ed7292cb54c618e52fa859f483fafb5445511e5b226b 0035-gcc-go-signal-34-is-special-on-musl-libc.patch +07921d5c30f3a23ba1c0540e106abe49e1675f183ffe2b326bdab80c59847b9ed5f39efd2836bc47d4ac1b3a3152f8de092c498ba91682e51c20548a65c0f105 0036-gcc-go-undef-SETCONTEXT_CLOBBERS_TLS-in-proc.c.patch +ef8df8a047b4145f30884b052345e4e390fc1efb35a9c7da63899aa115c19b8cc04513a57b2340a6a58ed02dc6881b10f684da653734afe5acf69761e3d064e7 0037-gcc-go-link-to-libucontext.patch +cf000459b493815bb0c9bccbbccc61ab8101f067b5b45d0f30cf49bf0ec6745f6ae360e4b5dccdb5c9bef1974835830efbb349c2ab38d1ee4dcc22385546873b 0038-Use-generic-errstr.go-implementation-on-musl.patch +0baffb0d19c26a387d38525c87b3500c4486bf11aeb9d98cec559eb67db4b71d5bc580fa6aebb9a12295422edb53aea77101e521e91f5189c744749448b89b4a 0039-configure-Add-enable-autolink-libatomic-use-in-LINK_.patch +d80074e1fa09cf6f7047a4dac7acadcfb53fcc93667af3348c61b22390999d618f2b16107c30a0fc52b145e27f14d6fddbe43ea36e6a9089741cb3b0b64fd856 0040-configure-fix-detection-of-atomic-builtins-in-libato.patch +04434b605d71b6d4e9dedd03a810f250725d31fc70a5ad28d69499a04436caf6b0ec69f5c7223cb511063cc18c350ffdd95b722de97467f827789006ebcb2c73 0041-libgo-Recognize-off64_t-and-loff_t-definitions-of-mu.patch +a3dc43ba56f12f4243c186572b32809d47a9d29c7a40edcf7f6da34c7add65a271c77635a5b9ae325d167e24a2e6bbe883c63eccec3af5d6f925cb304f8ba92b 0042-Fix-attempt-to-use-poisoned-calloc-error-in-libgccji.patch +04ebbf2143a2d4b6c6d768c3aeea2899e6261adf414e16faed1247bc94eeaf61e54f88a2ba7ffdca90e9c0ee87c6fd7e3746481d184c539b8e0130a14b215fa7 0043-stddef.h-add-support-for-musl-typedef-macro-guards.patch +e47183b5a565bdc64a497e14124d767a3e889e9f9d77a92567b0047b285c5ca49897b46ba681e339a8982611b70583ae87a3472dae33f07becaeceb21b3cfe74 0044-gcc-go-Use-int64-type-as-offset-argument-for-mmap.patch +a5adab61de2d4b2c3ccb1a55c70384a8496c447f7727a6680fa29263c4f57599a3dfb85e1e322859797f86605491af0f68f9dd1141ab4bbbe8b5183f67f3b32e 0045-libgo-include-asm-ptrace.h-for-pt_regs-definition-on.patch +9c0e461eeba709110ca88d60236190c9b71d57d4e13786e2f15521a902e37dacc08d466966764abce9bc84e27d06e2e8523a1a80325f8a16d6ec16d2bf89fa05 0046-Disable-fsplit-stack-support-on-non-glibc-targets.patch +f62778ab53125a9ba5a8088e064c2182c014bc264a46fd3d28d1ee0142dd02a7ed2c684dc63e9768a56a6f8f65621bea20026cd6b65053c2ff9ee51568ee260d 0047-x86-Properly-disable-fsplit-stack-support-on-non-gli.patch +c44c6e5b28b622897af60e7e2dbf0d0284379eb57b39b480936e6d8b3743a24287c2a9ed69a530ef4f2327b5e5ca61ce00e92d415e0ed033e54bdffde345e6a9 0048-gdc-unconditionally-link-libgphobos-against-libucont.patch +160ef16fde90546474e1548f1487c18d9b8edbae1d42a13ad06041b03214d06ff2c3586acd4d0bae27d48e48bb651861c6b9a140ade4ac59f00a268e85275da4 0049-properly-disable-fsplit-stack-on-non-glibc-targets-P.patch +f4d9ebf6d5c80d2f303404b9bf315bf81435c0d369b03b92f8e8510d82db72c2a30d84603307ddc0697df3845862ba93045e4a3724f8e491e7c01bd4396d8864 0050-x86-Fix-fsplit-stack-feature-detection-via-TARGET_CA.patch +8ac54b3a46f7270d975fa3e1198ac37a2311a4b9940938958ffc148e4e9c82c3e81cf3e3c3abd43cef29137897cd6768220b432f828672e036308f7994422d2e 0051-go-gospec-forcibly-disable-fsplit-stack-support.patch +fa59b0fb081d97f8f63506b8793699588a95c602b5d468140eb1e80456597e52e1cc45dc0b234ac8e60e2b0cd606d94d111c8b0ae64c0a2be1bc1b8a184ceb93 libgo-musl-1.2.3.patch +" diff --git a/cross-images/mini-aports/main/gcc/fix-cxxflags-passing.patch b/cross-images/mini-aports/main/gcc/fix-cxxflags-passing.patch deleted file mode 100644 index 8eb1de7..0000000 --- a/cross-images/mini-aports/main/gcc/fix-cxxflags-passing.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- gcc-4.8.1/Makefile.in.orig -+++ gcc-4.8.1/Makefile.in -@@ -169,6 +169,7 @@ - # built for the build system to override those in BASE_FLAGS_TO_PASSS. - EXTRA_BUILD_FLAGS = \ - CFLAGS="$(CFLAGS_FOR_BUILD)" \ -+ CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \ - LDFLAGS="$(LDFLAGS_FOR_BUILD)" - - # This is the list of directories to built for the host system. diff --git a/cross-images/mini-aports/main/gcc/gcc-4.9-musl-fortify.patch b/cross-images/mini-aports/main/gcc/gcc-4.9-musl-fortify.patch deleted file mode 100644 index daae954..0000000 --- a/cross-images/mini-aports/main/gcc/gcc-4.9-musl-fortify.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- gcc-4.9.2/gcc/config/linux.h.orig 2015-03-09 13:27:13.289736710 +0000 -+++ gcc-4.9.2/gcc/config/linux.h 2015-03-09 13:29:32.295625046 +0000 -@@ -146,6 +146,8 @@ - - #ifdef NATIVE_SYSTEM_HEADER_DIR - #define INCLUDE_DEFAULTS_MUSL_NATIVE \ -+ { NATIVE_SYSTEM_HEADER_DIR "/fortify", 0, 0, 0, 1, 2 }, \ -+ { NATIVE_SYSTEM_HEADER_DIR "/fortify", 0, 0, 0, 1, 0 }, \ - { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \ - { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 }, - #else diff --git a/cross-images/mini-aports/main/gcc/gcc-6.1-musl-libssp.patch b/cross-images/mini-aports/main/gcc/gcc-6.1-musl-libssp.patch deleted file mode 100644 index fe5c614..0000000 --- a/cross-images/mini-aports/main/gcc/gcc-6.1-musl-libssp.patch +++ /dev/null @@ -1,20 +0,0 @@ -Author: Timo Teräs - -Alpine musl package provides libssp_nonshared.a. We link to it unconditionally, -as otherwise we get link failures if some objects are -fstack-protector built -and final link happens with -fno-stack-protector. This seems to be the common -case when bootstrapping gcc, the piepatches do not seem to fully fix the -crosstoolchain and bootstrap sequence wrt. stack-protector flag usage. - ---- gcc-6.1.0/gcc/gcc.c.orig -+++ gcc-6.1.0/gcc/gcc.c -@@ -870,8 +870,7 @@ - - #ifndef LINK_SSP_SPEC - #ifdef TARGET_LIBC_PROVIDES_SSP --#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ -- "|fstack-protector-strong|fstack-protector-explicit:}" -+#define LINK_SSP_SPEC "-lssp_nonshared" - #else - #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ - "|fstack-protector-strong|fstack-protector-explicit" \ diff --git a/cross-images/mini-aports/main/gcc/gcc-as-needed-push-pop.patch b/cross-images/mini-aports/main/gcc/gcc-as-needed-push-pop.patch deleted file mode 100644 index a5a4e9d..0000000 --- a/cross-images/mini-aports/main/gcc/gcc-as-needed-push-pop.patch +++ /dev/null @@ -1,43 +0,0 @@ -From: Jakub Jelinek -Subject: [PATCH] Use --push-state --as-needed and --pop-state instead of --as-needed and --no-as-needed for libgcc - -As discussed, using --as-needed and --no-as-needed is dangerous, because -it results in --no-as-needed even for libraries after -lgcc_s, even when the -default is --as-needed or --as-needed has been specified earlier on the -command line. - -If the linker supports --push-state/--pop-state, we should IMHO use it. - -2018-04-11 Jakub Jelinek - - * configure.ac (LD_AS_NEEDED_OPTION, LD_NO_AS_NEEDED_OPTION): Use - --push-state --as-needed and --pop-state instead of --as-needed and - --no-as-needed if ld supports it. - * configure: Regenerated. - -Index: b/gcc/configure.ac -=================================================================== ---- a/gcc/configure.ac -+++ b/gcc/configure.ac -@@ -5518,11 +5518,21 @@ if test $in_tree_ld = yes ; then - if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 16 -o "$gcc_cv_gld_major_version" -gt 2 \ - && test $in_tree_ld_is_elf = yes; then - gcc_cv_ld_as_needed=yes -+ if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 28; then -+ gcc_cv_ld_as_needed_option='--push-state --as-needed' -+ gcc_cv_ld_no_as_needed_option='--pop-state' -+ fi - fi - elif test x$gcc_cv_ld != x; then - # Check if linker supports --as-needed and --no-as-needed options - if $gcc_cv_ld --help 2>&1 | grep as-needed > /dev/null; then - gcc_cv_ld_as_needed=yes -+ if $gcc_cv_ld --help 2>&1 | grep push-state > /dev/null; then -+ if $gcc_cv_ld --help 2>&1 | grep pop-state > /dev/null; then -+ gcc_cv_ld_as_needed_option='--push-state --as-needed' -+ gcc_cv_ld_no_as_needed_option='--pop-state' -+ fi -+ fi - fi - case "$target:$gnu_ld" in - *-*-solaris2*:no) diff --git a/cross-images/mini-aports/main/gcc/libgo-musl-1.2.3.patch b/cross-images/mini-aports/main/gcc/libgo-musl-1.2.3.patch new file mode 100644 index 0000000..15a4229 --- /dev/null +++ b/cross-images/mini-aports/main/gcc/libgo-musl-1.2.3.patch @@ -0,0 +1,13 @@ +diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh +index 6fef104..06289a4 100755 +--- a/libgo/mksysinfo.sh ++++ b/libgo/mksysinfo.sh +@@ -126,7 +126,7 @@ if ! grep '^const SIGCLD ' ${OUT} >/dev/null 2>&1; then + fi + + # The syscall numbers. We force the names to upper case. +-grep '^const _SYS_' gen-sysinfo.go | \ ++grep '^const _SYS_[a-z]' gen-sysinfo.go | \ + sed -e 's/const _\(SYS_[^= ]*\).*$/\1/' | \ + while read sys; do + sup=`echo $sys | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` diff --git a/cross-images/mini-aports/main/libc-dev/APKBUILD b/cross-images/mini-aports/main/libc-dev/APKBUILD index 76dc1b0..6f79ce9 100644 --- a/cross-images/mini-aports/main/libc-dev/APKBUILD +++ b/cross-images/mini-aports/main/libc-dev/APKBUILD @@ -1,12 +1,13 @@ # Contributor: Natanael Copa # Maintainer: Natanael Copa pkgname=libc-dev -pkgver=0.7.1 -pkgrel=0 +pkgver=0.7.2 +pkgrel=3 pkgdesc="Meta package to pull in correct libc" -url="http://alpinelinux.org" +url="https://alpinelinux.org" arch="noarch" -license="BSD" +license="BSD-2-Clause AND BSD-3-Clause" +options="!check" # No test suite makedepends_build=" " makedepends_host=" " makedepends="$makedepends_build $makedepends_host" @@ -15,23 +16,21 @@ subpackages="libc-utils:utils bsd-compat-headers:bsdcompat" source="sys-cdefs.h sys-queue.h sys-tree.h + sgidefs.h " prepare() { mkdir -p "$builddir" - cd "$builddir" -} - -build() { - return 0 -} - -check() { - return 0 } package() { mkdir -p "$pkgdir" + + case "$CTARGET" in + mips*) + install -D "$srcdir"/sgidefs.h "$pkgdir"/usr/include/sgidefs.h + ;; + esac } utils() { @@ -56,4 +55,5 @@ bsdcompat() { sha512sums="8c3fddd73b696a38e633953715c79c47703739be27ee085fc6c960a57b6746ca05bf6406f7e6126cc1a13204254fd5830afb566624e1f298f4d6b58216013c28 sys-cdefs.h 2f0d5e6e4dc3350285cf17009265dddcbe12431c111868eea39bc8cb038ab7c1f2acacbb21735c4e9d4a1fd106a8fc0f8611ea33987d4faba37dde5ce6da0750 sys-queue.h -07cb70f2f0ddb31e23dd913c6f561fc9885667c5803fdf3a559676c99d08834b4104589bacb5d17b4a0b379c68c81a1cf3173832b3da33a7b936fa7b93706844 sys-tree.h" +07cb70f2f0ddb31e23dd913c6f561fc9885667c5803fdf3a559676c99d08834b4104589bacb5d17b4a0b379c68c81a1cf3173832b3da33a7b936fa7b93706844 sys-tree.h +7f8fc4b50aa88106adfba4971b2e441d6f480efef45ba8dce3b6c1235b1835a31883718e3d1f0606ad7366b965e52e00faf91c322e53f3af35da630126f26de4 sgidefs.h" diff --git a/cross-images/mini-aports/main/libc-dev/sgidefs.h b/cross-images/mini-aports/main/libc-dev/sgidefs.h new file mode 100644 index 0000000..22c110c --- /dev/null +++ b/cross-images/mini-aports/main/libc-dev/sgidefs.h @@ -0,0 +1,13 @@ +#include + +#ifndef _ABIO32 +# define _ABIO32 _MIPS_SIM_ABI32 +#endif + +#ifndef _ABIN32 +# define _ABIN32 _MIPS_SIM_NABI32 +#endif + +#ifndef _ABI64 +# define _ABI64 _MIPS_SIM_ABI64 +#endif diff --git a/cross-images/mini-aports/main/linux-headers/0003-remove-inclusion-of-sysinfo.h-in-kernel.h.patch b/cross-images/mini-aports/main/linux-headers/0003-remove-inclusion-of-sysinfo.h-in-kernel.h.patch index b5c4e17..f3381c4 100644 --- a/cross-images/mini-aports/main/linux-headers/0003-remove-inclusion-of-sysinfo.h-in-kernel.h.patch +++ b/cross-images/mini-aports/main/linux-headers/0003-remove-inclusion-of-sysinfo.h-in-kernel.h.patch @@ -13,17 +13,17 @@ Upstream-Status: Submitted include/uapi/linux/kernel.h | 2 ++ 1 file changed, 2 insertions(+) -Index: linux-4.8-rc4/include/uapi/linux/kernel.h -=================================================================== ---- linux-4.8-rc4.orig/include/uapi/linux/kernel.h -+++ linux-4.8-rc4/include/uapi/linux/kernel.h -@@ -1,7 +1,9 @@ +diff --git a/include/uapi/linux/kernel.h b/include/uapi/linux/kernel.h +index fadf2db71fe8..813800ed141f 100644 +--- a/include/uapi/linux/kernel.h ++++ b/include/uapi/linux/kernel.h +@@ -2,7 +2,9 @@ #ifndef _UAPI_LINUX_KERNEL_H #define _UAPI_LINUX_KERNEL_H +#ifdef __GLIBC__ #include +#endif + #include - /* - * 'kernel.h' contains some often-used function prototypes etc + #endif /* _UAPI_LINUX_KERNEL_H */ diff --git a/cross-images/mini-aports/main/linux-headers/APKBUILD b/cross-images/mini-aports/main/linux-headers/APKBUILD index c021eac..cd437c1 100644 --- a/cross-images/mini-aports/main/linux-headers/APKBUILD +++ b/cross-images/mini-aports/main/linux-headers/APKBUILD @@ -1,35 +1,27 @@ # Maintainer: Natanael Copa pkgname=linux-headers -pkgver=4.19.36 +pkgver=5.16.7 _kernver=${pkgver%.*} -pkgrel=0 +pkgrel=1 pkgdesc="Linux system headers" -url="http://kernel.org" -arch="all" +url="https://kernel.org/" +arch="noarch" license="GPL-2.0-only" -makedepends="perl" +makedepends="perl rsync" options="!check !dbg !strip !tracedeps" -source="https://kernel.org/pub/linux/kernel/v4.x/linux-$_kernver.tar.xz - https://kernel.org/pub/linux/kernel/v4.x/patch-$pkgver.xz +source="https://kernel.org/pub/linux/kernel/v5.x/linux-$_kernver.tar.xz + https://kernel.org/pub/linux/kernel/v5.x/patch-$pkgver.xz revert-broken-uapi.patch 0003-remove-inclusion-of-sysinfo.h-in-kernel.h.patch - fix-aarch64-asm-ptrace.patch + include-uapi-linux-swab-Fix-potentially-missing-__always_inline.patch " +builddir="$srcdir/linux-$_kernver" prepare() { - cd "$srcdir"/linux-$_kernver if [ "$_kernver" != "$pkgver" ]; then - unxz -c < "$srcdir"/patch-$pkgver.xz | patch -p1 || return 1 + unxz -c < "$srcdir"/patch-$pkgver.xz | patch -p1 fi - for i in $source; do - case $i in - *.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;; - esac - done -} - -build() { - return 0 + default_prepare } package() { @@ -41,12 +33,12 @@ package() { mips*) _carch="mips" ;; s390*) _carch="s390" ;; ppc*) _carch="powerpc" ;; + riscv*) _carch="riscv" ;; # not sure about this -- ppc64*) _carch="powerpc64" ;; esac - cd "$srcdir"/linux-$_kernver mkdir -p "$pkgdir/usr" - make headers_install ARCH="${_carch}" INSTALL_HDR_PATH="$pkgdir/usr" || return 1 + make headers_install ARCH="$_carch" INSTALL_HDR_PATH="$pkgdir/usr" find "$pkgdir/usr" \( -name .install -o -name ..install.cmd \) -exec \ rm -f {} \; @@ -55,8 +47,10 @@ package() { rm -rf "$pkgdir"/usr/include/drm } -sha512sums="ab67cc746b375a8b135e8b23e35e1d6787930d19b3c26b2679787d62951cbdbc3bb66f8ededeb9b890e5008b2459397f9018f1a6772fdef67780b06a4cb9f6f4 linux-4.19.tar.xz -a8281d6edb21fbca3ecc8a11e3692f6f80bb9b1e6f302486eee5a7367304ca88ff9224689c7be1530c30cc23cbe6e6371e40c084499e45090340409b0e93bf77 patch-4.19.36.xz +sha512sums=" +7a257dd576bc8493595ec7d6f3c9cb6e22c772a8b2dbe735d2485c4f5c56e26a08695546e7e0f1f1cd04a533f25e829361958d4da0b98bf0ba8094dd57a85aaf linux-5.16.tar.xz +784fd87796b818f921deed92e1646058fa21e89b436c4d31dde2aeb5e445eb2bec76e9f6587f3179a9a531aeee770b027ecd2322d828f27e7a30c85fb95bb671 patch-5.16.7.xz 32597f2672d1ec365a936d15041a7cf219ef9353241d4a5c378244cf2fc155610443a19bbcd391c86099a0b08486c45e042ec7c90b0d04fe675c3ad0ffc36b53 revert-broken-uapi.patch -302283b1b5f560c850e24aad73febcf7f906ed62b4cad2d826bf140ffe59191631f3cd4ac29525c349cdfe61aba6a47886a0d76f1c6a4a16b744d59b94ea5df8 0003-remove-inclusion-of-sysinfo.h-in-kernel.h.patch -8b510dae7656ec9decee611773c21c0b379ccc8a776e4e0135cc28764fec611e9fc8bdee6a457d8df21f1399d3141659a20b70a0cb5efbb3e3b7aa7d5a5573ce fix-aarch64-asm-ptrace.patch" +607c074d72aca88fea9ecdbd62198d8f7857daca75e5d027966e0a9997338d6ac8ce0a1e9114b19232b390751d05acca09e28b0cfad2a12d5942f5575a9f4684 0003-remove-inclusion-of-sysinfo.h-in-kernel.h.patch +7cfa786144009c52d682e307bb512156e4812d7abe03b3fed99651a02d80567d47ee6f347f88d083c1b9805e0c09625fc3df08a8d0ae96b169d24eb5b83917b7 include-uapi-linux-swab-Fix-potentially-missing-__always_inline.patch +" diff --git a/cross-images/mini-aports/main/linux-headers/fix-aarch64-asm-ptrace.patch b/cross-images/mini-aports/main/linux-headers/fix-aarch64-asm-ptrace.patch deleted file mode 100644 index 516ec20..0000000 --- a/cross-images/mini-aports/main/linux-headers/fix-aarch64-asm-ptrace.patch +++ /dev/null @@ -1,27 +0,0 @@ -Work around redefinition of sigcontext in libc headers - -Introduced with: -https://github.com/torvalds/linux/commit/43d4da2c45b2f5d62f8a79ff7c6f95089bb24656 - -diff --git a/arch/arm64/include/uapi/asm/ptrace.h b/arch/arm64/include/uapi/asm/ptrace.h -index 98c4ce5..c44efed 100644 ---- a/arch/arm64/include/uapi/asm/ptrace.h -+++ b/arch/arm64/include/uapi/asm/ptrace.h -@@ -23,8 +23,6 @@ - #include - - #include --#include -- - - /* - * PSR bits -@@ -64,8 +62,6 @@ - - #ifndef __ASSEMBLY__ - --#include -- - /* - * User structures for general purpose, floating point and debug registers. - */ diff --git a/cross-images/mini-aports/main/linux-headers/fix-little_endian.patch b/cross-images/mini-aports/main/linux-headers/fix-little_endian.patch deleted file mode 100644 index eee74df..0000000 --- a/cross-images/mini-aports/main/linux-headers/fix-little_endian.patch +++ /dev/null @@ -1,14 +0,0 @@ -little_endian.h uses __always_inline which is defined in stddef.h - -diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h -index 601c904..cd98982 100644 ---- a/include/uapi/linux/byteorder/little_endian.h -+++ b/include/uapi/linux/byteorder/little_endian.h -@@ -9,6 +9,7 @@ - #define __LITTLE_ENDIAN_BITFIELD - #endif - -+#include - #include - #include - diff --git a/cross-images/mini-aports/main/linux-headers/include-uapi-linux-swab-Fix-potentially-missing-__always_inline.patch b/cross-images/mini-aports/main/linux-headers/include-uapi-linux-swab-Fix-potentially-missing-__always_inline.patch new file mode 100644 index 0000000..3ef4477 --- /dev/null +++ b/cross-images/mini-aports/main/linux-headers/include-uapi-linux-swab-Fix-potentially-missing-__always_inline.patch @@ -0,0 +1,55 @@ +From 2b7d2ece0b60b8f450f29119f28668dc74bb692e Mon Sep 17 00:00:00 2001 +From: Matt Redfearn +Date: Wed, 3 Jan 2018 09:57:30 +0000 +Subject: [PATCH] include/uapi/linux/swab: Fix potentially missing + __always_inline +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Commit bc27fb68aaad ("include/uapi/linux/byteorder, swab: force inlining +of some byteswap operations") added __always_inline to swab functions +and commit 283d75737837 ("uapi/linux/stddef.h: Provide __always_inline to +userspace headers") added a definition of __always_inline for use in +exported headers when the kernel's compiler.h is not available. + +However, since swab.h does not include stddef.h, if the header soup does +not indirectly include it, the definition of __always_inline is missing, +resulting in a compilation failure, which was observed compiling the +perf tool using exported headers containing this commit: + +In file included from /usr/include/linux/byteorder/little_endian.h:12:0, + from /usr/include/asm/byteorder.h:14, + from tools/include/uapi/linux/perf_event.h:20, + from perf.h:8, + from builtin-bench.c:18: +/usr/include/linux/swab.h:160:8: error: unknown type name ‘__always_inline’ + static __always_inline __u16 __swab16p(const __u16 *p) + +Fix this by replacing the inclusion of linux/compiler.h with +linux/stddef.h to ensure that we pick up that definition if required, +without relying on it's indirect inclusion. compiler.h is then included +indirectly, via stddef.h. + +Fixes: 283d75737837 ("uapi/linux/stddef.h: Provide __always_inline to userspace headers") +Signed-off-by: Matt Redfearn +--- + include/uapi/linux/swab.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h +index 7272f85d6d6a..3736f2fe1541 100644 +--- a/include/uapi/linux/swab.h ++++ b/include/uapi/linux/swab.h +@@ -3,7 +3,7 @@ + #define _UAPI_LINUX_SWAB_H + + #include +-#include ++#include + #include + #include + +-- +2.27.0 + diff --git a/cross-images/mini-aports/main/musl/APKBUILD b/cross-images/mini-aports/main/musl/APKBUILD index 0c5f569..8c3d71e 100644 --- a/cross-images/mini-aports/main/musl/APKBUILD +++ b/cross-images/mini-aports/main/musl/APKBUILD @@ -1,20 +1,26 @@ -# Contributor: +# Contributor: Ariadne Conill # Maintainer: Timo Teräs pkgname=musl -pkgver=1.1.22 -pkgrel=3 +pkgver=1.2.3 +pkgrel=0 pkgdesc="the musl c library (libc) implementation" -url="http://www.musl-libc.org/" +url="https://musl.libc.org/" arch="all" license="MIT" -subpackages="$pkgname-dev $pkgname-dbg libc6-compat:compat:noarch" +options="lib64" +subpackages=" + $pkgname-dbg + $pkgname-libintl:libintl:noarch + $pkgname-dev + libc6-compat:compat:noarch + " case "$BOOTSTRAP" in nocc) pkgname="musl-dev"; subpackages="";; nolibc) ;; *) subpackages="$subpackages $pkgname-utils";; esac -source="http://www.musl-libc.org/releases/musl-$pkgver.tar.gz - CVE-2019-14697.patch +_commit="v1.2.3" +source="musl-$_commit.tar.gz::https://git.musl-libc.org/cgit/musl/snapshot/$_commit.tar.gz handle-aux-at_base.patch ldconfig @@ -25,16 +31,16 @@ source="http://www.musl-libc.org/releases/musl-$pkgver.tar.gz " # secfixes: -# 1.1.22-r3: +# 1.2.2_pre2-r0: +# - CVE-2020-28928 +# 1.1.23-r2: # - CVE-2019-14697 # 1.1.15-r4: # - CVE-2016-8859 -builddir="$srcdir"/musl-$pkgver +builddir="$srcdir"/$_commit build() { - cd "$builddir" - [ "$BOOTSTRAP" = "nocc" ] && return 0 # provide minimal libssp_nonshared.a so we don't need libssp from gcc @@ -50,7 +56,7 @@ build() { fi # note: not autotools - LDFLAGS="$LDFLAGS -Wl,-soname,libc.musl-${CARCH}.so.1" \ + LDFLAGS="$LDFLAGS -Wl,-soname,libc.musl-$CARCH.so.1" \ ./configure \ --build=$CBUILD \ --host=$CHOST \ @@ -58,13 +64,13 @@ build() { --sysconfdir=/etc \ --mandir=/usr/share/man \ --infodir=/usr/share/info \ - --localstatedir=/var + --localstatedir=/var \ + --enable-debug \ + --disable-eh-frame make } package() { - cd "$builddir" - case "$CARCH" in aarch64*) ARCH="aarch64" ;; arm*) ARCH="arm" ;; @@ -75,6 +81,7 @@ package() { s390*) ARCH="s390x" ;; mips64*) ARCH="mips64" ;; mips*) ARCH="mips" ;; + riscv64) ARCH="riscv64" ;; esac if [ "$BOOTSTRAP" = "nocc" ]; then @@ -87,21 +94,17 @@ package() { # make LDSO the be the real file, and libc the symlink local LDSO=$(make -f Makefile --eval "$(echo -e 'print-ldso:\n\t@echo $$(basename $(LDSO_PATHNAME))')" print-ldso) mv -f "$pkgdir"/usr/lib/libc.so "$pkgdir"/lib/"$LDSO" - ln -sf "$LDSO" "$pkgdir"/lib/libc.musl-${CARCH}.so.1 + ln -sf "$LDSO" "$pkgdir"/lib/libc.musl-$CARCH.so.1 ln -sf ../../lib/"$LDSO" "$pkgdir"/usr/lib/libc.so mkdir -p "$pkgdir"/usr/bin cat >>"$pkgdir"/usr/bin/ldd <<-EOF #!/bin/sh - exec /lib/$LDSO --list -- "\$@" + exec /lib/$LDSO --list "\$@" EOF chmod 755 "$pkgdir"/usr/bin/ldd fi - # remove libintl.h, currently we don't want by default any NLS - # and use GNU gettext where needed. the plan is to migrate to - # musl gettext() later on as fully as possible. - rm "$pkgdir"/usr/include/libintl.h } utils() { @@ -121,6 +124,16 @@ utils() { install -D -m755 "$srcdir"/ldconfig "$subpkgdir"/sbin } +# currently we don't want by default any NLS +# and use GNU gettext where needed. the plan is to migrate to +# musl gettext() later on as fully as possible. +libintl() { + pkgdesc="musl libintl.h header" + mkdir -p "$subpkgdir"/usr/include + mv "$pkgdir"/usr/include/libintl.h \ + "$subpkgdir"/usr/include/ +} + compat() { pkgdesc="compatibility libraries for glibc" @@ -143,18 +156,19 @@ compat() { x86_64) _ld="lib64/ld-linux-x86-64.so.2";; esac mkdir -p "$subpkgdir/${_ld%/*}" - ln -sf "/lib/libc.musl-${CARCH}.so.1" "$subpkgdir/$_ld" + ln -sf "/lib/libc.musl-$CARCH.so.1" "$subpkgdir/$_ld" for i in libc.so.6 libcrypt.so.1 libm.so.6 libpthread.so.0 librt.so.1 libutil.so.1; do - ln -sf "/lib/libc.musl-${CARCH}.so.1" "$subpkgdir/lib/$i" + ln -sf "/lib/libc.musl-$CARCH.so.1" "$subpkgdir/lib/$i" done } -sha512sums="08a40d722672504427238e71c9e52a723c6a14735abe9581d6d4bb3f86662d5d51a3f32a6aed6420c1f9680e22a3a554a9b87ae342635be971e2db49cc9fdb87 musl-1.1.22.tar.gz -37ab61c96b940848e4114de105d87754c7039f52eb2fc19d8bf59c27f484bffbac8b4740e9478207eae03bd7416f7036e04197d0efe30ee5293b17d6d5c1cc15 CVE-2019-14697.patch -6a7ff16d95b5d1be77e0a0fbb245491817db192176496a57b22ab037637d97a185ea0b0d19da687da66c2a2f5578e4343d230f399d49fe377d8f008410974238 handle-aux-at_base.patch +sha512sums=" +9a1b8f9208d99582ac00e3c46c829aa1fad3b7f09aa7d6822f02f25542453d3d977c69519ad01430b8dd624ac9dc70f47d611e36aefd7fef31ea47a7679e3111 musl-v1.2.3.tar.gz +a76f79b801497ad994746cf82bb6eaf86f9e1ae646e6819fbae8532a7f4eee53a96ac1d4e789ec8f66aea2a68027b0597f7a579b3369e01258da8accfce41370 handle-aux-at_base.patch 8d3a2d5315fc56fee7da9abb8b89bb38c6046c33d154c10d168fb35bfde6b0cf9f13042a3bceee34daf091bc409d699223735dcf19f382eeee1f6be34154f26f ldconfig 062bb49fa54839010acd4af113e20f7263dde1c8a2ca359b5fb2661ef9ed9d84a0f7c3bc10c25dcfa10bb3c5a4874588dff636ac43d5dbb3d748d75400756d0b __stack_chk_fail_local.c 0d80f37b34a35e3d14b012257c50862dfeb9d2c81139ea2dfa101d981d093b009b9fa450ba27a708ac59377a48626971dfc58e20a3799084a65777a0c32cbc7d getconf.c -378d70e65bcc65bb4e1415354cecfa54b0c1146dfb24474b69e418cdbf7ad730472cd09f6f103e1c99ba6c324c9560bccdf287f5889bbc3ef0bdf0e08da47413 getent.c -9d42d66fb1facce2b85dad919be5be819ee290bd26ca2db00982b2f8e055a0196290a008711cbe2b18ec9eee8d2270e3b3a4692c5a1b807013baa5c2b70a2bbf iconv.c" +7f5b9d934d82deb5f8b23e16169a5d9b99ccab3a4708df06a95d685e1b24a3a3e69b3dcf4942f2f66c12a3d4bf0c5827e2ee2e8c4d7b1997359fccc2ac212dee getent.c +9d42d66fb1facce2b85dad919be5be819ee290bd26ca2db00982b2f8e055a0196290a008711cbe2b18ec9eee8d2270e3b3a4692c5a1b807013baa5c2b70a2bbf iconv.c +" diff --git a/cross-images/mini-aports/main/musl/CVE-2019-14697.patch b/cross-images/mini-aports/main/musl/CVE-2019-14697.patch deleted file mode 100644 index eae91a0..0000000 --- a/cross-images/mini-aports/main/musl/CVE-2019-14697.patch +++ /dev/null @@ -1,233 +0,0 @@ -From f3ed8bfe8a82af1870ddc8696ed4cc1d5aa6b441 Mon Sep 17 00:00:00 2001 -From: Rich Felker -Date: Mon, 5 Aug 2019 18:41:47 -0400 -Subject: fix x87 stack imbalance in corner cases of i386 math asm - -commit 31c5fb80b9eae86f801be4f46025bc6532a554c5 introduced underflow -code paths for the i386 math asm, along with checks on the fpu status -word to skip the underflow-generation instructions if the underflow -flag was already raised. unfortunately, at least one such path, in -log1p, returned with 2 items on the x87 stack rather than just 1 item -for the return value. this is a violation of the ABI's calling -convention, and could cause subsequent floating point code to produce -NANs due to x87 stack overflow. if floating point results are used in -flow control, this can lead to runaway wrong code execution. - -rather than reviewing each "underflow already raised" code path for -correctness, remove them all. they're likely slower than just -performing the underflow code unconditionally, and significantly more -complex. - -all of this code should be ripped out and replaced by C source files -with inline asm. doing so would preclude this kind of error by having -the compiler perform all x87 stack register allocation and stack -manipulation, and would produce comparable or better code. however -such a change is a much larger project. ---- - src/math/i386/asin.s | 10 ++-------- - src/math/i386/atan.s | 7 ++----- - src/math/i386/atan2.s | 5 +---- - src/math/i386/atan2f.s | 5 +---- - src/math/i386/atanf.s | 7 ++----- - src/math/i386/exp.s | 10 ++-------- - src/math/i386/log1p.s | 7 ++----- - src/math/i386/log1pf.s | 7 ++----- - 8 files changed, 14 insertions(+), 44 deletions(-) - -diff --git a/src/math/i386/asin.s b/src/math/i386/asin.s -index a9f691bf..920d967a 100644 ---- a/src/math/i386/asin.s -+++ b/src/math/i386/asin.s -@@ -7,13 +7,10 @@ asinf: - cmp $0x01000000,%eax - jae 1f - # subnormal x, return x with underflow -- fnstsw %ax -- and $16,%ax -- jnz 2f - fld %st(0) - fmul %st(1) - fstps 4(%esp) --2: ret -+ ret - - .global asinl - .type asinl,@function -@@ -30,11 +27,8 @@ asin: - cmp $0x00200000,%eax - jae 1f - # subnormal x, return x with underflow -- fnstsw %ax -- and $16,%ax -- jnz 2f - fsts 4(%esp) --2: ret -+ ret - 1: fld %st(0) - fld1 - fsub %st(0),%st(1) -diff --git a/src/math/i386/atan.s b/src/math/i386/atan.s -index d73137b2..a26feae1 100644 ---- a/src/math/i386/atan.s -+++ b/src/math/i386/atan.s -@@ -10,8 +10,5 @@ atan: - fpatan - ret - # subnormal x, return x with underflow --1: fnstsw %ax -- and $16,%ax -- jnz 2f -- fsts 4(%esp) --2: ret -+1: fsts 4(%esp) -+ ret -diff --git a/src/math/i386/atan2.s b/src/math/i386/atan2.s -index a7d2979b..1fa0524d 100644 ---- a/src/math/i386/atan2.s -+++ b/src/math/i386/atan2.s -@@ -10,8 +10,5 @@ atan2: - cmp $0x00200000,%eax - jae 1f - # subnormal x, return x with underflow -- fnstsw %ax -- and $16,%ax -- jnz 1f - fsts 4(%esp) --1: ret -+ ret -diff --git a/src/math/i386/atan2f.s b/src/math/i386/atan2f.s -index 14b88ce5..0b264726 100644 ---- a/src/math/i386/atan2f.s -+++ b/src/math/i386/atan2f.s -@@ -10,10 +10,7 @@ atan2f: - cmp $0x01000000,%eax - jae 1f - # subnormal x, return x with underflow -- fnstsw %ax -- and $16,%ax -- jnz 1f - fld %st(0) - fmul %st(1) - fstps 4(%esp) --1: ret -+ ret -diff --git a/src/math/i386/atanf.s b/src/math/i386/atanf.s -index 8caddefa..893beac5 100644 ---- a/src/math/i386/atanf.s -+++ b/src/math/i386/atanf.s -@@ -10,10 +10,7 @@ atanf: - fpatan - ret - # subnormal x, return x with underflow --1: fnstsw %ax -- and $16,%ax -- jnz 2f -- fld %st(0) -+1: fld %st(0) - fmul %st(1) - fstps 4(%esp) --2: ret -+ ret -diff --git a/src/math/i386/exp.s b/src/math/i386/exp.s -index c7aa5b6e..df87c497 100644 ---- a/src/math/i386/exp.s -+++ b/src/math/i386/exp.s -@@ -7,13 +7,10 @@ expm1f: - cmp $0x01000000,%eax - jae 1f - # subnormal x, return x with underflow -- fnstsw %ax -- and $16,%ax -- jnz 2f - fld %st(0) - fmul %st(1) - fstps 4(%esp) --2: ret -+ ret - - .global expm1l - .type expm1l,@function -@@ -30,11 +27,8 @@ expm1: - cmp $0x00200000,%eax - jae 1f - # subnormal x, return x with underflow -- fnstsw %ax -- and $16,%ax -- jnz 2f - fsts 4(%esp) --2: ret -+ ret - 1: fldl2e - fmulp - mov $0xc2820000,%eax -diff --git a/src/math/i386/log1p.s b/src/math/i386/log1p.s -index 6b6929c7..354f391a 100644 ---- a/src/math/i386/log1p.s -+++ b/src/math/i386/log1p.s -@@ -16,9 +16,6 @@ log1p: - fyl2x - ret - # subnormal x, return x with underflow --2: fnstsw %ax -- and $16,%ax -- jnz 1f -- fsts 4(%esp) -+2: fsts 4(%esp) - fstp %st(1) --1: ret -+ ret -diff --git a/src/math/i386/log1pf.s b/src/math/i386/log1pf.s -index c0bcd30f..4d3484cd 100644 ---- a/src/math/i386/log1pf.s -+++ b/src/math/i386/log1pf.s -@@ -16,10 +16,7 @@ log1pf: - fyl2x - ret - # subnormal x, return x with underflow --2: fnstsw %ax -- and $16,%ax -- jnz 1f -- fxch -+2: fxch - fmul %st(1) - fstps 4(%esp) --1: ret -+ ret --- -cgit v1.2.1 - -From 6818c31c9bc4bbad5357f1de14bedf781e5b349e Mon Sep 17 00:00:00 2001 -From: Rich Felker -Date: Mon, 5 Aug 2019 19:57:07 -0400 -Subject: fix build regression in i386 asm for atan2, atan2f - -commit f3ed8bfe8a82af1870ddc8696ed4cc1d5aa6b441 inadvertently removed -labels that were still needed. ---- - src/math/i386/atan2.s | 2 +- - src/math/i386/atan2f.s | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/math/i386/atan2.s b/src/math/i386/atan2.s -index 1fa0524d..76b95f31 100644 ---- a/src/math/i386/atan2.s -+++ b/src/math/i386/atan2.s -@@ -11,4 +11,4 @@ atan2: - jae 1f - # subnormal x, return x with underflow - fsts 4(%esp) -- ret -+1: ret -diff --git a/src/math/i386/atan2f.s b/src/math/i386/atan2f.s -index 0b264726..c9408a90 100644 ---- a/src/math/i386/atan2f.s -+++ b/src/math/i386/atan2f.s -@@ -13,4 +13,4 @@ atan2f: - fld %st(0) - fmul %st(1) - fstps 4(%esp) -- ret -+1: ret --- -cgit v1.2.1 - diff --git a/cross-images/mini-aports/main/musl/getent.c b/cross-images/mini-aports/main/musl/getent.c index b10d75a..4a6aa6f 100644 --- a/cross-images/mini-aports/main/musl/getent.c +++ b/cross-images/mini-aports/main/musl/getent.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -428,6 +429,29 @@ static int services(int argc, char *argv[]) return rv; } +static int shadow(int argc, char *argv[]) +{ + struct spwd *sp; + int i, rv; + + rv = RV_OK; + if (argc == 2) { + while ((sp = getspent()) != NULL) + putspent(sp, stdout); + } else { + for (i = 2; i < argc; i++) { + sp = getspnam(argv[i]); + if (sp == NULL) { + rv = RV_NOTFOUND; + break; + } + putspent(sp, stdout); + } + } + endspent(); + return rv; +} + static int shells(int argc, char *argv[]) { const char *sh; @@ -471,6 +495,7 @@ static struct getentdb { { "passwd", passwd, }, { "protocols", protocols, }, { "services", services, }, + { "shadow", shadow, }, { "shells", shells, }, { NULL, NULL, }, diff --git a/cross-images/mini-aports/main/musl/handle-aux-at_base.patch b/cross-images/mini-aports/main/musl/handle-aux-at_base.patch index c164638..7c9f2dc 100644 --- a/cross-images/mini-aports/main/musl/handle-aux-at_base.patch +++ b/cross-images/mini-aports/main/musl/handle-aux-at_base.patch @@ -1,3 +1,6 @@ +This is required to make the gcompat ELF interpreter stub work with some +packed binaries. + diff --git a/src/env/__init_tls.c b/src/env/__init_tls.c index b125eb1..616c6a6 100644 --- a/src/env/__init_tls.c diff --git a/cross-images/mini-aports/scripts/bootstrap.sh b/cross-images/mini-aports/scripts/bootstrap.sh index 5933e90..b98165d 100755 --- a/cross-images/mini-aports/scripts/bootstrap.sh +++ b/cross-images/mini-aports/scripts/bootstrap.sh @@ -5,12 +5,16 @@ set -e TARGET_ARCH="$1" SUDO_APK=abuild-apk +# optional cross build packages +: ${KERNEL_PKG=linux-firmware linux-lts} + # get abuild configurables [ -e /usr/share/abuild/functions.sh ] || (echo "abuild not found" ; exit 1) CBUILDROOT="$(CTARGET=$TARGET_ARCH . /usr/share/abuild/functions.sh ; echo $CBUILDROOT)" . /usr/share/abuild/functions.sh [ -z "$CBUILD_ARCH" ] && die "abuild is too old (use 2.29.0 or later)" [ -z "$CBUILDROOT" ] && die "CBUILDROOT not set for $TARGET_ARCH" +export CBUILD # deduce aports directory [ -z "$APORTS" ] && APORTS=$(realpath $(dirname $0)/../) @@ -43,12 +47,16 @@ Steps for introducing new architecture include: - adding the arch type detection to apk-tools - adjusting build rules for packages that are arch aware: gcc, openssl, linux-headers -- create new kernel config for linux-vanilla +- create new kernel config for linux-lts After these steps the initial cross-build can be completed by running this with the target arch as parameter, e.g.: ./$program aarch64 +The cross-compiler generated by this script is not intended +nor supported for any use other than building the base system +and other packages in the bootstrap path. + EOF return 1 fi @@ -56,7 +64,12 @@ fi if [ ! -d "$CBUILDROOT" ]; then msg "Creating sysroot in $CBUILDROOT" mkdir -p "$CBUILDROOT/etc/apk/keys" - cp /etc/apk/keys/* "$CBUILDROOT/etc/apk/keys" + # /etc/apk/keys and ~/.abuild/ can contain files with the same names. + # if that is the case, cp will abort copying and fail. Then on the next + # run of the bootstrap script, 1) the keys are not in the sysroot and + # 2) the apk database is not initialized the sysroot + # Thus it's unusable at that point and needs to be deleted manually. + cp -a /etc/apk/keys/* "$CBUILDROOT/etc/apk/keys" ${SUDO_APK} add --quiet --initdb --arch $TARGET_ARCH --root $CBUILDROOT fi @@ -87,25 +100,41 @@ CTARGET=$TARGET_ARCH BOOTSTRAP=nobase APKBUILD=$(apkbuildname build-base) abuild msg "Cross building base system" -# add implicit target prerequisite packages -apk info --quiet --installed --root "$CBUILDROOT" libgcc libstdc++ musl-dev || \ - ${SUDO_APK} --root "$CBUILDROOT" add --repository "$REPODEST/main" libgcc libstdc++ musl-dev +# Implicit dependencies for early targets +EXTRADEPENDS_TARGET="libgcc libstdc++ musl-dev" + +# On a few architectures like riscv64 we need to account for +# gcc requiring -ltomic to be set explicitly if a C[++]11 program +# uses atomics (e.g. #include ): +# https://github.com/riscv/riscv-gnu-toolchain/issues/183#issuecomment-253721765 +# The reason gcc itself is needed is because .so is in that package, +# not in libatomic. +if [ "$TARGET_ARCH" = "riscv64" ]; then + NEEDS_LIBATOMIC="yes" +fi # ordered cross-build -for PKG in fortify-headers linux-headers musl libc-dev ; do +for PKG in fortify-headers linux-headers musl libc-dev ; do + if [ "$NEEDS_LIBATOMIC" = "yes" ]; then + EXTRADEPENDS_BUILD="libatomic gcc-$TARGET_ARCH g++-$TARGET_ARCH" + fi + EXTRADEPENDS_TARGET="$EXTRADEPENDS_TARGET" EXTRADEPENDS_BUILD="$EXTRADEPENDS_BUILD" \ CHOST=$TARGET_ARCH BOOTSTRAP=bootimage APKBUILD=$(apkbuildname $PKG) abuild -r case "$PKG" in - fortify-headers | libc-dev | build-base) - # headers packages which are implicit but mandatory dependency - apk info --quiet --installed --root "$CBUILDROOT" $PKG || \ - ${SUDO_APK} --update --root "$CBUILDROOT" --repository "$REPODEST/main" add $PKG + fortify-headers | libc-dev) + # Additional implicit dependencies once built + EXTRADEPENDS_TARGET="$EXTRADEPENDS_TARGET $PKG" + ;; + gcc) + if [ "$NEEDS_LIBATOMIC" = "yes" ]; then + EXTRADEPENDS_TARGET="libatomic gcc $EXTRADEPENDS_TARGET" + fi ;; - musl | gcc) - # target libraries rebuilt, force upgrade - [ "$(apk upgrade --root "$CBUILDROOT" --repository "$REPODEST/main" --available --simulate | wc -l)" -gt 1 ] && - ${SUDO_APK} upgrade --root "$CBUILDROOT" --repository "$REPODEST/main" --available + build-base) + # After build-base, that alone is sufficient dependency in the target + EXTRADEPENDS_TARGET="busybox $PKG" ;; esac done