Subject: Re: bug#48721: [PATCH] gnu: gcc-8: Make static libs reproducible

From: Ludovic Courtès <[email-masked]>
Date: Sat, 29 May 2021 19:09:06 +0200

Hi Carl,

Carl Dong <[email-masked]> skribis:

> This fixes the nonreproducibility in gcc documented here:
> https://reproducible-builds.org/docs/archives/#gnu-libtool
>
> * gnu/packages/patches/gcc-8-sort-libtool-find-output.patch: New patch.
> * gnu/packages/gcc.scm (gcc-8)[source]: Apply it.

Well done.  Did you observe it in practice?  (On ‘core-updates’ maybe?)

I wonder if this explains the issues that Chris Marusich and Léo
stumbled upon while working on the POWER9 port.

I’m surprised that this is still an issue since this was fixed in
Libtool proper long ago, probably before GCC 8 was released.

>  gnu/packages/gcc.scm                          |   3 +-
>  .../gcc-8-sort-libtool-find-output.patch      | 392 ++++++++++++++++++

> diff --git a/gnu/packages/patches/gcc-8-sort-libtool-find-output.patch b/gnu/packages/patches/gcc-8-sort-libtool-find-output.patch
> new file mode 100644
> index 0000000000..1dfe3ba132
> --- /dev/null
> +++ b/gnu/packages/patches/gcc-8-sort-libtool-find-output.patch

Please add a line or two explaining what it does, or ‘guix lint’ will be
unhappy.  :-)

> @@ -0,0 +1,392 @@
> +diff --git a/gcc/configure b/gcc/configure
> +index 97ba7d7d69c..e37a96f0c0c 100755
> +--- a/gcc/configure
> ++++ b/gcc/configure
> +@@ -19720,20 +19720,20 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
> + 	      prelink_cmds_CXX='tpldir=Template.dir~
> + 		rm -rf $tpldir~
> + 		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
> +-		compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"'
> ++		compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
> + 	      old_archive_cmds_CXX='tpldir=Template.dir~
> + 		rm -rf $tpldir~
> + 		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
> +-		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
> ++		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~

The patch is big, but it looks like using ‘substitute*’ wouldn’t be an
easy task, so maybe it’s better this way.  WDYT?

Thanks!

Ludo’.