All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] kbuild: cleanup asm-offset generation, and make it work with clang
@ 2017-04-21  6:21 Masahiro Yamada
  2017-04-21  6:21 ` [PATCH v2 1/2] kbuild: consolidate redundant sed script ASM offset generation Masahiro Yamada
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Masahiro Yamada @ 2017-04-21  6:21 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Matthias Kaehlcke, David Howells, Michael Davidson, Michal Marek,
	Jan Beulich, Alexander van Heukelum, Masahiro Yamada,
	Jeroen Hofstee, linux-kernel

1/2 is a trivial cleanup of sed script

2/2 imports clang work-around from U-Boot.


Changes in v2:
  - V1 did not work with LLVM's integrated assembler because
    it uses <tab> instead of <space> around the .ascii string.
    Restore [:space:].

Jeroen Hofstee (1):
  kbuild: fix asm-offset generation to work with clang

Masahiro Yamada (1):
  kbuild: consolidate redundant sed script ASM offset generation

 include/linux/kbuild.h | 6 +++---
 scripts/Makefile.lib   | 9 ++++++---
 2 files changed, 9 insertions(+), 6 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] kbuild: consolidate redundant sed script ASM offset generation
  2017-04-21  6:21 [PATCH v2 0/2] kbuild: cleanup asm-offset generation, and make it work with clang Masahiro Yamada
@ 2017-04-21  6:21 ` Masahiro Yamada
  2017-04-21  6:21 ` [PATCH v2 2/2] kbuild: fix asm-offset generation to work with clang Masahiro Yamada
  2017-04-23  7:01 ` [PATCH v2 0/2] kbuild: cleanup asm-offset generation, and make it " Masahiro Yamada
  2 siblings, 0 replies; 4+ messages in thread
From: Masahiro Yamada @ 2017-04-21  6:21 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Matthias Kaehlcke, David Howells, Michael Davidson, Michal Marek,
	Jan Beulich, Alexander van Heukelum, Masahiro Yamada,
	linux-kernel

This part ended up in redundant code after touched by multiple
people.

[1] Commit 3234282f33b2 ("x86, asm: Fix CFI macro invocations to
deal with shortcomings in gas") added parentheses for defined
expressions to support old gas for x86.

[2] Commit a22dcdb0032c ("x86, asm: Fix ancient-GAS workaround")
split the pattern into two to avoid parentheses for non-numeric
expressions.

[3] Commit 95a2f6f72d37 ("Partially revert patch that encloses
asm-offset.h numbers in brackets") removed parentheses from numeric
expressions as well because parentheses in MN10300 assembly have a
special meaning (pointer access).

Apparently, there is a conflict between [1] and [3].  After all,
[3] took precedence, and a long time has passed since then.

Now, merge the two patterns again because the first one is covered
by the other.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
---

Changes in v2: None

 scripts/Makefile.lib | 1 -
 1 file changed, 1 deletion(-)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index e36427a..9c20690 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -415,7 +415,6 @@ cmd_xzmisc = (cat $(filter-out FORCE,$^) | \
 # Default sed regexp - multiline due to syntax constraints
 define sed-offsets
 	"/^->/{s:->#\(.*\):/* \1 */:; \
-	s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
 	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
 	s:->::; p;}"
 endef
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] kbuild: fix asm-offset generation to work with clang
  2017-04-21  6:21 [PATCH v2 0/2] kbuild: cleanup asm-offset generation, and make it work with clang Masahiro Yamada
  2017-04-21  6:21 ` [PATCH v2 1/2] kbuild: consolidate redundant sed script ASM offset generation Masahiro Yamada
@ 2017-04-21  6:21 ` Masahiro Yamada
  2017-04-23  7:01 ` [PATCH v2 0/2] kbuild: cleanup asm-offset generation, and make it " Masahiro Yamada
  2 siblings, 0 replies; 4+ messages in thread
From: Masahiro Yamada @ 2017-04-21  6:21 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Matthias Kaehlcke, David Howells, Michael Davidson, Michal Marek,
	Jan Beulich, Alexander van Heukelum, Jeroen Hofstee,
	Masahiro Yamada, linux-kernel

From: Jeroen Hofstee <jeroen@myspectrum.nl>

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>
---

Changes in v2:
  - V1 did not work with LLVM's integrated assembler because
    it uses <tab> instead of <space> around the .ascii string.
    Restore [:space:].

 include/linux/kbuild.h | 6 +++---
 scripts/Makefile.lib   | 8 ++++++--
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/include/linux/kbuild.h b/include/linux/kbuild.h
index 22a7219..4e80f3a 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.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
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 9c20690..9e70196 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -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
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] kbuild: cleanup asm-offset generation, and make it work with clang
  2017-04-21  6:21 [PATCH v2 0/2] kbuild: cleanup asm-offset generation, and make it work with clang Masahiro Yamada
  2017-04-21  6:21 ` [PATCH v2 1/2] kbuild: consolidate redundant sed script ASM offset generation Masahiro Yamada
  2017-04-21  6:21 ` [PATCH v2 2/2] kbuild: fix asm-offset generation to work with clang Masahiro Yamada
@ 2017-04-23  7:01 ` Masahiro Yamada
  2 siblings, 0 replies; 4+ messages in thread
From: Masahiro Yamada @ 2017-04-23  7:01 UTC (permalink / raw)
  To: Linux Kbuild mailing list
  Cc: Matthias Kaehlcke, David Howells, Michael Davidson, Michal Marek,
	Jan Beulich, Alexander van Heukelum, Masahiro Yamada,
	Jeroen Hofstee, Linux Kernel Mailing List

2017-04-21 15:21 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>:
> 1/2 is a trivial cleanup of sed script
>
> 2/2 imports clang work-around from U-Boot.


Series, applied to linux-kbuild/kbuild.


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-04-23  7:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-21  6:21 [PATCH v2 0/2] kbuild: cleanup asm-offset generation, and make it work with clang Masahiro Yamada
2017-04-21  6:21 ` [PATCH v2 1/2] kbuild: consolidate redundant sed script ASM offset generation Masahiro Yamada
2017-04-21  6:21 ` [PATCH v2 2/2] kbuild: fix asm-offset generation to work with clang Masahiro Yamada
2017-04-23  7:01 ` [PATCH v2 0/2] kbuild: cleanup asm-offset generation, and make it " Masahiro Yamada

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.