summaryrefslogtreecommitdiff
path: root/etc/patches/gcc-10
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2023-10-20 16:07:58 +0200
committerOliver Reiche <oliver.reiche@huawei.com>2023-10-20 16:07:58 +0200
commit060a0cf338d6024eee37cc344c224fe3bcb78e81 (patch)
tree3fea7c654b69ecf3490fe9c6cbc542aba0d5bd8f /etc/patches/gcc-10
downloadbootstrappable-toolchain-060a0cf338d6024eee37cc344c224fe3bcb78e81.tar.gz
Initial commit
Diffstat (limited to 'etc/patches/gcc-10')
-rw-r--r--etc/patches/gcc-10/detect-glibc-via-__GLIBC__.patch69
-rw-r--r--etc/patches/gcc-10/reproducibility/0001-strip-build-directory-from-fixinclues.patch29
-rw-r--r--etc/patches/gcc-10/reproducibility/0002-compute-reproducible-checksums.patch75
-rw-r--r--etc/patches/gcc-10/reproducibility/series2
4 files changed, 175 insertions, 0 deletions
diff --git a/etc/patches/gcc-10/detect-glibc-via-__GLIBC__.patch b/etc/patches/gcc-10/detect-glibc-via-__GLIBC__.patch
new file mode 100644
index 0000000..dcad1e6
--- /dev/null
+++ b/etc/patches/gcc-10/detect-glibc-via-__GLIBC__.patch
@@ -0,0 +1,69 @@
+From c913861c81772b42b5a5279d035430f11dc8a790 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Fri, 4 Aug 2023 17:57:20 +0200
+Subject: [PATCH] config.guess: Detect glibc via __GLIBC__
+
+Backport from GCC 11.1.0
+ Git commit: 53a90650663e59948f86505660604b5769cf808c and
+ 74af13c174714dd3b9f1ded4b39955f003c16361
+
+Co-authored-by: Iain Sandoe <iain@sandoe.co.uk>
+Co-authored-by: Kito Cheng <kito.cheng@sifive.com>
+---
+ config.guess | 28 +++++++++++++++++++---------
+ 1 file changed, 19 insertions(+), 9 deletions(-)
+
+diff --git a/config.guess b/config.guess
+index 97ad073..8792dd3 100755
+--- a/config.guess
++++ b/config.guess
+@@ -136,9 +136,7 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+ case "$UNAME_SYSTEM" in
+ Linux|GNU|GNU/*)
+- # If the system lacks a compiler, then just pick glibc.
+- # We could probably try harder.
+- LIBC=gnu
++ LIBC=unknown
+
+ set_cc_for_build
+ cat <<-EOF > "$dummy.c"
+@@ -147,17 +145,29 @@ Linux|GNU|GNU/*)
+ LIBC=uclibc
+ #elif defined(__dietlibc__)
+ LIBC=dietlibc
+- #else
++ #elif defined(__GLIBC__)
+ LIBC=gnu
++ #else
++ #include <stdarg.h>
++ /* First heuristic to detect musl libc. */
++ #ifdef __DEFINED_va_list
++ LIBC=musl
++ #endif
+ #endif
+ EOF
+ eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
+
+- # If ldd exists, use it to detect musl libc.
+- if command -v ldd >/dev/null && \
+- ldd --version 2>&1 | grep -q ^musl
+- then
+- LIBC=musl
++ # Second heuristic to detect musl libc.
++ if [ "$LIBC" = unknown ] &&
++ command -v ldd >/dev/null &&
++ ldd --version 2>&1 | grep -q ^musl; then
++ LIBC=musl
++ fi
++
++ # If the system lacks a compiler, then just pick glibc.
++ # We could probably try harder.
++ if [ "$LIBC" = unknown ]; then
++ LIBC=gnu
+ fi
+ ;;
+ esac
+--
+2.30.2
+
diff --git a/etc/patches/gcc-10/reproducibility/0001-strip-build-directory-from-fixinclues.patch b/etc/patches/gcc-10/reproducibility/0001-strip-build-directory-from-fixinclues.patch
new file mode 100644
index 0000000..d9a545f
--- /dev/null
+++ b/etc/patches/gcc-10/reproducibility/0001-strip-build-directory-from-fixinclues.patch
@@ -0,0 +1,29 @@
+From a097d475fa8806265f445d11f3074f506baf4a3e Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Fri, 18 Aug 2023 14:36:57 +0200
+Subject: [PATCH 1/2] Strip build directory from fixinclues
+
+... to achieve a reproducible binary, which contains the
+configure string. For this to work, the user needs to set
+"BUILD_ROOT_DIR" before building.
+---
+ fixincludes/configure | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/fixincludes/configure b/fixincludes/configure
+index 6e2d67b65..b7d91c7ab 100755
+--- a/fixincludes/configure
++++ b/fixincludes/configure
+@@ -6374,6 +6374,9 @@ cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
+ BEGIN {
+ _ACEOF
+
++# Remove host machine's build path from confdefs.h
++sed -i 's|'${BUILD_ROOT_DIR:-/nonexistent}'|/build|g' confdefs.h
++
+ # Transform confdefs.h into an awk script `defines.awk', embedded as
+ # here-document in config.status, that substitutes the proper values into
+ # config.h.in to produce config.h.
+--
+2.30.2
+
diff --git a/etc/patches/gcc-10/reproducibility/0002-compute-reproducible-checksums.patch b/etc/patches/gcc-10/reproducibility/0002-compute-reproducible-checksums.patch
new file mode 100644
index 0000000..3aeb9fb
--- /dev/null
+++ b/etc/patches/gcc-10/reproducibility/0002-compute-reproducible-checksums.patch
@@ -0,0 +1,75 @@
+From effd0097f1b34616b410473493bd8eeb388835d8 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Mon, 21 Aug 2023 18:03:56 +0200
+Subject: [PATCH 2/2] Compute reproducible checksums
+
+... for variable toolchain paths:
+* remove linker path from gcc's checksum-options
+* disable thin archives (for stripping libbackend.a)
+* strip debug info before computing checksums
+For removing the linker path, the user needs to set
+"BUILD_ROOT_DIR" before building.
+---
+ gcc/Makefile.in | 3 ++-
+ gcc/c/Make-lang.in | 6 +++++-
+ gcc/cp/Make-lang.in | 6 +++++-
+ 3 files changed, 12 insertions(+), 3 deletions(-)
+
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index 5d05e8e0d..1346bbe72 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -284,7 +284,7 @@ USE_THIN_ARCHIVES = no
+ ifeq ($(THIN_ARCHIVE_SUPPORT),yes)
+ ifeq ($(AR_FLAGS),rc)
+ ifeq ($(RANLIB_FLAGS),)
+-USE_THIN_ARCHIVES = yes
++#USE_THIN_ARCHIVES = yes
+ endif
+ endif
+ endif
+@@ -2075,6 +2075,7 @@ gcc-cross$(exeext): xgcc$(exeext)
+
+ checksum-options:
+ echo "$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS)" > checksum-options.tmp \
++ && sed -i 's|'$${BUILD_ROOT_DIR:-/nonexistent}'|/build|g' checksum-options.tmp \
+ && $(srcdir)/../move-if-change checksum-options.tmp checksum-options
+
+ #
+diff --git a/gcc/c/Make-lang.in b/gcc/c/Make-lang.in
+index 8944b9b9f..7ed444c5f 100644
+--- a/gcc/c/Make-lang.in
++++ b/gcc/c/Make-lang.in
+@@ -76,7 +76,11 @@ cc1-checksum.c : build/genchecksum$(build_exeext) checksum-options \
+ && cmp -s ../stage_current ../stage_final; then \
+ cp ../prev-gcc/cc1-checksum.c cc1-checksum.c; \
+ else \
+- build/genchecksum$(build_exeext) $(C_OBJS) $(BACKEND) $(LIBDEPS) \
++ rm -rf stripped_c_checksum_inputs; \
++ mkdir stripped_c_checksum_inputs; \
++ cp $(C_OBJS) $(BACKEND) $(LIBDEPS) stripped_c_checksum_inputs/; \
++ strip -g stripped_c_checksum_inputs/*; \
++ build/genchecksum$(build_exeext) $$(ls stripped_c_checksum_inputs/* | LC_ALL=C sort) \
+ checksum-options > cc1-checksum.c.tmp && \
+ $(srcdir)/../move-if-change cc1-checksum.c.tmp cc1-checksum.c; \
+ fi
+diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
+index 7896591dd..c65afcb85 100644
+--- a/gcc/cp/Make-lang.in
++++ b/gcc/cp/Make-lang.in
+@@ -111,7 +111,11 @@ cc1plus-checksum.c : build/genchecksum$(build_exeext) checksum-options \
+ && cmp -s ../stage_current ../stage_final; then \
+ cp ../prev-gcc/cc1plus-checksum.c cc1plus-checksum.c; \
+ else \
+- build/genchecksum$(build_exeext) $(CXX_OBJS) $(BACKEND) $(LIBDEPS) \
++ rm -rf stripped_cp_checksum_inputs; \
++ mkdir stripped_cp_checksum_inputs; \
++ cp $(CXX_OBJS) $(BACKEND) $(CODYLIB) $(LIBDEPS) stripped_cp_checksum_inputs; \
++ strip -g stripped_cp_checksum_inputs/*; \
++ build/genchecksum$(build_exeext) $$(ls stripped_cp_checksum_inputs/* | LC_ALL=C sort) \
+ checksum-options > cc1plus-checksum.c.tmp && \
+ $(srcdir)/../move-if-change cc1plus-checksum.c.tmp cc1plus-checksum.c; \
+ fi
+--
+2.30.2
+
diff --git a/etc/patches/gcc-10/reproducibility/series b/etc/patches/gcc-10/reproducibility/series
new file mode 100644
index 0000000..1ec9fe3
--- /dev/null
+++ b/etc/patches/gcc-10/reproducibility/series
@@ -0,0 +1,2 @@
+0001-strip-build-directory-from-fixinclues.patch
+0002-compute-reproducible-checksums.patch