[U-Boot] [PATCH v2 6/8] clang: workaround for generated constants

Jeroen Hofstee jeroen at myspectrum.nl
Wed Jul 30 21:54:54 CEST 2014


KBuild abuses the asm statement to write to a file and
clang chokes about these invalid asm statements. Hack it
even more by fooling this is actual valid asm code.

cc: Masahiro Yamada <yamada.m at jp.panasonic.com>
cc: Tom Rini <trini at ti.com>
Signed-off-by: Jeroen Hofstee <jeroen at myspectrum.nl>
---
 Kbuild                 | 3 ++-
 include/linux/kbuild.h | 6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/Kbuild b/Kbuild
index 6e1698c..ef97787 100644
--- a/Kbuild
+++ b/Kbuild
@@ -53,7 +53,8 @@ targets += arch/$(ARCH)/lib/asm-offsets.s
 
 # Default sed regexp - multiline due to syntax constraints
 define sed-y
-	"/^->/{s:->#\(.*\):/* \1 */:; \
+	"s:[[:space:]]*\.ascii[[:space:]]*\"\(.*\)\":\1:; \
+	/^->/{s:->#\(.*\):/* \1 */:; \
 	s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
 	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
 	s:->::; p;}"
diff --git a/include/linux/kbuild.h b/include/linux/kbuild.h
index ab7805a..8a9f645 100644
--- a/include/linux/kbuild.h
+++ b/include/linux/kbuild.h
@@ -7,14 +7,14 @@
 #define __LINUX_KBUILD_H
 
 #define DEFINE(sym, val) \
-	asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+	asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))
 
-#define BLANK() asm volatile("\n->" : : )
+#define BLANK() asm volatile("\n.ascii \"->\"" : : )
 
 #define OFFSET(sym, str, mem) \
 	DEFINE(sym, offsetof(struct str, mem))
 
 #define COMMENT(x) \
-	asm volatile("\n->#" x)
+	asm volatile("\n.ascii \"->#" x "\"")
 
 #endif
-- 
1.9.1



More information about the U-Boot mailing list