98d7c11
From 656e495d515b0fc1f01add164aa4bba9a49ceb31 Mon Sep 17 00:00:00 2001
b77fe59
From: Peter Jones <pjones@redhat.com>
98d7c11
Date: Tue, 13 Mar 2018 15:20:34 -0400
98d7c11
Subject: [PATCH 23/25] Call ar in deterministic mode.
b77fe59
b77fe59
We need the x86_64 and i686 builds of .a's to be the same, and that
b77fe59
means we need to not have timestamps.  Also force the timestamps on disk
b77fe59
just in case that doesn't work, because RHEL's ar /silently ignores -D/.
b77fe59
b77fe59
v2: use "ar rvD" not "ar rv -D".
b77fe59
b77fe59
It's a wonder anybody ever gets these command line options right, if
b77fe59
"ar rv -D libfoo.a foo.o" doesn't use deterministic mode (or
b77fe59
complain), but "ar rvD libfoo.a foo.o" does.
b77fe59
b77fe59
v3: Add a bunch of junk to try to set timestamps to 0 manually
b77fe59
b77fe59
For some reason I'm still getting timestamps in the .a even though ar seems to
b77fe59
be invoked correctly.  When I do "mock -r rhel-7-build --shell" and run make
b77fe59
manually, they're fine.  Very strange.
b77fe59
b77fe59
v4: go back to v2, the problem isn't in the make process.
b77fe59
b77fe59
"ar rDv" works just fine, but /usr/lib/rpm/redhat/brp-strip-static-archive is
b77fe59
calling "%{__strip} -g $for_each.a", and it's rewriting our binary from
b77fe59
ts/uid/gid of 0/0/0 to $epoch/$UID/$GID.  Awesomely /usr/bin/strip it seems to
b77fe59
have 3 modes of operation:
b77fe59
-U: the default, which adds $epoch/$UID/$GID to your binary archive
b77fe59
    instead of just removing stuff.  Clearly the Principle of Least
b77fe59
    Surprise is strong here.
b77fe59
-p: preserve the timestamp from the original .a, but add UID and GID,
b77fe59
    because this is 1980 and people use ar(1) for archiving stuff they
b77fe59
    might want that out of.
b77fe59
-D: Condescend at you in a command line error and explain that -D both
b77fe59
    is and is not a valid option:
b77fe59
      /usr/bin/strip: invalid option -- 'D'
b77fe59
      Usage: /usr/bin/strip <option(s)> in-file(s)
b77fe59
      Removes symbols and sections from files
b77fe59
      The options are:
b77fe59
      ...
b77fe59
      -D --enable-deterministic-archives
b77fe59
                  Produce deterministic output when stripping archives
b77fe59
    So I agree that it's invalid, but I think we may be pronouncing that
b77fe59
    second vowel differently.  They say in-VAL-id, I say IN-vuh-lid.
b77fe59
b77fe59
Nobody should ever have to run "strace -ttt -v -f -o make.strace make all",
b77fe59
just to discover the problem isn't even in there.
b77fe59
b77fe59
Related: rhbz#1310782
b77fe59
b77fe59
Signed-off-by: Peter Jones <pjones@redhat.com>
98d7c11
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
b77fe59
---
b77fe59
 Make.defaults | 2 +-
f458757
 1 file changed, 1 insertion(+), 1 deletion(-)
b77fe59
b77fe59
diff --git a/Make.defaults b/Make.defaults
f458757
index ed4b60c2423..ba743f17893 100755
b77fe59
--- a/Make.defaults
b77fe59
+++ b/Make.defaults
f458757
@@ -177,7 +177,7 @@ CFLAGS  += $(ARCH3264) -g -O2 -Wall -Wextra -Werror \
f458757
            $(if $(findstring gcc,$(CC)),-fno-merge-all-constants,)
b77fe59
 endif
b77fe59
 
b77fe59
-ARFLAGS += -U
b77fe59
+ARFLAGS := rDv
b77fe59
 ASFLAGS += $(ARCH3264)
b77fe59
 LDFLAGS	+= -nostdlib --warn-common --no-undefined --fatal-warnings \
b77fe59
 	   --build-id=sha1
b77fe59
-- 
98d7c11
2.15.0
b77fe59