All of lore.kernel.org
 help / color / mirror / Atom feed
* building Linux for ARMv7 with llvm breaks sparse
@ 2022-03-31 11:01 Marc Kleine-Budde
  2022-03-31 19:17 ` Linus Torvalds
  0 siblings, 1 reply; 7+ messages in thread
From: Marc Kleine-Budde @ 2022-03-31 11:01 UTC (permalink / raw)
  To: linux-sparse

[-- Attachment #1: Type: text/plain, Size: 2713 bytes --]

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

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: building Linux for ARMv7 with llvm breaks sparse
  2022-03-31 11:01 building Linux for ARMv7 with llvm breaks sparse Marc Kleine-Budde
@ 2022-03-31 19:17 ` Linus Torvalds
  2022-03-31 19:22   ` Linus Torvalds
  0 siblings, 1 reply; 7+ messages in thread
From: Linus Torvalds @ 2022-03-31 19:17 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: Sparse Mailing-list

On Thu, Mar 31, 2022 at 4:01 AM Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> | -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

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

* Re: building Linux for ARMv7 with llvm breaks sparse
  2022-03-31 19:17 ` Linus Torvalds
@ 2022-03-31 19:22   ` Linus Torvalds
  2022-03-31 19:31     ` Marc Kleine-Budde
  0 siblings, 1 reply; 7+ messages in thread
From: Linus Torvalds @ 2022-03-31 19:22 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: Sparse Mailing-list

On Thu, Mar 31, 2022 at 12:17 PM Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> 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

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

* Re: building Linux for ARMv7 with llvm breaks sparse
  2022-03-31 19:22   ` Linus Torvalds
@ 2022-03-31 19:31     ` Marc Kleine-Budde
  2022-03-31 19:57       ` Linus Torvalds
  0 siblings, 1 reply; 7+ messages in thread
From: Marc Kleine-Budde @ 2022-03-31 19:31 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Sparse Mailing-list

[-- Attachment #1: Type: text/plain, Size: 1266 bytes --]

On 31.03.2022 12:22:08, Linus Torvalds wrote:
> On Thu, Mar 31, 2022 at 12:17 PM Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> >
> > 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.

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

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: building Linux for ARMv7 with llvm breaks sparse
  2022-03-31 19:31     ` Marc Kleine-Budde
@ 2022-03-31 19:57       ` Linus Torvalds
  2022-05-22  9:08         ` [PATCH] handle clang's option "-meabi gnu" Luc Van Oostenryck
  0 siblings, 1 reply; 7+ messages in thread
From: Linus Torvalds @ 2022-03-31 19:57 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: Sparse Mailing-list

On Thu, Mar 31, 2022 at 12:31 PM Marc Kleine-Budde <mkl@pengutronix.de> wrote:
>
> 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

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

* [PATCH] handle clang's option "-meabi gnu"
  2022-03-31 19:57       ` Linus Torvalds
@ 2022-05-22  9:08         ` Luc Van Oostenryck
  2022-05-23  9:17           ` Marc Kleine-Budde
  0 siblings, 1 reply; 7+ messages in thread
From: Luc Van Oostenryck @ 2022-05-22  9:08 UTC (permalink / raw)
  To: linux-sparse; +Cc: Linus Torvalds, Luc Van Oostenryck, Marc Kleine-Budde

From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>

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.

Link: https://lore.kernel.org/r/20220331110118.vr4miyyytqlssjoi@pengutronix.de
Reported-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 options.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/options.c b/options.c
index 6704fc8d2c8d..0224c290d322 100644
--- a/options.c
+++ b/options.c
@@ -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 {
-- 
2.36.1


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

* Re: [PATCH] handle clang's option "-meabi gnu"
  2022-05-22  9:08         ` [PATCH] handle clang's option "-meabi gnu" Luc Van Oostenryck
@ 2022-05-23  9:17           ` Marc Kleine-Budde
  0 siblings, 0 replies; 7+ messages in thread
From: Marc Kleine-Budde @ 2022-05-23  9:17 UTC (permalink / raw)
  To: Luc Van Oostenryck; +Cc: linux-sparse, Linus Torvalds, Luc Van Oostenryck

[-- Attachment #1: Type: text/plain, Size: 990 bytes --]

On 22.05.2022 11:08:24, Luc Van Oostenryck wrote:
> From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
> 
> 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.
> 
> Link: https://lore.kernel.org/r/20220331110118.vr4miyyytqlssjoi@pengutronix.de
> Reported-by: Marc Kleine-Budde <mkl@pengutronix.de>
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>

Tested-by: Marc Kleine-Budde <mkl@pengutronix.de>

regards,
Marc

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2022-05-23  9:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-31 11:01 building Linux for ARMv7 with llvm breaks sparse Marc Kleine-Budde
2022-03-31 19:17 ` Linus Torvalds
2022-03-31 19:22   ` Linus Torvalds
2022-03-31 19:31     ` Marc Kleine-Budde
2022-03-31 19:57       ` Linus Torvalds
2022-05-22  9:08         ` [PATCH] handle clang's option "-meabi gnu" Luc Van Oostenryck
2022-05-23  9:17           ` Marc Kleine-Budde

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.