From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 51866 invoked by alias); 25 Jun 2018 11:39:04 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 51855 invoked by uid 89); 25 Jun 2018 11:39:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_SHORT,SPF_PASS autolearn=ham version=3.3.2 spammy=profiling, CC, rm, esac X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 25 Jun 2018 11:39:02 +0000 Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 78C51AC12; Mon, 25 Jun 2018 11:38:59 +0000 (UTC) From: "Bernhard M. Wiedemann" To: gcc-patches@gcc.gnu.org Cc: Joseph Myers , "Bernhard M. Wiedemann" Subject: [PATCH] libtool: Sort output of 'find' to enable deterministic builds. Date: Mon, 25 Jun 2018 11:39:00 -0000 Message-Id: <20180625113856.12031-1-bwiedemann@suse.de> In-Reply-To: References: X-SW-Source: 2018-06/txt/msg01539.txt.bz2 so that gcc builds in a reproducible way in spite of indeterministic filesystem readdir order See https://reproducible-builds.org/ for why this is good. While working on the reproducible builds effort, I found that when building the gcc8 package for openSUSE, there were differences between each build in resulting binaries like gccgo, cc1obj and cpp because the order of objects in libstdc++.a varied based on the order of entries returned by the filesystem. Two remaining issues are with timestamps in the ada build and with profiledbootstrap that only is reproducible if all inputs in the profiling run remain constant (and make -j breaks it too) Testcases: none included because patch is trivial and it would need to compare builds on 2 filesystems. Bootstrapping and testing: tested successfully with gcc8 on x86_64 [gcc] 2018-06-19 Bernhard M. Wiedemann libtool: Sort output of 'find' to enable deterministic builds. --- pulled in libtool commit 74c8993c178a1386ea5e2363a01d919738402f30 because a full update appears to be too troublesome after 8+ years of divergence, but we still really want that fix. See also https://gcc.gnu.org/ml/gcc/2017-10/msg00060.html --- libtool.m4 | 8 ++++---- ltmain.sh | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libtool.m4 b/libtool.m4 index 24d13f344..940faaa16 100644 --- a/libtool.m4 +++ b/libtool.m4 @@ -6005,20 +6005,20 @@ if test "$_lt_caught_CXX_error" != yes; then _LT_TAGVAR(prelink_cmds, $1)='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`"' _LT_TAGVAR(old_archive_cmds, $1)='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`~ $RANLIB $oldlib' _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' diff --git a/ltmain.sh b/ltmain.sh index 9503ec85d..79f9ba89a 100644 --- a/ltmain.sh +++ b/ltmain.sh @@ -2917,7 +2917,7 @@ func_extract_archives () darwin_file= darwin_files= for darwin_file in $darwin_filelist; do - darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` + darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ @@ -2932,7 +2932,7 @@ func_extract_archives () func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac - my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` + my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done func_extract_archives_result="$my_oldobjs" -- 2.13.7