Update this to try to get determanistic builds.

Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
Peter Jones 2017-06-13 16:24:26 -04:00
parent 1d1034c44c
commit b77fe59ae4
5 changed files with 164 additions and 9 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
clog
gnu-efi?3.0*.tar.*
*.rpm
gnu-efi-*/
.build*.log

View File

@ -0,0 +1,25 @@
From 6671a712db5c4dfecd4e7026057a99d9b1c4fe5e Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 7 Mar 2017 10:11:19 -0500
Subject: [PATCH] Nerf -Werror=pragma away
---
Make.defaults | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Make.defaults b/Make.defaults
index a7778a7..8882701 100755
--- a/Make.defaults
+++ b/Make.defaults
@@ -87,6 +87,8 @@ OBJDIR := $(TOPDIR)/$(ARCH)
# Arch-specific compilation flags
CPPFLAGS += -DCONFIG_$(ARCH)
+CFLAGS += -Wno-error=pragmas
+
ifeq ($(ARCH),ia64)
CFLAGS += -mfixed-range=f32-f127
endif
--
2.9.3

View File

@ -0,0 +1,34 @@
From bbd1ee0379327a58e042d288e371f314b7df2d55 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 15 Mar 2017 17:33:39 -0400
Subject: [PATCH] Make ia32 use our own div asm on gnu C as well.
---
lib/ia32/math.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/ia32/math.c b/lib/ia32/math.c
index 81f51bf..fce7a8d 100644
--- a/lib/ia32/math.c
+++ b/lib/ia32/math.c
@@ -140,7 +140,7 @@ DivU64x32 (
// divide 64bit by 32bit and get a 64bit result
// N.B. only works for 31bit divisors!!
{
-#if defined(__GNUC__) && !defined(__MINGW32__)
+#if 0 && defined(__GNUC__) && !defined(__MINGW32__)
if (Remainder)
*Remainder = Dividend % Divisor;
return Dividend / Divisor;
@@ -157,7 +157,7 @@ DivU64x32 (
Rem = 0;
for (bit=0; bit < 64; bit++) {
-#ifdef __MINGW32__
+#if defined(__GNUC__) || defined(__MINGW32__)
asm (
"shll $1, %0\n\t"
"rcll $1, 4%0\n\t"
--
2.12.0

View File

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

View File

@ -1,7 +1,7 @@
Summary: Development Libraries and headers for EFI
Name: gnu-efi
Version: 3.0.5
Release: 7%{?dist}
Release: 8%{?dist}%{?buildid}
Epoch: 1
Group: Development/System
License: BSD
@ -10,10 +10,14 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
ExclusiveArch: x86_64 aarch64 %{arm} %{ix86}
BuildRequires: git
%ifarch x86_64
BuildRequires: glibc32
#BuildRequires: glibc32
BuildRequires: glibc-devel(x86-32)
%endif
Source: http://superb-dca2.dl.sourceforge.net/project/gnu-efi/gnu-efi-%{version}.tar.bz2
# dammit, rpmlint, shut up.
%define lib %{nil}lib%{nil}
Patch0001: 0001-Mark-our-explicit-fall-through-so-Wextra-will-work-i.patch
Patch0002: 0002-Fix-some-types-gcc-doesn-t-like.patch
Patch0003: 0003-Fix-arm-build-paths-in-the-makefile.patch
@ -24,9 +28,25 @@ Patch0007: 0007-make-clang-not-complain-about-fno-merge-constants.patch
Patch0008: 0008-Fix-another-place-clang-complains-about.patch
Patch0009: 0009-route80h-remove-some-dead-code.patch
Patch0010: 0010-Make-clang-not-complain-about-the-debughook-s-optimi.patch
Patch0011: 0011-Nerf-Werror-pragma-away.patch
Patch0012: 0012-Make-ia32-use-our-own-div-asm-on-gnu-C-as-well.patch
Patch0013: 0013-Call-ar-in-deterministic-mode.patch
%define debug_package %{nil}
# brp-strip-static-archive will senselessly /add/ timestamps and uid/gid
# data to our .a and make them not multilib clean if we don't have this.
# Note that if we don't have the shell quotes there, -p becomes $2 on its
# invocation, and so it completely ignores it.
#
# Also note that if we try to use -D as we should (so it doesn't add
# uid/gid), strip(1) from binutils-2.25.1-22.base.el7.x86_64 throws a
# syntax error.
#
# True story.
#
%global __strip "%{__strip} -p"
# Figure out the right file path to use
%global efidir %(eval echo $(grep ^ID= /etc/os-release | sed -e 's/^ID=//' -e 's/rhel/redhat/'))
@ -82,8 +102,8 @@ git config --unset user.name
make
make apps
%ifarch x86_64
setarch linux32 -B make ARCH=ia32 PREFIX=%{_prefix} LIBDIR=%{_prefix}/lib
setarch linux32 -B make ARCH=ia32 PREFIX=%{_prefix} LIBDIR=%{_prefix}/lib apps
setarch linux32 -B make ARCH=ia32 PREFIX=%{_prefix} LIBDIR=%{_prefix}/%{lib}
setarch linux32 -B make ARCH=ia32 PREFIX=%{_prefix} LIBDIR=%{_prefix}/%{lib} apps
%endif
%install
@ -96,11 +116,11 @@ mv %{buildroot}/%{_libdir}/*.lds %{buildroot}/%{_libdir}/*.o %{buildroot}/%{_lib
mv %{efiarch}/apps/{route80h.efi,modelist.efi} %{buildroot}/boot/efi/EFI/%{efidir}/%{efiarch}/
%ifarch x86_64
mkdir -p %{buildroot}/%{_prefix}/lib/gnuefi
mkdir -p %{buildroot}/%{_prefix}/%{lib}/gnuefi
mkdir -p %{buildroot}/boot/efi/EFI/%{efidir}/ia32
setarch linux32 -B make PREFIX=%{_prefix} LIBDIR=%{_prefix}/lib INSTALLROOT=%{buildroot} ARCH=ia32 install
mv %{buildroot}/%{_prefix}/lib/*.{lds,o} %{buildroot}/%{_prefix}/lib/gnuefi/
setarch linux32 -B make PREFIX=%{_prefix} LIBDIR=%{_prefix}/%{lib} INSTALLROOT=%{buildroot} ARCH=ia32 install
mv %{buildroot}/%{_prefix}/%{lib}/*.{lds,o} %{buildroot}/%{_prefix}/%{lib}/gnuefi/
mv ia32/apps/{route80h.efi,modelist.efi} %{buildroot}/boot/efi/EFI/%{efidir}/ia32/
%endif
@ -108,7 +128,7 @@ mv ia32/apps/{route80h.efi,modelist.efi} %{buildroot}/boot/efi/EFI/%{efidir}/ia3
rm -rf %{buildroot}
%files
%{_prefix}/lib*/*
%{_prefix}/%{lib}*/*
%files devel
%defattr(-,root,root,-)
@ -120,6 +140,9 @@ rm -rf %{buildroot}
%attr(0644,root,root) /boot/efi/EFI/%{efidir}/*/*.efi
%changelog
* Tue Jun 13 2017 Peter Jones <pjones@redhat.com> - 3.0.5-8
- Update this to try to get determanistic builds.
* Mon Mar 20 2017 Peter Jones <pjones@redhat.com> - 3.0.5-7
- Also build the ia32 bits in a separate 32-bit package for other consumers.