building Linux for ARMv7 with llvm breaks sparse
Hello,
building a 32bit ARM kernel with llvm (LLVM=1 LLVM_IAS=1) and C=1 breaks current sparse:
| sparse -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise | -Wno-return-void -Wno-unknown-attribute -D__ARMEL__ -D__arm__ | --arch=arm -mlittle-endian -m32 -Wp,-MMD,scripts/mod/.empty.o.d | -nostdinc -I/path/to/linux/arch/arm/include | -I./arch/arm/include/generated | -I/path/to/linux/include -I./include | -I/path/to/linux/arch/arm/include/uapi | -I./arch/arm/include/generated/uapi | -I/path/to/linux/include/uapi | -I./include/generated/uapi -include | /path/to/linux/include/linux/compiler-version.h | -include /path/to/linux/include/linux/kconfig.h | -include | /path/to/linux/include/linux/compiler_types.h | -D__KERNEL__ -mlittle-endian -Qunused-arguments | -fmacro-prefix-map=/path/to/linux/= | -DKBUILD_EXTRA_WARN1 -Wall -Wundef -Werror=strict-prototypes | -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE | -Werror=implicit-function-declaration -Werror=implicit-int | -Werror=return-type -Wno-format-security -std=gnu11 | --target=arm-linux-gnueabi -fintegrated-as | -Werror=unknown-warning-option -Werror=ignored-optimization-argument | -fno-dwarf2-cfi-asm -mabi=aapcs-linux -mfpu=vfp -funwind-tables | -meabi gnu -marm -Wa,-W -D__LINUX_ARM_ARCH__=6 -march=armv6k ^^^^^^^^^^ | -mtune=arm1136j-s -msoft-float -Uarm -fno-delete-null-pointer-checks | -Wno-frame-address -Wno-address-of-packed-member -O2 | -Wframe-larger-than=1024 -fstack-protector-strong -Werror -Wno-gnu | -mno-global-merge -Wno-unused-but-set-variable | -Wno-unused-const-variable -fomit-frame-pointer | -fno-stack-clash-protection -Wdeclaration-after-statement -Wvla | -Wno-pointer-sign -Wcast-function-type -fno-strict-overflow | -fno-stack-check -Werror=date-time -Werror=incompatible-pointer-types | -Wextra -Wunused -Wno-unused-parameter -Wmissing-declarations | -Wmissing-format-attribute -Wmissing-prototypes -Wold-style-definition | -Wmissing-include-dirs -Wunused-but-set-variable | -Wunused-const-variable -Wno-missing-field-initializers | -Wno-sign-compare -Wno-type-limits -Wno-shift-negative-value -g | -gdwarf-4 -I /path/to/linux/scripts/mod -I | ./scripts/mod -DKBUILD_MODFILE='"scripts/mod/empty"' | -DKBUILD_BASENAME='"empty"' -DKBUILD_MODNAME='"empty"' | -D__KBUILD_MODNAME=kmod_empty | /path/to/linux/scripts/mod/empty.c | | No such file: gnu
regards,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Quoted 2 lines · Marc Kleine-Budde
| -meabi gnu
^^^^^^^^^^
That's certainly technically valid syntax, but it's unusual, and it breaks the normal sparse "ignore stuff we don't know about" thing.
Does it all work if we just make the kernel use the normal
-meabi=gnu
syntax instead?
And by that "all work" I mean not just sparse, but the actual real clang/arm build.
Linus
Quoted 6 lines · Linus Torvalds
Does it all work if we just make the kernel use the normal
-meabi=gnu
syntax instead?
IOW, just something like this
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -110,7 +110,7 @@ CFLAGS_ABI +=-funwind-tables
endif
ifeq ($(CONFIG_CC_IS_CLANG),y)
-CFLAGS_ABI += -meabi gnu
+CFLAGS_ABI += -meabi=gnu
endif
ifeq ($(CONFIG_CURRENT_POINTER_IN_TPIDRURO),y)that's basically what we do for all the other '-mxyz=abc' cases, so it's really that use of -meabi that stands out as being the odd man out.
Linus
Quoted 23 lines · Linus Torvalds
Quoted 6 lines · Linus Torvalds
Does it all work if we just make the kernel use the normal
-meabi=gnu
syntax instead?
IOW, just something like this
--- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -110,7 +110,7 @@ CFLAGS_ABI +=-funwind-tables endif ifeq ($(CONFIG_CC_IS_CLANG),y) -CFLAGS_ABI += -meabi gnu +CFLAGS_ABI += -meabi=gnu endif ifeq ($(CONFIG_CURRENT_POINTER_IN_TPIDRURO),y)
Quoted 3 lines
that's basically what we do for all the other '-mxyz=abc' cases, so it's really that use of -meabi that stands out as being the odd man out.
No :/
| clang: error: unknown argument '-meabi=gnu'; did you mean '-mabi=gnu'?
The documentation says no "=":
| https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-meabi
regards,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Quoted 8 lines · Marc Kleine-Budde
No :/
| clang: error: unknown argument '-meabi=gnu'; did you mean '-mabi=gnu'?
The documentation says no "=":
| https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-meabi
Wow. What a horrible inconsistency. Every single other '-mxyz arg' thing seems to use '=', so it's really -meabi that stands out as being broken.
Oh well. Sparse does handle these kinds of architecture things in other places, but I'm not personally really very motivated to fix it due to just being pissed off at clang idiocy.
Linus
PATCH 1/1 handle clang's option "-meabi gnu"
From: Luc Van Oostenryck <[email protected]>
Clang has an option "-meabi <arg>" which is used by the kernel for ARMv7. This kind of option, taking a argument without a separating '=', can't be ignored like most other options and must this be special-cased.
So, add the special case for this option and consume the argument if it's one of the valid one.
--- options.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
options.c +13 -0
@@ -685,6 +685,19 @@ static const struct flag mflags[] = {static char **handle_switch_m (char *arg,char **next) { +if (!strcmp (arg,"meabi" ) && next[1 ] && next[1 ][0 ] !='-' ) { +// clang has such an option with syntax: -meabi <arg> +// It's used by the kernel for armv7. +// GCC has the same opion but with no argument. +// Parse it here to consume the possible argument. +static const char *valid[] = {"gnu" ,"4" ,"5" ,"default" ,NULL }; +int i; +for (i =0 ; valid[i]; i++) { +if (!strcmp (next[1 ], valid[i])) +return ++next; + } + } +if (!strcmp (arg,"multiarch-dir" )) {return handle_multiarch_dir (arg, next); }else {
Signature · 1 line
2.36.1
Re: [PATCH] handle clang's option "-meabi gnu"
Quoted 6 lines · Luc Van Oostenryck
From: Luc Van Oostenryck <[email protected]>
Clang has an option "-meabi <arg>" which is used by the kernel for ARMv7. This kind of option, taking a argument without a separating '=', can't be ignored like most other options and must this be special-cased.
Quoted 6 lines
So, add the special case for this option and consume the argument if it's one of the valid one.
Reported-by Marc Kleine-Budde <[email protected]>Signed-off-by Luc Van Oostenryck <[email protected]>
regards,
Marc
Signature · 4 lines
Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |