Re: [PATCH] kbuild, LLVMLinux: Fix asm-offset generation to work with clang

2014-09-24 Thread Behan Webster

On 09/24/14 03:37, Arnd Bergmann wrote:

On Tuesday 23 September 2014 12:25:31 beh...@converseincode.com wrote:

  #define DEFINE(sym, val) \
-asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+   asm volatile("\n@->" #sym " %0 " #val : : "i" (val))

Isn't the '@' character to start a comment architecture specific?
I had worried about that as well (as we discussed at LCU), but with the 
limited testing I tried this with it seemed to indicate that gas was 
smart enough to handle it in most cases. However the kbuild test robot 
indicates that this patch breaks MIPS. So indeed your concern is justified.


Gotta love the kbuild test robot. Thank you Fengguang Wu!


If this makes it work on ARM, what about other architectures?

For now, I think I need to try something else.

Thanks,

Behan

--
Behan Webster
beh...@converseincode.com

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] kbuild, LLVMLinux: Fix asm-offset generation to work with clang

2014-09-24 Thread Arnd Bergmann
On Tuesday 23 September 2014 12:25:31 beh...@converseincode.com wrote:
> 
>  #define DEFINE(sym, val) \
> -asm volatile("\n->" #sym " %0 " #val : : "i" (val))
> +   asm volatile("\n@->" #sym " %0 " #val : : "i" (val))

Isn't the '@' character to start a comment architecture specific?

If this makes it work on ARM, what about other architectures?

Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] kbuild, LLVMLinux: Fix asm-offset generation to work with clang

2014-09-24 Thread Arnd Bergmann
On Tuesday 23 September 2014 12:25:31 beh...@converseincode.com wrote:
 
  #define DEFINE(sym, val) \
 -asm volatile(\n- #sym  %0  #val : : i (val))
 +   asm volatile(\n@- #sym  %0  #val : : i (val))

Isn't the '@' character to start a comment architecture specific?

If this makes it work on ARM, what about other architectures?

Arnd
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] kbuild, LLVMLinux: Fix asm-offset generation to work with clang

2014-09-24 Thread Behan Webster

On 09/24/14 03:37, Arnd Bergmann wrote:

On Tuesday 23 September 2014 12:25:31 beh...@converseincode.com wrote:

  #define DEFINE(sym, val) \
-asm volatile(\n- #sym  %0  #val : : i (val))
+   asm volatile(\n@- #sym  %0  #val : : i (val))

Isn't the '@' character to start a comment architecture specific?
I had worried about that as well (as we discussed at LCU), but with the 
limited testing I tried this with it seemed to indicate that gas was 
smart enough to handle it in most cases. However the kbuild test robot 
indicates that this patch breaks MIPS. So indeed your concern is justified.


Gotta love the kbuild test robot. Thank you Fengguang Wu!


If this makes it work on ARM, what about other architectures?

For now, I think I need to try something else.

Thanks,

Behan

--
Behan Webster
beh...@converseincode.com

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] kbuild, LLVMLinux: Fix asm-offset generation to work with clang

2014-09-23 Thread behanw
From: Behan Webster 

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 
Reviewed-by: Mark Charlebois 
Reviewed-by: Jan-Simon Möller 
Cc: Jan Moskyto Matejka 
Cc: Greg Kroah-Hartman 
Cc: Ard Biesheuvel 
Cc: "H. Peter Anvin" 
Cc: Tom Gundersen 
Cc: Masahiro Yamada 
Cc: Arnd Bergmann 
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] kbuild, LLVMLinux: Fix asm-offset generation to work with clang

2014-09-23 Thread behanw
From: Behan Webster beh...@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 beh...@converseincode.com
Reviewed-by: Mark Charlebois charl...@gmail.com
Reviewed-by: Jan-Simon Möller dl...@gmx.de
Cc: Jan Moskyto Matejka m...@suse.cz
Cc: Greg Kroah-Hartman gre...@linuxfoundation.org
Cc: Ard Biesheuvel ard.biesheu...@linaro.org
Cc: H. Peter Anvin h...@linux.intel.com
Cc: Tom Gundersen t...@jklm.no
Cc: Masahiro Yamada yamad...@jp.panasonic.com
Cc: Arnd Bergmann a...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/