toolchain/toolchain-wrapper: let recent GCC handle SOURCE_DATE_EPOCH
authorJohn Keeping <john@metanate.com>
Fri, 26 Jun 2020 15:49:27 +0000 (16:49 +0100)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Sat, 27 Jun 2020 15:19:53 +0000 (17:19 +0200)
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>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
toolchain/toolchain-wrapper.c
toolchain/toolchain-wrapper.mk

index 39e9f0850fa0cfa33d78203b0e678ee782f2c3f9..0fb6064b1cab4e27d9636d109c0a7530b7043048 100644 (file)
@@ -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)
 {
index 09dda17890cd0a34d3e62cdc5cf09a5102b65429..f1312c5c7f9639b2f16063e0cad9b07b4155c581 100644 (file)
@@ -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