summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2018-04-16 13:18:31 +0900
committerTom Rini <trini@konsulko.com>2018-04-28 10:42:35 -0400
commit1eb2e71edd55e16562e3912881c449db69623352 (patch)
tree5a9a8a36517c9d693ecb58be86a46843a8281220 /Makefile
parentfac379e1ea4090471c7fdbc184f83409ae4be942 (diff)
kbuild: use -fmacro-prefix-map to make __FILE__ a relative path
The __FILE__ macro is used everywhere in U-Boot to locate the file printing the log message, such as WARN_ON(), etc. If U-Boot is built out of tree, this can be a long absolute path. This is because Kbuild runs in the objtree instead of the srctree, then __FILE__ is expanded to a file path prefixed with $(srctree)/. A brand-new option from GCC, -fmacro-prefix-map, solves this problem. If your compiler supports it, __FILE__ is the relative path from the srctree regardless of O= option. This provides more readable log, more reproducible builds, and smaller image size. [ Linux commit: a73619a845d5625079cc1b3b820f44c899618388 ] Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile3
1 files changed, 3 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 143644c987..316944c9d0 100644
--- a/Makefile
+++ b/Makefile
@@ -595,6 +595,9 @@ endif
KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks)
+# change __FILE__ to the relative path from the srctree
+KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
+
KBUILD_CFLAGS += -g
# $(KBUILD_AFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
# option to the assembler.