]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
kbuild: fix asm-offset generation to work with clang
authorJeroen Hofstee <jeroen@myspectrum.nl>
Fri, 21 Apr 2017 06:21:11 +0000 (15:21 +0900)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Sun, 23 Apr 2017 06:51:26 +0000 (15:51 +0900)
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.

[masahiro:
 Import Jeroen's work for U-Boot:
 http://patchwork.ozlabs.org/patch/375026/
 Tweak sed script a little to avoid garbage '#' for GCC case, like
 #define NR_PAGEFLAGS 23 /* __NR_PAGEFLAGS       # */ ]

Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Tested-by: Matthias Kaehlcke <mka@chromium.org>
include/linux/kbuild.h
scripts/Makefile.lib

index 22a72198c14b7e338f4f10ed334f7c73be8cfcae..4e80f3a9ad58abc815926b701a8fbc83c153b5a9 100644 (file)
@@ -2,14 +2,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
index 8109c133887daffca6cf167279462970c7b87936..2209ed696fb49ea3dedf5257cd51c8ebaea16d7c 100644 (file)
@@ -413,10 +413,14 @@ cmd_xzmisc = (cat $(filter-out FORCE,$^) | \
 # ---------------------------------------------------------------------------
 
 # Default sed regexp - multiline due to syntax constraints
+#
+# Use [:space:] because LLVM's integrated assembler inserts <tab> around
+# the .ascii directive whereas GCC keeps the <space> as-is.
 define sed-offsets
-       "/^->/{s:->#\(.*\):/* \1 */:; \
+       's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \
+       /^->/{s:->#\(.*\):/* \1 */:; \
        s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
-       s:->::; p;}"
+       s:->::; p;}'
 endef
 
 # Use filechk to avoid rebuilds when a header changes, but the resulting file