Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] toolchain/toolchain-wrapper: let recent GCC handle SOURCE_DATE_EPOCH
@ 2020-06-26 15:49 John Keeping
  2020-06-27 15:20 ` Thomas Petazzoni
  2020-07-16 16:32 ` Peter Korsgaard
  0 siblings, 2 replies; 3+ messages in thread
From: John Keeping @ 2020-06-26 15:49 UTC (permalink / raw)
  To: buildroot

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 <john@metanate.com>
---
 toolchain/toolchain-wrapper.c  | 10 ++++++++++
 toolchain/toolchain-wrapper.mk |  3 +++
 2 files changed, 13 insertions(+)

diff --git a/toolchain/toolchain-wrapper.c b/toolchain/toolchain-wrapper.c
index 39e9f0850f..0fb6064b1c 100644
--- a/toolchain/toolchain-wrapper.c
+++ b/toolchain/toolchain-wrapper.c
@@ -179,6 +179,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
@@ -232,6 +233,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)
 {
diff --git a/toolchain/toolchain-wrapper.mk b/toolchain/toolchain-wrapper.mk
index 09dda17890..4d45e3d8a2 100644
--- a/toolchain/toolchain-wrapper.mk
+++ b/toolchain/toolchain-wrapper.mk
@@ -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
+ifneq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_7),y)
+TOOLCHAIN_WRAPPER_OPTS += -DBR_NEED_SOURCE_DATE_EPOCH
+endif
 endif
 
 # We create a list like '"-mfoo", "-mbar", "-mbarfoo"' so that each flag is a
-- 
2.27.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH] toolchain/toolchain-wrapper: let recent GCC handle SOURCE_DATE_EPOCH
  2020-06-26 15:49 [Buildroot] [PATCH] toolchain/toolchain-wrapper: let recent GCC handle SOURCE_DATE_EPOCH John Keeping
@ 2020-06-27 15:20 ` Thomas Petazzoni
  2020-07-16 16:32 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Petazzoni @ 2020-06-27 15:20 UTC (permalink / raw)
  To: buildroot

On Fri, 26 Jun 2020 16:49:27 +0100
John Keeping <john@metanate.com> wrote:

> 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 <john@metanate.com>
> ---
>  toolchain/toolchain-wrapper.c  | 10 ++++++++++
>  toolchain/toolchain-wrapper.mk |  3 +++
>  2 files changed, 13 insertions(+)

Applied to master, thanks.

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCH] toolchain/toolchain-wrapper: let recent GCC handle SOURCE_DATE_EPOCH
  2020-06-26 15:49 [Buildroot] [PATCH] toolchain/toolchain-wrapper: let recent GCC handle SOURCE_DATE_EPOCH John Keeping
  2020-06-27 15:20 ` Thomas Petazzoni
@ 2020-07-16 16:32 ` Peter Korsgaard
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2020-07-16 16:32 UTC (permalink / raw)
  To: buildroot

>>>>> "John" == John Keeping <john@metanate.com> writes:

 > 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 <john@metanate.com>

Seems pretty safe to add, so:

Committed to 2020.02.x and 2020.05.x, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-16 16:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-26 15:49 [Buildroot] [PATCH] toolchain/toolchain-wrapper: let recent GCC handle SOURCE_DATE_EPOCH John Keeping
2020-06-27 15:20 ` Thomas Petazzoni
2020-07-16 16:32 ` Peter Korsgaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox