aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Rosenkränzer <bero@linaro.org>2017-02-23 00:18:44 +0100
committerBernhard Rosenkränzer <bero@linaro.org>2017-02-23 21:49:51 +0100
commited4c9c7faddaccc5d53e77f3b32ccec722feb234 (patch)
tree0c46723e5e167e9156949887547ff94f74e4a12d
parent7cac5dcabbd143e3da7d9de98f0e1d29a13724df (diff)
downloadhikey-clang-ed4c9c7faddaccc5d53e77f3b32ccec722feb234.tar.gz
kbuild, LLVMLinux: Make asm-offset generation work with clang
When using clang with -fno-integerated-as, clang will use the gnu assembler instead of the integrated assembler. However clang will still perform asm error checking before sending the inline assembly language to gas. The generation of asm-offsets from within C code is dependent on gcc's blind passing of whatever is in asm() through to gas. Arbirary text is passed through which is then modified by a sed script into the appropriate .h and .S code. Since the arbitrary text is not valid assembly language, clang fails. This can be fixed by making the arbitrary text into an ASM comment and then updating the sed scripts accordingly to work as expected. This solution works for both gcc and clang. Signed-off-by: Behan Webster <behanw@converseincode.com> Forward-ported-by: Bernhard Rosenkränzer <bero@linaro.org> Signed-off-by: Bernhard Rosenkränzer <bero@linaro.org> Reviewed-by: Mark Charlebois <charlebm@gmail.com> Reviewed-by: Jan-Simon Möller <dl9pf@gmx.de> Cc: Jan Moskyto Matejka <mq@suse.cz> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: "H. Peter Anvin" <hpa@linux.intel.com> Cc: Tom Gundersen <teg@jklm.no> Cc: Masahiro Yamada <yamada.m@jp.panasonic.com> Cc: Arnd Bergmann <arnd@arndb.de>
-rw-r--r--Kbuild25
-rw-r--r--include/linux/kbuild.h6
-rw-r--r--scripts/mod/Makefile8
3 files changed, 32 insertions, 7 deletions
diff --git a/Kbuild b/Kbuild
index 3d0ae152af7c..0a4022da6b6e 100644
--- a/Kbuild
+++ b/Kbuild
@@ -75,6 +75,31 @@ offsets-file := include/generated/asm-offsets.h
always += $(offsets-file)
targets += arch/$(SRCARCH)/kernel/asm-offsets.s
+# Default sed regexp - multiline due to syntax constraints
+define sed-y
+ "/^@->/{s:@->#\(.*\):/* \1 */:; \
+ s:^@->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
+ s:^@->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
+ s:@->::; p;}"
+endef
+
+quiet_cmd_offsets = GEN $@
+define cmd_offsets
+ (set -e; \
+ echo "#ifndef __ASM_OFFSETS_H__"; \
+ echo "#define __ASM_OFFSETS_H__"; \
+ echo "/*"; \
+ echo " * DO NOT MODIFY."; \
+ echo " *"; \
+ echo " * This file was generated by Kbuild"; \
+ echo " *"; \
+ echo " */"; \
+ echo ""; \
+ sed -ne $(sed-y) $<; \
+ echo ""; \
+ echo "#endif" ) > $@
+endef
+
# We use internal kbuild rules to avoid the "is up to date" message from make
arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
$(obj)/$(timeconst-file) $(obj)/$(bounds-file) FORCE
diff --git a/include/linux/kbuild.h b/include/linux/kbuild.h
index 22a72198c14b..75fa2c3e0e1d 100644
--- a/include/linux/kbuild.h
+++ b/include/linux/kbuild.h
@@ -2,14 +2,14 @@
#define __LINUX_KBUILD_H
#define DEFINE(sym, val) \
- asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+ asm volatile("\n@->" #sym " %0 " #val : : "i" (val))
-#define BLANK() asm volatile("\n->" : : )
+#define BLANK() asm volatile("\n@->" : : )
#define OFFSET(sym, str, mem) \
DEFINE(sym, offsetof(struct str, mem))
#define COMMENT(x) \
- asm volatile("\n->#" x)
+ asm volatile("\n@->#" x)
#endif
diff --git a/scripts/mod/Makefile b/scripts/mod/Makefile
index 19d9bcadc0cc..c3db2fa31052 100644
--- a/scripts/mod/Makefile
+++ b/scripts/mod/Makefile
@@ -8,10 +8,10 @@ modpost-objs := modpost.o file2alias.o sumversion.o
devicetable-offsets-file := devicetable-offsets.h
define sed-y
- "/^->/{s:->#\(.*\):/* \1 */:; \
- s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
- s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
- s:->::; p;}"
+ "/^@->/{s:@->#\(.*\):/* \1 */:; \
+ s:^@->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
+ s:^@->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
+ s:@->::; p;}"
endef
quiet_cmd_offsets = GEN $@