Message ID | 1492149003-19136-3-git-send-email-yamada.masahiro@socionext.com |
---|---|
State | New |
Headers | show |
Series | kbuild: cleanup asm-offset generation, and make it work with clang | expand |
El Fri, Apr 14, 2017 at 02:50:03PM +0900 Masahiro Yamada ha dit: > 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. > > Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl> > [masahiro: > Import Jeroen's work for U-Boot: > http://patchwork.ozlabs.org/patch/375026/ > Tweak sed script a little to drop garbage '#' for GCC case, like > #define NR_PAGEFLAGS 23 /* __NR_PAGEFLAGS # */ ] > Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Matthias Kaehlcke <mka@chromium.org> Tested-by: Matthias Kaehlcke <mka@chromium.org> I tested with x86 and arm64. Please note that two more changes are needed to avoid breaking frv and um: https://patchwork.kernel.org/patch/9660473/ https://patchwork.kernel.org/patch/9660503/ Maybe these should be part of your patch set? I only sent them out separately to avoid cross posting with my initial patch for this issue being a RFC. Cheers Matthias
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..a050859 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -414,9 +414,10 @@ cmd_xzmisc = (cat $(filter-out FORCE,$^) | \ # Default sed regexp - multiline due to syntax constraints define sed-offsets - "/^->/{s:->#\(.*\):/* \1 */:; \ + 's:^\.ascii *"\(.*\)".*:\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