1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 579039: Limit SOURCE_DATE_EPOCH to fit 32bit unsigned int

The impementation in GCC allows a value up to 253402300799 that
corresponds to "Dec 31 9999 23:59:59 UTC". Apparently, this is due
to some limit of __DATE__ and __TIME__ within the preprocessor.
Regardless, as the reporter claims to have problem with values
outside the range of a 32bit unsigned integer, lets use
"(1 << 32) - 1" as a limit.

Contributed by STMicroelectronics

Change-Id: Ifa7995cd9edb460d4ad6544b5231eef88d7e39a0
Signed-off-by: Torbjörn Svensson <torbjorn.svensson@st.com>
This commit is contained in:
Torbjörn Svensson 2022-03-09 18:16:17 +01:00
parent 0ae896b0f1
commit 66f3c6b08d
5 changed files with 2 additions and 2 deletions

View file

@ -15,7 +15,7 @@ import os
import hashlib import hashlib
import subprocess import subprocess
LONG_MAX = (1 << 64) - 1 UINT32_MAX = (1 << 32) - 1
DEBUG = True DEBUG = True
def usage(msg=None): def usage(msg=None):
@ -65,7 +65,7 @@ sha1.update(data)
debug("Content hashed: {}".format(sha1.hexdigest())) debug("Content hashed: {}".format(sha1.hexdigest()))
# Set the SOURCE_DATE_EPOCH environment variable to the hash value # Set the SOURCE_DATE_EPOCH environment variable to the hash value
os.environ["SOURCE_DATE_EPOCH"] = str(int(sha1.hexdigest(), base=16) % LONG_MAX) os.environ["SOURCE_DATE_EPOCH"] = str(int(sha1.hexdigest(), base=16) % UINT32_MAX)
debug("SOURCE_DATE_EPOCH: {}".format(os.environ["SOURCE_DATE_EPOCH"])) debug("SOURCE_DATE_EPOCH: {}".format(os.environ["SOURCE_DATE_EPOCH"]))
# Run the compiler with the environement variable set # Run the compiler with the environement variable set