* [PATCH 2/6] modpost: sync mk_elfconfig.c with Linux 5.7-rc2
2020-04-24 18:59 [PATCH 1/6] kbuild: remove meaningless headers_check from help target Masahiro Yamada
@ 2020-04-24 18:59 ` Masahiro Yamada
2020-04-24 18:59 ` [PATCH 3/6] kbuild: swap the include order of arch Makefile and auto.conf.cmd Masahiro Yamada
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Masahiro Yamada @ 2020-04-24 18:59 UTC (permalink / raw)
To: barebox; +Cc: Masahiro Yamada
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.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/mod/Makefile | 2 +-
scripts/mod/mk_elfconfig.c | 11 +----------
scripts/mod/modpost.c | 2 ++
3 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/scripts/mod/Makefile b/scripts/mod/Makefile
index c5aa34892..e02b9f4ce 100644
--- a/scripts/mod/Makefile
+++ b/scripts/mod/Makefile
@@ -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)
diff --git a/scripts/mod/mk_elfconfig.c b/scripts/mod/mk_elfconfig.c
index db3881f14..680eade89 100644
--- a/scripts/mod/mk_elfconfig.c
+++ b/scripts/mod/mk_elfconfig.c
@@ -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;
}
-
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 795ee8d09..a42f1e6ce 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -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) */
--
2.25.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/6] kbuild: swap the include order of arch Makefile and auto.conf.cmd
2020-04-24 18:59 [PATCH 1/6] kbuild: remove meaningless headers_check from help target Masahiro Yamada
2020-04-24 18:59 ` [PATCH 2/6] modpost: sync mk_elfconfig.c with Linux 5.7-rc2 Masahiro Yamada
@ 2020-04-24 18:59 ` Masahiro Yamada
2020-04-24 18:59 ` [PATCH 4/6] kbuild: make DEFCONFIG_LIST work Masahiro Yamada
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Masahiro Yamada @ 2020-04-24 18:59 UTC (permalink / raw)
To: barebox; +Cc: 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.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
Makefile | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 797ed214a..e01a7491a 100644
--- a/Makefile
+++ b/Makefile
@@ -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
--
2.25.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 4/6] kbuild: make DEFCONFIG_LIST work
2020-04-24 18:59 [PATCH 1/6] kbuild: remove meaningless headers_check from help target Masahiro Yamada
2020-04-24 18:59 ` [PATCH 2/6] modpost: sync mk_elfconfig.c with Linux 5.7-rc2 Masahiro Yamada
2020-04-24 18:59 ` [PATCH 3/6] kbuild: swap the include order of arch Makefile and auto.conf.cmd Masahiro Yamada
@ 2020-04-24 18:59 ` Masahiro Yamada
2020-04-24 18:59 ` [PATCH 5/6] kbuild: use $(SRCARCH) to point to the arch directory Masahiro Yamada
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Masahiro Yamada @ 2020-04-24 18:59 UTC (permalink / raw)
To: barebox; +Cc: 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.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
common/Kconfig | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/common/Kconfig b/common/Kconfig
index 400c0553c..893bdeaff 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -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
--
2.25.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 5/6] kbuild: use $(SRCARCH) to point to the arch directory
2020-04-24 18:59 [PATCH 1/6] kbuild: remove meaningless headers_check from help target Masahiro Yamada
` (2 preceding siblings ...)
2020-04-24 18:59 ` [PATCH 4/6] kbuild: make DEFCONFIG_LIST work Masahiro Yamada
@ 2020-04-24 18:59 ` Masahiro Yamada
2020-04-24 18:59 ` [PATCH 6/6] kbuild: set SRCARCH=arm when ARCH=arm64 Masahiro Yamada
2020-04-27 7:56 ` [PATCH 1/6] kbuild: remove meaningless headers_check from help target Sascha Hauer
5 siblings, 0 replies; 7+ messages in thread
From: Masahiro Yamada @ 2020-04-24 18:59 UTC (permalink / raw)
To: barebox; +Cc: 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.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
Makefile | 26 +++++++++++++-------------
images/Makefile | 6 +++---
scripts/Makefile.build | 2 +-
3 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/Makefile b/Makefile
index e01a7491a..477741a72 100644
--- a/Makefile
+++ b/Makefile
@@ -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), \
diff --git a/images/Makefile b/images/Makefile
index fe29c75e2..0aa4676ae 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -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
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 601a4d9cd..57c946769 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -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) \
--
2.25.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 6/6] kbuild: set SRCARCH=arm when ARCH=arm64
2020-04-24 18:59 [PATCH 1/6] kbuild: remove meaningless headers_check from help target Masahiro Yamada
` (3 preceding siblings ...)
2020-04-24 18:59 ` [PATCH 5/6] kbuild: use $(SRCARCH) to point to the arch directory Masahiro Yamada
@ 2020-04-24 18:59 ` Masahiro Yamada
2020-04-27 7:56 ` [PATCH 1/6] kbuild: remove meaningless headers_check from help target Sascha Hauer
5 siblings, 0 replies; 7+ messages in thread
From: Masahiro Yamada @ 2020-04-24 18:59 UTC (permalink / raw)
To: barebox; +Cc: 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).
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
Makefile | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 477741a72..16b23c107 100644
--- a/Makefile
+++ b/Makefile
@@ -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.
--
2.25.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/6] kbuild: remove meaningless headers_check from help target
2020-04-24 18:59 [PATCH 1/6] kbuild: remove meaningless headers_check from help target Masahiro Yamada
` (4 preceding siblings ...)
2020-04-24 18:59 ` [PATCH 6/6] kbuild: set SRCARCH=arm when ARCH=arm64 Masahiro Yamada
@ 2020-04-27 7:56 ` Sascha Hauer
5 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2020-04-27 7:56 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: barebox
Hi Masahiro,
On Sat, Apr 25, 2020 at 03:59:19AM +0900, Masahiro Yamada wrote:
> 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").
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
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
--
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 7+ messages in thread