Skip to content

Commit

Permalink
toolchain/toolchain-wrapper: let recent GCC handle SOURCE_DATE_EPOCH
Browse files Browse the repository at this point in the history
When using precompiled headers, changing any macros defined on the
command line will invalidate the precompiled header.  With
toolchain-wrapper adding __DATE__ and __TIME__, any commits to Buildroot
will invalidate incremental builds regardless of whether the precompiled
header actually uses those values (affecting _OVERRIDE_SRCDIR).

GCC-7 and later support SOURCE_DATE_EPOCH and use it to define __DATE__
and __TIME__ internally, avoiding any impact on precompiled headers.

Disable the custom handling in toolchain-wrapper if GCC is version 7 or
newer.

Signed-off-by: John Keeping <[email protected]>
Signed-off-by: Thomas Petazzoni <[email protected]>
(cherry picked from commit 408bc354a9c14b3940938cfb7a3e3eefa81641a5)
Signed-off-by: Peter Korsgaard <[email protected]>
  • Loading branch information
johnkeeping authored and jacmet committed Jul 16, 2020
1 parent 72bf704 commit 9c0a81a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions toolchain/toolchain-wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ static void check_unsafe_path(const char *arg,
}
}

#ifdef BR_NEED_SOURCE_DATE_EPOCH
/* Returns false if SOURCE_DATE_EPOCH was not defined in the environment.
*
* Returns true if SOURCE_DATE_EPOCH is in the environment and represent
Expand Down Expand Up @@ -230,6 +231,15 @@ bool parse_source_date_epoch_from_env(void)
}
return true;
}
#else
bool parse_source_date_epoch_from_env(void)
{
/* The compiler is recent enough to handle SOURCE_DATE_EPOCH itself
* so we do not need to do anything here.
*/
return false;
}
#endif

int main(int argc, char **argv)
{
Expand Down
3 changes: 3 additions & 0 deletions toolchain/toolchain-wrapper.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ TOOLCHAIN_WRAPPER_OPTS += -ffile-prefix-map=$(BASE_DIR)=buildroot
else
TOOLCHAIN_WRAPPER_OPTS += -D__FILE__=\"\" -D__BASE_FILE__=\"\" -Wno-builtin-macro-redefined
endif
ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_7),)
TOOLCHAIN_WRAPPER_OPTS += -DBR_NEED_SOURCE_DATE_EPOCH
endif
endif

# We create a list like '"-mfoo", "-mbar", "-mbarfoo"' so that each flag is a
Expand Down

0 comments on commit 9c0a81a

Please sign in to comment.