mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: behanw@converseincode.com
To: mq@suse.cz
Cc: linux-kernel@vger.kernel.org,
	Behan Webster <behanw@converseincode.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	"H. Peter Anvin" <hpa@linux.intel.com>,
	Tom Gundersen <teg@jklm.no>,
	Masahiro Yamada <yamada.m@jp.panasonic.com>,
	Arnd Bergmann <arnd@arndb.de>
Subject: [PATCH] kbuild, LLVMLinux: Fix asm-offset generation to work with clang
Date: Tue, 23 Sep 2014 12:25:31 -0700	[thread overview]
Message-ID: <1411500331-9861-1-git-send-email-behanw@converseincode.com> (raw)

From: Behan Webster <behanw@converseincode.com>

When using clang with -no-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>
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>
---
 Kbuild                 | 8 ++++----
 include/linux/kbuild.h | 6 +++---
 scripts/mod/Makefile   | 8 ++++----
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/Kbuild b/Kbuild
index b8b708a..2f509c9 100644
--- a/Kbuild
+++ b/Kbuild
@@ -52,10 +52,10 @@ 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;}"
+	"/^@->/{s:->#\(.*\):/* \1 */:; \
+	s:^@->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
+	s:^@->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
+	s:@->::; p;}"
 endef
 
 quiet_cmd_offsets = GEN     $@
diff --git a/include/linux/kbuild.h b/include/linux/kbuild.h
index 22a7219..75fa2c3 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 c11212f..86f6b85 100644
--- a/scripts/mod/Makefile
+++ b/scripts/mod/Makefile
@@ -6,10 +6,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     $@
-- 
1.9.1


             reply	other threads:[~2014-09-23 19:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-23 19:25 behanw [this message]
2014-09-24 10:37 ` Arnd Bergmann
2014-09-24 18:27   ` Behan Webster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1411500331-9861-1-git-send-email-behanw@converseincode.com \
    --to=behanw@converseincode.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mq@suse.cz \
    --cc=teg@jklm.no \
    --cc=yamada.m@jp.panasonic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome