summaryrefslogtreecommitdiff
path: root/etc/patches/gcc-13
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-13
downloadbootstrappable-toolchain-060a0cf338d6024eee37cc344c224fe3bcb78e81.tar.gz
Initial commit
Diffstat (limited to 'etc/patches/gcc-13')
-rw-r--r--etc/patches/gcc-13/reproducibility/0001-strip-build-directory-from-config-arguments.patch42
-rw-r--r--etc/patches/gcc-13/reproducibility/0002-strip-build-directory-from-fixinclues.patch29
-rw-r--r--etc/patches/gcc-13/reproducibility/0003-strip-build-directory-from-mkheaders.conf.patch25
-rw-r--r--etc/patches/gcc-13/reproducibility/0004-compute-reproducible-checksums.patch75
-rw-r--r--etc/patches/gcc-13/reproducibility/0005-do-not-hardcode-rpath-into-cc1-libs.patch26
-rw-r--r--etc/patches/gcc-13/reproducibility/series5
6 files changed, 202 insertions, 0 deletions
diff --git a/etc/patches/gcc-13/reproducibility/0001-strip-build-directory-from-config-arguments.patch b/etc/patches/gcc-13/reproducibility/0001-strip-build-directory-from-config-arguments.patch
new file mode 100644
index 0000000..20e16d4
--- /dev/null
+++ b/etc/patches/gcc-13/reproducibility/0001-strip-build-directory-from-config-arguments.patch
@@ -0,0 +1,42 @@
+From 0d902bfa02d5b5e6ef4e32dcdbe3b9c201c84fc6 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Mon, 14 Aug 2023 12:33:04 +0200
+Subject: [PATCH 1/5] Strip build directory from config arguments
+
+... to achieve a reproducible binary, which contains the
+configure string. For this to work, the user needs to set
+"BUILD_ROOT_DIR" before building.
+---
+ gcc/configure | 2 ++
+ gcc/configure.ac | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/gcc/configure b/gcc/configure
+index 530f4d695..65d8e64db 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -13162,6 +13162,8 @@ fi
+ sed -e 's/\\/\\\\/g; s/"/\\"/g' <<EOF >conftest.out
+ $gcc_config_arguments
+ EOF
++# Remove host machine's build path from config arguments
++sed -i 's|'${BUILD_ROOT_DIR:-/nonexistent}'|/build|g' conftest.out
+ gcc_config_arguments_str=`cat conftest.out`
+ rm -f conftest.out
+
+diff --git a/gcc/configure.ac b/gcc/configure.ac
+index 09082e8cc..98e33b293 100644
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -2167,6 +2167,8 @@ fi
+ sed -e 's/\\/\\\\/g; s/"/\\"/g' <<EOF >conftest.out
+ $gcc_config_arguments
+ EOF
++# Remove host machine's build path from config arguments
++sed -i 's|'${BUILD_ROOT_DIR:-/nonexistent}'|/build|g' conftest.out
+ gcc_config_arguments_str=`cat conftest.out`
+ rm -f conftest.out
+
+--
+2.30.2
+
diff --git a/etc/patches/gcc-13/reproducibility/0002-strip-build-directory-from-fixinclues.patch b/etc/patches/gcc-13/reproducibility/0002-strip-build-directory-from-fixinclues.patch
new file mode 100644
index 0000000..fd1ea04
--- /dev/null
+++ b/etc/patches/gcc-13/reproducibility/0002-strip-build-directory-from-fixinclues.patch
@@ -0,0 +1,29 @@
+From a6fc1b1f0a05fbd6ba664393695ad20d3577a517 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 2/5] 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 bdcc41f6d..9dc499bc1 100755
+--- a/fixincludes/configure
++++ b/fixincludes/configure
+@@ -6384,6 +6384,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-13/reproducibility/0003-strip-build-directory-from-mkheaders.conf.patch b/etc/patches/gcc-13/reproducibility/0003-strip-build-directory-from-mkheaders.conf.patch
new file mode 100644
index 0000000..356a2f9
--- /dev/null
+++ b/etc/patches/gcc-13/reproducibility/0003-strip-build-directory-from-mkheaders.conf.patch
@@ -0,0 +1,25 @@
+From b3cd904a8b4c35cd399a1c3726547a2edbe575fc Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Fri, 8 Sep 2023 16:16:29 +0200
+Subject: [PATCH 3/5] Strip build directory from mkheaders.conf
+
+---
+ gcc/Makefile.in | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/gcc/Makefile.in b/gcc/Makefile.in
+index f07dfe135..56a3f8e59 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -4014,6 +4014,8 @@ install-mkheaders: stmp-int-hdrs install-itoolsdirs \
+ >> $(DESTDIR)$(itoolsdatadir)/mkheaders.conf
+ echo 'STMP_FIXINC="$(STMP_FIXINC)"' \
+ >> $(DESTDIR)$(itoolsdatadir)/mkheaders.conf
++ sed -i 's|'$${BUILD_ROOT_DIR:-/nonexistent}'|/build|g' \
++ $(DESTDIR)$(itoolsdatadir)/mkheaders.conf
+
+ # Use this target to install the program `collect2' under the name `collect2'.
+ install-collect2: collect2 installdirs
+--
+2.30.2
+
diff --git a/etc/patches/gcc-13/reproducibility/0004-compute-reproducible-checksums.patch b/etc/patches/gcc-13/reproducibility/0004-compute-reproducible-checksums.patch
new file mode 100644
index 0000000..8eaeaac
--- /dev/null
+++ b/etc/patches/gcc-13/reproducibility/0004-compute-reproducible-checksums.patch
@@ -0,0 +1,75 @@
+From 6ca5ec25d5dc33d3c54072619601e980af976050 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 4/5] 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 ad9a5d94c..45ea14ffa 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -293,7 +293,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
+@@ -2188,6 +2188,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 b3b12dcff..1733b40a7 100644
+--- a/gcc/c/Make-lang.in
++++ b/gcc/c/Make-lang.in
+@@ -77,7 +77,11 @@ cc1-checksum.cc : build/genchecksum$(build_exeext) checksum-options \
+ && cmp -s ../stage_current ../stage_final; then \
+ cp ../prev-gcc/cc1-checksum.cc cc1-checksum.cc; \
+ 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.cc.tmp && \
+ $(srcdir)/../move-if-change cc1-checksum.cc.tmp cc1-checksum.cc; \
+ fi
+diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
+index 4ee26fad9..30fe695ec 100644
+--- a/gcc/cp/Make-lang.in
++++ b/gcc/cp/Make-lang.in
+@@ -135,7 +135,11 @@ cc1plus-checksum.cc : build/genchecksum$(build_exeext) checksum-options \
+ && cmp -s ../stage_current ../stage_final; then \
+ cp ../prev-gcc/cc1plus-checksum.cc cc1plus-checksum.cc; \
+ else \
+- build/genchecksum$(build_exeext) $(CXX_OBJS) $(BACKEND) $(CODYLIB) $(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.cc.tmp && \
+ $(srcdir)/../move-if-change cc1plus-checksum.cc.tmp cc1plus-checksum.cc; \
+ fi
+--
+2.30.2
+
diff --git a/etc/patches/gcc-13/reproducibility/0005-do-not-hardcode-rpath-into-cc1-libs.patch b/etc/patches/gcc-13/reproducibility/0005-do-not-hardcode-rpath-into-cc1-libs.patch
new file mode 100644
index 0000000..8c40fa9
--- /dev/null
+++ b/etc/patches/gcc-13/reproducibility/0005-do-not-hardcode-rpath-into-cc1-libs.patch
@@ -0,0 +1,26 @@
+From e091349f7ab0316cbe4b000783b5dd8f79a04424 Mon Sep 17 00:00:00 2001
+From: Oliver Reiche <oliver.reiche@huawei.com>
+Date: Fri, 8 Sep 2023 14:59:34 +0200
+Subject: [PATCH 5/5] Do not hardcode rpath into cc1 libs
+
+... which is a temporary path anyway.
+---
+ libcc1/configure | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libcc1/configure b/libcc1/configure
+index a9fb5f7..f39f76b 100755
+--- a/libcc1/configure
++++ b/libcc1/configure
+@@ -17313,7 +17313,7 @@ finish_cmds=$lt_finish_cmds
+ finish_eval=$lt_finish_eval
+
+ # Whether we should hardcode library paths into libraries.
+-hardcode_into_libs=$hardcode_into_libs
++hardcode_into_libs=no #$hardcode_into_libs
+
+ # Compile-time system search path for libraries.
+ sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+--
+2.30.2
+
diff --git a/etc/patches/gcc-13/reproducibility/series b/etc/patches/gcc-13/reproducibility/series
new file mode 100644
index 0000000..996d939
--- /dev/null
+++ b/etc/patches/gcc-13/reproducibility/series
@@ -0,0 +1,5 @@
+0001-strip-build-directory-from-config-arguments.patch
+0002-strip-build-directory-from-fixinclues.patch
+0003-strip-build-directory-from-mkheaders.conf.patch
+0004-compute-reproducible-checksums.patch
+0005-do-not-hardcode-rpath-into-cc1-libs.patch