From patchwork Tue Jun 19 07:32:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bernhard M. Wiedemann" X-Patchwork-Id: 931453 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-479992-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="RNWNIekr"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41906r3vn1z9s4w for ; Tue, 19 Jun 2018 17:32:51 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=i3fY9/N12RT5mhYlTk+SVFarcyAaw46XAPIvOOnmomA41Y00aK0jN 9+wfOHphB9kxvPjk1pQDcQMIX1vZdfXuOTVWePFSaKX31CQ7rWM/XMi0Fu8WpMrQ v9UepYZ7ZqxS/Q4KX+iEdancTCYktmtH8D9fPR4D0ArAWTZb5N2xvQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=z2AeSGA+uKeEIx9ao79S/9uI1uA=; b=RNWNIekrYPfcrzCsLX/W y13IJkbjSfclLKb7CShcNif34HOvhSN/vhUGtioF/gPXlKu2aLOdMRnGxKZbuRX5 EBhrtLIOltqvHFkS21HfcESPfhAOn+vog/m61kFMefvbesqwMPSx44ngOsAkhNKH SJ+HlPWzQhEG3NarwLMiBPM= Received: (qmail 78986 invoked by alias); 19 Jun 2018 07:32:44 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 78975 invoked by uid 89); 19 Jun 2018 07:32:43 -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= 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; Tue, 19 Jun 2018 07:32:42 +0000 Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 21945AF73 for ; Tue, 19 Jun 2018 07:32:40 +0000 (UTC) From: "Bernhard M. Wiedemann" To: gcc-patches@gcc.gnu.org Cc: "Bernhard M. Wiedemann" Subject: [PATCH] libtool: Sort output of 'find' to enable deterministic builds. Date: Tue, 19 Jun 2018 09:32:35 +0200 Message-Id: <20180619073235.12992-1-bwiedemann@suse.de> In-Reply-To: References: 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 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 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"