[LLD] [COFF] Pick timestamps from the SOURCE_DATE_EPOCH variable (#81326)
authorMartin Storsjö <martin@martin.st>
Sat, 10 Feb 2024 21:57:12 +0000 (23:57 +0200)
committerTom Stellard <tstellar@redhat.com>
Sun, 11 Feb 2024 01:48:47 +0000 (17:48 -0800)
commit0d656f0f12d447ac0e197618a0d25495d66388d1
tree78546c47c647305ba64b67136524a99d81784205
parent91cb452c3cd1e527dd74ece20a83b9fb2ffa6f5c
[LLD] [COFF] Pick timestamps from the SOURCE_DATE_EPOCH variable (#81326)

The SOURCE_DATE_EPOCH environment variable can be set in order to get
reproducible build.

When linking PE/COFF modules with LLD, the timestamp field is set to the
current time, unless either the /timestamp: or /Brepro option is set. If
neither of them is set, check the SOURCE_DATE_EPOCH variable, before
resorting to using the actual current date and time.

See https://reproducible-builds.org/docs/source-date-epoch/ for reference
on the use of this variable.

(cherry picked from commit 0df8aed6c30f08ded526038a6bbb4daf113a31c1)
lld/COFF/Driver.cpp
lld/test/COFF/timestamp.test