[klibc] [PATCH] klibc: reproducible builds

Mike Waychison mikew at google.com
Tue Oct 19 23:43:23 PDT 2010


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 :)



More information about the klibc mailing list