toolchain/toolchain-wrapper: handle __{BASE_,}FILE__ macro for reproducibility
authorAtharva Lele <itsatharva@gmail.com>
Sat, 31 Aug 2019 18:01:13 +0000 (23:31 +0530)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Mon, 6 Jan 2020 22:24:52 +0000 (23:24 +0100)
commit71d690145474554eb3310fa57db3a335bad6c242
treecbe5eac1cf4ed84a79a67b3bf5250995f2a65484
parent425f79087a02ec2fd53c76bb155efb41708aef68
toolchain/toolchain-wrapper: handle __{BASE_,}FILE__ macro for reproducibility

Many tools use __FILE__ or __BASE_FILE__ for debugging and both
capture the build path. This results in non-reproducible images when
building in different directories.

If the config uses GCC 8 or above, we use -ffile-prefix-map=old=new
and let gcc take care of the path remapping in __FILE__. Since GCC
versions before v8 did not have this feature, we use an empty string
in that case, and disable the builtin-macro-redefined warning which
would otherwise trigger and cause build issues with -Werror.

Signed-off-by: Atharva Lele <itsatharva@gmail.com>
[Thomas:
 - as suggested by Arnout, use the empty string for the __FILE__ and
   __BASE_FILE__ value
 - as suggested by Romain, also handle __BASE_FILE__ in addition to
   __FILE__
 - pass -Wno-builtin-macro-redefined to avoid build errors when
   -Werror is passed]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
toolchain/toolchain-wrapper.mk