Skip to contentSkip to conversation

kbuild: use -fmacro-prefix-map for .S sources compilation

PATCH Superseded Denys Zagorui 2 participants 2 messages Oct 29, 2020 – Nov 2, 2020 Kbuild

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: use -fmacro-prefix-map for .S sources compilation

Follow-up to a73619a845d5 ("kbuild: use -fmacro-prefix-map to make __FILE__ a relative path") commit. Assembler sources also use __FILE__ macro so this flag should be also apllied to that sources.

---
 Makefile | 1 +
 1 file changed, 1 insertion(+)
Makefile +1 -0
index ee2284a5cad2..26c4294f6e25 100644
@@ -947,6 +947,7 @@ KBUILD_CFLAGS   += $(call cc-option,-Werror=designated-init)
 
 # change __FILE__ to the relative path from the srctree
 KBUILD_CFLAGS	+= $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
+KBUILD_AFLAGS	+= $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
 
 # ensure -fcf-protection is disabled when using retpoline as it is
 # incompatible with -mindirect-branch=thunk-extern
Signature · 1 line
2.19.0.dirty
#1 lore raw
Quoted 15 lines · Denys Zagorui

Follow-up to a73619a845d5 ("kbuild: use -fmacro-prefix-map to make __FILE__ a relative path") commit. Assembler sources also use __FILE__ macro so this flag should be also apllied to that sources.

---
 Makefile | 1 +
 1 file changed, 1 insertion(+)
Makefile +0 -0
index ee2284a5cad2..26c4294f6e25 100644

Makefile KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init) · line 950

Quoted 4 lines
Makefile +1 -0
@@ -947,6 +947,7 @@ KBUILD_CFLAGS   += $(call cc-option,-Werror=designated-init)
 
 # change __FILE__ to the relative path from the srctree
 KBUILD_CFLAGS  += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
+KBUILD_AFLAGS  += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)

-fmacro-prefix-map is a preprocessor option.

https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gcc/Preprocessor-Options.html#Preprocessor-Options

I think it makes more sense to replace

KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)

with

KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)

Then, this flag will be passed to .S files as well as .c files.

Quoted 5 lines
Makefile +0 -1
 # ensure -fcf-protection is disabled when using retpoline as it is
 # incompatible with -mindirect-branch=thunk-extern
--

2.19.0.dirty

--
Best Regards
Masahiro Yamada