Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkgs/build-support/cc-wrapper/cc-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ source @out@/nix-support/add-hardening.sh
extraAfter=($NIX_@infixSalt@_CFLAGS_COMPILE)
extraBefore=(${hardeningCFlags[@]+"${hardeningCFlags[@]}"})

# When enforcing purity, pretend gcc can't find the current date and
# time
if [[ "${NIX_ENFORCE_PURITY:-}" = 1 ]]; then
extraAfter=(-D__DATE__=\"???-??-????\"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean?

Suggested change
extraAfter=(-D__DATE__=\"???-??-????\"
extraAfter=(-D__DATE__=\"??-??-????\"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know what debian is doing here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that there has been a patch to gcc (since 2016) to allow using SOURCE_DATE_EPOCH https://wiki.debian.org/ReproducibleBuilds/TimestampsFromCPPMacros.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some packages (e.g. pycrypto) do already have SOURCE_DATE_EPOCH defined, though it would be preferable to do this globally.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is

# Set a fallback default value for SOURCE_DATE_EPOCH, used by some
# build tools to provide a deterministic substitute for the "current"
# time. Note that 1 = 1970-01-01 00:00:01. We don't use 0 because it
# confuses some applications.
export SOURCE_DATE_EPOCH
: ${SOURCE_DATE_EPOCH:=1}
, but not used by all packages built with gcc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But why we need these macros then, when the environment variable is already exported?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a packages ignores environment variables, we are likely detecting this because cc wrapper will also not find libraries and headers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose since the SOURCE_DATE_EPOCH is only supported for gcc >=7.x, but not so for earlier versions, and so I have to modify it to be enabled only for early gcc's.

-D__TIME__=\"??:??:??\"
-Wno-builtin-macro-redefined
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mhm. Can this hit us somewhere else?

"${extraAfter[@]}")
fi

if [ "$dontLink" != 1 ]; then

# Add the flags that should only be passed to the compiler when
Expand Down