LKML Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] kbuild: tell sparse about the $ARCH
@ 2019-11-09 12:12 Luc Van Oostenryck
  2019-11-09 14:23 ` Masahiro Yamada
  0 siblings, 1 reply; 2+ messages in thread
From: Luc Van Oostenryck @ 2019-11-09 12:12 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: linux-kbuild, linux-kernel, Ben Dooks, Luc Van Oostenryck

Sparse uses the same executable for all archs and uses flags
like -m64, -mbig-endian or -D__arm__ for arch-specific parameters.
But Sparse also uses value from the host machine used to build
Sparse as default value for the target machine.

This works, of course, well for native build but can create
problems when cross-compiling, like defining both '__i386__'
and '__arm__' when cross-compiling for arm on a x86-64 machine.

Fix this by explicitely telling sparse the target architecture.

Reported-by: Ben Dooks <ben.dooks@codethink.co.uk>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Makefile b/Makefile
index 6f54f2f95743..05a8906dde63 100644
--- a/Makefile
+++ b/Makefile
@@ -937,6 +937,9 @@ ifeq ($(CONFIG_RELR),y)
 LDFLAGS_vmlinux	+= --pack-dyn-relocs=relr
 endif
 
+# make the checker run with the right architecture
+CHECKFLAGS += --arch=$(ARCH)
+
 # insure the checker run with the right endianness
 CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
 
-- 
2.24.0


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

* Re: [PATCH] kbuild: tell sparse about the $ARCH
  2019-11-09 12:12 [PATCH] kbuild: tell sparse about the $ARCH Luc Van Oostenryck
@ 2019-11-09 14:23 ` Masahiro Yamada
  0 siblings, 0 replies; 2+ messages in thread
From: Masahiro Yamada @ 2019-11-09 14:23 UTC (permalink / raw)
  To: Luc Van Oostenryck
  Cc: Linux Kbuild mailing list, Linux Kernel Mailing List, Ben Dooks

On Sat, Nov 9, 2019 at 9:12 PM Luc Van Oostenryck
<luc.vanoostenryck@gmail.com> wrote:
>
> Sparse uses the same executable for all archs and uses flags
> like -m64, -mbig-endian or -D__arm__ for arch-specific parameters.
> But Sparse also uses value from the host machine used to build
> Sparse as default value for the target machine.
>
> This works, of course, well for native build but can create
> problems when cross-compiling, like defining both '__i386__'
> and '__arm__' when cross-compiling for arm on a x86-64 machine.
>
> Fix this by explicitely telling sparse the target architecture.
>
> Reported-by: Ben Dooks <ben.dooks@codethink.co.uk>
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
> ---

Applied to linux-kbuild. Thanks.


>  Makefile | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index 6f54f2f95743..05a8906dde63 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -937,6 +937,9 @@ ifeq ($(CONFIG_RELR),y)
>  LDFLAGS_vmlinux        += --pack-dyn-relocs=relr
>  endif
>
> +# make the checker run with the right architecture
> +CHECKFLAGS += --arch=$(ARCH)
> +
>  # insure the checker run with the right endianness
>  CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
>
> --
> 2.24.0
>


-- 
Best Regards
Masahiro Yamada

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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-09 12:12 [PATCH] kbuild: tell sparse about the $ARCH Luc Van Oostenryck
2019-11-09 14:23 ` Masahiro Yamada

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git