[ipxe-devel] how to provide a stable _build_id?

Olaf Hering olaf at aepfle.de
Thu Nov 3 10:09:21 UTC 2016


On Thu, Feb 12, Michael Brown wrote:

> On 12/02/15 13:44, Olaf Hering wrote:
> > In the spirit of 335a7ddcd4e2d0faaee6d5b1edf0307dfba3d0e5 ("[build] Sort
> > objects in blib.a") to get reproducible binaries from the very same
> > source on different build hosts, the last missing piece to reach that
> > goal is this code in src/Makefile.housekeeping:
> > 
> > ...
> > # Command to generate build ID.  Must be unique for each $(BIN)/%.tmp,
> > # even within the same build run.
> > #
> > BUILD_ID_CMD    := perl -e 'printf "0x%08x", int ( rand ( 0xffffffff ) );'
> > ...
> > --defsym _build_id=`$(BUILD_ID_CMD)`
> > ...
> > 
> > The comment makes it clear: appearently some code out there wants this ever
> > changing build_id. What code is it, what will break if _build_id gets a fixed
> > value, and what can be done to give each object an stable but unique id?
> 
> romprefix.S uses it to identify multiple instances of itself (e.g. when a
> multi-port NIC exposes the same ROM via multiple PCI functions), in order to
> share PMM-allocated blocks.  mromprefix.S also uses it to locate its own ROM
> image within the borrowed PCI BAR.
> 
> For this to work, it is important that different binaries (even if built
> from the same bin/blib.a) will never have the same build ID.

Looks like this issue never moved forward. This solves it for me:

-BUILD_ID_CMD   := perl -e 'printf "0x%08x", int ( rand ( 0xffffffff ) );'
+BUILD_ID_CMD    := bash -x -c 'declare -i i=1 ; while : ; do dir=$$(printf 0x%08x $$i) ; : $$(( i++ )) ; mkdir "$${dir}" || continue ; echo "$${dir}" ; break ; done'

I'm sure the shell part can be done in perl as well.

Olaf



More information about the ipxe-devel mailing list