diff --git a/aports/cross/binutils-x86_64/APKBUILD b/aports/cross/binutils-x86_64/APKBUILD new file mode 100644 index 00000000..2f57037b --- /dev/null +++ b/aports/cross/binutils-x86_64/APKBUILD @@ -0,0 +1,69 @@ +# Automatically generated aport, do not edit! +# Generator: pmbootstrap aportgen binutils-x86_64 +# Based on: main/binutils + + +pkgname="binutils-x86_64" +pkgver=2.28 +pkgrel=3 +pkgdesc="Tools necessary to build programs for x86_64 targets" +url="https://www.gnu.org/software/binutils/" +depends="" +makedepends_build="" +makedepends_host="" +makedepends="gettext libtool autoconf automake bison" +arch="all" +license="GPL-2.0 GPL-3.0-or-later LGPL-2.0 BSD" +subpackages="" +source="http://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.bz2 + binutils-ld-fix-static-linking.patch + hash-style-configure-flag.patch + CVE-2017-7614.patch + gold-mips.patch + " +builddir="$srcdir/binutils-$pkgver" + +if [ "$CHOST" != "$CTARGET" ]; then + pkgname="binutils-$CTARGET_ARCH" + subpackages="" + sonameprefix="binutils:" +fi + +# secfixes: +# 2.28-r1: +# - CVE-2017-7614 + +build() { + _target="$(arch_to_hostspec x86_64)" + cd "$builddir" + "$builddir"/configure \ + --build="$CBUILD" \ + --target=$_target \ + --with-lib-path=/usr/lib \ + --prefix=/usr \ + --with-sysroot=/usr/$_target \ + --enable-ld=default \ + --enable-gold=yes \ + --enable-plugins \ + --enable-deterministic-archives \ + --disable-multilib \ + --disable-werror \ + --disable-nls + make +} + +package() { + cd "$builddir" + make install DESTDIR="$pkgdir" + + # remove man, info folders + rm -rf "$pkgdir"/usr/share +} + + + +sha512sums="ede2e4e59a800260eea8c14eafbaee94e30abadafd5c419a3370f9f62213cf027d6400a1d4970b6958bd4d220e675dcd483a708107016e7abd5c99d7392ba8fd binutils-2.28.tar.bz2 +ecee33b0e435aa704af1c334e560f201638ff79e199aa11ed78a72f7c9b46f85fbb227af5748e735fd681d1965fcc42ac81b0c8824e540430ce0c706c81e8b49 binutils-ld-fix-static-linking.patch +404a483adc8bf8112d953c53a853d21588745752687ee3ca57def539201b9e87844b23ba3c666d7c9648911cdeb55144382c3726ae3845e12b232c3f001c1bfe hash-style-configure-flag.patch +03e2329a216eaaaebc00a2b487a8ffa57657845ea3428f24a1029eabaca2103cb00f39cb4824fe6b70ce9c124e0f850c893746fcf203a6a69288d19df624c60a CVE-2017-7614.patch +f55cf2e0bf82f97583a1abe10710e4013ecf7d64f1da2ef8659a44a06d0dd8beaf58dab98a183488ea137f03e32d62efc878d95f018f836f8cec870bc448556f gold-mips.patch" diff --git a/aports/cross/binutils-x86_64/CVE-2017-7614.patch b/aports/cross/binutils-x86_64/CVE-2017-7614.patch new file mode 100644 index 00000000..5f3b550f --- /dev/null +++ b/aports/cross/binutils-x86_64/CVE-2017-7614.patch @@ -0,0 +1,84 @@ +From ad32986fdf9da1c8748e47b8b45100398223dba8 Mon Sep 17 00:00:00 2001 +From: Nick Clifton +Date: Tue, 4 Apr 2017 11:23:36 +0100 +Subject: [PATCH] Fix null pointer dereferences when using a link built with + clang. + + PR binutils/21342 + * elflink.c (_bfd_elf_define_linkage_sym): Prevent null pointer + dereference. + (bfd_elf_final_link): Only initialize the extended symbol index + section if there are extended symbol tables to list. +--- + bfd/elflink.c | 35 +++++++++++++++++++++-------------- + 2 files changed, 29 insertions(+), 14 deletions(-) + +diff --git a/bfd/elflink.c b/bfd/elflink.c +index 776357f..9bf75c8 100644 +--- a/bfd/elflink.c ++++ b/bfd/elflink.c +@@ -119,15 +119,18 @@ _bfd_elf_define_linkage_sym (bfd *abfd, + defined in shared libraries can't be overridden, because we + lose the link to the bfd which is via the symbol section. */ + h->root.type = bfd_link_hash_new; ++ bh = &h->root; + } ++ else ++ bh = NULL; + +- bh = &h->root; + bed = get_elf_backend_data (abfd); + if (!_bfd_generic_link_add_one_symbol (info, abfd, name, BSF_GLOBAL, + sec, 0, NULL, FALSE, bed->collect, + &bh)) + return NULL; + h = (struct elf_link_hash_entry *) bh; ++ BFD_ASSERT (h != NULL); + h->def_regular = 1; + h->non_elf = 0; + h->root.linker_def = 1; +@@ -12038,24 +12041,28 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) + { + /* Finish up and write out the symbol string table (.strtab) + section. */ +- Elf_Internal_Shdr *symstrtab_hdr; ++ Elf_Internal_Shdr *symstrtab_hdr = NULL; + file_ptr off = symtab_hdr->sh_offset + symtab_hdr->sh_size; + +- symtab_shndx_hdr = & elf_symtab_shndx_list (abfd)->hdr; +- if (symtab_shndx_hdr != NULL && symtab_shndx_hdr->sh_name != 0) ++ if (elf_symtab_shndx_list (abfd)) + { +- symtab_shndx_hdr->sh_type = SHT_SYMTAB_SHNDX; +- symtab_shndx_hdr->sh_entsize = sizeof (Elf_External_Sym_Shndx); +- symtab_shndx_hdr->sh_addralign = sizeof (Elf_External_Sym_Shndx); +- amt = bfd_get_symcount (abfd) * sizeof (Elf_External_Sym_Shndx); +- symtab_shndx_hdr->sh_size = amt; ++ symtab_shndx_hdr = & elf_symtab_shndx_list (abfd)->hdr; + +- off = _bfd_elf_assign_file_position_for_section (symtab_shndx_hdr, +- off, TRUE); ++ if (symtab_shndx_hdr != NULL && symtab_shndx_hdr->sh_name != 0) ++ { ++ symtab_shndx_hdr->sh_type = SHT_SYMTAB_SHNDX; ++ symtab_shndx_hdr->sh_entsize = sizeof (Elf_External_Sym_Shndx); ++ symtab_shndx_hdr->sh_addralign = sizeof (Elf_External_Sym_Shndx); ++ amt = bfd_get_symcount (abfd) * sizeof (Elf_External_Sym_Shndx); ++ symtab_shndx_hdr->sh_size = amt; + +- if (bfd_seek (abfd, symtab_shndx_hdr->sh_offset, SEEK_SET) != 0 +- || (bfd_bwrite (flinfo.symshndxbuf, amt, abfd) != amt)) +- return FALSE; ++ off = _bfd_elf_assign_file_position_for_section (symtab_shndx_hdr, ++ off, TRUE); ++ ++ if (bfd_seek (abfd, symtab_shndx_hdr->sh_offset, SEEK_SET) != 0 ++ || (bfd_bwrite (flinfo.symshndxbuf, amt, abfd) != amt)) ++ return FALSE; ++ } + } + + symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr; +-- +2.9.3 + diff --git a/aports/cross/binutils-x86_64/binutils-ld-fix-static-linking.patch b/aports/cross/binutils-x86_64/binutils-ld-fix-static-linking.patch new file mode 100644 index 00000000..bc5d7626 --- /dev/null +++ b/aports/cross/binutils-x86_64/binutils-ld-fix-static-linking.patch @@ -0,0 +1,46 @@ +This fixes static linking for our hardened toolchain +diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc +index e8126cb..9532bfb 100644 +--- a/ld/scripttempl/elf.sc ++++ b/ld/scripttempl/elf.sc +@@ -235,8 +235,8 @@ test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS=" + if test "${ENABLE_INITFINI_ARRAY}" = "yes"; then + SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))" + SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))" +- CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors" +- DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors" ++ CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin*.o *crtend*.o $OTHER_EXCLUDE_FILES) .ctors" ++ DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin*.o *crtend*.o $OTHER_EXCLUDE_FILES) .dtors" + else + SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))" + SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))" +@@ -270,15 +270,14 @@ CTOR=".ctors ${CONSTRUCTING-0} : + doesn't matter which directory crtbegin.o + is in. */ + +- KEEP (*crtbegin.o(.ctors)) +- KEEP (*crtbegin?.o(.ctors)) ++ KEEP (*crtbegin*.o(.ctors)) + + /* We don't want to include the .ctor section from + the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + +- KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors)) ++ KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + ${CONSTRUCTING+${CTOR_END}} +@@ -286,9 +285,8 @@ CTOR=".ctors ${CONSTRUCTING-0} : + DTOR=".dtors ${CONSTRUCTING-0} : + { + ${CONSTRUCTING+${DTOR_START}} +- KEEP (*crtbegin.o(.dtors)) +- KEEP (*crtbegin?.o(.dtors)) +- KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors)) ++ KEEP (*crtbegin*.o(.dtors)) ++ KEEP (*(EXCLUDE_FILE (*crtend*.o $OTHER_EXCLUDE_FILES) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ${CONSTRUCTING+${DTOR_END}} diff --git a/aports/cross/binutils-x86_64/gold-mips.patch b/aports/cross/binutils-x86_64/gold-mips.patch new file mode 100644 index 00000000..291a2aae --- /dev/null +++ b/aports/cross/binutils-x86_64/gold-mips.patch @@ -0,0 +1,39 @@ +# DP: Fix gold on mips64 targets. + +gold/ + +2016-08-09 Aurelien Jarno + + * configure.tgt: Add mips64el*-*-*|mips64le*-*-* and mips64*-*-*. + + +--- a/gold/configure.tgt ++++ b/gold/configure.tgt +@@ -153,6 +153,13 @@ aarch64*-*) + targ_big_endian=false + targ_extra_big_endian=true + ;; ++mips*64*el*-*-*|mips*64*le*-*-*) ++ targ_obj=mips ++ targ_machine=EM_MIPS_RS3_LE ++ targ_size=64 ++ targ_big_endian=false ++ targ_extra_big_endian=true ++ ;; + mips*el*-*-*|mips*le*-*-*) + targ_obj=mips + targ_machine=EM_MIPS_RS3_LE +@@ -160,6 +167,13 @@ mips*el*-*-*|mips*le*-*-*) + targ_big_endian=false + targ_extra_big_endian=true + ;; ++mips*64*-*-*) ++ targ_obj=mips ++ targ_machine=EM_MIPS ++ targ_size=64 ++ targ_big_endian=true ++ targ_extra_big_endian=false ++ ;; + mips*-*-*) + targ_obj=mips + targ_machine=EM_MIPS diff --git a/aports/cross/binutils-x86_64/hash-style-configure-flag.patch b/aports/cross/binutils-x86_64/hash-style-configure-flag.patch new file mode 100644 index 00000000..6d4db4bc --- /dev/null +++ b/aports/cross/binutils-x86_64/hash-style-configure-flag.patch @@ -0,0 +1,348 @@ +From 2760f24c4942853eac7b921e4b8843d57a602654 Mon Sep 17 00:00:00 2001 +From: Romain Geissler +Date: Tue, 8 Aug 2017 07:25:39 +0930 +Subject: [PATCH] Add configure flag to enable gnu hash style by default. + +ld/ + * configure.ac: Add --enable-default-hash-style option. + * ldmain.c (main): Set link_info.emit_hash to DEFAULT_EMIT_SYSV_HASH. + Set link_info.emit_gnu_hash to DEFAULT_EMIT_GNU_HASH. + * configure: Regenerate. + * config.in: Regenerate. + +gold/ + * configure.ac: Add --enable-default-hash-style option. + * options.h (hash_style): Use DEFAULT_HASH_STYLE as default value. + * configure: Regenerate. + * config.in: Regenerate. +--- + gold/ChangeLog | 8 ++++++++ + gold/config.in | 3 +++ + gold/configure | 27 +++++++++++++++++++++++++++ + gold/configure.ac | 20 ++++++++++++++++++++ + gold/options.h | 2 +- + ld/ChangeLog | 9 +++++++++ + ld/config.in | 6 ++++++ + ld/configure | 42 ++++++++++++++++++++++++++++++++++++++---- + ld/configure.ac | 34 ++++++++++++++++++++++++++++++++++ + ld/ldmain.c | 3 ++- + 10 files changed, 148 insertions(+), 6 deletions(-) + +diff --git a/gold/ChangeLog b/gold/ChangeLog +index d598386..93836dd 100644 +--- a/gold/ChangeLog ++++ b/gold/ChangeLog +@@ -1,3 +1,11 @@ ++2017-08-08 Romain Geissler ++ Alan Modra ++ ++ * configure.ac: Add --enable-default-hash-style option. ++ * options.h (hash_style): Use DEFAULT_HASH_STYLE as default value. ++ * configure: Regenerate. ++ * config.in: Regenerate. ++ + 2017-02-22 Alan Modra + + * powerpc.cc (Target_powerpc::make_iplt_section): Check that +diff --git a/gold/config.in b/gold/config.in +index d9f7b76..5855fca 100644 +--- a/gold/config.in ++++ b/gold/config.in +@@ -10,6 +10,9 @@ + /* Define if building universal (internal helper macro) */ + #undef AC_APPLE_UNIVERSAL_BUILD + ++/* Set the default --hash-style value */ ++#undef DEFAULT_HASH_STYLE ++ + /* Define to 1 if you want to enable -z relro in ELF linker by default. */ + #undef DEFAULT_LD_Z_RELRO + +diff --git a/gold/configure b/gold/configure +index cb020be..90a706d 100755 +--- a/gold/configure ++++ b/gold/configure +@@ -797,6 +797,7 @@ enable_threads + enable_plugins + enable_relro + enable_targets ++enable_default_hash_style + with_lib_path + enable_dependency_tracking + enable_nls +@@ -1447,6 +1448,8 @@ Optional Features: + --enable-plugins linker plugins + --enable-relro enable -z relro in ELF linker by default + --enable-targets alternative target configurations ++ --enable-default-hash-style={sysv,gnu,both} ++ use this default hash style + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors + --disable-nls do not use Native Language Support +@@ -3410,6 +3413,30 @@ if test -n "$enable_targets"; then + done + fi + ++# Decide which "--hash-style" to use by default ++# Provide a configure time option to override our default. ++# Check whether --enable-default-hash-style was given. ++if test "${enable_default_hash_style+set}" = set; then : ++ enableval=$enable_default_hash_style; case "${enable_default_hash_style}" in ++ sysv | gnu | both) ;; ++ *) as_fn_error "bad value ${enable_default_hash_style} for enable-default-hash-style option" "$LINENO" 5 ;; ++esac ++else ++ case "${target}" in ++ # Enable gnu hash only on GNU targets, but not mips ++ mips*-*-*) enable_default_hash_style=sysv ;; ++ *-*-gnu* | *-*-linux* | *-*-nacl*) enable_default_hash_style=both ;; ++ *) enable_default_hash_style=sysv ;; ++esac ++fi ++ ++ ++ ++cat >>confdefs.h <<_ACEOF ++#define DEFAULT_HASH_STYLE "${enable_default_hash_style}" ++_ACEOF ++ ++ + # See which specific instantiations we need. + targetobjs= + all_targets= +diff --git a/gold/configure.ac b/gold/configure.ac +index cbe3380..d7fa1f8 100644 +--- a/gold/configure.ac ++++ b/gold/configure.ac +@@ -161,6 +161,26 @@ if test -n "$enable_targets"; then + done + fi + ++# Decide which "--hash-style" to use by default ++# Provide a configure time option to override our default. ++AC_ARG_ENABLE([default-hash-style], ++AS_HELP_STRING([--enable-default-hash-style={sysv,gnu,both}], ++ [use this default hash style]), ++[case "${enable_default_hash_style}" in ++ sysv | gnu | both) ;; ++ *) AC_MSG_ERROR([bad value ${enable_default_hash_style} for enable-default-hash-style option]) ;; ++esac], ++[case "${target}" in ++ # Enable gnu hash only on GNU targets, but not mips ++ mips*-*-*) enable_default_hash_style=sysv ;; ++ *-*-gnu* | *-*-linux* | *-*-nacl*) enable_default_hash_style=both ;; ++ *) enable_default_hash_style=sysv ;; ++esac]) ++ ++AC_DEFINE_UNQUOTED([DEFAULT_HASH_STYLE], ++ ["${enable_default_hash_style}"], ++ [Set the default --hash-style value]) ++ + # See which specific instantiations we need. + targetobjs= + all_targets= +diff --git a/gold/options.h b/gold/options.h +index a8b1d46..ce21a42 100644 +--- a/gold/options.h ++++ b/gold/options.h +@@ -921,7 +921,7 @@ class General_options + N_("Min fraction of empty buckets in dynamic hash"), + N_("FRACTION")); + +- DEFINE_enum(hash_style, options::TWO_DASHES, '\0', "sysv", ++ DEFINE_enum(hash_style, options::TWO_DASHES, '\0', DEFAULT_HASH_STYLE, + N_("Dynamic hash style"), N_("[sysv,gnu,both]"), + {"sysv", "gnu", "both"}); + +diff --git a/ld/ChangeLog b/ld/ChangeLog +index ba7d1d4..cf91d55 100644 +--- a/ld/ChangeLog ++++ b/ld/ChangeLog +@@ -1,3 +1,12 @@ ++2017-08-08 Romain Geissler ++ Alan Modra ++ ++ * configure.ac: Add --enable-default-hash-style option. ++ * ldmain.c (main): Set link_info.emit_hash to DEFAULT_EMIT_SYSV_HASH. ++ Set link_info.emit_gnu_hash to DEFAULT_EMIT_GNU_HASH. ++ * configure: Regenerate. ++ * config.in: Regenerate. ++ + 2017-03-02 Tristan Gingold + + * configure: Regenerate. +diff --git a/ld/config.in b/ld/config.in +index 2c6d698..b2318e1 100644 +--- a/ld/config.in ++++ b/ld/config.in +@@ -7,6 +7,12 @@ + #endif + #define __CONFIG_H__ 1 + ++/* Define to 1 if you want to emit gnu hash in the ELF linker by default. */ ++#undef DEFAULT_EMIT_GNU_HASH ++ ++/* Define to 1 if you want to emit sysv hash in the ELF linker by default. */ ++#undef DEFAULT_EMIT_SYSV_HASH ++ + /* Define if you want compressed debug sections by default. */ + #undef DEFAULT_FLAG_COMPRESS_DEBUG + +diff --git a/ld/configure b/ld/configure +index 36af969..40c67fd 100755 +--- a/ld/configure ++++ b/ld/configure +@@ -793,6 +793,7 @@ enable_gold + enable_got + enable_compressed_debug_sections + enable_relro ++enable_default_hash_style + enable_werror + enable_build_warnings + enable_nls +@@ -1452,6 +1453,8 @@ Optional Features: + --enable-compressed-debug-sections={all,ld,none} + compress debug sections by default] + --enable-relro enable -z relro in ELF linker by default ++ --enable-default-hash-style={sysv,gnu,both} ++ use this default hash style + --enable-werror treat compile warnings as errors + --enable-build-warnings enable build-time compiler warnings + --disable-nls do not use Native Language Support +@@ -11724,7 +11727,7 @@ else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +-#line 11727 "configure" ++#line 11730 "configure" + #include "confdefs.h" + + #if HAVE_DLFCN_H +@@ -11830,7 +11833,7 @@ else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +-#line 11833 "configure" ++#line 11836 "configure" + #include "confdefs.h" + + #if HAVE_DLFCN_H +@@ -15555,6 +15558,33 @@ if test "${enable_relro+set}" = set; then : + esac + fi + ++# Decide which "--hash-style" to use by default ++# Provide a configure time option to override our default. ++# Check whether --enable-default-hash-style was given. ++if test "${enable_default_hash_style+set}" = set; then : ++ enableval=$enable_default_hash_style; case "${enable_default_hash_style}" in ++ sysv | gnu | both) ;; ++ *) as_fn_error "bad value ${enable_default_hash_style} for enable-default-hash-style option" "$LINENO" 5 ;; ++esac ++else ++ case "${target}" in ++ # Enable gnu hash only on GNU targets, but not mips ++ mips*-*-*) enable_default_hash_style=sysv ;; ++ *-*-gnu* | *-*-linux* | *-*-nacl*) enable_default_hash_style=both ;; ++ *) enable_default_hash_style=sysv ;; ++esac ++fi ++ ++ ++case "${enable_default_hash_style}" in ++ sysv | both) ac_default_emit_sysv_hash=1 ;; ++ *) ac_default_emit_sysv_hash=0 ;; ++esac ++ ++case "${enable_default_hash_style}" in ++ gnu | both) ac_default_emit_gnu_hash=1 ;; ++ *) ac_default_emit_gnu_hash=0 ;; ++esac + + # Set the 'development' global. + . $srcdir/../bfd/development.sh +@@ -17212,9 +17242,13 @@ cat >>confdefs.h <<_ACEOF + #define DEFAULT_LD_Z_RELRO $ac_default_ld_z_relro + _ACEOF + ++cat >>confdefs.h <<_ACEOF ++#define DEFAULT_EMIT_SYSV_HASH $ac_default_emit_sysv_hash ++_ACEOF + +- +- ++cat >>confdefs.h <<_ACEOF ++#define DEFAULT_EMIT_GNU_HASH $ac_default_emit_gnu_hash ++_ACEOF + + + +diff --git a/ld/configure.ac b/ld/configure.ac +index 36a9f50..1876ad7 100644 +--- a/ld/configure.ac ++++ b/ld/configure.ac +@@ -166,6 +166,32 @@ AC_ARG_ENABLE(relro, + no) ac_default_ld_z_relro=0 ;; + esac])dnl + ++# Decide which "--hash-style" to use by default ++# Provide a configure time option to override our default. ++AC_ARG_ENABLE([default-hash-style], ++AS_HELP_STRING([--enable-default-hash-style={sysv,gnu,both}], ++ [use this default hash style]), ++[case "${enable_default_hash_style}" in ++ sysv | gnu | both) ;; ++ *) AC_MSG_ERROR([bad value ${enable_default_hash_style} for enable-default-hash-style option]) ;; ++esac], ++[case "${target}" in ++ # Enable gnu hash only on GNU targets, but not mips ++ mips*-*-*) enable_default_hash_style=sysv ;; ++ *-*-gnu* | *-*-linux* | *-*-nacl*) enable_default_hash_style=both ;; ++ *) enable_default_hash_style=sysv ;; ++esac]) ++ ++case "${enable_default_hash_style}" in ++ sysv | both) ac_default_emit_sysv_hash=1 ;; ++ *) ac_default_emit_sysv_hash=0 ;; ++esac ++ ++case "${enable_default_hash_style}" in ++ gnu | both) ac_default_emit_gnu_hash=1 ;; ++ *) ac_default_emit_gnu_hash=0 ;; ++esac ++ + AM_BINUTILS_WARNINGS + + AM_LC_MESSAGES +@@ -394,6 +420,14 @@ AC_DEFINE_UNQUOTED(DEFAULT_LD_Z_RELRO, + $ac_default_ld_z_relro, + [Define to 1 if you want to enable -z relro in ELF linker by default.]) + ++AC_DEFINE_UNQUOTED([DEFAULT_EMIT_SYSV_HASH], ++ [$ac_default_emit_sysv_hash], ++ [Define to 1 if you want to emit sysv hash in the ELF linker by default.]) ++ ++AC_DEFINE_UNQUOTED([DEFAULT_EMIT_GNU_HASH], ++ [$ac_default_emit_gnu_hash], ++ [Define to 1 if you want to emit gnu hash in the ELF linker by default.]) ++ + AC_SUBST(elf_list_options) + AC_SUBST(elf_shlib_list_options) + AC_SUBST(elf_plt_unwind_list_options) +diff --git a/ld/ldmain.c b/ld/ldmain.c +index 1e48b1a..579d961 100644 +--- a/ld/ldmain.c ++++ b/ld/ldmain.c +@@ -282,7 +282,8 @@ main (int argc, char **argv) + link_info.keep_memory = TRUE; + link_info.combreloc = TRUE; + link_info.strip_discarded = TRUE; +- link_info.emit_hash = TRUE; ++ link_info.emit_hash = DEFAULT_EMIT_SYSV_HASH; ++ link_info.emit_gnu_hash = DEFAULT_EMIT_GNU_HASH; + link_info.callbacks = &link_callbacks; + link_info.input_bfds_tail = &link_info.input_bfds; + /* SVR4 linkers seem to set DT_INIT and DT_FINI based on magic _init +-- +2.14.2 + diff --git a/aports/cross/gcc-x86_64/001_all_default-ssp-strong.patch b/aports/cross/gcc-x86_64/001_all_default-ssp-strong.patch new file mode 100644 index 00000000..95949eb0 --- /dev/null +++ b/aports/cross/gcc-x86_64/001_all_default-ssp-strong.patch @@ -0,0 +1,215 @@ +# DP: Turn on -fstack-protector by default for C, C++, ObjC, ObjC++. +# DP: Build libgcc using -fno-stack-protector. + +--- + gcc/Makefile.in | 2 ++ + gcc/cp/lang-specs.h | 6 +++--- + gcc/doc/invoke.texi | 4 ++++ + gcc/gcc.c | 18 ++++++++++++++---- + gcc/objc/lang-specs.h | 10 +++++----- + gcc/objcp/lang-specs.h | 8 ++++---- + 6 files changed, 32 insertions(+), 16 deletions(-) + +Index: b/gcc/gcc.c +=================================================================== +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -858,6 +858,14 @@ proper position among the other output f + #define LINK_GCC_C_SEQUENCE_SPEC "%G %L %G" + #endif + ++#ifndef SSP_DEFAULT_SPEC ++#ifdef TARGET_LIBC_PROVIDES_SSP ++#define SSP_DEFAULT_SPEC "%{!fno-stack-protector:%{!fstack-protector-all:%{!ffreestanding:%{!nostdlib:%{!fstack-protector:-fstack-protector-strong}}}}}" ++#else ++#define SSP_DEFAULT_SPEC "" ++#endif ++#endif ++ + #ifndef LINK_SSP_SPEC + #ifdef TARGET_LIBC_PROVIDES_SSP + #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ +@@ -1057,6 +1065,7 @@ static const char *cc1_spec = CC1_SPEC; + static const char *cc1plus_spec = CC1PLUS_SPEC; + static const char *link_gcc_c_sequence_spec = LINK_GCC_C_SEQUENCE_SPEC; + static const char *link_ssp_spec = LINK_SSP_SPEC; ++static const char *ssp_default_spec = SSP_DEFAULT_SPEC; + static const char *asm_spec = ASM_SPEC; + static const char *asm_final_spec = ASM_FINAL_SPEC; + static const char *link_spec = LINK_SPEC; +@@ -1112,7 +1121,7 @@ static const char *cpp_unique_options = + static const char *cpp_options = + "%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w}\ + %{f*} %{g*:%{!g0:%{g*} %{!fno-working-directory:-fworking-directory}}} %{O*}\ +- %{undef} %{save-temps*:-fpch-preprocess}"; ++ %{undef} %{save-temps*:-fpch-preprocess} %(ssp_default)"; + + /* This contains cpp options which are not passed when the preprocessor + output will be used by another program. */ +@@ -1301,9 +1310,9 @@ static const struct compiler default_com + %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \ + %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\ + cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \ +- %(cc1_options)}\ ++ %(cc1_options) %(ssp_default)}\ + %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\ +- cc1 %(cpp_unique_options) %(cc1_options)}}}\ ++ cc1 %(cpp_unique_options) %(cc1_options) %(ssp_default)}}}\ + %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 1}, + {"-", + "%{!E:%e-E or -x required when input is from standard input}\ +@@ -1328,7 +1337,7 @@ static const struct compiler default_com + %W{o*:--output-pch=%*}}%V}}}}}}}", 0, 0, 0}, + {".i", "@cpp-output", 0, 0, 0}, + {"@cpp-output", +- "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, ++ "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %(ssp_default) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, + {".s", "@assembler", 0, 0, 0}, + {"@assembler", + "%{!M:%{!MM:%{!E:%{!S:as %(asm_debug) %(asm_options) %i %A }}}}", 0, 0, 0}, +@@ -1560,6 +1569,7 @@ static struct spec_list static_specs[] = + INIT_STATIC_SPEC ("cc1plus", &cc1plus_spec), + INIT_STATIC_SPEC ("link_gcc_c_sequence", &link_gcc_c_sequence_spec), + INIT_STATIC_SPEC ("link_ssp", &link_ssp_spec), ++ INIT_STATIC_SPEC ("ssp_default", &ssp_default_spec), + INIT_STATIC_SPEC ("endfile", &endfile_spec), + INIT_STATIC_SPEC ("link", &link_spec), + INIT_STATIC_SPEC ("lib", &lib_spec), +Index: b/gcc/cp/lang-specs.h +=================================================================== +--- a/gcc/cp/lang-specs.h ++++ b/gcc/cp/lang-specs.h +@@ -46,7 +46,7 @@ along with GCC; see the file COPYING3. + %(cpp_options) %2 -o %{save-temps*:%b.ii} %{!save-temps*:%g.ii} \n}\ + cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}\ + %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}\ +- %(cc1_options) %2\ ++ %(cc1_options) %(ssp_default) %2\ + %{!fsyntax-only:-o %g.s \ + %{!fdump-ada-spec*:%{!o*:--output-pch=%i.gch}\ + %W{o*:--output-pch=%*}}%V}}}}", +@@ -58,11 +58,11 @@ along with GCC; see the file COPYING3. + %(cpp_options) %2 -o %{save-temps*:%b.ii} %{!save-temps*:%g.ii} \n}\ + cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}\ + %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}\ +- %(cc1_options) %2\ ++ %(cc1_options) %(ssp_default) %2\ + %{!fsyntax-only:%(invoke_as)}}}}", + CPLUSPLUS_CPP_SPEC, 0, 0}, + {".ii", "@c++-cpp-output", 0, 0, 0}, + {"@c++-cpp-output", + "%{!M:%{!MM:%{!E:\ +- cc1plus -fpreprocessed %i %(cc1_options) %2\ ++ cc1plus -fpreprocessed %i %(cc1_options) %(ssp_default) %2\ + %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, +Index: b/gcc/params.def +=================================================================== +--- a/gcc/params.def ++++ b/gcc/params.def +@@ -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", +Index: b/gcc/objc/lang-specs.h +=================================================================== +--- a/gcc/objc/lang-specs.h ++++ b/gcc/objc/lang-specs.h +@@ -29,9 +29,9 @@ along with GCC; see the file COPYING3. + %{traditional|traditional-cpp:\ + %eGNU Objective C no longer supports traditional compilation}\ + %{save-temps*|no-integrated-cpp:cc1obj -E %(cpp_options) -o %{save-temps*:%b.mi} %{!save-temps*:%g.mi} \n\ +- cc1obj -fpreprocessed %{save-temps*:%b.mi} %{!save-temps*:%g.mi} %(cc1_options) %{print-objc-runtime-info} %{gen-decls}}\ ++ cc1obj -fpreprocessed %{save-temps*:%b.mi} %{!save-temps*:%g.mi} %(cc1_options) %(ssp_default) %{print-objc-runtime-info} %{gen-decls}}\ + %{!save-temps*:%{!no-integrated-cpp:\ +- cc1obj %(cpp_unique_options) %(cc1_options) %{print-objc-runtime-info} %{gen-decls}}}\ ++ cc1obj %(cpp_unique_options) %(cc1_options) %(ssp_default) %{print-objc-runtime-info} %{gen-decls}}}\ + %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, + {"@objective-c-header", + "%{E|M|MM:cc1obj -E %{traditional|traditional-cpp:-traditional-cpp}\ +@@ -40,18 +40,18 @@ along with GCC; see the file COPYING3. + %{traditional|traditional-cpp:\ + %eGNU Objective C no longer supports traditional compilation}\ + %{save-temps*|no-integrated-cpp:cc1obj -E %(cpp_options) -o %{save-temps*:%b.mi} %{!save-temps*:%g.mi} \n\ +- cc1obj -fpreprocessed %b.mi %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\ ++ cc1obj -fpreprocessed %b.mi %(cc1_options) %(ssp_default) %{print-objc-runtime-info} %{gen-decls}\ + -o %g.s %{!o*:--output-pch=%i.gch}\ + %W{o*:--output-pch=%*}%V}\ + %{!save-temps*:%{!no-integrated-cpp:\ +- cc1obj %(cpp_unique_options) %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\ ++ cc1obj %(cpp_unique_options) %(cc1_options) %(ssp_default) %{print-objc-runtime-info} %{gen-decls}\ + -o %g.s %{!o*:--output-pch=%i.gch}\ + %W{o*:--output-pch=%*}%V}}}}}", 0, 0, 0}, + {".mi", "@objective-c-cpp-output", 0, 0, 0}, + {"@objective-c-cpp-output", +- "%{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\ ++ "%{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %(ssp_default) %{print-objc-runtime-info} %{gen-decls}\ + %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, + {"@objc-cpp-output", + "%nobjc-cpp-output is deprecated; please use objective-c-cpp-output instead\n\ +- %{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\ ++ %{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %(ssp_default) %{print-objc-runtime-info} %{gen-decls}\ + %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, +Index: b/gcc/objcp/lang-specs.h +=================================================================== +--- a/gcc/objcp/lang-specs.h ++++ b/gcc/objcp/lang-specs.h +@@ -36,7 +36,7 @@ along with GCC; see the file COPYING3. + %(cpp_options) %2 -o %{save-temps*:%b.mii} %{!save-temps*:%g.mii} \n}\ + cc1objplus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.mii} %{!save-temps*:%g.mii}}\ + %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}\ +- %(cc1_options) %2\ ++ %(cc1_options) %(ssp_default) %2\ + -o %g.s %{!o*:--output-pch=%i.gch} %W{o*:--output-pch=%*}%V}}}", + CPLUSPLUS_CPP_SPEC, 0, 0}, + {"@objective-c++", +@@ -46,16 +46,16 @@ along with GCC; see the file COPYING3. + %(cpp_options) %2 -o %{save-temps*:%b.mii} %{!save-temps*:%g.mii} \n}\ + cc1objplus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.mii} %{!save-temps*:%g.mii}}\ + %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}\ +- %(cc1_options) %2\ ++ %(cc1_options) %(ssp_default) %2\ + %{!fsyntax-only:%(invoke_as)}}}}", + CPLUSPLUS_CPP_SPEC, 0, 0}, + {".mii", "@objective-c++-cpp-output", 0, 0, 0}, + {"@objective-c++-cpp-output", + "%{!M:%{!MM:%{!E:\ +- cc1objplus -fpreprocessed %i %(cc1_options) %2\ ++ cc1objplus -fpreprocessed %i %(cc1_options) %(ssp_default) %2\ + %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, + {"@objc++-cpp-output", + "%nobjc++-cpp-output is deprecated; please use objective-c++-cpp-output instead\n\ + %{!M:%{!MM:%{!E:\ +- cc1objplus -fpreprocessed %i %(cc1_options) %2\ ++ cc1objplus -fpreprocessed %i %(cc1_options) %(ssp_default) %2\ + %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, +Index: b/gcc/doc/invoke.texi +=================================================================== +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -9247,6 +9247,9 @@ + The minimum size of variables taking part in stack slot sharing when not + optimizing. The default value is 32. + ++The Alpine Linux default is "4", to increase ++the number of functions protected by the stack protector. ++ + @item max-jump-thread-duplication-stmts + Maximum number of statements allowed in a block that needs to be + duplicated when threading jumps. +@@ -10185,6 +10188,11 @@ + Like @option{-fstack-protector} but includes additional functions to + be protected --- those that have local array definitions, or have + references to local frame addresses. ++ ++NOTE: In Alpine Linux, ++@option{-fstack-protector-strong} is enabled by default for C, ++C++, ObjC, ObjC++, if none of @option{-fno-stack-protector}, ++@option{-nostdlib}, nor @option{-ffreestanding} are found. + + @item -fstack-protector-explicit + @opindex fstack-protector-explicit diff --git a/aports/cross/gcc-x86_64/002_all_default-relro.patch b/aports/cross/gcc-x86_64/002_all_default-relro.patch new file mode 100644 index 00000000..c461017d --- /dev/null +++ b/aports/cross/gcc-x86_64/002_all_default-relro.patch @@ -0,0 +1,33 @@ +# 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=*:% 0 + +--- + gcc/doc/invoke.texi | 6 ++++++ + gcc/c-family/c-cppbuiltin.c | 3 + + 2 files changed, 9 insertions(+), 0 deletions(-) + +Index: b/gcc/doc/invoke.texi +=================================================================== +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -7840,6 +7840,12 @@ also turns on the following optimization + Please note the warning under @option{-fgcse} about + invoking @option{-O2} on programs that use computed gotos. + ++NOTE: In Alpine Linux, @option{-D_FORTIFY_SOURCE=2} is ++set by default, and is activated when @option{-O} is set to 2 or higher. ++This enables additional compile-time and run-time checks for several libc ++functions. To disable, specify either @option{-U_FORTIFY_SOURCE} or ++@option{-D_FORTIFY_SOURCE=0}. ++ + @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__"); diff --git a/aports/cross/gcc-x86_64/005_all_default-as-needed.patch b/aports/cross/gcc-x86_64/005_all_default-as-needed.patch new file mode 100644 index 00000000..ee4f7962 --- /dev/null +++ b/aports/cross/gcc-x86_64/005_all_default-as-needed.patch @@ -0,0 +1,241 @@ +# DP: On linux targets pass --as-needed by default to the linker, but always +# DP: link the sanitizer libraries with --no-as-needed. + +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -568,8 +568,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 +--- a/gcc/config/gnu-user.h ++++ b/gcc/config/gnu-user.h +@@ -124,13 +124,13 @@ + #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 + #define LIBTSAN_EARLY_SPEC "%{static-libtsan:%{!shared:" \ + LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \ +- LD_DYNAMIC_OPTION "}}%{!static-libtsan:-ltsan}" ++ LD_DYNAMIC_OPTION "}}%{!static-libtsan:%{!fuse-ld=gold:--push-state} --no-as-needed -ltsan %{fuse-ld=gold:--as-needed;:--pop-state}}" + #undef LIBLSAN_EARLY_SPEC + #define LIBLSAN_EARLY_SPEC "%{static-liblsan:%{!shared:" \ + LD_STATIC_OPTION " --whole-archive -llsan --no-whole-archive " \ +- 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 +@@ -36,5 +36,6 @@ + + #define LINUX_TARGET_LINK_SPEC "%{h*} \ ++ --as-needed \ + %{static:-Bstatic} \ + %{shared:-shared} \ + %{symbolic:-Bsymbolic} \ +Index: b/gcc/config/ia64/linux.h +=================================================================== +--- a/gcc/config/ia64/linux.h ++++ b/gcc/config/ia64/linux.h +@@ -58,7 +58,7 @@ do { \ + #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-ia64.so.2" + + #undef LINK_SPEC +-#define LINK_SPEC "\ ++#define LINK_SPEC " --as-needed \ + %{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}} \ + %{!shared: \ + %{!static: \ +Index: b/gcc/config/s390/linux.h +=================================================================== +--- a/gcc/config/s390/linux.h ++++ b/gcc/config/s390/linux.h +@@ -65,7 +65,7 @@ along with GCC; see the file COPYING3. + + #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 +=================================================================== +--- a/gcc/config/rs6000/linux64.h ++++ b/gcc/config/rs6000/linux64.h +@@ -466,12 +466,12 @@ extern int dot_symbols; + " -m elf64ppc") + #endif + +-#define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " %{!shared: %{!static: \ ++#define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " --as-needed %{!shared: %{!static: \ + %{rdynamic:-export-dynamic} \ + -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "}} \ + %(link_os_extra_spec32)" + +-#define LINK_OS_LINUX_SPEC64 LINK_OS_LINUX_EMUL64 " %{!shared: %{!static: \ ++#define LINK_OS_LINUX_SPEC64 LINK_OS_LINUX_EMUL64 " --as-needed %{!shared: %{!static: \ + %{rdynamic:-export-dynamic} \ + -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}} \ + %(link_os_extra_spec64)" +Index: b/gcc/config/rs6000/sysv4.h +=================================================================== +--- a/gcc/config/rs6000/sysv4.h ++++ b/gcc/config/rs6000/sysv4.h +@@ -784,7 +784,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEF + CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \ + MUSL_DYNAMIC_LINKER) + +-#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 +@@ -57,5 +57,6 @@ see the files COPYING3 and COPYING.RUNTI + %{" 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: \ + %{rdynamic:-export-dynamic} \ +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 + +-#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 +@@ -73,5 +73,6 @@ + %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \ + -X \ ++ --as-needed \ + %{mbig-endian:-EB} %{mlittle-endian:-EL}" \ + SUBTARGET_EXTRA_LINK_SPEC + +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 \ + %{!shared: \ + %{!static: \ + %{rdynamic:-export-dynamic} \ +Index: b/libjava/Makefile.am +=================================================================== +--- a/libjava/Makefile.am ++++ b/libjava/Makefile.am +@@ -627,14 +631,14 @@ + rm .libs/libgcj_bc.so; \ + mv .libs/libgcj_bc.so.1.0.0 .libs/libgcj_bc.so; \ + $(libgcj_bc_dummy_LINK) -xc /dev/null -Wl,-soname,libgcj_bc.so.1 \ +- -o .libs/libgcj_bc.so.1.0.0 -lgcj || exit; \ ++ -o .libs/libgcj_bc.so.1.0.0 -Wl,--no-as-needed -lgcj || exit; \ + rm .libs/libgcj_bc.so.1; \ + $(LN_S) libgcj_bc.so.1.0.0 .libs/libgcj_bc.so.1 + + ## This rule creates the libgcj_bc library that is actually installed. + install/libgcj_bc.la: $(libgcj_bc_la_OBJECTS) $(libgcj_bc_la_DEPENDENCIES) install/$(am__dirstamp) + $(libgcj_bc_la_LINK) $(am_libgcj_bc_la_rpath) $(libgcj_bc_la_LDFLAGS) \ +- $(libgcj_bc_la_OBJECTS) $(libgcj_bc_la_LIBADD) $(LIBS) ++ $(libgcj_bc_la_OBJECTS) $(libgcj_bc_la_LIBADD) $(LIBS) -Wl,--no-as-needed -lgcj + + ## Note that property_files is defined in sources.am. + propertyo_files = $(patsubst classpath/resource/%,%,$(addsuffix .lo,$(property_files))) +@@ -762,7 +766,7 @@ + rm $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so; \ + mv $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so.1.0.0 $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so; \ + $(libgcj_bc_dummy_LINK) -xc /dev/null -Wl,-soname,libgcj_bc.so.1 \ +- -o $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so.1.0.0 -lgcj || exit; \ ++ -o $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so.1.0.0 -Wl,--no-as-needed -lgcj || exit; \ + rm $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so.1; \ + $(LN_S) libgcj_bc.so.1.0.0 $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so.1; \ + rm $(DESTDIR)$(toolexeclibdir)/libgcj_bc.la; + +Index: b/libjava/Makefile.in +=================================================================== +--- a/libjava/Makefile.in ++++ b/libjava/Makefile.in +@@ -10644,13 +10648,13 @@ + rm .libs/libgcj_bc.so; \ + mv .libs/libgcj_bc.so.1.0.0 .libs/libgcj_bc.so; \ + $(libgcj_bc_dummy_LINK) -xc /dev/null -Wl,-soname,libgcj_bc.so.1 \ +- -o .libs/libgcj_bc.so.1.0.0 -lgcj || exit; \ ++ -o .libs/libgcj_bc.so.1.0.0 -Wl,--no-as-needed -lgcj || exit; \ + rm .libs/libgcj_bc.so.1; \ + $(LN_S) libgcj_bc.so.1.0.0 .libs/libgcj_bc.so.1 + + install/libgcj_bc.la: $(libgcj_bc_la_OBJECTS) $(libgcj_bc_la_DEPENDENCIES) install/$(am__dirstamp) + $(libgcj_bc_la_LINK) $(am_libgcj_bc_la_rpath) $(libgcj_bc_la_LDFLAGS) \ +- $(libgcj_bc_la_OBJECTS) $(libgcj_bc_la_LIBADD) $(LIBS) ++ $(libgcj_bc_la_OBJECTS) $(libgcj_bc_la_LIBADD) $(LIBS) -Wl,--no-as-needed -lgcj + + $(propertyo_files): %.lo: classpath/resource/% + $(mkinstalldirs) `dirname $@`; \ +@@ -12494,7 +12498,7 @@ + @USE_LIBGCJ_BC_TRUE@ rm $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so; \ + @USE_LIBGCJ_BC_TRUE@ mv $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so.1.0.0 $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so; \ + @USE_LIBGCJ_BC_TRUE@ $(libgcj_bc_dummy_LINK) -xc /dev/null -Wl,-soname,libgcj_bc.so.1 \ +-@USE_LIBGCJ_BC_TRUE@ -o $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so.1.0.0 -lgcj || exit; \ ++@USE_LIBGCJ_BC_TRUE@ -o $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so.1.0.0 -Wl,--no-as-needed -lgcj || exit; \ + @USE_LIBGCJ_BC_TRUE@ rm $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so.1; \ + @USE_LIBGCJ_BC_TRUE@ $(LN_S) libgcj_bc.so.1.0.0 $(DESTDIR)$(toolexeclibdir)/libgcj_bc.so.1; \ + @USE_LIBGCJ_BC_TRUE@ rm $(DESTDIR)$(toolexeclibdir)/libgcj_bc.la; + diff --git a/aports/cross/gcc-x86_64/011_all_default-warn-format-security.patch b/aports/cross/gcc-x86_64/011_all_default-warn-format-security.patch new file mode 100644 index 00000000..a58383a8 --- /dev/null +++ b/aports/cross/gcc-x86_64/011_all_default-warn-format-security.patch @@ -0,0 +1,43 @@ +Enable -Wformat and -Wformat-security by default. + + +--- a/gcc/c-family/c.opt ++++ b/gcc/c-family/c.opt +@@ -412,7 +412,7 @@ C ObjC C++ ObjC++ Var(warn_format_nonliteral) Warning LangEnabledBy(C ObjC C++ O + Warn about format strings that are not literals + + Wformat-security +-C ObjC C++ ObjC++ Var(warn_format_security) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 2, 0) ++C ObjC C++ ObjC++ Var(warn_format_security) Init(1) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 2, 0) + Warn about possible security problems with format functions + + Wformat-y2k +@@ -424,7 +424,7 @@ C ObjC C++ ObjC++ Var(warn_format_zero_length) Warning LangEnabledBy(C ObjC C++ + Warn about zero-length formats + + Wformat= +-C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0) ++C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format) Init(1) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0) + Warn about printf/scanf/strftime/strfmon format string anomalies + + Wignored-qualifiers +--- a/gcc/doc/gcc.info ++++ b/gcc/doc/gcc.info +@@ -3451,6 +3451,8 @@ compiler warns that an unrecognized option is present. + '-Wno-format-contains-nul', '-Wno-format-extra-args', and + '-Wno-format-zero-length'. '-Wformat' is enabled by '-Wall'. + ++ This option is enabled by default in Alpine Linux. ++ + '-Wno-format-contains-nul' + If '-Wformat' is specified, do not warn about format strings + that contain NUL bytes. +@@ -3496,6 +3498,8 @@ compiler warns that an unrecognized option is present. + future warnings may be added to '-Wformat-security' that are + not included in '-Wformat-nonliteral'.) + ++ This option is enabled by default in Alpine Linux. ++ + '-Wformat-y2k' + If '-Wformat' is specified, also warn about 'strftime' formats + that may yield only a two-digit year. diff --git a/aports/cross/gcc-x86_64/012_all_default-warn-trampolines.patch b/aports/cross/gcc-x86_64/012_all_default-warn-trampolines.patch new file mode 100644 index 00000000..9ab4378d --- /dev/null +++ b/aports/cross/gcc-x86_64/012_all_default-warn-trampolines.patch @@ -0,0 +1,25 @@ +Enable -Wtrampolines by default. + + +--- a/gcc/common.opt ++++ b/gcc/common.opt +@@ -648,7 +648,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 +--- a/gcc/doc/gcc.info ++++ b/gcc/doc/gcc.info +@@ -4021,6 +4021,8 @@ compiler warns that an unrecognized option is present. + and thus requires the stack to be made executable in order for the + program to work properly. + ++ This warning is enabled by default in Gentoo. ++ + '-Wfloat-equal' + Warn if floating-point values are used in equality comparisons. + diff --git a/aports/cross/gcc-x86_64/020_all_msgfmt-libstdc++-link.patch b/aports/cross/gcc-x86_64/020_all_msgfmt-libstdc++-link.patch new file mode 100644 index 00000000..a70ea50a --- /dev/null +++ b/aports/cross/gcc-x86_64/020_all_msgfmt-libstdc++-link.patch @@ -0,0 +1,39 @@ +Ensure that msgfmt doesn't encounter problems during gcc bootstrapping. + +Solves error messages like the following: + +msgfmt: /var/tmp/portage/sys-devel/gcc-4.1.2/work/build/./gcc/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/libstdc++.so.6) + +The libgcc_s.so used during build doesn't satisfy the needs of the +libstdc++.so that msgfmt is linked against. On the other hand, msgfmt +is used as a stand-alone application here, and what library it uses +behind the scenes is of no concern to the gcc build process. +Therefore, simply invoking it "as usual", i.e. without any special +library path, will make it work as expected here. + +2011-09-19 Martin von Gagern + +References: +https://bugs.gentoo.org/372377 +https://bugs.gentoo.org/295480 + +--- 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 + EXTRA_DIST = string_literals.cc POTFILES.in $(PACKAGE).pot $(LOCALE_IN) + + .po.mo: ++ env --unset=LD_LIBRARY_PATH \ + $(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 + + + .po.mo: ++ env --unset=LD_LIBRARY_PATH \ + $(MSGFMT) -o $@ $< + + all-local: all-local-$(USE_NLS) diff --git a/aports/cross/gcc-x86_64/050_all_libiberty-asprintf.patch b/aports/cross/gcc-x86_64/050_all_libiberty-asprintf.patch new file mode 100644 index 00000000..bee0c4c2 --- /dev/null +++ b/aports/cross/gcc-x86_64/050_all_libiberty-asprintf.patch @@ -0,0 +1,18 @@ +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/aports/cross/gcc-x86_64/051_all_libiberty-pic.patch b/aports/cross/gcc-x86_64/051_all_libiberty-pic.patch new file mode 100644 index 00000000..b6160a73 --- /dev/null +++ b/aports/cross/gcc-x86_64/051_all_libiberty-pic.patch @@ -0,0 +1,10 @@ +--- 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/aports/cross/gcc-x86_64/053_all_libitm-no-fortify-source.patch b/aports/cross/gcc-x86_64/053_all_libitm-no-fortify-source.patch new file mode 100644 index 00000000..5ab15afc --- /dev/null +++ b/aports/cross/gcc-x86_64/053_all_libitm-no-fortify-source.patch @@ -0,0 +1,27 @@ +https://bugs.gentoo.org/508852 +https://gcc.gnu.org/PR61164 + +2014-04-27 Magnus Granberg + + #508852 + * libitm/configure.tgt: Disable FORTIFY + +--- a/libitm/configure.tgt ++++ b/libitm/configure.tgt +@@ -43,6 +43,16 @@ if test "$gcc_cv_have_tls" = yes ; then + esac + fi + ++# FIXME: error: inlining failed in call to always_inline ++# ‘int vfprintf(FILE*, const char*, __va_list_tag*)’ ++# : function body can be overwritten at link time ++# Disable Fortify in libitm for now. #508852 ++case "${target}" in ++ *-*-linux*) ++ XCFLAGS="${XCFLAGS} -U_FORTIFY_SOURCE" ++ ;; ++esac ++ + # 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 diff --git a/aports/cross/gcc-x86_64/067_all_gcc-poison-system-directories.patch b/aports/cross/gcc-x86_64/067_all_gcc-poison-system-directories.patch new file mode 100644 index 00000000..10367161 --- /dev/null +++ b/aports/cross/gcc-x86_64/067_all_gcc-poison-system-directories.patch @@ -0,0 +1,194 @@ +http://cgit.openembedded.org/openembedded-core/plain/meta/recipes-devtools/gcc/gcc-6.1/0010-gcc-poison-system-directories.patch + +From d76250323dad69212c958e4857a98d99ab51a39e Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Fri, 29 Mar 2013 08:59:00 +0400 +Subject: [PATCH 10/46] gcc: poison-system-directories + +Signed-off-by: Khem Raj + +Upstream-Status: Inappropriate [distribution: codesourcery] +--- + gcc/common.opt | 4 ++++ + gcc/config.in | 6 ++++++ + gcc/configure | 16 ++++++++++++++++ + gcc/configure.ac | 10 ++++++++++ + gcc/doc/invoke.texi | 9 +++++++++ + gcc/gcc.c | 2 ++ + gcc/incpath.c | 19 +++++++++++++++++++ + 7 files changed, 66 insertions(+) + +diff --git a/gcc/common.opt b/gcc/common.opt +index 67048db..733185c 100644 +--- a/gcc/common.opt ++++ b/gcc/common.opt +@@ -659,6 +659,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. + ++Wpoison-system-directories ++Common Var(flag_poison_system_directories) Init(1) Warning ++Warn for -I and -L options using system directories if cross compiling ++ + Wshadow + Common Var(warn_shadow) Warning + Warn when one local variable shadows another. +diff --git a/gcc/config.in b/gcc/config.in +index 115cb61..105b30f 100644 +--- a/gcc/config.in ++++ b/gcc/config.in +@@ -187,6 +187,12 @@ + #endif + + ++/* Define to warn for use of native system header directories */ ++#ifndef USED_FOR_TARGET ++#undef ENABLE_POISON_SYSTEM_DIRECTORIES ++#endif ++ ++ + /* Define if you want all operations on RTL (the basic data structure of the + 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 1c6e340..8f83152 100755 +--- a/gcc/configure ++++ b/gcc/configure +@@ -942,6 +942,7 @@ with_system_zlib + enable_maintainer_mode + enable_link_mutex + enable_version_specific_runtime_libs ++enable_poison_system_directories + enable_plugin + enable_host_shared + enable_libquadmath_support +@@ -1681,6 +1682,8 @@ Optional Features: + --enable-version-specific-runtime-libs + specify that runtime libraries should be installed + in a compiler-specific directory ++ --enable-poison-system-directories ++ warn for use of native system header directories + --enable-plugin enable plugin support + --enable-host-shared build host code as shared libraries + --disable-libquadmath-support +@@ -28908,6 +28911,19 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then : + fi + + ++# Check whether --enable-poison-system-directories was given. ++if test "${enable_poison_system_directories+set}" = set; then : ++ enableval=$enable_poison_system_directories; ++else ++ enable_poison_system_directories=no ++fi ++ ++if test "x${enable_poison_system_directories}" = "xyes"; then ++ ++$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h ++ ++fi ++ + # Substitute configuration variables + + +diff --git a/gcc/configure.ac b/gcc/configure.ac +index 6c1dcd9..0fccaef 100644 +--- a/gcc/configure.ac ++++ b/gcc/configure.ac +@@ -5861,6 +5861,16 @@ AC_ARG_ENABLE(version-specific-runtime-libs, + [specify that runtime libraries should be + installed in a compiler-specific directory])]) + ++AC_ARG_ENABLE([poison-system-directories], ++ AS_HELP_STRING([--enable-poison-system-directories], ++ [warn for use of native system header directories]),, ++ [enable_poison_system_directories=no]) ++if test "x${enable_poison_system_directories}" = "xyes"; then ++ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES], ++ [1], ++ [Define to warn for use of native system header directories]) ++fi ++ + # Substitute configuration variables + AC_SUBST(subdirs) + AC_SUBST(srcdir) +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index 821f8fd..8bb49e7 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -284,6 +284,7 @@ Objective-C and Objective-C++ Dialects}. + -Wparentheses -Wno-pedantic-ms-format @gol + -Wplacement-new -Wplacement-new=@var{n} @gol + -Wpointer-arith -Wno-pointer-to-int-cast @gol ++-Wno-poison-system-directories @gol + -Wno-pragmas -Wredundant-decls -Wno-return-local-addr @gol + -Wreturn-type -Wsequence-point -Wshadow -Wno-shadow-ivar @gol + -Wshift-overflow -Wshift-overflow=@var{n} @gol +@@ -4723,6 +4724,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. + ++@item -Wno-poison-system-directories ++@opindex Wno-poison-system-directories ++Do not warn for @option{-I} or @option{-L} options using system ++directories such as @file{/usr/include} when cross compiling. This ++option is intended for use in chroot environments when such ++directories contain the correct headers and libraries for the target ++system rather than the host. ++ + @item -Wfloat-equal + @opindex Wfloat-equal + @opindex Wno-float-equal +diff --git a/gcc/gcc.c b/gcc/gcc.c +index 1af5920..4cfef7f 100644 +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -1017,6 +1017,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}} \ ++ %{Wno-poison-system-directories:--no-poison-system-directories} \ ++ %{Werror=poison-system-directories:--error-poison-system-directories} \ + %{static:} %{L*} %(mfwrap) %(link_libgcc) " \ + VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o " CHKP_SPEC " \ + %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\ +diff --git a/gcc/incpath.c b/gcc/incpath.c +index ea40f4a..856da41 100644 +--- a/gcc/incpath.c ++++ b/gcc/incpath.c +@@ -26,6 +26,7 @@ + #include "intl.h" + #include "incpath.h" + #include "cppdefault.h" ++#include "diagnostic-core.h" + + /* Microsoft Windows does not natively support inodes. + VMS has non-numeric inodes. */ +@@ -381,6 +382,24 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose) + } + fprintf (stderr, _("End of search list.\n")); + } ++ ++#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES ++ if (flag_poison_system_directories) ++ { ++ struct cpp_dir *p; ++ ++ for (p = heads[QUOTE]; p; p = p->next) ++ { ++ if ((!strncmp (p->name, "/usr/include", 12)) ++ || (!strncmp (p->name, "/usr/local/include", 18)) ++ || (!strncmp (p->name, "/usr/X11R6/include", 18))) ++ warning (OPT_Wpoison_system_directories, ++ "include location \"%s\" is unsafe for " ++ "cross-compilation", ++ p->name); ++ } ++ } ++#endif + } + + /* Use given -I paths for #include "..." but not #include <...>, and +-- +2.8.2 + diff --git a/aports/cross/gcc-x86_64/090_all_pr55930-dependency-tracking.patch b/aports/cross/gcc-x86_64/090_all_pr55930-dependency-tracking.patch new file mode 100644 index 00000000..a8743e08 --- /dev/null +++ b/aports/cross/gcc-x86_64/090_all_pr55930-dependency-tracking.patch @@ -0,0 +1,18 @@ +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/aports/cross/gcc-x86_64/201-cilkrts.patch b/aports/cross/gcc-x86_64/201-cilkrts.patch new file mode 100644 index 00000000..4aac10d6 --- /dev/null +++ b/aports/cross/gcc-x86_64/201-cilkrts.patch @@ -0,0 +1,59 @@ +From 594e3c1ab576daddeb86015efc8b1677020b1878 Mon Sep 17 00:00:00 2001 +From: Szabolcs Nagy +Date: Sat, 24 Oct 2015 20:39:30 +0000 +Subject: [PATCH 1/6] cilkrts + +--- + libcilkrts/runtime/os-unix.c | 22 +++++++--------------- + 1 file changed, 7 insertions(+), 15 deletions(-) + +diff --git a/libcilkrts/runtime/os-unix.c b/libcilkrts/runtime/os-unix.c +index cb582dd..e43d7d5 100644 +--- a/libcilkrts/runtime/os-unix.c ++++ b/libcilkrts/runtime/os-unix.c +@@ -51,6 +51,7 @@ + #if defined __linux__ + # include + # include ++# include + #elif defined __APPLE__ + # include + // Uses sysconf(_SC_NPROCESSORS_ONLN) in verbose output +@@ -400,28 +401,19 @@ COMMON_SYSDEP void __cilkrts_sleep(void) + + COMMON_SYSDEP void __cilkrts_yield(void) + { +-#if __APPLE__ || __FreeBSD__ || __VXWORKS__ +- // On MacOS, call sched_yield to yield quantum. I'm not sure why we +- // don't do this on Linux also. +- sched_yield(); +-#elif defined(__DragonFly__) +- // On DragonFly BSD, call sched_yield to yield quantum. +- sched_yield(); +-#elif defined(__MIC__) ++#if defined(__MIC__) + // On MIC, pthread_yield() really trashes things. Arch's measurements + // showed that calling _mm_delay_32() (or doing nothing) was a better + // option. Delaying 1024 clock cycles is a reasonable compromise between + // giving up the processor and latency starting up when work becomes + // available + _mm_delay_32(1024); +-#elif defined(__ANDROID__) || (defined(__sun__) && defined(__svr4__)) +- // On Android and Solaris, call sched_yield to yield quantum. I'm not +- // sure why we don't do this on Linux also. +- sched_yield(); +-#else +- // On Linux, call pthread_yield (which in turn will call sched_yield) +- // to yield quantum. ++#elif defined(__sun__) && !defined(__svr4__) ++ // On old SunOS call pthread_yield to yield a quantum. + pthread_yield(); ++#else ++ // On other platforms call sched_yield to yield a quantum. ++ sched_yield(); + #endif + } + +-- +2.8.1 + diff --git a/aports/cross/gcc-x86_64/203-libgcc_s.patch b/aports/cross/gcc-x86_64/203-libgcc_s.patch new file mode 100644 index 00000000..c74351c7 --- /dev/null +++ b/aports/cross/gcc-x86_64/203-libgcc_s.patch @@ -0,0 +1,56 @@ +From 9e3eab51e518018d9d99b3123598b1e2322a6af3 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 + +--- + gcc/config/i386/i386.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, + { + case IX86_BUILTIN_CPU_INIT: + { +- /* Make it call __cpu_indicator_init in libgcc. */ ++ /* Make it call __cpu_indicator_init_local in libgcc.a. */ + tree call_expr, fndecl, type; + type = build_function_type_list (integer_type_node, NULL_TREE); +- fndecl = build_fn_decl ("__cpu_indicator_init", type); ++ fndecl = build_fn_decl ("__cpu_indicator_init_local", type); + call_expr = build_call_expr (fndecl, 0); + 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 +--- a/libgcc/config/i386/cpuinfo.c ++++ b/libgcc/config/i386/cpuinfo.c +@@ -485,7 +485,7 @@ __cpu_indicator_init (void) + return 0; + } + +-#if defined SHARED && defined USE_ELF_SYMVER +-__asm__ (".symver __cpu_indicator_init, __cpu_indicator_init@GCC_4.8.0"); +-__asm__ (".symver __cpu_model, __cpu_model@GCC_4.8.0"); ++#ifndef SHARED ++int __cpu_indicator_init_local (void) ++ __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 +--- a/libgcc/config/i386/t-linux ++++ b/libgcc/config/i386/t-linux +@@ -3,4 +3,4 @@ + # t-slibgcc-elf-ver and t-linux + SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/i386/libgcc-glibc.ver + +-HOST_LIBGCC2_CFLAGS += -mlong-double-80 -DUSE_ELF_SYMVER ++HOST_LIBGCC2_CFLAGS += -mlong-double-80 +-- +2.8.1 + diff --git a/aports/cross/gcc-x86_64/204-linux_libc_has_function.patch b/aports/cross/gcc-x86_64/204-linux_libc_has_function.patch new file mode 100644 index 00000000..2dcedc3a --- /dev/null +++ b/aports/cross/gcc-x86_64/204-linux_libc_has_function.patch @@ -0,0 +1,25 @@ +From edec78452d693fb524daa9a6efd45c850b27b25c Mon Sep 17 00:00:00 2001 +From: Szabolcs Nagy +Date: Fri, 6 Nov 2015 23:59:20 +0000 +Subject: [PATCH 4/6] linux_libc_has_function + +--- + gcc/config/linux.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gcc/config/linux.c b/gcc/config/linux.c +index 250296b..16c3768 100644 +--- a/gcc/config/linux.c ++++ b/gcc/config/linux.c +@@ -26,7 +26,7 @@ along with GCC; see the file COPYING3. If not see + bool + linux_libc_has_function (enum function_class fn_class) + { +- if (OPTION_GLIBC) ++ if (OPTION_GLIBC || OPTION_MUSL) + return true; + if (OPTION_BIONIC) + if (fn_class == function_c94 +-- +2.8.1 + diff --git a/aports/cross/gcc-x86_64/205-nopie.patch b/aports/cross/gcc-x86_64/205-nopie.patch new file mode 100644 index 00000000..e3da94d1 --- /dev/null +++ b/aports/cross/gcc-x86_64/205-nopie.patch @@ -0,0 +1,75 @@ +From b6015aca9c9cc83739fd0ed637a835119b2c4e34 Mon Sep 17 00:00:00 2001 +From: Szabolcs Nagy +Date: Sat, 7 Nov 2015 02:08:05 +0000 +Subject: [PATCH 5/6] nopie + +--- + gcc/configure | 27 +++++++++++++++++++++++++++ + gcc/configure.ac | 13 +++++++++++++ + 2 files changed, 40 insertions(+) + +diff --git a/gcc/configure b/gcc/configure +index 1c6e340..7e8b5d6 100755 +--- a/gcc/configure ++++ b/gcc/configure +@@ -29390,6 +29390,33 @@ fi + $as_echo "$gcc_cv_no_pie" >&6; } + if test "$gcc_cv_no_pie" = "yes"; then + NO_PIE_FLAG="-no-pie" ++else ++ # Check if -nopie works. ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -nopie option" >&5 ++$as_echo_n "checking for -nopie option... " >&6; } ++if test "${gcc_cv_nopie+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ saved_LDFLAGS="$LDFLAGS" ++ LDFLAGS="$LDFLAGS -nopie" ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++int main(void) {return 0;} ++_ACEOF ++if ac_fn_cxx_try_link "$LINENO"; then : ++ gcc_cv_nopie=yes ++else ++ gcc_cv_nopie=no ++fi ++rm -f core conftest.err conftest.$ac_objext \ ++ conftest$ac_exeext conftest.$ac_ext ++ LDFLAGS="$saved_LDFLAGS" ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_nopie" >&5 ++$as_echo "$gcc_cv_nopie" >&6; } ++ if test "$gcc_cv_nopie" = "yes"; then ++ NO_PIE_FLAG="-nopie" ++ fi + fi + + +diff --git a/gcc/configure.ac b/gcc/configure.ac +index 6c1dcd9..0ca7647 100644 +--- a/gcc/configure.ac ++++ b/gcc/configure.ac +@@ -6098,6 +6098,19 @@ AC_CACHE_CHECK([for -no-pie option], + LDFLAGS="$saved_LDFLAGS"]) + if test "$gcc_cv_no_pie" = "yes"; then + NO_PIE_FLAG="-no-pie" ++else ++ # Check if -nopie works. ++ AC_CACHE_CHECK([for -nopie option], ++ [gcc_cv_nopie], ++ [saved_LDFLAGS="$LDFLAGS" ++ LDFLAGS="$LDFLAGS -nopie" ++ AC_LINK_IFELSE([int main(void) {return 0;}], ++ [gcc_cv_nopie=yes], ++ [gcc_cv_nopie=no]) ++ LDFLAGS="$saved_LDFLAGS"]) ++ if test "$gcc_cv_nopie" = "yes"; then ++ NO_PIE_FLAG="-nopie" ++ fi + fi + AC_SUBST([NO_PIE_FLAG]) + +-- +2.8.1 + diff --git a/aports/cross/gcc-x86_64/207-static-pie.patch b/aports/cross/gcc-x86_64/207-static-pie.patch new file mode 100644 index 00000000..9355c584 --- /dev/null +++ b/aports/cross/gcc-x86_64/207-static-pie.patch @@ -0,0 +1,40 @@ +diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h +index b0bf40a..d4b56fe 100644 +--- a/gcc/config/gnu-user.h ++++ b/gcc/config/gnu-user.h +@@ -51,10 +51,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + #if defined HAVE_LD_PIE + #define GNU_USER_TARGET_STARTFILE_SPEC \ + "%{!shared: %{pg|p|profile:gcrt1.o%s;: \ +- %{" PIE_SPEC ":Scrt1.o%s} %{" NO_PIE_SPEC ":crt1.o%s}}} \ +- crti.o%s %{static:crtbeginT.o%s;: %{shared:crtbeginS.o%s} \ ++ %{" PIE_SPEC ":%{static:rcrt1.o%s;:Scrt1.o%s}} %{" NO_PIE_SPEC ":crt1.o%s}}} \ ++ crti.o%s %{shared:crtbeginS.o%s;: \ + %{" PIE_SPEC ":crtbeginS.o%s} \ +- %{" NO_PIE_SPEC ":crtbegin.o%s}} \ ++ %{" NO_PIE_SPEC ":%{static:crtbeginT.o%s;:crtbegin.o%s}}} \ + %{fvtable-verify=none:%s; \ + fvtable-verify=preinit:vtv_start_preinit.o%s; \ + fvtable-verify=std:vtv_start.o%s} \ +diff --git a/gcc/gcc.c b/gcc/gcc.c +index 0208d61..731564e 100644 +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -870,7 +870,7 @@ proper position among the other output files. */ + #endif + + #ifdef ENABLE_DEFAULT_PIE +-#define NO_PIE_SPEC "no-pie|static" ++#define NO_PIE_SPEC "no-pie" + #define PIE_SPEC NO_PIE_SPEC "|r|shared:;" + #define NO_FPIE1_SPEC "fno-pie" + #define FPIE1_SPEC NO_FPIE1_SPEC ":;" +@@ -916,7 +916,7 @@ 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:--no-dynamic-linker -Bsymbolic}" + #endif + #else + #define LD_PIE_SPEC "" diff --git a/aports/cross/gcc-x86_64/300-main-gcc-add-musl-s390x-dynamic-linker.patch b/aports/cross/gcc-x86_64/300-main-gcc-add-musl-s390x-dynamic-linker.patch new file mode 100644 index 00000000..24195787 --- /dev/null +++ b/aports/cross/gcc-x86_64/300-main-gcc-add-musl-s390x-dynamic-linker.patch @@ -0,0 +1,32 @@ +From be841c16dd544553c67faac79bd4cc3cd10a1dc0 Mon Sep 17 00:00:00 2001 +From: "Tuan M. Hoang" +Date: Mon, 21 Nov 2016 01:42:16 +0700 +Subject: [PATCH] main/gcc: add musl s390x dynamic linker + +--- + gcc/config/s390/linux.h | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/gcc/config/s390/linux.h b/gcc/config/s390/linux.h +index 1e3ed35..a244214 100644 +--- a/gcc/config/s390/linux.h ++++ b/gcc/config/s390/linux.h +@@ -63,6 +63,15 @@ 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" + ++#undef MUSL_DYNAMIC_LINKER ++#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-s390x.so.1" ++#undef MUSL_DYNAMIC_LINKER32 ++#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-s390x.so.1" ++#undef MUSL_DYNAMIC_LINKER64 ++#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-s390x.so.1" ++#undef MUSL_DYNAMIC_LINKERX32 ++#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-s390x.so.1" ++ + #undef LINK_SPEC + #define LINK_SPEC \ + "%{m31:-m elf_s390}%{m64:-m elf64_s390} --as-needed \ +-- +2.10.2 + diff --git a/aports/cross/gcc-x86_64/310-build-gcj-s390x.patch b/aports/cross/gcc-x86_64/310-build-gcj-s390x.patch new file mode 100644 index 00000000..1e522ee1 --- /dev/null +++ b/aports/cross/gcc-x86_64/310-build-gcj-s390x.patch @@ -0,0 +1,28 @@ +From 697a7ba791fce2ffab2ed723d909a89684019e3d Mon Sep 17 00:00:00 2001 +From: "Tuan M. Hoang" +Date: Sun, 19 Feb 2017 17:03:33 +0000 +Subject: [PATCH] main/gcc : when building gcc-java on s390x, libgcj.so + complains about undefined reference to __data_start. Using + SEARCH_FOR_DATA_START instead solved it. Credit to Andrew Haley at RedHat. + +--- + boehm-gc/include/private/gcconfig.h | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/boehm-gc/include/private/gcconfig.h b/boehm-gc/include/private/gcconfig.h +index 4ca6a80..a15fff6 100644 +--- a/boehm-gc/include/private/gcconfig.h ++++ b/boehm-gc/include/private/gcconfig.h +@@ -1837,8 +1837,7 @@ + # define OS_TYPE "LINUX" + # define LINUX_STACKBOTTOM + # define DYNAMIC_LOADING +- extern int __data_start[]; +-# define DATASTART ((ptr_t)(__data_start)) ++# define SEARCH_FOR_DATA_START + extern int _end[]; + # define DATAEND (_end) + # define CACHE_LINE_SIZE 256 +-- +2.11.1 + diff --git a/aports/cross/gcc-x86_64/320-libffi-gnulinux.patch b/aports/cross/gcc-x86_64/320-libffi-gnulinux.patch new file mode 100644 index 00000000..b3b4fc93 --- /dev/null +++ b/aports/cross/gcc-x86_64/320-libffi-gnulinux.patch @@ -0,0 +1,13 @@ +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/aports/cross/gcc-x86_64/APKBUILD b/aports/cross/gcc-x86_64/APKBUILD new file mode 100644 index 00000000..ff383b76 --- /dev/null +++ b/aports/cross/gcc-x86_64/APKBUILD @@ -0,0 +1,718 @@ +# Automatically generated aport, do not edit! +# Generator: pmbootstrap aportgen gcc-x86_64 +# Based on: main/gcc + +CTARGET_ARCH=x86_64 +CTARGET="$(arch_to_hostspec ${CTARGET_ARCH})" +CBUILDROOT="/usr/$CTARGET" +LANG_OBJC=false +LANG_JAVA=false +LANG_GO=false +LANG_FORTRAN=false +LANG_ADA=false +options="!strip !tracedeps" + +# Wrap the package function, to make the resulting package +# lazy-reproducible +package() { + # Repack the *.a files to be reproducible (see #64) + _temp="$_builddir"/_reproducible-patch + cd "$_builddir" + for f in $(find -name '*.a'); do + # Copy to a temporary folder + echo "Repack $f to be reproducible" + mkdir -p "$_temp" + cd "$_temp" + cp "$_builddir"/"$f" . + + # Repack with a sorted file order + ar x *.a + rm *.a + ar r sorted.a $(find -name '*.o' | sort) + + # Copy back and clean up + cp -v sorted.a "$_builddir"/"$f" + cd .. + rm -r "$_temp" + done + + # Unmodified package function from the gcc APKBUILD + _package + + # Workaround for: postmarketOS/binary-package-repo#1 + echo "Replacing hardlinks with symlinks" + rm -v "$pkgdir"/usr/bin/"$CTARGET"-c++ + ln -s -v /usr/bin/"$CTARGET"-g++ "$pkgdir"/usr/bin/"$CTARGET"-c++ + rm -v "$pkgdir"/usr/bin/"$CTARGET"-gcc-"$pkgver" + ln -s -v /usr/bin/"$CTARGET"-gcc "$pkgdir"/usr/bin/"$CTARGET"-gcc-"$pkgver" +} + +pkgname="gcc-x86_64" +pkgver=6.4.0 +[ "$BOOTSTRAP" = "nolibc" ] && pkgname="gcc-pass2" +[ "$CBUILD" != "$CHOST" ] && _cross="-$CARCH" || _cross="" +[ "$CHOST" != "$CTARGET" ] && _target="-$CTARGET_ARCH" || _target="" + +pkgname="gcc-x86_64" +pkgrel=6 +pkgdesc="Stage2 cross-compiler for x86_64" +url="http://gcc.gnu.org" +arch="all" +license="GPL LGPL" +_gccrel=$pkgver-r$pkgrel +depends="isl binutils-x86_64" +makedepends_build="gcc g++ 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 musl-dev-x86_64 binutils-x86_64" +subpackages="g++-x86_64:gpp" +[ "$CHOST" = "$CTARGET" ] && subpackages="gcc-doc$_target" +replaces="libstdc++ binutils" + +: ${LANG_CXX:=true} +: ${LANG_OBJC:=true} +: ${LANG_JAVA:=true} +: ${LANG_GO:=true} +: ${LANG_FORTRAN:=true} +: ${LANG_ADA:=true} + +LIBGOMP="false" +LIBGCC="false" +LIBATOMIC="false" +LIBITM="false" + +if [ "$CHOST" != "$CTARGET" ]; then + if [ "$BOOTSTRAP" = nolibc ]; then + LANG_CXX=false + LANG_ADA=false + LIBGCC=false + _builddir="$srcdir/build-cross-pass2" + else + _builddir="$srcdir/build-cross-final" + fi + LANG_OBJC=false + LANG_JAVA=false + LANG_GO=false + LANG_FORTRAN=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 + # _FOR_xxx variants. wrap it in CFLAGS and CXXFLAGS. + export CFLAGS="$CPPFLAGS $CFLAGS" + export CXXFLAGS="$CPPFLAGS $CXXFLAGS" + unset CPPFLAGS + export CFLAGS_FOR_TARGET=" " + export CXXFLAGS_FOR_TARGET=" " + export LDFLAGS_FOR_TARGET=" " + + STRIP_FOR_TARGET="$CTARGET-strip" +elif [ "$CBUILD" != "$CHOST" ]; then + # fixup flags. seems gcc treats CPPFLAGS as global without + # _FOR_xxx variants. wrap it in CFLAGS and CXXFLAGS. + export CFLAGS="$CPPFLAGS $CFLAGS" + export CXXFLAGS="$CPPFLAGS $CXXFLAGS" + unset CPPFLAGS + + # reset flags and cc for build + export CC_FOR_BUILD="gcc" + export CXX_FOR_BUILD="g++" + export CFLAGS_FOR_BUILD=" " + export CXXFLAGS_FOR_BUILD=" " + export LDFLAGS_FOR_BUILD=" " + export CFLAGS_FOR_TARGET=" " + export CXXFLAGS_FOR_TARGET=" " + export LDFLAGS_FOR_TARGET=" " + + # Languages that do not need bootstrapping + LANG_OBJC=false + LANG_JAVA=false + LANG_GO=false + LANG_FORTRAN=false + + STRIP_FOR_TARGET=${CROSS_COMPILE}strip + _builddir="$srcdir/build-cross-native" +else + STRIP_FOR_TARGET=${CROSS_COMPILE}strip + _builddir="$srcdir/build" +fi + +# Go needs {set,make,swap}context, unimplemented in musl +[ "$CTARGET_LIBC" = musl ] && LANG_GO=false + +# libitm has TEXTRELs in ARM build, so disable for now +case "$CTARGET_ARCH" in +arm*) LIBITM=false ;; +mips*) LIBITM=false ;; +esac + +# Fortran uses libquadmath if toolchain has __float128 +# currently on x86, x86_64 and ia64 +LIBQUADMATH=$LANG_FORTRAN +case "$CTARGET_ARCH" in +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 + depends="$depends libgomp=$_gccrel" + subpackages="$subpackages libgomp::$CTARGET_ARCH" +fi + +_languages=c +if $LANG_CXX; then + _languages="$_languages,c++" +fi +if $LANG_OBJC; then + subpackages="$subpackages libobjc::$CTARGET_ARCH gcc-objc$_target:objc" + _languages="$_languages,objc" +fi +if $LANG_JAVA; then + subpackages="$subpackages libgcj::$CTARGET_ARCH gcc-java$_target:java" + _languages="$_languages,java" +fi +if $LANG_GO; then + subpackages="$subpackages libgo::$CTARGET_ARCH gcc-go$_target:go" + _languages="$_languages,go" +fi +if $LANG_FORTRAN; then + subpackages="$subpackages libgfortran::$CTARGET_ARCH gfortran$_target:gfortran" + _languages="$_languages,fortran" +fi +if $LANG_ADA; then + subpackages="$subpackages libgnat::$CTARGET_ARCH gcc-gnat$_target:gnat" + _languages="$_languages,ada" + makedepends_build="$makedepends_build gcc-gnat gcc-gnat$_cross" +fi +makedepends="$makedepends_build $makedepends_host" + +source="ftp://gcc.gnu.org/pub/gcc/releases/gcc-${_pkgbase:-$pkgver}/gcc-${_pkgbase:-$pkgver}.tar.xz + ftp://sourceware.org/pub/java/ecj-4.9.jar + + 001_all_default-ssp-strong.patch + 002_all_default-relro.patch + 003_all_default-fortify-source.patch + 005_all_default-as-needed.patch + 011_all_default-warn-format-security.patch + 012_all_default-warn-trampolines.patch + 020_all_msgfmt-libstdc++-link.patch + 050_all_libiberty-asprintf.patch + 051_all_libiberty-pic.patch + 053_all_libitm-no-fortify-source.patch + 067_all_gcc-poison-system-directories.patch + 090_all_pr55930-dependency-tracking.patch + + 201-cilkrts.patch + 203-libgcc_s.patch + 204-linux_libc_has_function.patch + 205-nopie.patch + 207-static-pie.patch + + libgcc-always-build-gcceh.a.patch + gcc-4.9-musl-fortify.patch + gcc-6.1-musl-libssp.patch + boehm-gc-musl.patch + gcc-pure64.patch + fix-gcj-stdgnu14-link.patch + fix-gcj-musl.patch + fix-gcj-iconv-musl.patch + + gcc-4.8-build-args.patch + fix-cxxflags-passing.patch + ada-fixes.patch + ada-shared.patch + ada-musl.patch + ada-aarch64-multiarch.patch + + 300-main-gcc-add-musl-s390x-dynamic-linker.patch + 310-build-gcj-s390x.patch + 320-libffi-gnulinux.patch + + fix-rs6000-pie.patch + fix-linux-header-use-in-libgcc.patch + gcc-pure64-mips.patch + ada-mips64.patch + " + +# we build out-of-tree +_gccdir="$srcdir"/gcc-${_pkgbase:-$pkgver} +_gcclibdir=/usr/lib/gcc/${CTARGET}/$pkgver +_gcclibexec=/usr/libexec/gcc/${CTARGET}/$pkgver + +prepare() { + cd "$_gccdir" + + _err= + for i in $source; do + case "$i" in + *.patch) + msg "Applying $i" + patch -p1 -F3 -i "$srcdir"/$i || _err="$_err $i" + ;; + esac + done + + if [ -n "$_err" ]; then + error "The following patches failed:" + for i in $_err; do + echo " $i" + done + return 1 + fi + + # see http://gcc.gnu.org/ml/java/2008-04/msg00027.html + mv "$srcdir"/ecj-*.jar ecj.jar + + echo ${pkgver} > gcc/BASE-VER +} + +build() { + local _arch_configure= + local _libc_configure= + local _cross_configure= + local _bootstrap_configure= + local _symvers= + + cd "$_gccdir" + + case "$CTARGET" in + aarch64-*-*-*) _arch_configure="--with-arch=armv8-a --with-abi=lp64";; + armv5-*-*-*eabi) _arch_configure="--with-arch=armv5te --with-tune=arm926ej-s --with-float=soft --with-abi=aapcs-linux";; + armv6-*-*-*eabihf) _arch_configure="--with-arch=armv6zk --with-tune=arm1176jzf-s --with-fpu=vfp --with-float=hard --with-abi=aapcs-linux";; + armv7-*-*-*eabihf) _arch_configure="--with-arch=armv7-a --with-tune=generic-armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-abi=aapcs-linux --with-mode=thumb";; + mips-*-*-*) _arch_configure="--with-arch=mips32 --with-mips-plt --with-float=soft --with-abi=32";; + mips64-*-*-*) _arch_configure="--with-arch=mips3 --with-tune=mips64 --with-mips-plt --with-float=soft --with-abi=64";; + mips64el-*-*-*) _arch_configure="--with-arch=mips3 --with-tune=mips64 --with-mips-plt --with-float=soft --with-abi=64";; + mipsel-*-*-*) _arch_configure="--with-arch=mips32 --with-mips-plt --with-float=soft --with-abi=32";; + powerpc-*-*-*) _arch_configure="--enable-secureplt --enable-decimal-float=no";; + powerpc64*-*-*-*) _arch_configure="--with-abi=elfv2 --enable-secureplt --enable-decimal-float=no --enable-targets=powerpcle-linux";; + 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";; + esac + + case "$CTARGET_ARCH" in + mips*) _hash_style_configure="--with-linker-hash-style=sysv" ;; + *) _hash_style_configure="--with-linker-hash-style=gnu" ;; + esac + + case "$CTARGET_LIBC" in + musl) + # musl does not support mudflap, or libsanitizer + # libmpx uses secure_getenv and struct _libc_fpstate not present in musl + # alpine musl provides libssp_nonshared.a, so we don't need libssp either + _libc_configure="--disable-libssp --disable-libmpx --disable-libmudflap --disable-libsanitizer" + _symvers="--disable-symvers" + export libat_cv_have_ifunc=no + ;; + esac + + [ "$CBUILD" != "$CHOST" ] && _cross_configure="--disable-bootstrap" + [ "$CHOST" != "$CTARGET" ] && _cross_configure="--disable-bootstrap --with-sysroot=$CBUILDROOT" + + case "$BOOTSTRAP" in + nolibc) _bootstrap_configure="--with-newlib --disable-shared --enable-threads=no" ;; + *) _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" + + msg "Building the following:" + echo "" + echo " CBUILD=$CBUILD" + echo " CHOST=$CHOST" + echo " CTARGET=$CTARGET" + echo " CTARGET_ARCH=$CTARGET_ARCH" + echo " CTARGET_LIBC=$CTARGET_LIBC" + echo " languages=$_languages" + echo " arch_configure=$_arch_configure" + echo " libc_configure=$_libc_configure" + echo " cross_configure=$_cross_configure" + echo " bootstrap_configure=$_bootstrap_configure" + echo " hash_style_configure=$_hash_style_configure" + echo "" + + mkdir -p "$_builddir" + cd "$_builddir" + "$_gccdir"/configure --prefix=/usr \ + --mandir=/usr/share/man \ + --infodir=/usr/share/info \ + --build=${CBUILD} \ + --host=${CHOST} \ + --target=${CTARGET} \ + --with-pkgversion="Alpine ${pkgver}" \ + --enable-checking=release \ + --disable-fixed-point \ + --disable-libstdcxx-pch \ + --disable-multilib \ + --disable-nls \ + --disable-werror \ + $_symvers \ + --enable-__cxa_atexit \ + --enable-default-pie \ + --enable-cloog-backend \ + --enable-languages=$_languages \ + $_arch_configure \ + $_libc_configure \ + $_cross_configure \ + $_bootstrap_configure \ + --with-system-zlib \ + $_hash_style_configure + make +} + +_package() { + cd "$_builddir" + 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 libgcj.a -o -name libgtkpeer.a \ + -o -name libgjsmalsa.a -o -name libgcj-tools.a \ + -o -name libjvm.a -o -name libgij.a -o -name libgcj_bc.a \ + -o -name libjavamath.a \ + | xargs rm -f + + # strip debug info from some static libs + ${STRIP_FOR_TARGET} -g `find "$pkgdir" \( -name libgfortran.a -o -name libobjc.a -o -name libgomp.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` + + if $LANG_JAVA; then + sed -i -e 's/lib: /&%{static:%eJava programs cannot be linked statically}/' \ + "$pkgdir"/usr/lib/libgcj.spec + fi + + if $LIBGOMP; then + mv "$pkgdir"/usr/lib/libgomp.spec "$pkgdir"/$_gcclibdir + fi + 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 + + 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 + + # move ada runtime libs + if $LANG_ADA; then + for i in $(find "$pkgdir"/$_gcclibdir/adalib/ -type f -maxdepth 1 -name "libgna*.so"); 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 + # 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 + if [ -h "$so" ]; then + local _real=$(basename $(readlink "$so")) + rm -f "$so" + echo "GROUP ($_real)" > "$so" + fi + done + else + # add c89/c99 wrapper scripts + cat >"$pkgdir"/usr/bin/c89 <&2 + exit 1;; + esac +done +exec gcc $fl ${1+"$@"} +EOF + cat >"$pkgdir"/usr/bin/c99 <<-EOF +#!/bin/sh +fl="-std=c99" +for opt; do + case "$opt" in + -std=c99|-std=iso9899:1999) fl="";; + -std=*) echo "`basename $0` called with non ISO C99 option $opt" >&2 + exit 1;; + esac +done +exec gcc $fl ${1+"$@"} +EOF + chmod 755 "$pkgdir"/usr/bin/c?9 + fi +} + +libatomic() { + pkgdesc="GCC Atomic library" + depends= + replaces="gcc" + + mkdir -p "$subpkgdir"/usr/lib + mv "$pkgdir"/usr/${_target:+$CTARGET/}lib/libatomic.so.* "$subpkgdir"/usr/lib/ +} + +libcxx() { + pkgdesc="GNU C++ standard runtime library" + depends= + + mkdir -p "$subpkgdir"/usr/lib + mv "$pkgdir"/usr/${_target:+$CTARGET/}lib/libstdc++.so.* "$subpkgdir"/usr/lib/ +} + +gpp() { + pkgdesc="GNU C++ standard library and compiler" + depends="libstdc++=$_gccrel gcc=$_gccrel libc-dev" + mkdir -p "$subpkgdir/$_gcclibexec" \ + "$subpkgdir"/usr/bin \ + "$subpkgdir"/usr/${_target:+$CTARGET/}include \ + "$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/ +} + +libobjc() { + pkgdesc="GNU Objective-C runtime" + replaces="objc" + depends= + mkdir -p "$subpkgdir"/usr/lib + mv "$pkgdir"/usr/${_target:+$CTARGET/}lib/libobjc.so.* "$subpkgdir"/usr/lib/ +} + +objc() { + pkgdesc="GNU Objective-C" + replaces="gcc" + depends="libc-dev gcc=$_gccrel libobjc=$_gccrel" + + mkdir -p "$subpkgdir"/$_gcclibdir/include \ + "$subpkgdir"/usr/lib + mv "$pkgdir"/$_gcclibdir/include/objc "$subpkgdir"/$_gcclibdir/include/ + mv "$pkgdir"/usr/lib/libobjc.so "$pkgdir"/usr/lib/libobjc.a \ + "$subpkgdir"/usr/lib/ +} + +libgcc() { + pkgdesc="GNU C compiler runtime libraries" + depends= + + mkdir -p "$subpkgdir"/usr/lib + mv "$pkgdir"/usr/${_target:+$CTARGET/}lib/libgcc_s.so.* "$subpkgdir"/usr/lib/ +} + +libgomp() { + pkgdesc="GCC shared-memory parallel programming API library" + depends= + replaces="gcc" + + mkdir -p "$subpkgdir"/usr/lib + mv "$pkgdir"/usr/${_target:+$CTARGET/}lib/libgomp.so.* "$subpkgdir"/usr/lib/ +} + +java() { + pkgdesc="Java support for GCC" + depends="zlib-dev gcc=$_gccrel libgcj=$_gccrel" + + paxmark -pm "$pkgdir"/$_gcclibexec/ecj1 + mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/usr/lib "$subpkgdir"/$_gcclibdir/ + cd "$pkgdir"/usr/bin + mv gcj gcj-dbtool gjavah gcjh jcf-dump "$subpkgdir"/usr/bin/ + cd "$pkgdir" + for i in $(find usr/ -name ecj1 -o -name jc1 -o -name jvgenmain); do + mkdir -p "$subpkgdir"/${i%/*} + mv "$pkgdir"/$i "$subpkgdir"/$i + done + for i in "$pkgdir"/usr/lib/libgcj*.so; do + if [ -L "$i" ]; then + mv "$i" "$subpkgdir"/usr/lib/ + fi + done + mv "$pkgdir"/usr/lib/libgij.so "$subpkgdir"/usr/lib/ + mv "$pkgdir"/usr/lib/libgcj.spec "$subpkgdir"/$_gcclibdir/ +} + +libgcj() { + pkgdesc="Java runtime library for gcc" + # libgcj_bc.so moved from gcc-java to libgcj + replaces="gcc-java" + depends= + + mkdir -p "$subpkgdir"/usr/bin + cd "$pkgdir"/usr/bin + paxmark -pmse "$pkgdir"/usr/bin/gij + mv aot-compile gappletviewer gc-analyze gij gjar gjarsigner gkeytool\ + gnative2ascii gorbd grmic grmid grmiregistry gserialver \ + gtnameserv jv-convert rebuild-gcj-db \ + "$subpkgdir"/usr/bin/ + cd "$pkgdir" + for i in $(find usr/lib -name jc1 -o -name jvgenmain); do + mkdir -p "$subpkgdir"/${i%/*} + mv "$pkgdir"/$i "$subpkgdir"/$i + done + mkdir -p "$subpkgdir"/usr/lib + mv "$pkgdir"/usr/lib/gcj-* \ + "$pkgdir"/usr/lib/libgcj_bc.so \ + "$pkgdir"/usr/lib/libgcj*.so.* \ + "$pkgdir"/usr/lib/libgij.so.* \ + "$pkgdir"/usr/lib/logging.properties \ + "$pkgdir"/usr/lib/security \ + "$subpkgdir"/usr/lib/ + + mkdir -p "$subpkgdir"/usr/share/ + mv "$pkgdir"/usr/share/java "$subpkgdir"/usr/share/ +} + +libgo() { + pkgdesc="Go runtime library for GCC" + depends= + + mkdir -p "$subpkgdir"/usr/lib + mv "$pkgdir"/usr/lib/libgo.so.* "$subpkgdir"/usr/lib/ +} + +go() { + pkgdesc="Go support for GCC" + depends="gcc=$_gccrel libgo=$_gccrel" + + 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"/$_gcclibexec/go1 "$subpkgdir"/$_gcclibexec/ + mv "$pkgdir"/usr/lib/libgo.a \ + "$pkgdir"/usr/lib/libgo.so \ + "$pkgdir"/usr/lib/libgobegin.a \ + "$subpkgdir"/usr/lib/ +} + +libgfortran() { + pkgdesc="Fortran runtime library for GCC" + depends= + + mkdir -p "$subpkgdir"/usr/lib + mv "$pkgdir"/usr/lib/libgfortran.so.* "$subpkgdir"/usr/lib/ +} + +libquadmath() { + replaces="gcc" + pkgdesc="128-bit math library for GCC" + depends= + + mkdir -p "$subpkgdir"/usr/lib + mv "$pkgdir"/usr/lib/libquadmath.so.* "$subpkgdir"/usr/lib/ +} + +gfortran() { + pkgdesc="GNU Fortran Compiler" + depends="gcc=$_gccrel libgfortran=$_gccrel" + $LIBQUADMATH && depends="$depends libquadmath=$_gccrel" + replaces="gcc" + + mkdir -p "$subpkgdir"/$_gcclibexec \ + "$subpkgdir"/$_gcclibdir \ + "$subpkgdir"/usr/lib \ + "$subpkgdir"/usr/bin + mv "$pkgdir"/usr/bin/*gfortran "$subpkgdir"/usr/bin/ + mv "$pkgdir"/usr/lib/libgfortran.a \ + "$pkgdir"/usr/lib/libgfortran.so \ + "$subpkgdir"/usr/lib/ + if $LIBQUADMATH; then + mv "$pkgdir"/usr/lib/libquadmath.a \ + "$pkgdir"/usr/lib/libquadmath.so \ + "$subpkgdir"/usr/lib/ + fi + mv "$pkgdir"/$_gcclibexec/f951 "$subpkgdir"/$_gcclibexec + mv "$pkgdir"/usr/lib/libgfortran.spec "$subpkgdir"/$_gcclibdir +} + +libgnat() { + pkgdesc="GNU Ada runtime shared libraries" + depends= + + mkdir -p "$subpkgdir"/usr/lib + mv "$pkgdir"/usr/lib/libgna*.so "$subpkgdir"/usr/lib/ +} + +gnat() { + pkgdesc="Ada support for GCC" + depends="gcc=$_gccrel" + [ "$CHOST" = "$CTARGET" ] && depends="$depends libgnat=$_gccrel" + + mkdir -p "$subpkgdir"/$_gcclibexec \ + "$subpkgdir"/$_gcclibdir \ + "$subpkgdir"/usr/bin + mv "$pkgdir"/$_gcclibexec/*gnat* "$subpkgdir"/$_gcclibexec/ + mv "$pkgdir"/$_gcclibdir/*ada* "$subpkgdir"/$_gcclibdir/ + mv "$pkgdir"/usr/bin/*gnat* "$subpkgdir"/usr/bin/ +} + +sha512sums="02c60e54527c7adf584798d5251f8a0b80c93d5deafce82501b2c28e6692e0bd783927bbfc4bc527a863c0cccc025150a34740a9e29badb02d4b48e56a8aba90 gcc-6.4.0.tar.xz +28f8c6fdbcb19e950b1d0bafb3bcc7a8cba87bc673aa6027cece116599cdee80f0cf5e95a1440544890239f5c754e8a93ab46d9daedd937faef445d7ea33b226 ecj-4.9.jar +a1335adc2fbee98e36c4437ff2587771b98ed4180726779020f65039498235626a411cdb0100dbd20cd19d12f0d94f9a21af179ff624676c28cead9d60598b5d 001_all_default-ssp-strong.patch +e36e95b81489163abd6fe9d58f7867bdca43e61143afacbfb17f4698c0b16ec5fd0061d8fab7b2ae615540bebd721c2e2227f80401b4e7fc253da9da62e6b513 002_all_default-relro.patch +f86466c62b8291fac46f9c250c7ad8fa5ab7b1cce2504442fd07ddc4543665b317ae28951f244e39aba29aeaf3fff252ec4f6a147aa16adb2b7aed747dd89188 003_all_default-fortify-source.patch +51282fea54c7e616367bbeb2479ba13fec6f24eb47bd04e2071907b3b36273b2ff24676f46ef8d22f241c8ab4857307861eee076eab66797c3a50a8ecaa1809a 005_all_default-as-needed.patch +3398386dd1e079d6545dd9799adc799c6b80e3984fac6899d0e1a7ee21b66d0c7e53cddf17a65d590c883db750f9f79aaedd857355a8b9f7fb9476c906237919 011_all_default-warn-format-security.patch +9adb0d2b9b67dd957df6c609b8714c7c078efb52cd88770905c37c67827be8fc83d1125037b9c29d77db21ce78756aa2bb0bacdb0b98d869ac126da76a298e21 012_all_default-warn-trampolines.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 +e87da18aa7ab92b02b06168658c63b42a6c73a08fad2a30f81ef6296100fdbe3c3a91548fd0cb24eaf591e862bb08e4b67249bc4b977b07da33523aee0c686bc 067_all_gcc-poison-system-directories.patch +4a328d1e1a56c20166307edcfa322068915784d9c08025b7f81cf69714da48fc266b6d34f77b9135c2f10da830d9df408276a1b78d1fd218637c2823506593c2 090_all_pr55930-dependency-tracking.patch +ef052d0c3c9642fcb5ed570069c5a49c8ef523c47ac8ce3f201a801766f72ae4ff7c3725a70ee66e52c0fb559621e35fe0cf5b88b901d71ceadd381f49653a08 201-cilkrts.patch +808e206f5e107084156fba333d4e091dcbd62f5d7756142bc292d4b0a52619f8c2aaca3617defc2f5b6552ba0439aebd33f4141329d88eab6ddf2dd637d92c08 203-libgcc_s.patch +fc0de05b36613b732a0222ea005c90653c6a40d6761b6894af2419272f4e74875f37e26af33a9b9940669ef89269c44c46d17ca5bcd54b5cd1176e5eaf2992c1 204-linux_libc_has_function.patch +98473bcaa77903a223ca9b0d2087c0921b287a2816d308cc32c8fe009e6cbf5dd1ae7fba27794ab8d9c09e117fe534413d91a464d1218474fc123ce0adfdc2c1 205-nopie.patch +3287d5b443bea8ec64132bcabe869c738ae98ea8f1a86df1c5d18c927f8816edbfcefeefc47792dbbb2bcacf50319af00e01b3735d34525913b64350770ad453 207-static-pie.patch +d08d7ead2de0429e5c9055d5b029ec2be9a8c821d22cecaf9b51f633652c493333f98963d9267fa2fa63850c50ae5eefd5f59e5910ec10d20044dac082182a8b libgcc-always-build-gcceh.a.patch +600fe5098dc54edaa9808fd5717af9dec058953f9ad37d49cfba1db4f7e9a7a8f02019342f75157fc575946fa693259422184de27b7ecc8386d9f3ecc0f7cc5d gcc-4.9-musl-fortify.patch +dbe0ee917fc7668571722364ab7c806731e3a31e8bfa30b4941b28b16b877d2a32b4a3897ef533399a28f82d43cac9b28e92de0493f0e779046db56584e07fa4 gcc-6.1-musl-libssp.patch +bda845a6aa1854d2c883910b115f79ccfa93dfc2b5eac69a3a236d83eb34cadc140731d616ffc24698c7abc8878dd15f231bcc5119f1860e575a120b311706c7 boehm-gc-musl.patch +fa62556719449caec6b2b434355bfbcaa5ae55ffe017b3e1f827f66a2aae21b79c571ee7a4ce723ea69169bc3a6447e73650991a200cc372adf2f102677518d7 gcc-pure64.patch +2253941f3d19b6d08801d3782f5f5ed56c3b73fbc9d3561a8f01c702963ac4fab91599c686076e7081eb6a80c37ccd33591ae978996d6eee1dc0ce0f1c50259a fix-gcj-stdgnu14-link.patch +f89ddeb21bc8f97e6a850a6b70b4501a8f3e49a4bc8cc82897488decda5d98ad01cb7f6c8b392d452e9579924a523bc75da6e0648c1c976d42e40af48b10343b fix-gcj-musl.patch +54d67cc008b735e47771314171930c5d8b8f5f5dc97fcf4214824c105c808f3e75d22d5a4fdf5068ed0457fa0d46c60cfb442e276259a4a5e9b8722a027d18e6 fix-gcj-iconv-musl.patch +abe9aaf9aa956058d0386a4396a511d176a46bb3906b90e952383646cdc158cbeb0a5dc616a1ccb1ca7d49fd0b5e351532aa15a3b13362abbf1ca4266f54a687 gcc-4.8-build-args.patch +35d6d59f0b7b968f282f56767c9e0823a7bdc5aa0d450aca50fbd802649a7ca608b47671244a3faa208a9b0d6832cabb5a22724157dc817b2c0ad63d09f93282 fix-cxxflags-passing.patch +9016b257abd8fa981de44a49512e35db814d1cbb47c1a87cd31c12d4ae20b13e9e149fe41691a7ec3c95bbcfde8a79194a8d2eaf547ceade3a246fad67c47dd8 ada-fixes.patch +3f5bc334d9f73d06f5f7c876738d02356acdd08958bea0e4d2095ebf15c2c2ec4e411abdae0297505ae9a1699ca01b17338e853184e84663203b192b0d35fc19 ada-shared.patch +631d4bdef6d8bde34df7978bb53ec28c3c909cf1f87139e5f148138d0f09adc58b41ecf0148bbf50fb4bc916c411e9bf8a2b6c046c75c0e77d754d8c35bcd4d7 ada-musl.patch +fa44c8158111627aa0e91c43e7cc3aa38642c2041c96532dd4f0932dae4d6f92ea2850b683abcf10e7e120299d42ea6b69adc00002a514c76be8e39e99fa052b ada-aarch64-multiarch.patch +4b4a0ff306a8ef34ff6e3284fbfca869012164a47ba7cb099085c1dd03e6ca0cdd462f82710e08c9a02895adc7484e4c5eef17b5aa264cf5d978fe8ad78eea93 300-main-gcc-add-musl-s390x-dynamic-linker.patch +385bc2fa50204f678964e5148c6170f572701dab920fbec8301f505bda34d182cde0adb7da042fee71719e12fb59f59181897f9b1bb4f4716ff59aad46ca1998 310-build-gcj-s390x.patch +f4ef08454e28c8732db69115e4998ec153399e8d229dd27f923dbdcf57b68128a65640d026cc7f45b58ba8764ab1eb575d4eb6d6dfc550a87a183f8b94e76181 320-libffi-gnulinux.patch +01c71cd5881fc07ea3b9b980697e89b3ca0fe98502958ceafc3fca18b2604c844e2f457feab711baf8e03f00a5383b0e38aac7eb954034e306f43d4a37f165ed fix-rs6000-pie.patch +34a818d5be67eb1f34e44a80b83c28a9b9c17d37fc9fac639f490d6bb5b53ebe3318140d09c236a17d7c98f5a7792ae3d6cefccda8067a5e942d6305b9d1f87c fix-linux-header-use-in-libgcc.patch +86be3338cc9c33089608bc4c5e3b7918c4e500a345c338f361b18c342119a6ed69af5495d72950de7106d760f003528b46ad14795e805f8a3331e206dcb234e3 gcc-pure64-mips.patch +508f3bca214d88531d739d761d07affc953689b1540905c73420b34c246e1e6b72588cf89f0e1462752633f8ddc88da8c0238be2a1b6e1c213829cecee7924cf ada-mips64.patch" diff --git a/aports/cross/gcc-x86_64/ada-aarch64-multiarch.patch b/aports/cross/gcc-x86_64/ada-aarch64-multiarch.patch new file mode 100644 index 00000000..ac60b6f6 --- /dev/null +++ b/aports/cross/gcc-x86_64/ada-aarch64-multiarch.patch @@ -0,0 +1,16 @@ +--- gcc-6.4.0/gcc/ada/gcc-interface/Makefile.in.orig ++++ gcc-6.4.0/gcc/ada/gcc-interface/Makefile.in +@@ -2042,13 +2042,8 @@ + system.ads + #else + #include ++#include + #endif + + #ifdef __MINGW32__ +--- gcc-6.1.0.orig/gcc/ada/terminals.c ++++ gcc-6.1.0/gcc/ada/terminals.c +@@ -1068,13 +1068,6 @@ + #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__) +-# include +-#endif +- + #include + #include + #include +@@ -1169,7 +1162,7 @@ + char *slave_name = NULL; + + #ifdef USE_GETPT +- master_fd = getpt (); ++ master_fd = posix_openpt (O_RDWR); + #elif defined (USE_OPENPTY) + status = openpty (&master_fd, &slave_fd, NULL, NULL, NULL); + #elif defined (USE_CLONE_DEVICE) diff --git a/aports/cross/gcc-x86_64/ada-mips64.patch b/aports/cross/gcc-x86_64/ada-mips64.patch new file mode 100644 index 00000000..b7cd3deb --- /dev/null +++ b/aports/cross/gcc-x86_64/ada-mips64.patch @@ -0,0 +1,224 @@ +From 5bbd6ca3755e2a199de98d2b270d8a6f616aa6a6 Mon Sep 17 00:00:00 2001 +From: Nils Andreas Svee +Date: Thu, 21 Dec 2017 16:46:12 +0100 +Subject: [PATCH] ada-mips64 + +--- + gcc/ada/gcc-interface/Makefile.in | 29 ++++++-- + gcc/ada/system-linux-mips64.ads | 147 ++++++++++++++++++++++++++++++++++++++ + 2 files changed, 171 insertions(+), 5 deletions(-) + create mode 100644 gcc/ada/system-linux-mips64.ads + +diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in +index 598b262d9..1844a6962 100644 +--- a/gcc/ada/gcc-interface/Makefile.in ++++ b/gcc/ada/gcc-interface/Makefile.in +@@ -1854,9 +1854,9 @@ ifeq ($(strip $(filter-out cygwin% mingw32% pe,$(target_os))),) + LIBRARY_VERSION := $(LIB_VERSION) + endif + +-# Mips Linux +-ifeq ($(strip $(filter-out mips linux%,$(target_cpu) $(target_os))),) +- LIBGNAT_TARGET_PAIRS = \ ++# Mips and Mips64 Linux ++ifeq ($(strip $(filter-out mips mips64 linux%,$(target_cpu) $(target_os))),) ++ LIBGNAT_TARGET_PAIRS_COMMON = \ + a-intnam.ads. -- ++-- -- ++-- GNAT was originally developed by the GNAT team at New York University. -- ++-- Extensive contributions were provided by Ada Core Technologies Inc. -- ++-- -- ++------------------------------------------------------------------------------ ++ ++package System is ++ pragma Pure; ++ -- Note that we take advantage of the implementation permission to make ++ -- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada ++ -- 2005, this is Pure in any case (AI-362). ++ ++ pragma No_Elaboration_Code_All; ++ -- Allow the use of that restriction in units that WITH this unit ++ ++ type Name is (SYSTEM_NAME_GNAT); ++ System_Name : constant Name := SYSTEM_NAME_GNAT; ++ ++ -- System-Dependent Named Numbers ++ ++ Min_Int : constant := Long_Long_Integer'First; ++ Max_Int : constant := Long_Long_Integer'Last; ++ ++ Max_Binary_Modulus : constant := 2 ** Long_Long_Integer'Size; ++ Max_Nonbinary_Modulus : constant := Integer'Last; ++ ++ Max_Base_Digits : constant := Long_Long_Float'Digits; ++ Max_Digits : constant := Long_Long_Float'Digits; ++ ++ Max_Mantissa : constant := 63; ++ Fine_Delta : constant := 2.0 ** (-Max_Mantissa); ++ ++ Tick : constant := 0.000_001; ++ ++ -- Storage-related Declarations ++ ++ type Address is private; ++ pragma Preelaborable_Initialization (Address); ++ Null_Address : constant Address; ++ ++ Storage_Unit : constant := 8; ++ Word_Size : constant := 64; ++ Memory_Size : constant := 2 ** 64; ++ ++ -- Address comparison ++ ++ function "<" (Left, Right : Address) return Boolean; ++ function "<=" (Left, Right : Address) return Boolean; ++ function ">" (Left, Right : Address) return Boolean; ++ function ">=" (Left, Right : Address) return Boolean; ++ function "=" (Left, Right : Address) return Boolean; ++ ++ pragma Import (Intrinsic, "<"); ++ pragma Import (Intrinsic, "<="); ++ pragma Import (Intrinsic, ">"); ++ pragma Import (Intrinsic, ">="); ++ pragma Import (Intrinsic, "="); ++ ++ -- Other System-Dependent Declarations ++ ++ type Bit_Order is (High_Order_First, Low_Order_First); ++ Default_Bit_Order : constant Bit_Order := High_Order_First; ++ pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning ++ ++ -- Priority-related Declarations (RM D.1) ++ ++ Max_Priority : constant Positive := 30; ++ Max_Interrupt_Priority : constant Positive := 31; ++ ++ subtype Any_Priority is Integer range 0 .. 31; ++ subtype Priority is Any_Priority range 0 .. 30; ++ subtype Interrupt_Priority is Any_Priority range 31 .. 31; ++ ++ Default_Priority : constant Priority := 15; ++ ++private ++ ++ type Address is mod Memory_Size; ++ Null_Address : constant Address := 0; ++ ++ -------------------------------------- ++ -- System Implementation Parameters -- ++ -------------------------------------- ++ ++ -- These parameters provide information about the target that is used ++ -- by the compiler. They are in the private part of System, where they ++ -- can be accessed using the special circuitry in the Targparm unit ++ -- whose source should be consulted for more detailed descriptions ++ -- of the individual switch values. ++ ++ Backend_Divide_Checks : constant Boolean := False; ++ Backend_Overflow_Checks : constant Boolean := True; ++ Command_Line_Args : constant Boolean := True; ++ Configurable_Run_Time : constant Boolean := False; ++ Denorm : constant Boolean := True; ++ Duration_32_Bits : constant Boolean := False; ++ Exit_Status_Supported : constant Boolean := True; ++ Fractional_Fixed_Ops : constant Boolean := False; ++ Frontend_Layout : constant Boolean := False; ++ Machine_Overflows : constant Boolean := False; ++ Machine_Rounds : constant Boolean := True; ++ Preallocated_Stacks : constant Boolean := False; ++ Signed_Zeros : constant Boolean := True; ++ Stack_Check_Default : constant Boolean := False; ++ Stack_Check_Probes : constant Boolean := True; ++ Stack_Check_Limits : constant Boolean := False; ++ Support_Aggregates : constant Boolean := True; ++ Support_Composite_Assign : constant Boolean := True; ++ Support_Composite_Compare : constant Boolean := True; ++ Support_Long_Shifts : constant Boolean := True; ++ Always_Compatible_Rep : constant Boolean := False; ++ Suppress_Standard_Library : constant Boolean := False; ++ Use_Ada_Main_Program_Name : constant Boolean := False; ++ Frontend_Exceptions : constant Boolean := False; ++ ZCX_By_Default : constant Boolean := True; ++ ++end System; +-- +2.15.1 + diff --git a/aports/cross/gcc-x86_64/ada-musl.patch b/aports/cross/gcc-x86_64/ada-musl.patch new file mode 100644 index 00000000..464c3d57 --- /dev/null +++ b/aports/cross/gcc-x86_64/ada-musl.patch @@ -0,0 +1,137 @@ +diff -rup gcc-5.1.0/gcc.orig/ada/adaint.c gcc-5.1.0/gcc/ada/adaint.c +--- gcc-5.1.0/gcc.orig/ada/adaint.c 2015-02-20 11:48:57.000000000 +0000 ++++ gcc-5.1.0/gcc/ada/adaint.c 2015-06-02 10:47:51.672767476 +0000 +@@ -70,6 +70,11 @@ + #include + #include + #endif ++ ++#if defined (linux) ++#define _GNU_SOURCE 1 ++#include ++#endif + + #ifdef __PikeOS__ + #define __BSD_VISIBLE 1 +@@ -3057,8 +3062,6 @@ __gnat_lwp_self (void) + return (void *) syscall (__NR_gettid); + } + +-#include +- + /* glibc versions earlier than 2.7 do not define the routines to handle + dynamically allocated CPU sets. For these targets, we use the static + versions. */ +@@ -3067,7 +3070,7 @@ __gnat_lwp_self (void) + + /* Dynamic cpu sets */ + +-cpu_set_t * ++void * + __gnat_cpu_alloc (size_t count) + { + return CPU_ALLOC (count); +@@ -3080,33 +3083,33 @@ __gnat_cpu_alloc_size (size_t count) + } + + void +-__gnat_cpu_free (cpu_set_t *set) ++__gnat_cpu_free (void *set) + { +- CPU_FREE (set); ++ CPU_FREE ((cpu_set_t *) set); + } + + void +-__gnat_cpu_zero (size_t count, cpu_set_t *set) ++__gnat_cpu_zero (size_t count, void *set) + { +- CPU_ZERO_S (count, set); ++ CPU_ZERO_S (count, (cpu_set_t *) set); + } + + void +-__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set) ++__gnat_cpu_set (int cpu, size_t count, void *set) + { + /* Ada handles CPU numbers starting from 1, while C identifies the first + CPU by a 0, so we need to adjust. */ +- CPU_SET_S (cpu - 1, count, set); ++ CPU_SET_S (cpu - 1, count, (cpu_set_t *) set); + } + + #else /* !CPU_ALLOC */ + + /* Static cpu sets */ + +-cpu_set_t * ++void * + __gnat_cpu_alloc (size_t count ATTRIBUTE_UNUSED) + { +- return (cpu_set_t *) xmalloc (sizeof (cpu_set_t)); ++ return xmalloc (sizeof (cpu_set_t)); + } + + size_t +@@ -3116,23 +3119,23 @@ __gnat_cpu_alloc_size (size_t count ATTR + } + + void +-__gnat_cpu_free (cpu_set_t *set) ++__gnat_cpu_free (void *set) + { + free (set); + } + + void +-__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, cpu_set_t *set) ++__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, void *set) + { +- CPU_ZERO (set); ++ CPU_ZERO ((cpu_set_t *) set); + } + + void +-__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set) ++__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, void *set) + { + /* Ada handles CPU numbers starting from 1, while C identifies the first + CPU by a 0, so we need to adjust. */ +- CPU_SET (cpu - 1, set); ++ CPU_SET (cpu - 1, (cpu_set_t *) set); + } + #endif /* !CPU_ALLOC */ + #endif /* linux */ +diff -rup gcc-5.1.0/gcc.orig/ada/adaint.h gcc-5.1.0/gcc/ada/adaint.h +--- gcc-5.1.0/gcc.orig/ada/adaint.h 2015-01-27 17:20:27.000000000 +0000 ++++ gcc-5.1.0/gcc/ada/adaint.h 2015-06-02 10:47:23.188910894 +0000 +@@ -287,13 +287,11 @@ extern void *__gnat_lwp_self (voi + + /* Routines for interface to required CPU set primitives */ + +-#include +- +-extern cpu_set_t *__gnat_cpu_alloc (size_t); ++extern void * __gnat_cpu_alloc (size_t); + extern size_t __gnat_cpu_alloc_size (size_t); +-extern void __gnat_cpu_free (cpu_set_t *); +-extern void __gnat_cpu_zero (size_t, cpu_set_t *); +-extern void __gnat_cpu_set (int, size_t, cpu_set_t *); ++extern void __gnat_cpu_free (void *); ++extern void __gnat_cpu_zero (size_t, void *); ++extern void __gnat_cpu_set (int, size_t, void *); + #endif + + #if defined (_WIN32) +diff -rup gcc-5.1.0/gcc.orig/ada/gcc-interface/Makefile.in gcc-5.1.0/gcc/ada/gcc-interface/Makefile.in +--- gcc-5.1.0/gcc.orig/ada/gcc-interface/Makefile.in 2015-04-09 20:29:28.000000000 +0000 ++++ gcc-5.1.0/gcc/ada/gcc-interface/Makefile.in 2015-06-02 10:47:23.188910894 +0000 +@@ -1910,7 +1910,7 @@ ifeq ($(strip $(filter-out powerpc% linu + endif + + # ARM linux, GNU eabi +-ifeq ($(strip $(filter-out arm% linux-gnueabi%,$(target_cpu) $(target_os))),) ++ifeq ($(strip $(filter-out arm% linux-gnueabi% linux-musleabi% linux-muslgnueabi%,$(target_cpu) $(target_os))),) + LIBGNAT_TARGET_PAIRS = \ + a-intnam.ads + # undef __KERNEL__ +-# else ++# elif defined(__GLIBC__) + /* Kernels prior to 2.1.1 defined struct sigcontext_struct instead of */ + /* struct sigcontext. libc6 (glibc2) uses "struct sigcontext" in */ + /* prototypes, so we have to include the top-level sigcontext.h to */ +--- gcc-4.8.2/boehm-gc/dyn_load.c.orig 2014-02-17 14:13:09.519850231 +0200 ++++ gcc-4.8.2/boehm-gc/dyn_load.c 2014-02-17 14:14:27.906093514 +0200 +@@ -459,9 +459,7 @@ + /* For glibc 2.2.4+. Unfortunately, it doesn't work for older */ + /* versions. Thanks to Jakub Jelinek for most of the code. */ + +-# if (defined(LINUX) || defined (__GLIBC__)) /* Are others OK here, too? */ \ +- && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \ +- || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG))) ++# if (defined(LINUX) || defined (__GLIBC__)) + + /* We have the header files for a glibc that includes dl_iterate_phdr. */ + /* It may still not be available in the library on the target system. */ +--- gcc-4.8.2/boehm-gc/include/private/gcconfig.h.orig 2014-02-17 14:14:36.026049422 +0200 ++++ gcc-4.8.2/boehm-gc/include/private/gcconfig.h 2014-02-17 14:17:11.345207887 +0200 +@@ -684,7 +684,7 @@ + # ifdef __ELF__ + # define DYNAMIC_LOADING + # include +-# if defined(__GLIBC__)&& __GLIBC__>=2 ++# if 1 + # define SEARCH_FOR_DATA_START + # else /* !GLIBC2 */ + extern char **__environ; +@@ -1147,7 +1147,7 @@ + # define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff)) + # endif + # include +-# if defined(__GLIBC__) && __GLIBC__ >= 2 ++# if 1 + # define SEARCH_FOR_DATA_START + # else + extern char **__environ; +@@ -1367,7 +1367,7 @@ + # define HBLKSIZE 4096 + # endif + # define USE_GENERIC_PUSH_REGS +-# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 2 || __GLIBC__ > 2 ++# if 1 + # define LINUX_STACKBOTTOM + # else + # define STACKBOTTOM 0x80000000 +@@ -1858,7 +1858,7 @@ + # ifdef __ELF__ + # define DYNAMIC_LOADING + # include +-# if defined(__GLIBC__) && __GLIBC__ >= 2 ++# if 1 + # define SEARCH_FOR_DATA_START + # else + extern char **__environ; diff --git a/aports/cross/gcc-x86_64/fix-cxxflags-passing.patch b/aports/cross/gcc-x86_64/fix-cxxflags-passing.patch new file mode 100644 index 00000000..8eb1de77 --- /dev/null +++ b/aports/cross/gcc-x86_64/fix-cxxflags-passing.patch @@ -0,0 +1,10 @@ +--- 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/aports/cross/gcc-x86_64/fix-gcj-iconv-musl.patch b/aports/cross/gcc-x86_64/fix-gcj-iconv-musl.patch new file mode 100644 index 00000000..b0015751 --- /dev/null +++ b/aports/cross/gcc-x86_64/fix-gcj-iconv-musl.patch @@ -0,0 +1,120 @@ +--- gcc-4.8.2/libjava/gnu/gcj/convert/natIconv.cc.orig 2014-02-18 18:46:14.897880526 +0200 ++++ gcc-4.8.2/libjava/gnu/gcj/convert/natIconv.cc 2014-02-18 18:50:08.766613550 +0200 +@@ -24,6 +24,13 @@ + + #ifdef HAVE_ICONV + #include ++#include ++ ++#if __BYTE_ORDER == __BIG_ENDIAN ++#define UCS2_CHARSET "UCS-2BE" ++#else ++#define UCS2_CHARSET "UCS-2LE" ++#endif + + template + static inline size_t +@@ -45,7 +52,7 @@ + _Jv_GetStringUTFRegion (encoding, 0, encoding->length(), buffer); + buffer[len] = '\0'; + +- iconv_t h = iconv_open ("UCS-2", buffer); ++ iconv_t h = iconv_open (UCS2_CHARSET, buffer); + if (h == (iconv_t) -1) + throw new ::java::io::UnsupportedEncodingException (encoding); + +@@ -99,18 +106,6 @@ + throw new ::java::io::CharConversionException (); + } + +- if (iconv_byte_swap) +- { +- size_t max = (old_out - outavail) / sizeof (jchar); +- for (size_t i = 0; i < max; ++i) +- { +- // Byte swap. +- jchar c = (((out[outpos + i] & 0xff) << 8) +- | ((out[outpos + i] >> 8) & 0xff)); +- outbuf[i] = c; +- } +- } +- + inpos += old_in - inavail; + return (old_out - outavail) / sizeof (jchar); + #else /* HAVE_ICONV */ +@@ -145,7 +140,7 @@ + _Jv_GetStringUTFRegion (encoding, 0, encoding->length(), buffer); + buffer[len] = '\0'; + +- iconv_t h = iconv_open (buffer, "UCS-2"); ++ iconv_t h = iconv_open (buffer, UCS2_CHARSET); + if (h == (iconv_t) -1) + throw new ::java::io::UnsupportedEncodingException (encoding); + +@@ -187,20 +182,6 @@ + char *inbuf = (char *) &chars[inpos]; + char *outbuf = (char *) &out[count]; + +- if (iconv_byte_swap) +- { +- // Ugly performance penalty -- don't use losing systems! +- temp_buffer = (jchar *) _Jv_Malloc (inlength * sizeof (jchar)); +- for (int i = 0; i < inlength; ++i) +- { +- // Byte swap. +- jchar c = (((chars[inpos + i] & 0xff) << 8) +- | ((chars[inpos + i] >> 8) & 0xff)); +- temp_buffer[i] = c; +- } +- inbuf = (char *) temp_buffer; +- } +- + size_t loop_old_in = old_in; + while (1) + { +@@ -252,44 +233,7 @@ + jboolean + gnu::gcj::convert::IOConverter::iconv_init (void) + { +- // Some versions of iconv() always return their UCS-2 results in +- // big-endian order, and they also require UCS-2 inputs to be in +- // big-endian order. For instance, glibc 2.1.3 does this. If the +- // UTF-8=>UCS-2 iconv converter has this feature, then we assume +- // that all UCS-2 converters do. (This might not be the best +- // heuristic, but is is all we've got.) +- jboolean result = false; +-#ifdef HAVE_ICONV +- iconv_t handle = iconv_open ("UCS-2", "UTF-8"); +- if (handle != (iconv_t) -1) +- { +- jchar c; +- unsigned char in[4]; +- char *inp, *outp; +- size_t inc, outc, r; +- +- // This is the UTF-8 encoding of \ufeff. At least Tru64 UNIX libiconv +- // needs the trailing NUL byte, otherwise iconv fails with EINVAL. +- in[0] = 0xef; +- in[1] = 0xbb; +- in[2] = 0xbf; +- in[3] = 0x00; +- +- inp = (char *) in; +- inc = 4; +- outp = (char *) &c; +- outc = 2; +- +- r = iconv_adapter (iconv, handle, &inp, &inc, &outp, &outc); +- // Conversion must be complete for us to use the result. +- if (r != (size_t) -1 && inc == 0 && outc == 0) +- result = (c != 0xfeff); +- +- // Release iconv handle. +- iconv_close (handle); +- } +-#endif /* HAVE_ICONV */ +- return result; ++ return false; + } + + void diff --git a/aports/cross/gcc-x86_64/fix-gcj-musl.patch b/aports/cross/gcc-x86_64/fix-gcj-musl.patch new file mode 100644 index 00000000..d26f510c --- /dev/null +++ b/aports/cross/gcc-x86_64/fix-gcj-musl.patch @@ -0,0 +1,49 @@ +--- gcc-4.8.2/libjava/gnu/classpath/natSystemProperties.cc.orig 2014-02-18 10:55:08.617678779 +0200 ++++ gcc-4.8.2/libjava/gnu/classpath/natSystemProperties.cc 2014-02-18 10:56:31.927227453 +0200 +@@ -289,7 +289,7 @@ + // just default to `en_US'. + setlocale (LC_ALL, ""); + char *locale = setlocale (LC_MESSAGES, ""); +- if (locale && strlen (locale) >= 2) ++ if (locale && strlen (locale) >= 2 && (locale[2] == '\0' || locale[2] == '_')) + { + char buf[3]; + buf[2] = '\0'; +--- gcc-4.8.2/libjava/posix-threads.cc.orig 2014-02-18 13:22:01.789933726 +0200 ++++ gcc-4.8.2/libjava/posix-threads.cc 2014-02-18 13:29:50.924058875 +0200 +@@ -657,6 +657,7 @@ + struct sched_param param; + pthread_attr_t attr; + struct starter *info; ++ size_t ss; + + if (data->flags & FLAG_START) + return; +@@ -675,8 +676,25 @@ + // Set stack size if -Xss option was given. + if (gcj::stack_size > 0) + { +- int e = pthread_attr_setstacksize (&attr, gcj::stack_size); ++ ss = gcj::stack_size; ++ } ++ else ++ { ++ int e = pthread_attr_getstacksize (&attr, &ss); ++ if (e != 0) ++ JvFail (strerror (e)); ++ ++ // Request at least 1meg of stack ++ if (ss >= 1024 * 1024) ++ ss = 0; ++ else ++ ss = 1024 * 1024; ++ } ++ ++ if (ss) ++ { ++ int e = pthread_attr_setstacksize (&attr, ss); + if (e != 0) + JvFail (strerror (e)); + } + + info = (struct starter *) _Jv_AllocBytes (sizeof (struct starter)); diff --git a/aports/cross/gcc-x86_64/fix-gcj-stdgnu14-link.patch b/aports/cross/gcc-x86_64/fix-gcj-stdgnu14-link.patch new file mode 100644 index 00000000..2b2ce0fa --- /dev/null +++ b/aports/cross/gcc-x86_64/fix-gcj-stdgnu14-link.patch @@ -0,0 +1,35 @@ +--- gcc-6.1.0/libjava/Makefile.am ++++ gcc-6.1.0/libjava/Makefile.am +@@ -488,10 +488,14 @@ + nat_files = $(nat_source_files:.cc=.lo) + xlib_nat_files = $(xlib_nat_source_files:.cc=.lo) + ++libgcj_la_CPPFLAGS = \ ++ $(AM_CPPFLAGS) \ ++ $(LIBSTDCXX_RAW_CXX_CXXFLAGS) ++ + # Include THREADLIBS here to ensure that the correct version of + # certain linuxthread functions get linked: + ## The mysterious backslash in the grep pattern is consumed by make. +-libgcj_la_LDFLAGS = -rpath $(toolexeclibdir) $(THREADLDFLAGS) $(extra_ldflags) $(THREADLIBS) \ ++libgcj_la_LDFLAGS = $(LIBSTDCXX_RAW_CXX_LDFLAGS) -rpath $(toolexeclibdir) $(THREADLDFLAGS) $(extra_ldflags) $(THREADLIBS) \ + $(LIBLTDL) $(SYS_ZLIBS) $(LIBJAVA_LDFLAGS_NOUNDEF) \ + -version-info `grep -v '^\#' $(srcdir)/libtool-version` \ + $(LIBGCJ_LD_SYMBOLIC_FUNCTIONS) $(LIBGCJ_LD_EXPORT_ALL) +--- gcc-6.1.0/libjava/Makefile.in ++++ gcc-6.1.0/libjava/Makefile.in +@@ -1103,9 +1103,13 @@ + nat_files = $(nat_source_files:.cc=.lo) + xlib_nat_files = $(xlib_nat_source_files:.cc=.lo) + ++libgcj_la_CPPFLAGS = \ ++ $(AM_CPPFLAGS) \ ++ $(LIBSTDCXX_RAW_CXX_CXXFLAGS) ++ + # Include THREADLIBS here to ensure that the correct version of + # certain linuxthread functions get linked: +-libgcj_la_LDFLAGS = -rpath $(toolexeclibdir) $(THREADLDFLAGS) $(extra_ldflags) $(THREADLIBS) \ ++libgcj_la_LDFLAGS = $(LIBSTDCXX_RAW_CXX_LDFLAGS) -rpath $(toolexeclibdir) $(THREADLDFLAGS) $(extra_ldflags) $(THREADLIBS) \ + $(LIBLTDL) $(SYS_ZLIBS) $(LIBJAVA_LDFLAGS_NOUNDEF) \ + -version-info `grep -v '^\#' $(srcdir)/libtool-version` \ + $(LIBGCJ_LD_SYMBOLIC_FUNCTIONS) $(LIBGCJ_LD_EXPORT_ALL) diff --git a/aports/cross/gcc-x86_64/fix-linux-header-use-in-libgcc.patch b/aports/cross/gcc-x86_64/fix-linux-header-use-in-libgcc.patch new file mode 100644 index 00000000..6dad1b2c --- /dev/null +++ b/aports/cross/gcc-x86_64/fix-linux-header-use-in-libgcc.patch @@ -0,0 +1,44 @@ +From 9cd4503714c4e596818c4ea8e15905c249b7a319 Mon Sep 17 00:00:00 2001 +From: nsz +Date: Thu, 25 Aug 2016 14:08:27 +0000 +Subject: [PATCH] [mips] Fix linux header use in libgcc + +libgcc/ + * config/mips/linux-unwind.h: Use sys/syscall.h. + + + +git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239759 138bc75d-0d04-0410-961f-82ee72b054a4 +--- + libgcc/ChangeLog | 4 ++++ + libgcc/config/mips/linux-unwind.h | 2 +- + 2 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog +index b78c4b2..99bd2f1 100644 +--- a/libgcc/ChangeLog ++++ b/libgcc/ChangeLog +@@ -1,3 +1,7 @@ ++2016-08-25 Szabolcs Nagy ++ ++ * config/mips/linux-unwind.h: Use sys/syscall.h. ++ + 2016-08-16 Joseph Myers + + PR libgcc/77265 +diff --git a/libgcc/config/mips/linux-unwind.h b/libgcc/config/mips/linux-unwind.h +index bf12de5..4035c121 100644 +--- a/libgcc/config/mips/linux-unwind.h ++++ b/libgcc/config/mips/linux-unwind.h +@@ -27,7 +27,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + state data appropriately. See unwind-dw2.c for the structs. */ + + #include +-#include ++#include + + /* The third parameter to the signal handler points to something with + * this structure defined in asm/ucontext.h, but the name clashes with +-- +2.9.3 + diff --git a/aports/cross/gcc-x86_64/fix-rs6000-pie.patch b/aports/cross/gcc-x86_64/fix-rs6000-pie.patch new file mode 100644 index 00000000..1fbc31a5 --- /dev/null +++ b/aports/cross/gcc-x86_64/fix-rs6000-pie.patch @@ -0,0 +1,59 @@ +--- gcc-6.3.0.orig/gcc/config/rs6000/sysv4.h ++++ gcc-6.3.0/gcc/config/rs6000/sysv4.h +@@ -753,23 +753,42 @@ + #endif + + #ifdef HAVE_LD_PIE +-#define STARTFILE_LINUX_SPEC "\ +-%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \ +-%{mnewlib:ecrti.o%s;:crti.o%s} \ +-%{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} \ +-" CRTOFFLOADBEGIN ++#define STARTFILE_LINUX_SPEC \ ++ "%{!shared: %{pg|p|profile:gcrt1.o%s;: \ ++ %{" PIE_SPEC ":%{static:rcrt1.o%s;:Scrt1.o%s}} %{" NO_PIE_SPEC ":crt1.o%s}}} \ ++ crti.o%s %{shared:crtbeginS.o%s;: \ ++ %{" PIE_SPEC ":crtbeginS.o%s} \ ++ %{" NO_PIE_SPEC ":%{static:crtbeginT.o%s;:crtbegin.o%s}}} \ ++ %{fvtable-verify=none:%s; \ ++ fvtable-verify=preinit:vtv_start_preinit.o%s; \ ++ fvtable-verify=std:vtv_start.o%s} \ ++ " CRTOFFLOADBEGIN + #else +-#define STARTFILE_LINUX_SPEC "\ +-%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \ +-%{mnewlib:ecrti.o%s;:crti.o%s} \ +-%{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} \ +-" CRTOFFLOADBEGIN ++#define STARTFILE_LINUX_SPEC \ ++ "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \ ++ crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} \ ++ %{fvtable-verify=none:%s; \ ++ fvtable-verify=preinit:vtv_start_preinit.o%s; \ ++ fvtable-verify=std:vtv_start.o%s} \ ++ " CRTOFFLOADBEGIN + #endif + +-#define ENDFILE_LINUX_SPEC "\ +-%{shared|pie:crtendS.o%s;:crtend.o%s} \ +-%{mnewlib:ecrtn.o%s;:crtn.o%s} \ +-" CRTOFFLOADEND ++#ifdef HAVE_LD_PIE ++#define ENDFILE_LINUX_SPEC \ ++ "%{fvtable-verify=none:%s; \ ++ fvtable-verify=preinit:vtv_end_preinit.o%s; \ ++ fvtable-verify=std:vtv_end.o%s} \ ++ %{shared:crtendS.o%s;: %{" PIE_SPEC ":crtendS.o%s} \ ++ %{" NO_PIE_SPEC ":crtend.o%s}} crtn.o%s \ ++ " CRTOFFLOADEND ++#else ++#define ENDFILE_LINUX_SPEC \ ++ "%{fvtable-verify=none:%s; \ ++ fvtable-verify=preinit:vtv_end_preinit.o%s; \ ++ fvtable-verify=std:vtv_end.o%s} \ ++ %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s \ ++ " CRTOFFLOADEND ++#endif + + #define LINK_START_LINUX_SPEC "" + diff --git a/aports/cross/gcc-x86_64/gcc-4.8-build-args.patch b/aports/cross/gcc-x86_64/gcc-4.8-build-args.patch new file mode 100644 index 00000000..c27e0096 --- /dev/null +++ b/aports/cross/gcc-x86_64/gcc-4.8-build-args.patch @@ -0,0 +1,41 @@ +When cross compiling a target gcc, target flags may be used on the host + +Configure identifies a number of warning flags (WARN_CFLAGS and +WARN_CXXFLAGS) from the $CC value. The cross compiler may be different +from the host compiler and may not support the same set of flags. This +leads to problems such as: + +cc1plus: error: unrecognized command line option "-Wno-narrowing" +cc1plus: error: unrecognized command line option "-Wno-overlength-strings" + +Work around this problem by removing the warning flags from the +BUILD_CXXFLAGS value, in a way similar to the BUILD_CFLAGS. + +Upstream-Status: Pending + +Signed-off-by: Mark Hatle + +Index: gcc-4.8.0/gcc/configure +=================================================================== +--- gcc-4.8.0.orig/gcc/configure ++++ gcc-4.8.0/gcc/configure +@@ -11720,6 +10581,7 @@ STMP_FIXINC=stmp-fixinc + if test x$build != x$host || test "x$coverage_flags" != x + then + BUILD_CFLAGS='$(INTERNAL_CFLAGS) $(T_CFLAGS) $(CFLAGS_FOR_BUILD)' ++ BUILD_CXXFLAGS='$(INTERNAL_CFLAGS) $(T_CFLAGS) $(CFLAGS_FOR_BUILD)' + BUILD_LDFLAGS='$(LDFLAGS_FOR_BUILD)' + fi + +Index: gcc-4.8.0/gcc/configure.ac +=================================================================== +--- gcc-4.8.0.orig/gcc/configure.ac ++++ gcc-4.8.0/gcc/configure.ac +@@ -1901,6 +1901,7 @@ STMP_FIXINC=stmp-fixinc AC_SUBST(STMP_F + if test x$build != x$host || test "x$coverage_flags" != x + then + BUILD_CFLAGS='$(INTERNAL_CFLAGS) $(T_CFLAGS) $(CFLAGS_FOR_BUILD)' ++ BUILD_CXXFLAGS='$(INTERNAL_CFLAGS) $(T_CFLAGS) $(CFLAGS_FOR_BUILD)' + BUILD_LDFLAGS='$(LDFLAGS_FOR_BUILD)' + fi + diff --git a/aports/cross/gcc-x86_64/gcc-4.9-musl-fortify.patch b/aports/cross/gcc-x86_64/gcc-4.9-musl-fortify.patch new file mode 100644 index 00000000..daae954c --- /dev/null +++ b/aports/cross/gcc-x86_64/gcc-4.9-musl-fortify.patch @@ -0,0 +1,11 @@ +--- 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/aports/cross/gcc-x86_64/gcc-6.1-musl-libssp.patch b/aports/cross/gcc-x86_64/gcc-6.1-musl-libssp.patch new file mode 100644 index 00000000..fe5c6143 --- /dev/null +++ b/aports/cross/gcc-x86_64/gcc-6.1-musl-libssp.patch @@ -0,0 +1,20 @@ +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/aports/cross/gcc-x86_64/gcc-pure64-mips.patch b/aports/cross/gcc-x86_64/gcc-pure64-mips.patch new file mode 100644 index 00000000..d78f2838 --- /dev/null +++ b/aports/cross/gcc-x86_64/gcc-pure64-mips.patch @@ -0,0 +1,47 @@ +From b8c4e45d052adc247341066f748421743704b481 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 + +--- + 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 +--- a/gcc/config/mips/mips.h ++++ b/gcc/config/mips/mips.h +@@ -3330,11 +3330,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 +-#define STANDARD_STARTFILE_PREFIX_1 "/lib32/" +-#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib32/" ++#define STANDARD_STARTFILE_PREFIX_1 "/lib/" ++#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/" + #elif MIPS_ABI_DEFAULT == ABI_64 +-#define STANDARD_STARTFILE_PREFIX_1 "/lib64/" +-#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib64/" ++#define STANDARD_STARTFILE_PREFIX_1 "/lib/" ++#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/" + #endif + + /* 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 +--- a/gcc/config/mips/t-linux64 ++++ b/gcc/config/mips/t-linux64 +@@ -21,6 +21,6 @@ MULTILIB_DIRNAMES = n32 32 64 + MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el) + MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft) + MULTILIB_OSDIRNAMES = \ +- ../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \ +- ../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \ +- ../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT)) ++ ../lib \ ++ ../lib32 \ ++ ../lib +-- +2.15.1 + diff --git a/aports/cross/gcc-x86_64/gcc-pure64.patch b/aports/cross/gcc-x86_64/gcc-pure64.patch new file mode 100644 index 00000000..2c350fe5 --- /dev/null +++ b/aports/cross/gcc-x86_64/gcc-pure64.patch @@ -0,0 +1,89 @@ +--- ./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 + +--- ./gcc/config/rs6000/t-linux.orig ++++ ./gcc/config/rs6000/t-linux +@@ -2,7 +2,8 @@ + # or soft-float. + ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float))) + ifneq (,$(findstring powerpc64,$(target))) +-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu) ++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 := $(subst -linux,le-linux,$(MULTIARCH_DIRNAME)) + endif + ifneq (,$(findstring powerpc64le,$(target))) +-MULTILIB_OSDIRNAMES := $(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES)) ++MULTILIB_OSDIRNAMES := m64=../lib ++MULTILIB_OSDIRNAMES += m32=../lib32 + endif + endif + +--- ./gcc/config/rs6000/t-linux64.orig ++++ ./gcc/config/rs6000/t-linux64 +@@ -28,8 +28,8 @@ + MULTILIB_OPTIONS := m64/m32 + MULTILIB_DIRNAMES := 64 32 + MULTILIB_EXTRA_OPTS := +-MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu) +-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu) ++MULTILIB_OSDIRNAMES := m64=../lib ++MULTILIB_OSDIRNAMES += m32=../lib32 + + rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c + $(COMPILE) $< +--- ./gcc/config/rs6000/t-linux64bele.orig ++++ ./gcc/config/rs6000/t-linux64bele +@@ -2,6 +2,6 @@ + + MULTILIB_OPTIONS += mlittle + MULTILIB_DIRNAMES += le +-MULTILIB_OSDIRNAMES += $(subst =,.mlittle=,$(subst lible32,lib32le,$(subst lible64,lib64le,$(subst lib,lible,$(subst -linux,le-linux,$(MULTILIB_OSDIRNAMES)))))) +-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mlittle%,$(MULTILIB_OSDIRNAMES))) ++MULTILIB_OSDIRNAMES = m64=../lib ++MULTILIB_OSDIRNAMES+= m32=../lib32 + MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN} +--- ./gcc/config/rs6000/t-linux64lebe.orig ++++ ./gcc/config/rs6000/t-linux64lebe +@@ -2,6 +2,6 @@ + + MULTILIB_OPTIONS += mbig + MULTILIB_DIRNAMES += be +-MULTILIB_OSDIRNAMES += $(subst =,.mbig=,$(subst libbe32,lib32be,$(subst libbe64,lib64be,$(subst lib,libbe,$(subst le-linux,-linux,$(MULTILIB_OSDIRNAMES)))))) +-MULTILIB_OSDIRNAMES += $(subst $(if $(findstring 64,$(target)),m64,m32).,,$(filter $(if $(findstring 64,$(target)),m64,m32).mbig%,$(MULTILIB_OSDIRNAMES))) ++MULTILIB_OSDIRNAMES := m64=../lib ++MULTILIB_OSDIRNAMES += m32=../lib32 + MULTILIB_MATCHES := ${MULTILIB_MATCHES_ENDIAN} diff --git a/aports/cross/gcc-x86_64/libgcc-always-build-gcceh.a.patch b/aports/cross/gcc-x86_64/libgcc-always-build-gcceh.a.patch new file mode 100644 index 00000000..74ae8973 --- /dev/null +++ b/aports/cross/gcc-x86_64/libgcc-always-build-gcceh.a.patch @@ -0,0 +1,39 @@ +Highly inspired by: + http://landley.net/hg/aboriginal/file/7e0747a665ab/sources/patches/gcc-core-libgcceh.patch + +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) + endif + ++all: libgcc_eh.a + ifeq ($(enable_shared),yes) +-all: libgcc_eh.a libgcc_s$(SHLIB_EXT) ++all: libgcc_s$(SHLIB_EXT) + ifneq ($(LIBUNWIND),) + all: libunwind$(SHLIB_EXT) + endif +@@ -950,10 +951,6 @@ + install-shared: + $(mkinstalldirs) $(DESTDIR)$(inst_libdir) + +- $(INSTALL_DATA) libgcc_eh.a $(DESTDIR)$(inst_libdir)/ +- chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a +- $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a +- + $(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 + $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcov.a + ++ $(INSTALL_DATA) libgcc_eh.a $(DESTDIR)$(inst_libdir)/ ++ chmod 644 $(DESTDIR)$(inst_libdir)/libgcc_eh.a ++ $(RANLIB) $(DESTDIR)$(inst_libdir)/libgcc_eh.a ++ + parts="$(INSTALL_PARTS)"; \ + for file in $$parts; do \ + rm -f $(DESTDIR)$(inst_libdir)/$$file; \ diff --git a/aports/cross/musl-x86_64/APKBUILD b/aports/cross/musl-x86_64/APKBUILD new file mode 100644 index 00000000..9be07640 --- /dev/null +++ b/aports/cross/musl-x86_64/APKBUILD @@ -0,0 +1,50 @@ +# Automatically generated aport, do not edit! +# Generator: pmbootstrap aportgen musl-x86_64 + +pkgname=musl-x86_64 +pkgver=1.1.18 +pkgrel=5 +subpackages="musl-dev-x86_64:package_dev" + +_arch="x86_64" +_mirror="http://dl-cdn.alpinelinux.org/alpine/" + +url="https://musl-libc.org" +license="MIT" +arch="all" +options="!check !strip" +pkgdesc="the musl library (lib c) implementation for $_arch" + +_target="$(arch_to_hostspec $_arch)" + +source=" + musl-$pkgver-r$pkgrel-$_arch.apk::$_mirror/edge/main/$_arch/musl-$pkgver-r$pkgrel.apk + musl-dev-$pkgver-r$pkgrel-$_arch.apk::$_mirror/edge/main/$_arch/musl-dev-$pkgver-r$pkgrel.apk +" + +package() { + mkdir -p "$pkgdir/usr/$_target" + cd "$pkgdir/usr/$_target" + tar -xf $srcdir/musl-$pkgver-r$pkgrel-$_arch.apk + rm .PKGINFO .SIGN.* +} +package_dev() { + mkdir -p "$subpkgdir/usr/$_target" + cd "$subpkgdir/usr/$_target" + tar -xf $srcdir/musl-dev-$pkgver-r$pkgrel-$_arch.apk + rm .PKGINFO .SIGN.* + + # symlink everything from /usr/$_target/usr/* to /usr/$_target/* + # so the cross-compiler gcc does not fail to build. + for _dir in include lib; do + mkdir -p "$subpkgdir/usr/$_target/$_dir" + cd "$subpkgdir/usr/$_target/usr/$_dir" + for i in *; do + cd "$subpkgdir/usr/$_target/$_dir" + ln -s /usr/$_target/usr/$_dir/$i $i + done + done +} + +sha512sums="88ae046a7687347cdb99e35be80472016fc9980a5d5be69abd4b66c6c4c9d727f67da6c2694b3c53bf4eb519f8226a81aaad3dcc18bf8074b2876cab00fbc75d musl-1.1.18-r5-x86_64.apk +4f7f5c43652df3996acb1de3964bba4e49b66e3f61936796fab06b8bc516fa67ff2ffdd28cdc8a638d3a65dedc2eb6a1f3342a0fd57efde2633b0f63f5345214 musl-dev-1.1.18-r5-x86_64.apk" diff --git a/pmb/config/__init__.py b/pmb/config/__init__.py index 002f6c89..326f8bd4 100644 --- a/pmb/config/__init__.py +++ b/pmb/config/__init__.py @@ -149,6 +149,8 @@ apkindex_retention_time = 4 # specify architectures supported by Alpine here. When creating a noarch # package, symlinks for all architectures get created - so only specify # architectures, where we really have device-* packages for. +# For cross-compiling we need the "musl-$ARCH", "binutils-$ARCH" and +# "gcc-$ARCH" packages of each target architecture. build_device_architectures = ["armhf", "aarch64", "x86_64"] # Packages, that will be installed in a chroot before it builds packages