RFC: Supporting SOURCE_DATE_EPOCH in ar

Fangrui Song i@maskray.me
Tue Aug 29 16:26:51 GMT 2023


On Tue, Aug 29, 2023 at 2:46 AM Nick Clifton via Binutils
<binutils@sourceware.org> wrote:
>
> Hi Guys,
>
>   I have been looking improving our support for reproducible builds, and
>   in particular how we might be able to use the SOURCE_DATE_EPOCH
>   environment variable when creating and maintaining static archives.  I
>   think that it can be done, and the attached patch is my proposal for
>   implementing this.
>
>   The patch makes several changes:
>
>     * Adding files to a reproduicble archive, either one created with
>       --enable-deterministic-archives or with SOURCE_DATA_EPOCH set is
>       allowed.  If the update ('u') modifier is in effect it will be
>       ignored and the new file(s) will always replace the old file(s).
>
>     * Running "ar ruD" will no longer trigger an error, but instead give
>       a warning message and then proceed as outlined above.
>
>     * It adds a new function - bfd_get_current_time() - which can be
>       used instead of calling time().  This will return
>       SOURCE_DATE_EPOCH if it is defined.  The function can also be used
>       to conditionally update the st_mtime field in a stat structure,
>       changing it only if SOURCE_DATE_EPOCH is defined.
>
>     * It adds three new tests to the binutils testsuite to check that
>       the new behaviour is supported correctly.
>
>   Any comments or suggestions ?
>
> Cheers
>   Nick
>
> https://reproducible-builds.org/docs/source-date-epoch/
>

Hi Nick,

Thanks for improving reproducibility!

I wonder whether binutils/configure.ac can default to
default_ar_deterministic=1.
https://wiki.debian.org/ReproducibleBuilds/TimestampsInStaticLibraries
Debian "binutils is now built with --enable-deterministic-archives
since version 2.25-6."
https://bugzilla.redhat.com/show_bug.cgi?id=1124342

With these changes, do we need more work on a
--disable-deterministic-archives build of ar operating on
deterministic archives?


More information about the Binutils mailing list