[1/1] BFD: Use SOURCE_DATE_EPOCH for COFF style armaps.

Message ID 20260415215731.441682-2-me@manueljacob.de
State New
Headers
Series [1/1] BFD: Use SOURCE_DATE_EPOCH for COFF style armaps. |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

Manuel Jacob April 15, 2026, 9:57 p.m. UTC
  Previously, ar created archives where the files have timestamps corresponding to SOURCE_DATE_EPOCH (if set), but the armap has a timestamp corresponding to the current system time. This change ensures that the armap has a timestamp corresponding to SOURCE_DATE_EPOCH as well (if set).

Per SOURCE_DATE_EPOCH specification [1]: “Build processes MUST use this variable for embedded timestamps in place of the "current" date and time.”

This change is not relevant when deterministic mode is enabled, since in that case, the armap timestamp will be set to 0, regardless of SOURCE_DATE_EPOCH.

[1] https://reproducible-builds.org/specs/source-date-epoch/

Signed-off-by: Manuel Jacob <me@manueljacob.de>
---
 bfd/archive.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Jan Beulich April 21, 2026, 3:45 p.m. UTC | #1
On 15.04.2026 23:57, Manuel Jacob wrote:
> Previously, ar created archives where the files have timestamps corresponding to SOURCE_DATE_EPOCH (if set), but the armap has a timestamp corresponding to the current system time. This change ensures that the armap has a timestamp corresponding to SOURCE_DATE_EPOCH as well (if set).
> 
> Per SOURCE_DATE_EPOCH specification [1]: “Build processes MUST use this variable for embedded timestamps in place of the "current" date and time.”
> 
> This change is not relevant when deterministic mode is enabled, since in that case, the armap timestamp will be set to 0, regardless of SOURCE_DATE_EPOCH.
> 
> [1] https://reproducible-builds.org/specs/source-date-epoch/
> 
> Signed-off-by: Manuel Jacob <me@manueljacob.de>

Okay.

Jan
  

Patch

diff --git a/bfd/archive.c b/bfd/archive.c
index db978dfea2c..44030eb3d63 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -2915,7 +2915,7 @@  _bfd_coff_write_armap (bfd *arch,
     return false;
   _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld",
 		    ((arch->flags & BFD_DETERMINISTIC_OUTPUT) == 0
-		     ? time (NULL) : 0));
+		     ? bfd_get_current_time (0) : 0));
   /* This, at least, is what Intel coff sets the values to.  */
   _bfd_ar_spacepad (hdr.ar_uid, sizeof (hdr.ar_uid), "%ld", 0);
   _bfd_ar_spacepad (hdr.ar_gid, sizeof (hdr.ar_gid), "%ld", 0);