Skip to contentSkip to conversation

kbuild: remove meaningless headers_check from help target

PATCH Applied Masahiro Yamada 2 participants 7 messages Apr 24, 2020 – Apr 27, 2020 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 kbuild: remove meaningless headers_check from help target

This is never shown because include/asm-$(ARCH)/Kbuild does not exist.

headers_check does not make any sense for barebox.

Linux also deprecated headers_check by commit 7ecaf069da52 ("kbuild:
move headers_check rule to usr/include/Makefile").

---

 Makefile | 3 ---
 1 file changed, 3 deletions(-)
Makefile +0 -3
index 626318624..797ed214a 100644
@@ -1077,9 +1077,6 @@ help:
 	@echo  'Static analysers'
 	@echo  '  checkstack      - Generate a list of stack hogs'
 	@echo  '  namespacecheck  - Name space analysis on compiled kernel'
-	@if [ -r include/asm-$(ARCH)/Kbuild ]; then \
-	 echo  '  headers_check   - Sanity check on exported headers'; \
-	 fi
 	@echo  ''
 	@echo  'Architecture specific targets ($(ARCH)):'
 	@$(if $(archhelp),$(archhelp),\
Signature · 7 lines
2.25.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 2/6 modpost: sync mk_elfconfig.c with Linux 5.7-rc2

Just get rid of the argument $(ARCH), then hardcode MODULE_SYMBOL_PREFIX. This should have no impact because none of v850, h8300, blackfin is supported by barebox.

---

 scripts/mod/Makefile       |  2 +-
 scripts/mod/mk_elfconfig.c | 11 +----------
 scripts/mod/modpost.c      |  2 ++
 3 files changed, 4 insertions(+), 11 deletions(-)
scripts/mod/Makefile +1 -1
index c5aa34892..e02b9f4ce 100644
@@ -8,7 +8,7 @@ modpost-objs	:= modpost.o sumversion.o
 $(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h
 
 quiet_cmd_elfconfig = MKELF   $@
-      cmd_elfconfig = $(obj)/mk_elfconfig $(ARCH) < $< > $@
+      cmd_elfconfig = $(obj)/mk_elfconfig < $< > $@
 
 $(obj)/elfconfig.h: $(obj)/empty.o $(obj)/mk_elfconfig FORCE
 	$(call if_changed,elfconfig)
scripts/mod/mk_elfconfig.c +1 -10
index db3881f14..680eade89 100644
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -9,9 +10,6 @@ main(int argc, char **argv)
 	unsigned char ei[EI_NIDENT];
 	union { short s; char c[2]; } endian_test;
 
-	if (argc != 2) {
-		fprintf(stderr, "Error: no arch\n");
-	}
 	if (fread(ei, 1, EI_NIDENT, stdin) != EI_NIDENT) {
 		fprintf(stderr, "Error: input truncated\n");
 		return 1;
@@ -55,12 +53,5 @@ main(int argc, char **argv)
 	else
 		exit(1);
 
-	if ((strcmp(argv[1], "v850") == 0) || (strcmp(argv[1], "h8300") == 0)
-	    || (strcmp(argv[1], "blackfin") == 0))
-		printf("#define MODULE_SYMBOL_PREFIX \"_\"\n");
-	else
-		printf("#define MODULE_SYMBOL_PREFIX \"\"\n");
-
 	return 0;
 }
-
scripts/mod/modpost.c +2 -0
index 795ee8d09..a42f1e6ce 100644
@@ -31,6 +31,8 @@ static inline int license_is_gpl_compatible(const char *license)
 }
 #endif
 
+#define MODULE_SYMBOL_PREFIX ""
+
 /* Are we using CONFIG_MODVERSIONS? */
 int modversions = 0;
 /* Warn about undefined symbols? (do so if we have vmlinux) */
Signature · 7 lines
2.25.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 3/6 kbuild: swap the include order of arch Makefile and auto.conf.cmd

In reply to Masahiro Yamada

Include

  include/config/auto.conf
  arch/$(ARCH)/Makefile
  include/config/auto.conf.cmd

in this order, which is the same as the current Linux does.

auto.conf.cmd contains the environment variables that were referenced from Kconfig files. If an environment variable defined in arch Makefile is referenced from Kconfig files, Kbuild would end up with eternal synconfig loop.

---

 Makefile | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
Makefile +6 -4
index 797ed214a..e01a7491a 100644
@@ -445,12 +445,16 @@ PHONY += scripts
 scripts: scripts_basic
 	$(Q)$(MAKE) $(build)=$(@)
 
+ifeq ($(dot-config),1)
+include include/config/auto.conf
+endif
+
 # Objects we will link into barebox / subdirs we need to visit
 common-y		:= common/ drivers/ commands/ lib/ crypto/ net/ fs/ firmware/
 
-ifeq ($(dot-config),1)
-include include/config/auto.conf
+include $(srctree)/arch/$(ARCH)/Makefile
 
+ifeq ($(dot-config),1)
 # Read in dependencies to all Kconfig* files, make sure to run syncconfig if
 # changes are detected. This should be included after arch/$(SRCARCH)/Makefile
 # because some architectures define CROSS_COMPILE there.
@@ -476,8 +480,6 @@ $(KCONFIG_CONFIG):
 	$(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
 endif # $(dot-config)
 
-include $(srctree)/arch/$(ARCH)/Makefile
-
 KBUILD_CFLAGS		+= -ggdb3
 
 # Force gcc to behave correct even for buggy distributions
Signature · 7 lines
2.25.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH 4/6 kbuild: make DEFCONFIG_LIST work

In reply to Masahiro Yamada

Most of the Kconfig commands (except defconfig and all*config) read the .config file as a base set of CONFIG options.

When it does not exist, the files in DEFCONFIG_LIST are searched in this order and loaded if found.

This is not working for barebox because ARCH_DEFCONFIG is not set by anyone, nor arch/$(ARCH)/defconfig exists.

Fix this.

---

 common/Kconfig | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
common/Kconfig +1 -2
index 400c0553c..893bdeaff 100644
@@ -1,8 +1,7 @@
 config DEFCONFIG_LIST
 	string
 	option defconfig_list
-	default ARCH_DEFCONFIG
-	default "arch/$(ARCH)/defconfig"
+	default "arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)"
 
 config GREGORIAN_CALENDER
 	bool
Signature · 7 lines
2.25.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

PATCH 5/6 kbuild: use $(SRCARCH) to point to the arch directory

In reply to Masahiro Yamada

A couple of arch directories in Linux are biarch, that is, a single arch/*/ directory supports both 32-bit and 64-bit.

In old days of Linux, they started as separated directories. arm/arm64 is the exceptional case, but the other architectures were unified.

e.g.)

  arch/i386, arch/x86_64    ->  arch/x86
  arch/sh, arch/sh64        ->  arch/sh
  arch/sparc, arch/sparc64  ->  arch/sparc

Linux commit 6752ed90da03 ("Kbuild: allow arch/xxx to use a different source path") introduced SRCARCH to point to the arch directory, still allowing to pass in the former ARCH=i386 or ARCH=x86_64.

The top Makefile in Linux converts ARCH to SRCARCH as follows:

  # Additional ARCH settings for x86
  ifeq ($(ARCH),i386)
          SRCARCH := x86
  endif
  ifeq ($(ARCH),x86_64)
          SRCARCH := x86
  endif

So, if you follow the upstream Kbuild convention, using arch/$(SRCARCH) is the correct way to point to the arch directory.

---

 Makefile               | 26 +++++++++++++-------------
 images/Makefile        |  6 +++---
 scripts/Makefile.build |  2 +-
 3 files changed, 17 insertions(+), 17 deletions(-)
Makefile +13 -13
index e01a7491a..477741a72 100644
@@ -307,8 +307,8 @@ export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_ve
 # Needed to be compatible with the O= option
 LINUXINCLUDE    := -Iinclude -I$(srctree)/dts/include \
                    $(if $(KBUILD_SRC), -I$(srctree)/include) \
-		   -I$(srctree)/arch/$(ARCH)/include \
-		   -I$(objtree)/arch/$(ARCH)/include \
+		   -I$(srctree)/arch/$(SRCARCH)/include \
+		   -I$(objtree)/arch/$(SRCARCH)/include \
                    -include $(srctree)/include/linux/kconfig.h
 
 KBUILD_CPPFLAGS        := -D__KERNEL__ -D__BAREBOX__ $(LINUXINCLUDE) -fno-builtin -ffreestanding
@@ -424,7 +424,7 @@ ifeq ($(config-targets),1)
 # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
 # KBUILD_DEFCONFIG may point out an alternative default configuration
 # used for 'make defconfig'
-include $(srctree)/arch/$(ARCH)/Makefile
+include $(srctree)/arch/$(SRCARCH)/Makefile
 export KBUILD_DEFCONFIG
 
 config: scripts_basic outputmakefile FORCE
@@ -452,7 +452,7 @@ endif
 # Objects we will link into barebox / subdirs we need to visit
 common-y		:= common/ drivers/ commands/ lib/ crypto/ net/ fs/ firmware/
 
-include $(srctree)/arch/$(ARCH)/Makefile
+include $(srctree)/arch/$(SRCARCH)/Makefile
 
 ifeq ($(dot-config),1)
 # Read in dependencies to all Kconfig* files, make sure to run syncconfig if
@@ -520,7 +520,7 @@ export KBUILD_IMAGE ?= barebox.bin
 export KBUILD_BINARY ?= barebox.bin
 # KBUILD_IMAGE and _BINARY may be overruled on the command line or
 # set in the environment.
-# Also any assignments in arch/$(ARCH)/Makefile take precedence over
+# Also any assignments in arch/$(SRCARCH)/Makefile take precedence over
 # the default value.
 
 barebox-flash-image: $(KBUILD_IMAGE) FORCE
@@ -574,7 +574,7 @@ export DEFAULT_COMPRESSION_SUFFIX
 # ---------------------------------------------------------------------------
 # barebox is built from the objects selected by $(barebox-init) and
 # $(barebox-main). Most are built-in.o files from top-level directories
-# in the kernel tree, others are specified in arch/$(ARCH)Makefile.
+# in the kernel tree, others are specified in arch/$(SRCARCH)/Makefile.
 # Ordering when linking is important, and $(barebox-init) must be first.
 #
 # FIXME: This picture is wrong for barebox. We have no init, driver, mm
@@ -601,7 +601,7 @@ export BAREBOX_PBL_OBJS := $(pbl-common-y)
 BAREBOX_LDS    := $(lds-y)
 
 # Rule to link barebox
-# May be overridden by arch/$(ARCH)/Makefile
+# May be overridden by arch/$(SRCARCH)/Makefile
 quiet_cmd_barebox__ ?= LD      $@
       cmd_barebox__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_barebox) -o $@ \
       -T $(BAREBOX_LDS)                         \
@@ -742,7 +742,7 @@ UIMAGE_BASE ?= $(shell printf "0x%08x" $$(($(CONFIG_TEXT_BASE) - 0x200000)))
 # For development provide a target which makes barebox loadable by an
 # unmodified u-boot
 quiet_cmd_barebox_mkimage = MKIMAGE $@
-      cmd_barebox_mkimage = $(srctree)/scripts/mkimage -A $(ARCH) -T firmware -C none \
+      cmd_barebox_mkimage = $(srctree)/scripts/mkimage -A $(SRCARCH) -T firmware -C none \
        -O barebox -a $(UIMAGE_BASE) -e $(UIMAGE_BASE) \
        -n "barebox $(KERNELRELEASE)" -d $< $@
 
@@ -851,9 +851,9 @@ prepare0: archprepare FORCE
 prepare prepare-all: prepare0
 
 # Leave this as default for preprocessing barebox.lds.S, which is now
-# done in arch/$(ARCH)/kernel/Makefile
+# done in arch/$(SRCARCH)/kernel/Makefile
 
-export CPPFLAGS_barebox.lds += -C -U$(ARCH)
+export CPPFLAGS_barebox.lds += -C -U$(SRCARCH)
 
 define symlink-config-h
 	if [ -f $(srctree)/$(BOARD)/config.h ]; then		\
@@ -1052,7 +1052,7 @@ rpm: include/config/kernel.release FORCE
 # Brief documentation of the typical targets used
 # ---------------------------------------------------------------------------
 
-boards := $(wildcard $(srctree)/arch/$(ARCH)/configs/*_defconfig)
+boards := $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*_defconfig)
 boards := $(sort $(notdir $(boards)))
 
 help:
@@ -1080,9 +1080,9 @@ help:
 	@echo  '  checkstack      - Generate a list of stack hogs'
 	@echo  '  namespacecheck  - Name space analysis on compiled kernel'
 	@echo  ''
-	@echo  'Architecture specific targets ($(ARCH)):'
+	@echo  'Architecture specific targets ($(SRCARCH)):'
 	@$(if $(archhelp),$(archhelp),\
-		echo '  No architecture specific help defined for $(ARCH)')
+		echo '  No architecture specific help defined for $(SRCARCH)')
 	@echo  ''
 	@$(if $(boards), \
 		$(foreach b, $(boards), \
images/Makefile +3 -3
index fe29c75e2..0aa4676ae 100644
@@ -50,7 +50,7 @@ quiet_cmd_objcopy_bin = OBJCOPYB $@
 pbl-lds := $(obj)/pbl.lds
 extra-y += $(pbl-lds)
 
-$(pbl-lds): $(obj)/../arch/$(ARCH)/lib/pbl.lds.S FORCE
+$(pbl-lds): $(obj)/../arch/$(SRCARCH)/lib/pbl.lds.S FORCE
 	$(call if_changed_dep,cpp_lds_S)
 
 quiet_cmd_elf__ ?= LD      $@
@@ -139,8 +139,8 @@ $(obj)/%.img: $(obj)/$$(FILE_$$(@F))
 	$(Q)if [ -z $(FILE_$(@F)) ]; then echo "FILE_$(@F) empty!"; false; fi
 	$(call if_changed,shipped)
 
-board = $(srctree)/arch/$(ARCH)/boards
-objboard = $(objtree)/arch/$(ARCH)/boards
+board = $(srctree)/arch/$(SRCARCH)/boards
+objboard = $(objtree)/arch/$(SRCARCH)/boards
 
 include $(srctree)/images/Makefile.am33xx
 include $(srctree)/images/Makefile.am35xx
scripts/Makefile.build +1 -1
index 601a4d9cd..57c946769 100644
@@ -175,7 +175,7 @@ cmd_modversions =							\
 	if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then	\
 		$(CPP) -D__GENKSYMS__ $(c_flags) $<			\
 		| $(GENKSYMS) $(if $(KBUILD_SYMTYPES),			\
-			      -T $(@D)/$(@F:.o=.symtypes)) -a $(ARCH)	\
+			      -T $(@D)/$(@F:.o=.symtypes)) 		\
 		> $(@D)/.tmp_$(@F:.o=.ver);				\
 									\
 		$(LD) $(KBUILD_LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) 		\
Signature · 7 lines
2.25.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

PATCH 6/6 kbuild: set SRCARCH=arm when ARCH=arm64

In reply to Masahiro Yamada

In Linux, ARCH can be passed from the command line or the environment. In barebox, "ARCH=arm64 make" works, but "make ARCH=arm64" does not.

Instead of overriding ARCH, use SRCARCH properly.

This is what Linux does for biarch directories (x86, sh, sparc).

---

 Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Makefile +4 -4
index 477741a72..16b23c107 100644
@@ -163,10 +163,6 @@ export srctree objtree VPATH
 # Alternatively CROSS_COMPILE can be set in the environment.
 # Default value for CROSS_COMPILE is not to prefix executables
 
-ifeq ($(ARCH),arm64)
-ARCH = arm
-endif
-
 ARCH            ?= sandbox
 CROSS_COMPILE   ?=
 
@@ -174,6 +170,10 @@ CROSS_COMPILE   ?=
 UTS_MACHINE := $(ARCH)
 SRCARCH 	:= $(ARCH)
 
+ifeq ($(ARCH),arm64)
+       SRCARCH := arm
+endif
+
 KCONFIG_CONFIG	?= .config
 
 # Default file for 'make defconfig'. This may be overridden by arch-Makefile.
Signature · 7 lines
2.25.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#6 lore raw
In reply to Masahiro Yamada

Hi Masahiro,

Quoted 9 lines · Masahiro Yamada

This is never shown because include/asm-$(ARCH)/Kbuild does not exist.

headers_check does not make any sense for barebox.

Linux also deprecated headers_check by commit 7ecaf069da52 ("kbuild:
move headers_check rule to usr/include/Makefile").

---

Applied, thanks

Thank you by the way for your constant stream of updates in the Kbuild/Kconfig area. It's an area most people don't really like to touch, still it needs quite some care. I really appreciate your work.

Regards,
Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox