Skip to contentSkip to conversation

xtensa: remove unneeded exports

PATCH Applied Masahiro Yamada 2 participants 10 messages Aug 11, 2021 – Aug 13, 2021 Tensilica Xtensa port (xtensa)

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 xtensa: remove unneeded exports

These are not used in any of subdirectories.

---

 arch/xtensa/Makefile | 2 --
 1 file changed, 2 deletions(-)
arch/xtensa/Makefile +0 -2
index e9c8f064c44d..6fab7fc87579 100644
@@ -17,7 +17,6 @@
 variant-y := $(patsubst "%",%,$(CONFIG_XTENSA_VARIANT_NAME))
 
 VARIANT = $(variant-y)
-export VARIANT
 
 ifneq ($(VARIANT),)
   ifdef cross_compiling
@@ -34,7 +33,6 @@ platform-$(CONFIG_XTENSA_PLATFORM_ISS)		:= iss
 platform-$(CONFIG_XTENSA_PLATFORM_XTFPGA)	:= xtfpga
 
 PLATFORM = $(platform-y)
-export PLATFORM
 
 # temporarily until string.h is fixed
 KBUILD_CFLAGS += -ffreestanding -D__linux__
Signature · 1 line
2.30.2
#1 lore raw

PATCH 2/4 xtensa: do not build variants directory

None of arch/xtensa/variants/*/ has Makefile, so 'buildvar' is always empty.

Perhaps, downstream variant code might be dropped in, but given the fact that none of upstream variants builds anything in their variant directory, I doubt this is needed.

---

 arch/xtensa/Makefile | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/xtensa/Makefile +2 -4
index 6fab7fc87579..3c0573fe6761 100644
@@ -55,9 +55,7 @@ KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(vardirs) $(plfdirs))
 
 KBUILD_DEFCONFIG := iss_defconfig
 
-# Only build variant and/or platform if it includes a Makefile
-
-buildvar := $(shell test -e $(srctree)/arch/xtensa/variants/$(VARIANT)/Makefile && echo arch/xtensa/variants/$(VARIANT)/)
+# Only build platform if it includes a Makefile
 buildplf := $(shell test -e $(srctree)/arch/xtensa/platforms/$(PLATFORM)/Makefile && echo arch/xtensa/platforms/$(PLATFORM)/)
 
 # Find libgcc.a
@@ -66,7 +64,7 @@ LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
 
 head-y		:= arch/xtensa/kernel/head.o
 core-y		+= arch/xtensa/kernel/ arch/xtensa/mm/
-core-y		+= $(buildvar) $(buildplf)
+core-y		+= $(buildplf)
 core-y 		+= arch/xtensa/boot/dts/
 
 libs-y		+= arch/xtensa/lib/ $(LIBGCC)
Signature · 1 line
2.30.2
maintainer Applied
#2 lore raw

Re: [PATCH 2/4] xtensa: do not build variants directory

Quoted 8 lines · Masahiro Yamada

None of arch/xtensa/variants/*/ has Makefile, so 'buildvar' is always empty.

Perhaps, downstream variant code might be dropped in, but given the fact that none of upstream variants builds anything in their variant directory, I doubt this is needed.

Quoted 5 lines

---

 arch/xtensa/Makefile | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Thanks, applied to my xtensa tree.

Signature · 2 lines
Thanks.
-- Max
#3 lore raw

PATCH 3/4 xtensa: build platform directories unconditionally

In reply to Masahiro Yamada

All of arch/xtensa/platforms/*/ have Makefile. You do not need to check the presence of Makefile.

---

 arch/xtensa/Makefile | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
arch/xtensa/Makefile +1 -6
index 3c0573fe6761..093e87b889be 100644
@@ -32,8 +32,6 @@ platform-$(CONFIG_XTENSA_PLATFORM_XT2000)	:= xt2000
 platform-$(CONFIG_XTENSA_PLATFORM_ISS)		:= iss
 platform-$(CONFIG_XTENSA_PLATFORM_XTFPGA)	:= xtfpga
 
-PLATFORM = $(platform-y)
-
 # temporarily until string.h is fixed
 KBUILD_CFLAGS += -ffreestanding -D__linux__
 KBUILD_CFLAGS += -pipe -mlongcalls -mtext-section-literals
@@ -55,16 +53,13 @@ KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(vardirs) $(plfdirs))
 
 KBUILD_DEFCONFIG := iss_defconfig
 
-# Only build platform if it includes a Makefile
-buildplf := $(shell test -e $(srctree)/arch/xtensa/platforms/$(PLATFORM)/Makefile && echo arch/xtensa/platforms/$(PLATFORM)/)
-
 # Find libgcc.a
 
 LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
 
 head-y		:= arch/xtensa/kernel/head.o
 core-y		+= arch/xtensa/kernel/ arch/xtensa/mm/
-core-y		+= $(buildplf)
+core-y		+= arch/xtensa/platforms/$(platform-y)/
 core-y 		+= arch/xtensa/boot/dts/
 
 libs-y		+= arch/xtensa/lib/ $(LIBGCC)
Signature · 1 line
2.30.2
maintainer Applied
#4 lore raw

Re: [PATCH 3/4] xtensa: build platform directories unconditionally

Quoted 9 lines · Masahiro Yamada

All of arch/xtensa/platforms/*/ have Makefile. You do not need to check the presence of Makefile.

---

 arch/xtensa/Makefile | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Thanks, applied to my xtensa tree.

Signature · 2 lines
Thanks.
-- Max
#5 lore raw

PATCH 4/4 xtensa: move core-y in arch/xtensa/Makefile to arch/xtensa/Kbuild

In reply to Masahiro Yamada

Use obj-y to clean up Makefile.

---

 arch/xtensa/Kbuild             | 1 +
 arch/xtensa/Makefile           | 3 ---
 arch/xtensa/platforms/Makefile | 4 ++++
 3 files changed, 5 insertions(+), 3 deletions(-)
 create mode 100644 arch/xtensa/platforms/Makefile
arch/xtensa/Kbuild +1 -0
index a4e40e534e6a..fd12f61745ba 100644
@@ -1 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0-only
+obj-y += kernel/ mm/ platforms/ boot/dts/
arch/xtensa/Makefile +0 -3
index 093e87b889be..96714ef7c89e 100644
@@ -58,9 +58,6 @@ KBUILD_DEFCONFIG := iss_defconfig
 LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
 
 head-y		:= arch/xtensa/kernel/head.o
-core-y		+= arch/xtensa/kernel/ arch/xtensa/mm/
-core-y		+= arch/xtensa/platforms/$(platform-y)/
-core-y 		+= arch/xtensa/boot/dts/
 
 libs-y		+= arch/xtensa/lib/ $(LIBGCC)
 
arch/xtensa/platforms/Makefile new file +4 -0
new file mode 100644
index 000000000000..e2e7e0726979
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_XTENSA_PLATFORM_XT2000)	+= xt2000/
+obj-$(CONFIG_XTENSA_PLATFORM_ISS)	+= iss/
+obj-$(CONFIG_XTENSA_PLATFORM_XTFPGA)	+= xtfpga/
Signature · 1 line
2.30.2
maintainer
#6 lore raw

Re: [PATCH 4/4] xtensa: move core-y in arch/xtensa/Makefile to arch/xtensa/Kbuild

Quoted 39 lines · Masahiro Yamada

Use obj-y to clean up Makefile.

---

 arch/xtensa/Kbuild             | 1 +
 arch/xtensa/Makefile           | 3 ---
 arch/xtensa/platforms/Makefile | 4 ++++
 3 files changed, 5 insertions(+), 3 deletions(-)
 create mode 100644 arch/xtensa/platforms/Makefile
arch/xtensa/Kbuild +1 -0
index a4e40e534e6a..fd12f61745ba 100644
@@ -1 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0-only
+obj-y += kernel/ mm/ platforms/ boot/dts/
arch/xtensa/Makefile +0 -3
index 093e87b889be..96714ef7c89e 100644
@@ -58,9 +58,6 @@ KBUILD_DEFCONFIG := iss_defconfig
 LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
 
 head-y         := arch/xtensa/kernel/head.o
-core-y         += arch/xtensa/kernel/ arch/xtensa/mm/
-core-y         += arch/xtensa/platforms/$(platform-y)/
-core-y                 += arch/xtensa/boot/dts/
 
 libs-y         += arch/xtensa/lib/ $(LIBGCC)
 
arch/xtensa/platforms/Makefile new file +0 -0
new file mode 100644
index 000000000000..e2e7e0726979

arch/xtensa/platforms/Makefile line 4

Quoted 4 lines
arch/xtensa/platforms/Makefile new file +4 -0
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_XTENSA_PLATFORM_XT2000)   += xt2000/
+obj-$(CONFIG_XTENSA_PLATFORM_ISS)      += iss/
+obj-$(CONFIG_XTENSA_PLATFORM_XTFPGA)   += xtfpga/

With this change platform directory names are duplicated in two makefiles. Can we move them to Kconfig with something like the following (on top of this change)?

---8<---

arch/xtensa/Kconfig +0 -0
index b843902ad9fd..fe5ae5ec71c9 100644
@@ -314,6 +314,12 @@ config PLATFORM_HAVE_XIP
 

menu "Platform options"

+config XTENSA_PLATFORM

+       string
+       default iss if XTENSA_PLATFORM_ISS
+       default xt2000 if XTENSA_PLATFORM_XT2000
+       default xtfpga if XTENSA_PLATFORM_XTFPGA

+
choice
prompt "Xtensa System Type"
default XTENSA_PLATFORM_ISS

arch/xtensa/Makefile +0 -0
index 96714ef7c89e..6b104ecdd19e 100644
@@ -26,12 +26,6 @@ ifneq ($(VARIANT),)
  endif

endif

-# Platform configuration
-

-platform-$(CONFIG_XTENSA_PLATFORM_XT2000)      := xt2000
-platform-$(CONFIG_XTENSA_PLATFORM_ISS)         := iss
-platform-$(CONFIG_XTENSA_PLATFORM_XTFPGA)      := xtfpga
-
# temporarily until string.h is fixed
KBUILD_CFLAGS += -ffreestanding -D__linux__
KBUILD_CFLAGS += -pipe -mlongcalls -mtext-section-literals
@@ -47,7 +41,7 @@ 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)) +plfdirs := $(patsubst %,arch/xtensa/platforms/%/,$(CONFIG_XTENSA_PLATFORM))

KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(vardirs) $(plfdirs))

arch/xtensa/platforms/Makefile +0 -0
index e2e7e0726979..08d0e9053db6 100644
@@ -1,4 +1,2 @@

# SPDX-License-Identifier: GPL-2.0-only

-obj-$(CONFIG_XTENSA_PLATFORM_XT2000)   += xt2000/
-obj-$(CONFIG_XTENSA_PLATFORM_ISS)      += iss/
-obj-$(CONFIG_XTENSA_PLATFORM_XTFPGA)   += xtfpga/

+obj-y += $(CONFIG_XTENSA_PLATFORM)/

---8<---

Signature · 2 lines
Thanks.
-- Max
#7 lore raw

Re: [PATCH 4/4] xtensa: move core-y in arch/xtensa/Makefile to arch/xtensa/Kbuild

Quoted 35 lines · Max Filippov
Quoted 33 lines · Masahiro Yamada

Use obj-y to clean up Makefile.

---

 arch/xtensa/Kbuild             | 1 +
 arch/xtensa/Makefile           | 3 ---
 arch/xtensa/platforms/Makefile | 4 ++++
 3 files changed, 5 insertions(+), 3 deletions(-)
 create mode 100644 arch/xtensa/platforms/Makefile
arch/xtensa/Kbuild +1 -0
index a4e40e534e6a..fd12f61745ba 100644
@@ -1 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0-only
+obj-y += kernel/ mm/ platforms/ boot/dts/
arch/xtensa/Makefile +0 -3
index 093e87b889be..96714ef7c89e 100644
@@ -58,9 +58,6 @@ KBUILD_DEFCONFIG := iss_defconfig
 LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
 
 head-y         := arch/xtensa/kernel/head.o
-core-y         += arch/xtensa/kernel/ arch/xtensa/mm/
-core-y         += arch/xtensa/platforms/$(platform-y)/
-core-y                 += arch/xtensa/boot/dts/
 
 libs-y         += arch/xtensa/lib/ $(LIBGCC)
 
Quoted 14 lines

arch/xtensa/platforms/Makefile line 4

Quoted 10 lines
arch/xtensa/platforms/Makefile new file +4 -0
new file mode 100644
index 000000000000..e2e7e0726979
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_XTENSA_PLATFORM_XT2000)   += xt2000/
+obj-$(CONFIG_XTENSA_PLATFORM_ISS)      += iss/
+obj-$(CONFIG_XTENSA_PLATFORM_XTFPGA)   += xtfpga/

With this change platform directory names are duplicated in two makefiles. Can we move them to Kconfig with something like the following (on top of this change)?

I do not like the idea much for the following reasons.

- The string value in Kconfig is enclosed by double-quotes.

In the .config file,

CONFIG_XTENSA_PLATFORM="iss"

So, you are doing

        obj-y  += "iss"/

instead of

        obj-y  += iss/

Still, it seems working because the shell will eventually get rid of double quotes, but that is not correct from the Kbuild perspective.

You need to write like this:

       obj-y += $(patsubst "%",%,$(CONFIG_XTENSA_PLATFORM))

- 'make clean' does not include any CONFIG option.

So,

   obj-y += $(CONFIG_XTENSA_PLATFORM)/

will expand into:

obj-y += /

Luckily, Kbuild will ignore it.
Kbuild will not try to clean the root directory, but this code
scares me.

- Kbuild cannot know the sub-directories of arch/xtensa/platforms/. So, you need to list the subdirectories anyway so 'make clean' can visit all the sub-directories.

arch/xtensa/platforms/Makefile

      # for 'make clean'
      obj-  += iss/ xt2000/ xtfpga/
Quoted 60 lines

---8<---

arch/xtensa/Kconfig +0 -0
index b843902ad9fd..fe5ae5ec71c9 100644
@@ -314,6 +314,12 @@ config PLATFORM_HAVE_XIP
 

menu "Platform options"

arch/xtensa/Kconfig +6 -0
+config XTENSA_PLATFORM
+       string
+       default iss if XTENSA_PLATFORM_ISS
+       default xt2000 if XTENSA_PLATFORM_XT2000
+       default xtfpga if XTENSA_PLATFORM_XTFPGA
+

choice
prompt "Xtensa System Type"
default XTENSA_PLATFORM_ISS

arch/xtensa/Makefile +0 -0
index 96714ef7c89e..6b104ecdd19e 100644
@@ -26,12 +26,6 @@ ifneq ($(VARIANT),)
  endif

endif

arch/xtensa/Makefile +0 -6
-# Platform configuration
-
-platform-$(CONFIG_XTENSA_PLATFORM_XT2000)      := xt2000
-platform-$(CONFIG_XTENSA_PLATFORM_ISS)         := iss
-platform-$(CONFIG_XTENSA_PLATFORM_XTFPGA)      := xtfpga
-
# temporarily until string.h is fixed
KBUILD_CFLAGS += -ffreestanding -D__linux__
KBUILD_CFLAGS += -pipe -mlongcalls -mtext-section-literals
arch/xtensa/Makefile +1 -1
@@ -47,7 +41,7 @@ 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))
+plfdirs := $(patsubst %,arch/xtensa/platforms/%/,$(CONFIG_XTENSA_PLATFORM))
 
 KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(vardirs) $(plfdirs))
 
arch/xtensa/platforms/Makefile +1 -5
index e2e7e0726979..08d0e9053db6 100644
@@ -1,4 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0-only
-obj-$(CONFIG_XTENSA_PLATFORM_XT2000)   += xt2000/
-obj-$(CONFIG_XTENSA_PLATFORM_ISS)      += iss/
-obj-$(CONFIG_XTENSA_PLATFORM_XTFPGA)   += xtfpga/
+obj-y += $(CONFIG_XTENSA_PLATFORM)/
 
---8<---
 
--

Thanks.
-- Max

Signature · 2 lines
Best Regards
Masahiro Yamada
maintainer
#8 lore raw

Re: [PATCH 4/4] xtensa: move core-y in arch/xtensa/Makefile to arch/xtensa/Kbuild

Quoted 52 lines · Masahiro Yamada
Quoted 35 lines · Max Filippov
Quoted 33 lines · Masahiro Yamada

Use obj-y to clean up Makefile.

---

 arch/xtensa/Kbuild             | 1 +
 arch/xtensa/Makefile           | 3 ---
 arch/xtensa/platforms/Makefile | 4 ++++
 3 files changed, 5 insertions(+), 3 deletions(-)
 create mode 100644 arch/xtensa/platforms/Makefile
arch/xtensa/Kbuild +1 -0
index a4e40e534e6a..fd12f61745ba 100644
@@ -1 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0-only
+obj-y += kernel/ mm/ platforms/ boot/dts/
arch/xtensa/Makefile +0 -3
index 093e87b889be..96714ef7c89e 100644
@@ -58,9 +58,6 @@ KBUILD_DEFCONFIG := iss_defconfig
 LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
 
 head-y         := arch/xtensa/kernel/head.o
-core-y         += arch/xtensa/kernel/ arch/xtensa/mm/
-core-y         += arch/xtensa/platforms/$(platform-y)/
-core-y                 += arch/xtensa/boot/dts/
 
 libs-y         += arch/xtensa/lib/ $(LIBGCC)
 
Quoted 14 lines

arch/xtensa/platforms/Makefile line 4

Quoted 10 lines
arch/xtensa/platforms/Makefile new file +4 -0
new file mode 100644
index 000000000000..e2e7e0726979
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_XTENSA_PLATFORM_XT2000)   += xt2000/
+obj-$(CONFIG_XTENSA_PLATFORM_ISS)      += iss/
+obj-$(CONFIG_XTENSA_PLATFORM_XTFPGA)   += xtfpga/

With this change platform directory names are duplicated in two makefiles. Can we move them to Kconfig with something like the following (on top of this change)?

Quoted 1 line

I do not like the idea much for the following reasons.

Ok, thanks for the explanation. Applied the original patch to my xtensa tree.

Signature · 2 lines
Thanks.
-- Max