sort various input files for reproducible build
cover sort various input files for reproducible build
The need for these changes was caught by build-compare, a tool used in openSUSE buildservice which prevents needless rebuilds and needless republish of a package.
Olaf
Olaf Hering (3):
docs: create reproducible html
etherboot: [build] sort objects in blib.a
mini-os: sort objects in binary archives
docs/Makefile | 10 +++++----- extras/mini-os/Makefile | 4 ++-- extras/mini-os/arch/x86/Makefile | 2 +- tools/firmware/etherboot/patches/build-compare.patch | 19 +++++++++++++++++++ tools/firmware/etherboot/patches/series | 1 + 5 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 tools/firmware/etherboot/patches/build-compare.patch
PATCH 1/3 docs: create reproducible html
The Makefile uses wildcard to collect a list of files. The resulting list of files is in directory order, which is random. As a result the generated html files will differ when build on different hosts.
Use the built-in sort function to get a stable list of files.
--- docs/Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
docs/Makefile +5 -5
@@ -7,14 +7,14 @@ VERSION := $(shell $(MAKE) -C $(XEN_ROOT)/xen --no-print-directory xenversion) DOC_ARCHES := arm x86_32 x86_64 # Documentation sources to build -MAN1SRC-y := $(wildcard man/xl*.pod.1) -MAN1SRC-y += $(wildcard man/xenstore*.pod.1) +MAN1SRC-y := $(sort $(wildcard man/xl*.pod.1)) +MAN1SRC-y += $(sort $(wildcard man/xenstore*.pod.1)) -MAN5SRC-y := $(wildcard man/xl*.pod.5) +MAN5SRC-y := $(sort $(wildcard man/xl*.pod.5)) -MARKDOWNSRC-y := $(wildcard misc/*.markdown) +MARKDOWNSRC-y := $(sort $(wildcard misc/*.markdown)) -TXTSRC-y := $(wildcard misc/*.txt) +TXTSRC-y := $(sort $(wildcard misc/*.txt)) DOC_MAN1 := $(patsubst man/%.pod.1,man1/%.1,$(MAN1SRC-y))
PATCH 2/3 etherboot: [build] sort objects in blib.a
In reply to Olaf HeringWhen building hvmloader for Xen tools the ipxe objects are also linked into the binary. Unfortunately the linker will place them in the order found in the archive. Since this order is random the resulting hvmloader binary differs when it was built from identical sources but on different build hosts. To help with creating a reproducible binary the elements in blib.a must simply be sorted before passing them to $(AR).
---
This was sent to the ipxe listm no reply so far:
http://lists.ipxe.org/pipermail/ipxe-devel/2015-February/003959.html
tools/firmware/etherboot/patches/build-compare.patch | 19 +++++++++++++++++++ tools/firmware/etherboot/patches/series | 1 + 2 files changed, 20 insertions(+)
tools/firmware/etherboot/patches/build-compare.patch new file +19 -0
@@ -0,0 +1,19 @@ +The result of $(wildcard *) is random. +Sort input files to reduce build-compare noise. +--- + ipxe/src/Makefile.housekeeping | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +Index: ipxe/src/Makefile.housekeeping +=================================================================== +--- ipxe/src/Makefile.housekeeping ++++ ipxe/src/Makefile.housekeeping +@@ -773,7 +773,7 @@ BLIB = $(BIN)/blib.a + $(BLIB) : $(BLIB_OBJS) $(BLIB_LIST) $(MAKEDEPS) + $(Q)$(RM) $(BLIB) + $(QM)$(ECHO) " [AR] $@" +- $(Q)$(AR) r $@ $(BLIB_OBJS) ++ $(Q)$(AR) r $@ $(sort $(BLIB_OBJS)) + $(Q)$(RANLIB) $@ + blib : $(BLIB) +
tools/firmware/etherboot/patches/series +1 -0
@@ -2,3 +2,4 @@ boot_prompt_option.patch build_fix_1.patch build_fix_2.patch build_fix_3.patch +build-compare.patch
Re: [PATCH 2/3] etherboot: [build] sort objects in blib.a
Quoted 7 lines · Olaf Hering
When building hvmloader for Xen tools the ipxe objects are also linked into the binary. Unfortunately the linker will place them in the order found in the archive. Since this order is random the resulting hvmloader binary differs when it was built from identical sources but on different build hosts. To help with creating a reproducible binary the elements in blib.a must simply be sorted before passing them to $(AR).
Quoted 5 lines
Signed-off-by Olaf Hering <[email protected]>Cc Ian Jackson <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Ian Campbell <[email protected]>Cc Wei Liu <[email protected]>
Applied along with the first patch of the series. I'm expect the third patch to be picked up after the mini-os split.
Quoted 2 lines
This was sent to the ipxe listm no reply so far:
http://lists.ipxe.org/pipermail/ipxe-devel/2015-February/003959.html
I see it has now been applied. I'm not sure who should be responsible for updating the baseline for firmware, for all I know it is me...
But maybe we want to wait for an upstream release anyhow.
PATCH 3/3 mini-os: sort objects in binary archives
In reply to Olaf HeringWhen building stubdom the mini-os objects are also linked into the binary. Unfortunately the linker will place them in the order found in the archive. Since this order is random the resulting stubdom binary differs when it was built from identical sources but on different build hosts. To help with creating a reproducible binary the elements in an archive must simply be sorted before passing them to $(AR).
--- extras/mini-os/Makefile | 4 ++-- extras/mini-os/arch/x86/Makefile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
extras/mini-os/Makefile +2 -2
@@ -148,9 +148,9 @@ arch_lib: ifeq ($(CONFIG_LWIP),y) # lwIP library -LWC := $(shell find $(LWIPDIR)/src -type f -name '*.c') +LWC := $(sort $(shell find $(LWIPDIR)/src -type f -name '*.c')) LWC := $(filter-out %6.c %ip6_addr.c %ethernetif.c, $(LWC)) -LWO := $(patsubst %.c,%.o,$(LWC)) +LWO := $(patsubst %.c,%.o,$(LWC) LWO += $(OBJ_DIR)/lwip-arch.o ifeq ($(CONFIG_NETFRONT),y) LWO += $(OBJ_DIR)/lwip-net.o
extras/mini-os/arch/x86/Makefile +1 -1
@@ -14,7 +14,7 @@ include ../../minios.mk # Sources here are all *.c *.S without $(XEN_TARGET_ARCH).S # This is handled in $(HEAD_ARCH_OBJ) -ARCH_SRCS := $(wildcard *.c) +ARCH_SRCS := $(sort $(wildcard *.c)) # The objects built from the sources. ARCH_OBJS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(ARCH_SRCS))
Re: [PATCH 3/3] mini-os: sort objects in binary archives
extras/mini-os/Makefile arch_lib: · line 153
Quoted 4 lines · Olaf Hering
+++ b/extras/mini-os/Makefile
extras/mini-os/Makefile +1
-1-LWO := $(patsubst %.c,%.o,$(LWC)) +LWO := $(patsubst %.c,%.o,$(LWC)
Somehow this brace disappeared. Should I resend or can this be adjusted when the patch gets merged?
Olaf
Re: [PATCH 3/3] mini-os: sort objects in binary archives
Quoted 10 lines · Olaf Hering
extras/mini-os/Makefile arch_lib: · line 153
Quoted 4 lines · Olaf Hering
+++ b/extras/mini-os/Makefile
extras/mini-os/Makefile +1
-1-LWO := $(patsubst %.c,%.o,$(LWC)) +LWO := $(patsubst %.c,%.o,$(LWC)Somehow this brace disappeared. Should I resend or can this be adjusted when the patch gets merged?
FWIW I can carry this patch in my series to split off mini-os if necessary. I need to rerun the extraction process anyway to include this patch. I would rather commence the splitting off sooner rather than later.
Or we can commit this patch as soon as possible. It looks OK to me apart from the minor error.
Otherwise we can commence splitting off and then apply this patch to the split-off mini-os tree.
Wei.
Quoted 6 lines
Olaf
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 3/3] mini-os: sort objects in binary archives
Quoted 2 lines · Wei Liu
Otherwise we can commence splitting off and then apply this patch to the split-off mini-os tree.
mini-os has just been split off, minus this patch.
I intend to let the push gate process that split (hopefully the gate will pass over the w/e) and then apply this patch as the first fresh commit in the new tree, which will help check all the bits are in place etc.
I can adjust the paths and fix missing bracket as I go. I'll also update MINIOS_UPSTREAM_REVISION in xen.git to the new thing.
Ian.
Re: [PATCH 3/3] mini-os: sort objects in binary archives
In reply to Olaf Heringextras/mini-os/Makefile arch_lib: · line 153
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 03.02.15 at 12:45, <[email protected]> wrote:
extras/mini-os/Makefile +2
-2@@ -148,9 +148,9 @@ arch_lib: ifeq ($(CONFIG_LWIP),y) # lwIP library -LWC := $(shell find $(LWIPDIR)/src -type f -name '*.c') +LWC := $(sort $(shell find $(LWIPDIR)/src -type f -name '*.c')) LWC := $(filter-out %6.c %ip6_addr.c %ethernetif.c, $(LWC)) -LWO := $(patsubst %.c,%.o,$(LWC)) +LWO := $(patsubst %.c,%.o,$(LWC)
This looks broken.
Jan
Re: [PATCH 3/3] mini-os: sort objects in binary archives
In reply to Olaf HeringQuoted 10 lines · Olaf Hering, le Tue 03 Feb 2015 12:45:37 +0100, a écrit :
When building stubdom the mini-os objects are also linked into the binary. Unfortunately the linker will place them in the order found in the archive. Since this order is random the resulting stubdom binary differs when it was built from identical sources but on different build hosts. To help with creating a reproducible binary the elements in an archive must simply be sorted before passing them to $(AR).
Signed-off-by Olaf Hering <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Samuel Thibault <[email protected]>
Provided that the missing parenthesis gets fixed,
Quoted 35 lines
--- extras/mini-os/Makefile | 4 ++-- extras/mini-os/arch/x86/Makefile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)extras/mini-os/Makefile +2
-2@@ -148,9 +148,9 @@ arch_lib: ifeq ($(CONFIG_LWIP),y) # lwIP library -LWC := $(shell find $(LWIPDIR)/src -type f -name '*.c') +LWC := $(sort $(shell find $(LWIPDIR)/src -type f -name '*.c')) LWC := $(filter-out %6.c %ip6_addr.c %ethernetif.c, $(LWC)) -LWO := $(patsubst %.c,%.o,$(LWC)) +LWO := $(patsubst %.c,%.o,$(LWC) LWO += $(OBJ_DIR)/lwip-arch.o ifeq ($(CONFIG_NETFRONT),y) LWO += $(OBJ_DIR)/lwip-net.oextras/mini-os/arch/x86/Makefile +1
-1@@ -14,7 +14,7 @@ include ../../minios.mk # Sources here are all *.c *.S without $(XEN_TARGET_ARCH).S # This is handled in $(HEAD_ARCH_OBJ) -ARCH_SRCS := $(wildcard *.c) +ARCH_SRCS := $(sort $(wildcard *.c)) # The objects built from the sources. ARCH_OBJS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(ARCH_SRCS))
Signature · 1 line
Samuel
Quoted 2 lines
Subject: pb fvwm95-2 comment l'installer le compiler??? Merci d'avance
je te conseille d'être un peu plus précis dans l'exposé de ton pb... -+- EJ in guide du linuxien pervers :"Les modéros sont sympas !" -+-
Re: [PATCH 3/3] mini-os: sort objects in binary archives
Quoted 8 lines · Samuel Thibault
Quoted 7 lines · Olaf Hering, le Tue 03 Feb 2015 12:45:37 +0100, a écrit :
When building stubdom the mini-os objects are also linked into the binary. Unfortunately the linker will place them in the order found in the archive. Since this order is random the resulting stubdom binary differs when it was built from identical sources but on different build hosts. To help with creating a reproducible binary the elements in an archive must simply be sorted before passing them to $(AR).
Quoted 7 lines
Quoted 3 lines
Signed-off-by Olaf Hering <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Samuel Thibault <[email protected]>Provided that the missing parenthesis gets fixed,
Acked-by Samuel Thibault <[email protected]>
I did s,extras/mini-os/,, on the paths and applied to mini-os.git.
I also pushed to xen.git (which includes Wei's build fix too):
commit 00f1fc5fd2bb9c7cf7f0e8a841ee741e547a4145
Author: Ian Campbell <[email protected]> Date: Wed Mar 11 10:47:33 2015 +0000
MINIOS_UPSTREAM_REVISION Update
Config.mk +3 -3
@@ -255,9 +255,9 @@ MINIOS_UPSTREAM_URL ?= git://xenbits.xen.org/mini-os.git endif OVMF_UPSTREAM_REVISION ?= a065efc7c7ce8bb3e5cb3e463099d023d4a92927 QEMU_UPSTREAM_REVISION ?= master -MINIOS_UPSTREAM_REVISION ?= 55f7cd7427ef3e7fe3563a3da46d8664a2ed0d6d -# Thu Jan 29 19:10:04 2015 +0000 -# Mini-OS: standalone build +MINIOS_UPSTREAM_REVISION ?= d0b7f0f62fd0e1154d29849b9f2e6de3783742ce +# Tue Mar 10 13:14:38 2015 +0000 +# mini-os: replace XEN_TARGET_ARCH with MINIOS_TARGET_ARCH SEABIOS_UPSTREAM_REVISION ?= rel-1.8.0 # Wed Feb 18 12:49:59 2015 -0500
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 3/3] mini-os: sort objects in binary archives
In reply to Olaf HeringQuoted 6 lines · Olaf Hering
When building stubdom the mini-os objects are also linked into the binary. Unfortunately the linker will place them in the order found in the archive. Since this order is random the resulting stubdom binary differs when it was built from identical sources but on different build hosts. To help with creating a reproducible binary the elements in an archive must simply be sorted before passing them to $(AR).
OOI why does this problem not also apply the to the regular .a and .so files we build?
Re: [PATCH 3/3] mini-os: sort objects in binary archives
Quoted 10 lines · Ian Campbell
Quoted 6 lines · Olaf Hering
When building stubdom the mini-os objects are also linked into the binary. Unfortunately the linker will place them in the order found in the archive. Since this order is random the resulting stubdom binary differs when it was built from identical sources but on different build hosts. To help with creating a reproducible binary the elements in an archive must simply be sorted before passing them to $(AR).
OOI why does this problem not also apply the to the regular .a and .so files we build?
Either because they are built from a fixed list of input files, or the linker places the individual object files in a fixed order into shared objects.
Olaf