From: Maciej ?enczykowski <maze at google.com> This adds a new setting: KBUILD_REPRODUCIBLE If it is non-empty, ar and ranlib will be called in such a way that timestamps do not affect the build output. This allows one to get perfectly reproducible builds. Signed-off-by: Maciej ?enczykowski <maze at google.com> --- scripts/Kbuild.klibc | 14 +++++++++----- usr/klibc/Kbuild | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc index 79d196f..6427be0 100644 --- a/scripts/Kbuild.klibc +++ b/scripts/Kbuild.klibc @@ -93,11 +93,15 @@ KLIBCMINOR := $(shell cut -d. -f2 $(srctree)/usr/klibc/version) KLIBCLD := $(LD) KLIBCCC := $(CC) KLIBCAR := $(AR) -KLIBCRANLIB := $(RANLIB) +KLIBCAR_cq := $(KLIBCAR) $(if $(KBUILD_REPRODUCIBLE),Dcq,cq) +KLIBCAR_crs := $(KLIBCAR) $(if $(KBUILD_REPRODUCIBLE),Dcrs,crs) +KLIBCAR_cru := $(KLIBCAR) $(if $(KBUILD_REPRODUCIBLE),Dcr,cru) +KLIBCAR_s := $(KLIBCAR) $(if $(KBUILD_REPRODUCIBLE),Ds,s) +KLIBCRANLIB := $(KLIBCAR_s) KLIBCSTRIP := $(STRIP) KLIBCNM := $(NM) -KLIBCOBJCOPY := $(OBJCOPY) -KLIBCOBJDUMP := $(OBJDUMP) +KLIBCOBJCOPY := $(OBJCOPY) +KLIBCOBJDUMP := $(OBJDUMP) # klibc include paths KLIBCCPPFLAGS := -nostdinc -iwithprefix include \ @@ -265,8 +269,8 @@ ifdef lib-target quiet_cmd_link_o_target = LD $@ # If the list of objects to link is empty, just create an empty lib.a cmd_link_o_target = $(if $(strip $(lib-y)),\ - rm -f $@; $(KLIBCAR) cru $@ $(filter $(lib-y), $^),\ - rm -f $@; $(KLIBCAR) crs $@) + rm -f $@; $(KLIBCAR_cru) $@ $(filter $(lib-y), $^),\ + rm -f $@; $(KLIBCAR_crs) $@) $(lib-target): $(lib-y) FORCE $(call if_changed,link_o_target) diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild index ab5212b..f64785e 100644 --- a/usr/klibc/Kbuild +++ b/usr/klibc/Kbuild @@ -109,7 +109,7 @@ klib-o-files = $(shell cat $(obj)/klib.list \ targets += libc.a __static_init.o quiet_cmd_libc = KLIBCAR $@ cmd_libc = rm -f $@; \ - $(KLIBCAR) cq $@ \ + $(KLIBCAR_cq) $@ \ $(call objectify,__static_init.o) $(klib-o-files); \ $(KLIBCRANLIB) $@ -- 1.7.1
On Tue, Oct 19, 2010 at 5:07 PM, Maciej ?enczykowski <zenczykowski at gmail.com> wrote:> From: Maciej ?enczykowski <maze at google.com> > > This adds a new setting: KBUILD_REPRODUCIBLE > If it is non-empty, ar and ranlib will be called in such > a way that timestamps do not affect the build output. > This allows one to get perfectly reproducible builds. > > Signed-off-by: Maciej ?enczykowski <maze at google.com> > --- > ?scripts/Kbuild.klibc | ? 14 +++++++++----- > ?usr/klibc/Kbuild ? ? | ? ?2 +- > ?2 files changed, 10 insertions(+), 6 deletions(-) > > diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc > index 79d196f..6427be0 100644 > --- a/scripts/Kbuild.klibc > +++ b/scripts/Kbuild.klibc > @@ -93,11 +93,15 @@ KLIBCMINOR ? ? ? ?:= $(shell cut -d. -f2 $(srctree)/usr/klibc/version) > ?KLIBCLD ? ? ? ? ?:= $(LD) > ?KLIBCCC ? ? ? ? ?:= $(CC) > ?KLIBCAR ? ? ? ? ?:= $(AR) > -KLIBCRANLIB ? ? ?:= $(RANLIB) > +KLIBCAR_cq ? ? ? := $(KLIBCAR) $(if $(KBUILD_REPRODUCIBLE),Dcq,cq) > +KLIBCAR_crs ? ? ?:= $(KLIBCAR) $(if $(KBUILD_REPRODUCIBLE),Dcrs,crs) > +KLIBCAR_cru ? ? ?:= $(KLIBCAR) $(if $(KBUILD_REPRODUCIBLE),Dcr,cru)Did you mean to drop 'u' here? It'd probably be clearer to have a macro that gets called: KLIBCAR := $(AR) # Macro that invokes KLIBCAR. Takes an argument of ar commands. Will specify "D" to ar if we wish to skip timestamps. invoke-KLIBCAR = $(KLIBCAR) $(if $(KBUILD_REPRODUCIBLE),D)$(1) So this: - ? ? ? ? ? ? ? ? ? ?rm -f $@; $(KLIBCAR) cru $@ $(filter $(lib-y), $^),\ - ? ? ? ? ? ? ? ? ? ?rm -f $@; $(KLIBCAR) crs $@) becomes + rm -f $@; $(call invoke-KLIBCAR,cru) $@ $(filter $(lib-y), $^),\ + rm -f $@; $(call invoke-KLIBCAR,crs) $@) Just a suggestion :)
Maximillian Attems
2010-Oct-30 13:25 UTC
[klibc] [PATCH] klibc: enable reproducible builds
On Mon, 25 Oct 2010, Maciej ?enczykowski wrote:> From: Maciej ?enczykowski <maze at google.com> > > This adds a new setting: KBUILD_REPRODUCIBLE > If it is non-empty, ar and ranlib will be called in such > a way that timestamps do not affect the build output. > This allows one to get perfectly reproducible builds. >thanks, applied and pushed out.