linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] xtensa: move CONFIG_CPU_*_ENDIAN defines to Kconfig
@ 2021-03-13 12:23 Masahiro Yamada
  2021-03-13 12:23 ` [PATCH v2 2/2] xtensa: remove unneeded export in boot-elf/Makefile Masahiro Yamada
  2021-03-14 14:33 ` [PATCH v2 1/2] xtensa: move CONFIG_CPU_*_ENDIAN defines to Kconfig Max Filippov
  0 siblings, 2 replies; 3+ messages in thread
From: Masahiro Yamada @ 2021-03-13 12:23 UTC (permalink / raw)
  To: Chris Zankel, Max Filippov, linux-xtensa
  Cc: Masahiro Yamada, Nick Desaulniers, linux-kernel

Move the definition of CONFIG_CPU_*_ENDIAN to Kconfig, the best place
for CONFIG options.

I slightly simplified the test code. You can use the -P option to suppress
linemarker generation. The grep command is unneeded.

  $ echo __XTENSA_EB__ | xtensa-linux-gcc -E -
  # 1 "<stdin>"
  # 1 "<built-in>"
  # 1 "<command-line>"
  # 1 "<stdin>"
  1

  $ echo __XTENSA_EB__ | xtensa-linux-gcc -E -P -
  1

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

Changes in v2:
 - more cleanups

 arch/xtensa/Kconfig                    | 6 ++++++
 arch/xtensa/Makefile                   | 9 +--------
 arch/xtensa/boot/Makefile              | 4 ----
 arch/xtensa/boot/boot-elf/Makefile     | 6 +-----
 arch/xtensa/boot/boot-redboot/Makefile | 6 +-----
 5 files changed, 9 insertions(+), 22 deletions(-)

diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 9ad6b7b82707..37b04ccc0a7f 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -84,6 +84,12 @@ config KASAN_SHADOW_OFFSET
 	hex
 	default 0x6e400000
 
+config CPU_BIG_ENDIAN
+	def_bool $(success,test "$(shell,echo __XTENSA_EB__ | $(CC) -E -P -)" = 1)
+
+config CPU_LITTLE_ENDIAN
+	def_bool !CPU_BIG_ENDIAN
+
 menu "Processor type and features"
 
 choice
diff --git a/arch/xtensa/Makefile b/arch/xtensa/Makefile
index cf0940708702..f43c731dec89 100644
--- a/arch/xtensa/Makefile
+++ b/arch/xtensa/Makefile
@@ -52,14 +52,7 @@ ifneq ($(CONFIG_LD_NO_RELAX),)
 KBUILD_LDFLAGS := --no-relax
 endif
 
-ifeq ($(shell echo __XTENSA_EB__ | $(CC) -E - | grep -v "\#"),1)
-CHECKFLAGS += -D__XTENSA_EB__
-KBUILD_CPPFLAGS += -DCONFIG_CPU_BIG_ENDIAN
-endif
-ifeq ($(shell echo __XTENSA_EL__ | $(CC) -E - | grep -v "\#"),1)
-CHECKFLAGS += -D__XTENSA_EL__
-KBUILD_CPPFLAGS += -DCONFIG_CPU_LITTLE_ENDIAN
-endif
+CHECKFLAGS += -D $(if $(CONFIG_CPU_BIG_ENDIAN),__XTENSA_EB__,__XTENSA_EL__)
 
 vardirs := $(patsubst %,arch/xtensa/variants/%/,$(variant-y))
 plfdirs := $(patsubst %,arch/xtensa/platforms/%/,$(platform-y))
diff --git a/arch/xtensa/boot/Makefile b/arch/xtensa/boot/Makefile
index f6bb352f94b4..a65b7a9ebff2 100644
--- a/arch/xtensa/boot/Makefile
+++ b/arch/xtensa/boot/Makefile
@@ -12,10 +12,6 @@
 KBUILD_CFLAGS	+= -fno-builtin -Iarch/$(ARCH)/boot/include
 HOSTFLAGS	+= -Iarch/$(ARCH)/boot/include
 
-BIG_ENDIAN	:= $(shell echo __XTENSA_EB__ | $(CC) -E - | grep -v "\#")
-
-export BIG_ENDIAN
-
 subdir-y	:= lib
 targets		+= vmlinux.bin vmlinux.bin.gz
 targets		+= uImage xipImage
diff --git a/arch/xtensa/boot/boot-elf/Makefile b/arch/xtensa/boot/boot-elf/Makefile
index f7c775d53012..47b9063f2c5d 100644
--- a/arch/xtensa/boot/boot-elf/Makefile
+++ b/arch/xtensa/boot/boot-elf/Makefile
@@ -4,11 +4,7 @@
 # for more details.
 #
 
-ifeq ($(BIG_ENDIAN),1)
-OBJCOPY_ARGS    := -O elf32-xtensa-be
-else
-OBJCOPY_ARGS    := -O elf32-xtensa-le
-endif
+OBJCOPY_ARGS := -O $(if $(CONFIG_CPU_BIG_ENDIAN),elf32-xtensa-be,elf32-xtensa-le)
 
 export OBJCOPY_ARGS
 export CPPFLAGS_boot.lds += -P -C
diff --git a/arch/xtensa/boot/boot-redboot/Makefile b/arch/xtensa/boot/boot-redboot/Makefile
index 07cb24afedc2..1d1d46215b1c 100644
--- a/arch/xtensa/boot/boot-redboot/Makefile
+++ b/arch/xtensa/boot/boot-redboot/Makefile
@@ -4,11 +4,7 @@
 # for more details.
 #
 
-ifeq ($(BIG_ENDIAN),1)
-OBJCOPY_ARGS 	:= -O elf32-xtensa-be
-else
-OBJCOPY_ARGS 	:= -O elf32-xtensa-le
-endif
+OBJCOPY_ARGS := -O $(if $(CONFIG_CPU_BIG_ENDIAN),elf32-xtensa-be,elf32-xtensa-le)
 
 LD_ARGS	= -T $(srctree)/$(obj)/boot.ld
 
-- 
2.27.0


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

* [PATCH v2 2/2] xtensa: remove unneeded export in boot-elf/Makefile
  2021-03-13 12:23 [PATCH v2 1/2] xtensa: move CONFIG_CPU_*_ENDIAN defines to Kconfig Masahiro Yamada
@ 2021-03-13 12:23 ` Masahiro Yamada
  2021-03-14 14:33 ` [PATCH v2 1/2] xtensa: move CONFIG_CPU_*_ENDIAN defines to Kconfig Max Filippov
  1 sibling, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2021-03-13 12:23 UTC (permalink / raw)
  To: Chris Zankel, Max Filippov, linux-xtensa
  Cc: Masahiro Yamada, Nick Desaulniers, linux-kernel

No one uses these as environment variables.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

Changes in v2:
  - New patch

 arch/xtensa/boot/boot-elf/Makefile | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/xtensa/boot/boot-elf/Makefile b/arch/xtensa/boot/boot-elf/Makefile
index 47b9063f2c5d..faec2002923b 100644
--- a/arch/xtensa/boot/boot-elf/Makefile
+++ b/arch/xtensa/boot/boot-elf/Makefile
@@ -6,9 +6,8 @@
 
 OBJCOPY_ARGS := -O $(if $(CONFIG_CPU_BIG_ENDIAN),elf32-xtensa-be,elf32-xtensa-le)
 
-export OBJCOPY_ARGS
-export CPPFLAGS_boot.lds += -P -C
-export KBUILD_AFLAGS += -mtext-section-literals
+CPPFLAGS_boot.lds += -P -C
+KBUILD_AFLAGS += -mtext-section-literals
 
 boot-y		:= bootstrap.o
 targets		+= $(boot-y) boot.lds
-- 
2.27.0


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

* Re: [PATCH v2 1/2] xtensa: move CONFIG_CPU_*_ENDIAN defines to Kconfig
  2021-03-13 12:23 [PATCH v2 1/2] xtensa: move CONFIG_CPU_*_ENDIAN defines to Kconfig Masahiro Yamada
  2021-03-13 12:23 ` [PATCH v2 2/2] xtensa: remove unneeded export in boot-elf/Makefile Masahiro Yamada
@ 2021-03-14 14:33 ` Max Filippov
  1 sibling, 0 replies; 3+ messages in thread
From: Max Filippov @ 2021-03-14 14:33 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Chris Zankel, open list:TENSILICA XTENSA PORT (xtensa),
	Nick Desaulniers, LKML

On Sat, Mar 13, 2021 at 4:24 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> Move the definition of CONFIG_CPU_*_ENDIAN to Kconfig, the best place
> for CONFIG options.
>
> I slightly simplified the test code. You can use the -P option to suppress
> linemarker generation. The grep command is unneeded.
>
>   $ echo __XTENSA_EB__ | xtensa-linux-gcc -E -
>   # 1 "<stdin>"
>   # 1 "<built-in>"
>   # 1 "<command-line>"
>   # 1 "<stdin>"
>   1
>
>   $ echo __XTENSA_EB__ | xtensa-linux-gcc -E -P -
>   1
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
> Changes in v2:
>  - more cleanups
>
>  arch/xtensa/Kconfig                    | 6 ++++++
>  arch/xtensa/Makefile                   | 9 +--------
>  arch/xtensa/boot/Makefile              | 4 ----
>  arch/xtensa/boot/boot-elf/Makefile     | 6 +-----
>  arch/xtensa/boot/boot-redboot/Makefile | 6 +-----
>  5 files changed, 9 insertions(+), 22 deletions(-)

Thanks. I've made one change and applied both patches to my xtensa tree.

[...]

> diff --git a/arch/xtensa/Makefile b/arch/xtensa/Makefile
> index cf0940708702..f43c731dec89 100644
> --- a/arch/xtensa/Makefile
> +++ b/arch/xtensa/Makefile
> @@ -52,14 +52,7 @@ ifneq ($(CONFIG_LD_NO_RELAX),)
>  KBUILD_LDFLAGS := --no-relax
>  endif
>
> -ifeq ($(shell echo __XTENSA_EB__ | $(CC) -E - | grep -v "\#"),1)
> -CHECKFLAGS += -D__XTENSA_EB__
> -KBUILD_CPPFLAGS += -DCONFIG_CPU_BIG_ENDIAN
> -endif
> -ifeq ($(shell echo __XTENSA_EL__ | $(CC) -E - | grep -v "\#"),1)
> -CHECKFLAGS += -D__XTENSA_EL__
> -KBUILD_CPPFLAGS += -DCONFIG_CPU_LITTLE_ENDIAN
> -endif
> +CHECKFLAGS += -D $(if $(CONFIG_CPU_BIG_ENDIAN),__XTENSA_EB__,__XTENSA_EL__)

I've removed the space between -D and the $(if ...) to make the result
look like the rest of -D options.

-- 
Thanks.
-- Max

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

end of thread, other threads:[~2021-03-14 14:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-13 12:23 [PATCH v2 1/2] xtensa: move CONFIG_CPU_*_ENDIAN defines to Kconfig Masahiro Yamada
2021-03-13 12:23 ` [PATCH v2 2/2] xtensa: remove unneeded export in boot-elf/Makefile Masahiro Yamada
2021-03-14 14:33 ` [PATCH v2 1/2] xtensa: move CONFIG_CPU_*_ENDIAN defines to Kconfig Max Filippov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).