Re: [PATCH 1/2] efi: payload: iomem: add commented out #define DEBUG 1

2023-05-30 Thread Masahiro Yamada
On Tue, May 30, 2023 at 9:38 PM Sascha Hauer  wrote:
>
> Picked some outdated address from Masahiro, so once again:


The macro name is misleading - perhaps, it should have
been named as __is_defined_as_1().

I do not know if __is_defined() is future-proof.
IS_BUILTIN, IS_MODULE, etc. are official,
but __is_defined() is internal.





>
> On Tue, May 23, 2023 at 11:40:34AM +0200, Ahmad Fatoum wrote:
> > The code uses __is_defined, which only works for undefined macros and
> > defined ones with a value. This is different than the debugging prints
> > that accept empty defined DEBUG, so add a commented out #define DEBUG 1
> > to alert those seeking to debug the code.
> >
> > Signed-off-by: Ahmad Fatoum 
> > ---
> >  common/efi/payload/iomem.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/common/efi/payload/iomem.c b/common/efi/payload/iomem.c
> > index 6b92ca993aa7..550d832668ed 100644
> > --- a/common/efi/payload/iomem.c
> > +++ b/common/efi/payload/iomem.c
> > @@ -3,6 +3,7 @@
> >
> >  #define pr_fmt(fmt) "efi-iomem: " fmt
> >
> > +// #define DEBUG 1
>
> I don't like this very much.
>
> Generally being able to do this is really appealing:
>
> if (__is_defined(DEBUG))
> ...
>
> Indeed this is so appealing that others may copy this. Having to
> remember then that there's a subtle difference between __is_defined() and
> #ifdef is not so nice though.
>
> We could add
>
> #define __ARG_PLACEHOLDER_ 0,
>
> to include/linux/kconfig.h. With this __is_defined() and #ifdef should
> do the same thing. It would even better to add this to the Linux
> upstream version of this file. I am not sure though if that has any
> unwanted side effects. Masahiro, do you have an opinion about this?
>
> Another option would be to add this somewhere:
>
> #ifdef DEBUG
> #undef DEBUG
> #define DEBUG 1
> #endif
>
> 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- |



-- 
Best Regards
Masahiro Yamada



Re: [PATCH 3/3] ARM: cleanup 32bit/64bit support in Kconfig

2023-03-24 Thread Masahiro YAMADA
On Fri, Mar 24, 2023 at 9:20 PM Sascha Hauer  wrote:
>
> The decision whether to build a 32bit or 64bit barebox has to be made
> first before anything else, so this makes CONFIG_64BIT a toplevel option
> without any further dependencies.
>
> With this patch we will only present the SoCs/boards which are actually
> supported by the selected code model in Kconfig.
>
> Without this patch it was often possible to select 32bit boards on a
> 64bit build or vice versa, which resulted in a broken build.
>
> Signed-off-by: Sascha Hauer 


>
> -choice
> -   prompt "Barebox code model"
> -   help
> - You should only select this option if you have a workload that
> - actually benefits from 64-bit processing or if your machine has
> - large memory. You will only be presented a single option in this
> - menu if your system does not support both 32-bit and 64-bit modes.
> -
> -config 32BIT
> -   bool "32-bit barebox"
> -   depends on CPU_SUPPORTS_32BIT_KERNEL
> -   help
> - Select this option if you want to build a 32-bit barebox.
> -
>  config 64BIT
> -   bool "64-bit barebox"
> -   depends on CPU_SUPPORTS_64BIT_KERNEL
> +   bool "64bit barebox" if "$(ARCH)" != "arm64"
> +   default "$(ARCH)" = "arm64"
> select ARCH_DMA_ADDR_T_64BIT
> help
>   Select this option if you want to build a 64-bit barebox.
>
> -endchoice
> +config 32BIT
> +   bool
> +   default !64BIT
> +   help
> + Select this option if you want to build a 32-bit barebox.
>


This help message is a bit strange - it is automatically
selected / unselected since it has no "prompt".





I see more CONFIG options with a weird help.





config 64BIT
def_bool y if X86_EFI
select ARCH_DMA_ADDR_T_64BIT
help
  Say yes to build a 64-bit binary - formerly known as x86_64
  Say no to build a 32-bit binary - formerly known as i386.



You cannot say yes or no here since Kconfig
does not show a prompt in the first place.



Re: [PATCH] ARM: Rockchip: let boards depend on 32/64bit

2023-03-23 Thread Masahiro YAMADA
On Wed, Mar 22, 2023 at 11:09 PM Sascha Hauer  wrote:
>
> So far we can enable support for 32bit and 64bit SoCs at the same time
> which results in an unbuildable barebox. This is annoying, let the board
> visibility depend on the selected code model.
>
> Signed-off-by: Sascha Hauer 


What is weird in the current approach is,
none of "make ARCH=arm64 allnoconfig"
"make ARCH=arm64 allyesconfig" sets CONFIG_64BIT.




I think CONFIG_64BIT should be the highest level option,
which is not selected by anyone, and does not depend on
any other CONFIG option.




config 64BIT
  bool "64bit" if "$(ARCH)" != "arm64"
  default "$(ARCH)" = "arm64"


Then, 32bit-only platforms depend on !64BIT.
and 64bit-only platforms depend on 64BIT.


config ARCH_ZYNQ
   bool "zynq (32bit)"
   depends on !64BIT

config ARCH_ZYNQMP
   bool "zynq (64bit)"
   depends on 64BIT















> ---
>  arch/arm/Kconfig   | 2 ++
>  arch/arm/mach-rockchip/Kconfig | 9 -
>  2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index abe649de49..2c1783d8e9 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -248,6 +248,8 @@ config ARCH_ROCKCHIP
> select OFTREE
> select HAVE_PBL_MULTI_IMAGES
> select HAS_DEBUG_LL
> +   select CPU_SUPPORTS_32BIT_KERNEL
> +   select CPU_SUPPORTS_64BIT_KERNEL
>
>  config ARCH_STM32MP
> bool "STMicroelectronics STM32MP"
> diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
> index 4ac75ab947..9b4913d5da 100644
> --- a/arch/arm/mach-rockchip/Kconfig
> +++ b/arch/arm/mach-rockchip/Kconfig
> @@ -30,7 +30,6 @@ config ARCH_RK3288
>  config ARCH_ROCKCHIP_V8
> bool
> select CPU_V8
> -   select CPU_SUPPORTS_64BIT_KERNEL
> select ARM_ATF
> select RELOCATABLE
>
> @@ -49,6 +48,8 @@ config ARCH_RK3568
>
>  comment "select Rockchip boards:"
>
> +if 32BIT
> +
>  config MACH_RADXA_ROCK
> select ARCH_RK3188
> select I2C
> @@ -62,6 +63,10 @@ config MACH_PHYTEC_SOM_RK3288
> help
>   Say Y here if you are using a RK3288 based Phytecs SOM
>
> +endif
> +
> +if 64BIT
> +
>  config MACH_RK3568_EVB
> select ARCH_RK3568
> bool "RK3568 EVB"
> @@ -86,6 +91,8 @@ config MACH_RADXA_ROCK3
> help
>   Say Y here if you are using a Radxa ROCK3
>
> +endif
> +
>  comment "select board features:"
>
>  config ARCH_ROCKCHIP_ATF
> --
> 2.30.2
>
>



Re: [RESEND PATCH] kconfig: Proposed language extension for multiple builds

2023-03-12 Thread Masahiro Yamada
On Sun, Mar 12, 2023 at 1:55 AM Tom Rini  wrote:
>
> On Fri, Mar 10, 2023 at 09:39:15PM -0800, Randy Dunlap wrote:
> > Hi--
> >
> > On 3/10/23 18:37, Simon Glass wrote:
> > > (I am sending this again to get more feedback)
> > >
> > > In the case of Linux, only one build is produced so there is only a
> > > single configuration. For other projects, such as U-Boot and Zephyr, the
> > > same code is used to produce multiple builds, each with related (but
> > > different) options enabled.
> > >
> > > This can be handled with the existing kconfig language, but it is quite
> > > verbose, somewhat tedious and very error-prone, since there is a lot of
> > > duplication. The result is hard to maintain.
> > >
> > > Describe an extension to the Kconfig language to support easier handling
> > > of this use case.
> > >
> > > Signed-off-by: Simon Glass 
> >
> > IMO Masahiro has already answered this multiple times and I agree with his 
> > answers.
> >
> > For others, the full previous thread is at
> >   
> > https://lore.kernel.org/all/20230219145453.1.Idaaf79c3e768b85750d5a7eb732052576c5e07e5@changeid/
>
> Well, I think what was unclear, or maybe we just wanted to confirm the
> answer was "none at all", was this. As good community neighbors, we see
> a generic issue in the Kconfig language, a tool used frequently outside
> of just the Linux kernel, and would like to contribute back. Ideally
> without having first gone off, designed and implemented something, and
> then been told it's all wrong and to rewrite it first. So what level of
> interest is there in this?

Sorry, no interest.
If you want to get a clear answer, NACK.

>
> As I pointed out in that thread, I believe barebox has examples where
> some keyword like we're proposing here would help them (and yes, there's
> only a dozen or so symbols so it's also manageable without anything
> special),

Barebox keeps PBL in very limited, ad-hoc implementation.
PBL has no more than 10 user-configurable options.
Sascha Hauer designed it this way.



Linux kernel also has a small loader (a.k.a decompressor) in
arch/*/boot/decompress/.

For example, CONFIG_KERNEL_GZIP is a CONFIG option
for the decompressor instead of the main kernel.

In this sense, you could apply your theory,
"Linux kernel is also multi build-phases, so Kconfig should have this
extension to move CONFIG_KERNEL_GZIP to another build phase".
No, no. The main kernel and the decompressor are well separated
and the latter is small and simple.

Barebox is the same - the main Barebox and PBL are well separated
and PBL is really small and simple.

The problems you are suffering from do not exist in Barebox.



> and Simon believes Zephyr will be in a similar situation soon
> enough (which doesn't use the kernel's implementation of the language).

Zephyr does not share any Kconfig code with Linux.
They use Python implementation, a.k.a. Kconfiglib.
It is up to the Zephyr community, but this requires extra effort.

> Frankly, I keep going back to "tristate" is just the original example of
> what we're talking about here (CONFIG_FOO=n, CONFIG_FOO_MODULE=y), not
> that I'm suggesting we would remove the tristate word.
> So we would really like to make sure as many people and projects are
> aware, as possible.

This is on the boundary.
We can make the tristate optional if it does not make the code too ugly.

But, if you do not add CONFIG_MODULES in your Kconfig file,
users will not see 'm' in the first place.

I know some help messages still mention 'm', but is this the problem
you want to solve?


> And as Simon asked in the thread, what about code refactoring that makes
> further maintenance easier? Clearly, such patches would need to be
> against the current appropriate tree.

If such patches clean up the code, they will be appreciated.

-- 
Best Regards
Masahiro Yamada



[PATCH] kbuild: replace $(H) with $(pound)

2022-02-07 Thread Masahiro Yamada
scripts/Kbuild.include defines 'pound', which is equivalent to 'H'.

  pound := \#

Replace $(H) with $(pound), and remove the 'H' definition.

Signed-off-by: Masahiro Yamada 
---

 scripts/Makefile.lib | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 13b1789c0..d981d48a2 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -339,8 +339,7 @@ $(obj)/%.dtb.S: $(obj)/%.dtb $(srctree)/scripts/gen-dtb-s 
FORCE
 dts-frags = $(subst $(quote),,$(CONFIG_EXTERNAL_DTS_FRAGMENTS))
 quiet_cmd_dtc = DTC $@
 # For compatibility between make 4.2 and 4.3
-H := \#
-cmd_dtc = /bin/echo -e '$(H)define $(subst -,_,$(*F))_dts 1\n'$(foreach f,$< 
$(dts-frags),'$(H)include "$(f)"\n') | \
+cmd_dtc = /bin/echo -e '$(pound)define $(subst -,_,$(*F))_dts 1\n'$(foreach 
f,$< $(dts-frags),'$(pound)include "$(f)"\n') | \
$(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) - ; \
$(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \
-i $(srctree)/arch/$(SRCARCH)/dts $(DTC_FLAGS) \
-- 
2.32.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] setlocalversion: update to Linux 5.16

2022-02-07 Thread Masahiro Yamada
It has been a long time since this script was updated.

Now resync it with Linux 5.16.

Signed-off-by: Masahiro Yamada 
---

 scripts/setlocalversion | 103 +++-
 1 file changed, 39 insertions(+), 64 deletions(-)

diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index cce4706cc..6b54e46a0 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -1,8 +1,14 @@
 #!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
 #
 # This scripts adds local version information from the version
 # control systems git, mercurial (hg) and subversion (svn).
 #
+# If something goes wrong, send a mail the kernel build mailinglist
+# (see MAINTAINERS) and CC Nico Schottelius
+# .
+#
+#
 
 usage() {
echo "Usage: $0 [--save-scmversion] [srctree]" >&2
@@ -38,11 +44,12 @@ scm_version()
fi
 
# Check for git and a git repo.
-   if test -d .git && head=`git rev-parse --verify --short HEAD 
2>/dev/null`; then
+   if test -z "$(git rev-parse --show-cdup 2>/dev/null)" &&
+  head=$(git rev-parse --verify HEAD 2>/dev/null); then
 
# If we are at a tagged commit (like "v2.6.30-rc6"), we ignore
# it, because this version is defined in the top level Makefile.
-   if [ -z "`git describe --exact-match 2>/dev/null`" ]; then
+   if [ -z "$(git describe --exact-match 2>/dev/null)" ]; then
 
# If only the short version is requested, don't bother
# running further git commands
@@ -52,69 +59,36 @@ scm_version()
fi
# If we are past a tagged commit (like
# "v2.6.30-rc5-302-g72357d5"), we pretty print it.
-   if atag="`git describe 2>/dev/null`"; then
-   echo "$atag" | awk -F- '{printf("-%05d-%s", 
$(NF-1),$(NF))}'
-
-   # If we don't have a tag at all we print -g{commitish}.
-   else
-   printf '%s%s' -g $head
+   if atag="$(git describe 2>/dev/null)"; then
+   echo "$atag" | awk -F- '{printf("-%05d", 
$(NF-1))}'
fi
-   fi
 
-   # Is this git on svn?
-   if git config --get svn-remote.svn.url >/dev/null; then
-   printf -- '-svn%s' "`git svn find-rev $head`"
+   # Add -g and exactly 12 hex chars.
+   printf '%s%s' -g "$(echo $head | cut -c1-12)"
fi
 
-   # Update index only on r/w media
-   [ -w . ] && git update-index --refresh --unmerged > /dev/null
-
-   # Check for uncommitted changes
-   if git diff-index --name-only HEAD | grep -qv 
"^scripts/package"; then
+   # Check for uncommitted changes.
+   # This script must avoid any write attempt to the source tree,
+   # which might be read-only.
+   # You cannot use 'git describe --dirty' because it tries to
+   # create .git/index.lock .
+   # First, with git-status, but --no-optional-locks is only
+   # supported in git >= 2.14, so fall back to git-diff-index if
+   # it fails. Note that git-diff-index does not refresh the
+   # index, so it may give misleading results. See
+   # git-update-index(1), git-diff-index(1), and git-status(1).
+   if {
+   git --no-optional-locks status -uno --porcelain 
2>/dev/null ||
+   git diff-index --name-only HEAD
+   } | read dummy; then
printf '%s' -dirty
fi
-
-   # All done with git
-   return
-   fi
-
-   # Check for mercurial and a mercurial repo.
-   if test -d .hg && hgid=`hg id 2>/dev/null`; then
-   # Do we have an tagged version?  If so, latesttagdistance == 1
-   if [ "`hg log -r . --template '{latesttagdistance}'`" == "1" ]; 
then
-   id=`hg log -r . --template '{latesttag}'`
-   printf '%s%s' -hg "$id"
-   else
-   tag=`printf '%s' "$hgid" | cut -d' ' -f2`
-   if [ -z "$tag" -o "$tag" = tip ]; then
-   id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`
-   printf '%s%s' -hg "$i

[PATCH] kvx: remove unused CONFIG_ARCHINFO

2022-02-07 Thread Masahiro Yamada
This is defined, but not used anywhere.

  $ git grep ARCHINFO
  arch/kvx/Kconfig:config ARCHINFO

Signed-off-by: Masahiro Yamada 
---

 arch/kvx/Kconfig | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/arch/kvx/Kconfig b/arch/kvx/Kconfig
index 1c3e29a9f..5e7ddeea1 100644
--- a/arch/kvx/Kconfig
+++ b/arch/kvx/Kconfig
@@ -38,13 +38,6 @@ config ARCH_TEXT_BASE
hex
default 0x11000
 
-menu "Kalray specific"
-
-config ARCHINFO
-   string
-   default "coolidge"
-endmenu
-
 menu "Board configuration"
 
 config BUILTIN_DTB
-- 
2.32.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 5/5] x86_64: do not pass the EFI image handle or system table to relocation

2021-11-16 Thread Masahiro Yamada
The _reloc() function in reloc_x86_64.c is passed with the EFI image
handle and system table, but they are unrelated to the relocation.
In fact, they are not used at all.

Remove them and clean up the assembler code as well.

Signed-off-by: Masahiro Yamada 
---

 arch/x86/mach-efi/crt0-efi-x86_64.S | 6 +-
 arch/x86/mach-efi/reloc_x86_64.c| 4 ++--
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/arch/x86/mach-efi/crt0-efi-x86_64.S 
b/arch/x86/mach-efi/crt0-efi-x86_64.S
index aa03106e9..d23c1fb2d 100644
--- a/arch/x86/mach-efi/crt0-efi-x86_64.S
+++ b/arch/x86/mach-efi/crt0-efi-x86_64.S
@@ -47,14 +47,10 @@ _start:
lea image_base(%rip), %rdi
lea _DYNAMIC(%rip), %rsi
 
-   popq %rcx
-   popq %rdx
-   pushq %rcx
-   pushq %rdx
call _relocate
 
-   popq %rdi
popq %rsi
+   popq %rdi
 
call efi_main
addq $8, %rsp
diff --git a/arch/x86/mach-efi/reloc_x86_64.c b/arch/x86/mach-efi/reloc_x86_64.c
index e83bacb30..f015ae047 100644
--- a/arch/x86/mach-efi/reloc_x86_64.c
+++ b/arch/x86/mach-efi/reloc_x86_64.c
@@ -41,9 +41,9 @@
 
 #include 
 
-asmlinkage efi_status_t _relocate (long, Elf64_Dyn *, efi_handle_t, 
efi_system_table_t *);
+asmlinkage efi_status_t _relocate(long, Elf64_Dyn *);
 
-efi_status_t _relocate (long ldbase, Elf64_Dyn *dyn, efi_handle_t image, 
efi_system_table_t *systab)
+efi_status_t _relocate(long ldbase, Elf64_Dyn *dyn)
 {
long relsz = 0, relent = 0;
Elf64_Rel *rel = 0;
-- 
2.30.2


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/5] x86: remove x86-specific cmd_barebox__

2021-11-16 Thread Masahiro Yamada
The difference from cmd_barebox__ in the top Makefile is:

  -shared -Bsymbolic -znocombreloc

Put the flags to LDFLAGS_barebox, and remove the x86-specific
cmd_barebox__.

Signed-off-by: Masahiro Yamada 
---

 arch/x86/Makefile | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 9fc64cc04..c73842cf8 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -28,7 +28,9 @@ endif
 
 ifndef CONFIG_MODULES
 # Add cleanup flags
-ifneq ($(CONFIG_X86_EFI),y)
+ifeq ($(CONFIG_X86_EFI),y)
+LDFLAGS_barebox += -shared -Bsymbolic -znocombreloc
+else
 KBUILD_CPPFLAGS += -fdata-sections -ffunction-sections
 LDFLAGS_barebox += -static --gc-sections
 endif
@@ -52,13 +54,6 @@ common-y += arch/x86/lib/
 lds-$(CONFIG_X86_32)   := arch/x86/mach-efi/elf_ia32_efi.lds
 lds-$(CONFIG_X86_64)   := arch/x86/mach-efi/elf_x86_64_efi.lds
 
-cmd_barebox__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_barebox) -o $@  \
-   -T $(lds-y) \
-   -shared -Bsymbolic -znocombreloc\
-   --whole-archive $(BAREBOX_OBJS) \
-   --no-whole-archive  \
-   $(filter-out $(BAREBOX_LDS) $(BAREBOX_OBJS) FORCE ,$^)
-
 quiet_cmd_efi_image = EFI-IMG $@
   cmd_efi_image = $(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic \
  -j .dynsym -j .rel -j .rela -j .reloc -j 
__barebox_initcalls \
-- 
2.30.2


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 4/5] x86: reuse cmd_objcopy to generate barebox.efi

2021-11-16 Thread Masahiro Yamada
The objcopy rule is defined in scripts/Makefile.lib

Reuse it.

Signed-off-by: Masahiro Yamada 
---

 arch/x86/Makefile | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 5623b2cea..53cbd5088 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -54,17 +54,16 @@ common-y += arch/x86/lib/
 lds-$(CONFIG_X86_32)   := arch/x86/mach-efi/elf_ia32_efi.lds
 lds-$(CONFIG_X86_64)   := arch/x86/mach-efi/elf_x86_64_efi.lds
 
-quiet_cmd_efi_image = EFI-IMG $@
-  cmd_efi_image = $(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic \
- -j .dynsym -j .rel -j .rela -j .reloc \
- -j .bbenv.* -j .bblogo.* --target=$(TARGET) $< $@
-
 KBUILD_BINARY := barebox
 
 KBUILD_LDFLAGS := --no-undefined
 
+OBJCOPYFLAGS_barebox.efi = \
+   -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel -j .rela \
+   -j .reloc -j .bbenv.* -j .bblogo.* --target=$(TARGET)
+
 barebox.efi: $(KBUILD_BINARY) FORCE
-   $(call if_changed,efi_image)
+   $(call if_changed,objcopy)
 
 KBUILD_IMAGE := barebox.efi
 
-- 
2.30.2


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 0/5] x86: misc cleanups

2021-11-16 Thread Masahiro Yamada




Masahiro Yamada (5):
  kbuild: remove unneeded -nostdlib flag
  x86: remove x86-specific cmd_barebox__
  x86: stop copying unneeded sections to barebox.efi
  x86: reuse cmd_objcopy to generate barebox.efi
  x86_64: do not pass the EFI image handle or system table to relocation

 arch/kvx/Makefile   |  2 +-
 arch/mips/Makefile  |  2 --
 arch/riscv/Makefile |  1 -
 arch/x86/Makefile   | 23 ---
 arch/x86/mach-efi/crt0-efi-x86_64.S |  6 +-
 arch/x86/mach-efi/reloc_x86_64.c|  4 ++--
 6 files changed, 12 insertions(+), 26 deletions(-)

-- 
2.30.2


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/5] kbuild: remove unneeded -nostdlib flag

2021-11-16 Thread Masahiro Yamada
The -nostdlib option requests the compiler to not use the standard
system startup files or libraries when linking.

arch/kvm/Makefile adds it to KBUILD_CFLAGS/AFLAGS, but it does not make
sense because those are unrelated to linking.

arch/{mips,riscv,x86}/Makefile passes it to the linker, but it is not
sensible either. As noted above, adding -nostdlib makes sense only
when $(CC) is used as a linker driver, but $(LD) is directly used for
linking barebox. (ld.bfd/ld.lld recognizes the -nostdlib flag, but its
behavior is obscure, and unneeded here.)

Signed-off-by: Masahiro Yamada 
---

 arch/kvx/Makefile   | 2 +-
 arch/mips/Makefile  | 2 --
 arch/riscv/Makefile | 1 -
 arch/x86/Makefile   | 2 +-
 4 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/kvx/Makefile b/arch/kvx/Makefile
index 13c4e2431..f29eeef92 100644
--- a/arch/kvx/Makefile
+++ b/arch/kvx/Makefile
@@ -8,7 +8,7 @@ ifeq ($(CROSS_COMPILE),)
 CROSS_COMPILE:= kvx-elf-
 endif
 
-DEFAULT_CFLAGS := -nostdlib -fno-builtin -fstrict-align -g
+DEFAULT_CFLAGS := -fno-builtin -fstrict-align -g
 DEFAULT_CFLAGS += -DTEXT_BASE=$(CONFIG_TEXT_BASE)
 
 LIBGCC_PATH = $(dir $(shell $(CC) $(KBUILD_CFLAGS) --print-libgcc-file-name))
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 4eb6ba772..786695194 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -72,8 +72,6 @@ KBUILD_BINARY := barebox.bin
 KBUILD_TARGET := barebox.bin
 endif
 
-LDFLAGS_barebox += -nostdlib
-
 machine-$(CONFIG_MACH_MIPS_MALTA)  := malta
 machine-$(CONFIG_MACH_MIPS_AR231X) := ar231x
 machine-$(CONFIG_MACH_MIPS_ATH79)  := ath79
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 0b1278936..23ea6178a 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -17,7 +17,6 @@ PBL_CPPFLAGS += $(riscv-cflags-y)
 LDFLAGS_pbl += $(riscv-ldflags-y)
 
 cflags-y += $(riscv-cflags-y)
-LDFLAGS_barebox += -nostdlib
 
 LDFLAGS_barebox += $(riscv-ldflags-y)
 
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index fd871ca21..9fc64cc04 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -54,7 +54,7 @@ lds-$(CONFIG_X86_64)   := arch/x86/mach-efi/elf_x86_64_efi.lds
 
 cmd_barebox__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_barebox) -o $@  \
-T $(lds-y) \
-   -shared -Bsymbolic -nostdlib -znocombreloc  \
+   -shared -Bsymbolic -znocombreloc\
--whole-archive $(BAREBOX_OBJS) \
--no-whole-archive  \
$(filter-out $(BAREBOX_LDS) $(BAREBOX_OBJS) FORCE ,$^)
-- 
2.30.2


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/5] x86: stop copying unneeded sections to barebox.efi

2021-11-16 Thread Masahiro Yamada
Stop copying the following sections:

  __barebox_initcalls
  __barebox_exitcalls
  __barebox_cmd
  .barebox_magic

Such sections do not exist.

Signed-off-by: Masahiro Yamada 
---

 arch/x86/Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index c73842cf8..5623b2cea 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -56,8 +56,7 @@ lds-$(CONFIG_X86_64)   := arch/x86/mach-efi/elf_x86_64_efi.lds
 
 quiet_cmd_efi_image = EFI-IMG $@
   cmd_efi_image = $(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic \
- -j .dynsym -j .rel -j .rela -j .reloc -j 
__barebox_initcalls \
- -j __barebox_exitcalls -j __barebox_cmd -j 
.barebox_magicvar \
+ -j .dynsym -j .rel -j .rela -j .reloc \
  -j .bbenv.* -j .bblogo.* --target=$(TARGET) $< $@
 
 KBUILD_BINARY := barebox
-- 
2.30.2


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 2/5] scripts: Add common library functions

2021-10-11 Thread Masahiro Yamada
On Mon, Oct 11, 2021 at 11:53 PM Sascha Hauer  wrote:
>
> On Mon, Oct 11, 2021 at 11:37:07PM +0900, Masahiro Yamada wrote:
> > On Wed, Oct 6, 2021 at 11:26 PM Sascha Hauer  wrote:
> > >
> > > Several functions are duplicated in different host tools. This patch
> > > starts collecting them in a single C file. We start with read_file()
> > > and read_file_2(), others follow in separate commits.
> > >
> > > It would be great to compile these functions in a separate library, but
> > > I don't know how this can be archieved in Kbuild. Instead, the C file
> > > is included where needed. Not nice, not beautiful, but at least enough
> > > to get something going.
> >
> >
> > You can try this.
> >
> >
> > hostprogs-always-$(CONFIG_IMD)   += bareboximd
> > bareboximd-objs := bareboximd.o common.o
> >
> >
> > hostprogs-always-$(CONFIG_OMAP3_USB_LOADER) += omap3-usb-loader
> > omap3-usb-loader-objs   := omap3-usb-loader.o common.o
>
> I did and it works well as long as common.o is used only in a single
> directory. Unfortunately some tools are in subdirectories, like for
> example scripts/imx/imx-usb-loader.c. Of course these could be moved up
> one level, but I didn't want to go that path.
> Do you see any possibility to archieve the same with files in different
> directories?
>

Then, I have no idea.

At least, the Makefile part needs to be moved up.

hostprogs-always-$(CONFIG_ARCH_IMX_IMXIMAGE)+= imx-image
imx-usb-loader-objs := imx/imx-usb-loader.o imx/imx.o  common.o

Probably, you do not want to do it.


-- 
Best Regards
Masahiro Yamada

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 2/5] scripts: Add common library functions

2021-10-11 Thread Masahiro Yamada
On Wed, Oct 6, 2021 at 11:26 PM Sascha Hauer  wrote:
>
> Several functions are duplicated in different host tools. This patch
> starts collecting them in a single C file. We start with read_file()
> and read_file_2(), others follow in separate commits.
>
> It would be great to compile these functions in a separate library, but
> I don't know how this can be archieved in Kbuild. Instead, the C file
> is included where needed. Not nice, not beautiful, but at least enough
> to get something going.


You can try this.


hostprogs-always-$(CONFIG_IMD)   += bareboximd
bareboximd-objs := bareboximd.o common.o


hostprogs-always-$(CONFIG_OMAP3_USB_LOADER) += omap3-usb-loader
omap3-usb-loader-objs   := omap3-usb-loader.o common.o





--
Best Regards
Masahiro Yamada

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/2] kconfig: update to Linux 5.13-rc1

2021-05-30 Thread Masahiro Yamada
The previous sync was Linux 5.9-rc2.

Resync scripts/kconfig/ with Linux 5.13-rc1.

Highlights:

 - make header names in include/config/ and CONFIG symbols match
   (scripts/basic/fixdep.c was adjusted)

 - remove all 'option' syntax
   (common/Kconfig was adjusted)

 - introduce KCONFIG_DEFCONFIG_LIST instead of 'option defconfig_list'

 - bug fixes and cleanups of nconfig

 - drop Qt4 support from xconfig

 - bug fixes, improvements, cleanups of xconfig

 - print a short log for syncconfig

Signed-off-by: Masahiro Yamada 
---

 Makefile  |  13 +-
 common/Kconfig|   7 +-
 scripts/basic/.gitignore  |   2 +-
 scripts/basic/fixdep.c|  45 +-
 scripts/kconfig/.gitignore|  13 +-
 scripts/kconfig/Makefile  |  73 ++-
 scripts/kconfig/conf.c| 440 +++
 scripts/kconfig/confdata.c| 278 ++
 scripts/kconfig/expr.h|   6 -
 scripts/kconfig/gconf.c   |  15 +-
 scripts/kconfig/internal.h|   9 +
 scripts/kconfig/lexer.l   |   4 -
 scripts/kconfig/lkc.h |  66 ++-
 scripts/kconfig/lkc_proto.h   |  15 +-
 scripts/kconfig/lxdialog/util.c   |   4 +-
 scripts/kconfig/mconf-cfg.sh  |   4 +-
 scripts/kconfig/mconf.c   |  15 +-
 scripts/kconfig/menu.c|  23 +-
 scripts/kconfig/nconf.c   |  59 +-
 scripts/kconfig/nconf.gui.c   | 284 --
 scripts/kconfig/nconf.h   |  51 +-
 scripts/kconfig/parser.y  |  27 +-
 scripts/kconfig/preprocess.c  |   2 +-
 scripts/kconfig/qconf-cfg.sh  |  14 +-
 scripts/kconfig/qconf.cc  | 517 --
 scripts/kconfig/qconf.h   |  77 +--
 scripts/kconfig/streamline_config.pl  |   9 +-
 scripts/kconfig/symbol.c  |   5 +-
 scripts/kconfig/tests/choice/Kconfig  |   2 +-
 .../tests/choice_value_with_m_dep/Kconfig |   2 +-
 scripts/kconfig/tests/conftest.py |   4 +
 scripts/kconfig/tests/inter_choice/Kconfig|   2 +-
 32 files changed, 932 insertions(+), 1155 deletions(-)
 create mode 100644 scripts/kconfig/internal.h

diff --git a/Makefile b/Makefile
index ec1770042..2ac804f07 100644
--- a/Makefile
+++ b/Makefile
@@ -352,9 +352,6 @@ KCONFIG_CONFIG  ?= .config
 
 export KCONFIG_CONFIG
 
-# Default file for 'make defconfig'. This may be overridden by arch-Makefile.
-export KBUILD_DEFCONFIG := defconfig
-
 # SHELL used by kbuild
 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
  else if [ -x /bin/bash ]; then echo /bin/bash; \
@@ -596,8 +593,11 @@ $(KCONFIG_CONFIG):
 # This exploits the 'multi-target pattern rule' trick.
 # The syncconfig should be executed only once to make all the targets.
 # (Note: use the grouped target '&:' when we bump to GNU Make 4.3)
-%/auto.conf %/auto.conf.cmd: $(KCONFIG_CONFIG)
-   $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
+quiet_cmd_syncconfig = SYNC$@
+  cmd_syncconfig = $(MAKE) -f $(srctree)/Makefile syncconfig
+
+%/config/auto.conf %/config/auto.conf.cmd %/generated/autoconf.h: 
$(KCONFIG_CONFIG)
+   +$(call cmd,syncconfig)
 else # !may-sync-config
 # External modules and some install targets need include/generated/autoconf.h
 # and include/config/auto.conf but do not care if they are up-to-date.
@@ -941,7 +941,8 @@ scripts: scripts_basic
 PHONY += prepare archprepare prepare0
 
 archprepare: outputmakefile scripts_basic include/config/kernel.release \
-   $(version_h) include/generated/utsrelease.h include/config.h
+   $(version_h) include/generated/utsrelease.h include/config.h \
+   include/generated/autoconf.h
 
 prepare0: archprepare FORCE
 ifneq ($(KBUILD_MODULES),)
diff --git a/common/Kconfig b/common/Kconfig
index db7cc6713..b18975850 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1,8 +1,3 @@
-config DEFCONFIG_LIST
-   string
-   option defconfig_list
-   default "arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)"
-
 config GREGORIAN_CALENDER
bool
 
@@ -333,7 +328,7 @@ config MODULES
depends on HAS_MODULES
depends on EXPERIMENTAL
bool "module support"
-   option modules
+   modules
help
  This option enables support for loadable modules via insmod. Module
  support is quite experimental at the moment. There is no convenient
diff --git a/scripts/basic/.gitignore b/scripts/basic/.gitignore
index 98ae1f509..961c91c8a 100644
--- a/scripts/basic/.gitignore
+++ b/scripts/basic/.gitignore
@@ -1,2 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0-only

Re: [PATCH] kconfig: update to Linux 5.13-rc1

2021-05-22 Thread Masahiro Yamada
On Mon, May 17, 2021 at 3:57 PM Sascha Hauer  wrote:
>
> Hi Masahiro,
>
> On Wed, May 12, 2021 at 12:08:45AM +0900, Masahiro Yamada wrote:
> > The previous sync was Linux 5.9-rc2.
> >
> > Resync scripts/kconfig/ with Linux 5.13-rc1.
> >
> > Highlights:
> >
> >  - make header names in include/config/ and CONFIG symbols match
> >(scripts/basic/fixdep.c was adjusted)
> >
> >  - remove all 'option' syntax
> >(common/Kconfig was adjusted)
> >
> >  - introduce KCONFIG_DEFCONFIG_LIST instead of 'option defconfig_list'
> >
> >  - bug fixes and cleanups of nconfig
> >
> >  - drop Qt4 support from xconfig
> >
> >  - bug fixes, improvements, cleanups of xconfig
> >
> >  - print a short log for syncconfig
> >
> > Signed-off-by: Masahiro Yamada 
> > ---
>
> This breaks building firmware:
>
> make[1]: *** No rule to make target 'include/config/extra/firmware/dir.h', 
> needed by 'firmware/lpddr4_pmu_train_1d_dmem.bin.gen.S'.  Stop.
>
> This happens on imx_v8_defconfig.
>
> Do we need an adoption of 3470d9eb6387 any maybe more?

Yes, I think so.

Thanks.

-- 
Best Regards
Masahiro Yamada

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] kconfig: update to Linux 5.13-rc1

2021-05-11 Thread Masahiro Yamada
The previous sync was Linux 5.9-rc2.

Resync scripts/kconfig/ with Linux 5.13-rc1.

Highlights:

 - make header names in include/config/ and CONFIG symbols match
   (scripts/basic/fixdep.c was adjusted)

 - remove all 'option' syntax
   (common/Kconfig was adjusted)

 - introduce KCONFIG_DEFCONFIG_LIST instead of 'option defconfig_list'

 - bug fixes and cleanups of nconfig

 - drop Qt4 support from xconfig

 - bug fixes, improvements, cleanups of xconfig

 - print a short log for syncconfig

Signed-off-by: Masahiro Yamada 
---

 Makefile  |  13 +-
 common/Kconfig|   7 +-
 scripts/basic/.gitignore  |   2 +-
 scripts/basic/fixdep.c|  45 +-
 scripts/kconfig/.gitignore|  13 +-
 scripts/kconfig/Makefile  |  73 ++-
 scripts/kconfig/conf.c| 440 +++
 scripts/kconfig/confdata.c| 278 ++
 scripts/kconfig/expr.h|   6 -
 scripts/kconfig/gconf.c   |  15 +-
 scripts/kconfig/internal.h|   9 +
 scripts/kconfig/lexer.l   |   4 -
 scripts/kconfig/lkc.h |  66 ++-
 scripts/kconfig/lkc_proto.h   |  15 +-
 scripts/kconfig/lxdialog/util.c   |   4 +-
 scripts/kconfig/mconf-cfg.sh  |   4 +-
 scripts/kconfig/mconf.c   |  15 +-
 scripts/kconfig/menu.c|  23 +-
 scripts/kconfig/nconf.c   |  59 +-
 scripts/kconfig/nconf.gui.c   | 284 --
 scripts/kconfig/nconf.h   |  51 +-
 scripts/kconfig/parser.y  |  27 +-
 scripts/kconfig/preprocess.c  |   2 +-
 scripts/kconfig/qconf-cfg.sh  |  14 +-
 scripts/kconfig/qconf.cc  | 517 --
 scripts/kconfig/qconf.h   |  77 +--
 scripts/kconfig/streamline_config.pl  |   9 +-
 scripts/kconfig/symbol.c  |   5 +-
 scripts/kconfig/tests/choice/Kconfig  |   2 +-
 .../tests/choice_value_with_m_dep/Kconfig |   2 +-
 scripts/kconfig/tests/conftest.py |   4 +
 scripts/kconfig/tests/inter_choice/Kconfig|   2 +-
 32 files changed, 932 insertions(+), 1155 deletions(-)
 create mode 100644 scripts/kconfig/internal.h

diff --git a/Makefile b/Makefile
index db1690bac..25c64232e 100644
--- a/Makefile
+++ b/Makefile
@@ -352,9 +352,6 @@ KCONFIG_CONFIG  ?= .config
 
 export KCONFIG_CONFIG
 
-# Default file for 'make defconfig'. This may be overridden by arch-Makefile.
-export KBUILD_DEFCONFIG := defconfig
-
 # SHELL used by kbuild
 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
  else if [ -x /bin/bash ]; then echo /bin/bash; \
@@ -596,8 +593,11 @@ $(KCONFIG_CONFIG):
 # This exploits the 'multi-target pattern rule' trick.
 # The syncconfig should be executed only once to make all the targets.
 # (Note: use the grouped target '&:' when we bump to GNU Make 4.3)
-%/auto.conf %/auto.conf.cmd: $(KCONFIG_CONFIG)
-   $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
+quiet_cmd_syncconfig = SYNC$@
+  cmd_syncconfig = $(MAKE) -f $(srctree)/Makefile syncconfig
+
+%/config/auto.conf %/config/auto.conf.cmd %/generated/autoconf.h: 
$(KCONFIG_CONFIG)
+   +$(call cmd,syncconfig)
 else # !may-sync-config
 # External modules and some install targets need include/generated/autoconf.h
 # and include/config/auto.conf but do not care if they are up-to-date.
@@ -941,7 +941,8 @@ scripts: scripts_basic
 PHONY += prepare archprepare prepare0
 
 archprepare: outputmakefile scripts_basic include/config/kernel.release \
-   $(version_h) include/generated/utsrelease.h include/config.h
+   $(version_h) include/generated/utsrelease.h include/config.h \
+   include/generated/autoconf.h
 
 prepare0: archprepare FORCE
 ifneq ($(KBUILD_MODULES),)
diff --git a/common/Kconfig b/common/Kconfig
index bddf802d3..3bbbc6e26 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1,8 +1,3 @@
-config DEFCONFIG_LIST
-   string
-   option defconfig_list
-   default "arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)"
-
 config GREGORIAN_CALENDER
bool
 
@@ -337,7 +332,7 @@ config MODULES
depends on HAS_MODULES
depends on EXPERIMENTAL
bool "module support"
-   option modules
+   modules
help
  This option enables support for loadable modules via insmod. Module
  support is quite experimental at the moment. There is no convenient
diff --git a/scripts/basic/.gitignore b/scripts/basic/.gitignore
index 98ae1f509..961c91c8a 100644
--- a/scripts/basic/.gitignore
+++ b/scripts/basic/.gitignore
@@ -1,2 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0-only

[PATCH] kconfig: update to Linux 5.9-rc2

2020-08-27 Thread Masahiro Yamada
The previous sync was Linux 5.7-rc2. Resync scripts/kconfig/ and
scripts/Kconfig.include with Linux 5.9-rc2.

Highlights:

 - fix and improve 'make xconfig'

 - remove '---help---' keyword

 - forbid nested 'choice' blocks

Signed-off-by: Masahiro Yamada 
---

 scripts/Kconfig.include   |   5 +-
 scripts/kconfig/.gitignore|   2 +-
 scripts/kconfig/Makefile  |  24 +-
 scripts/kconfig/images.c  |  30 +-
 scripts/kconfig/images.h  |  30 +-
 scripts/kconfig/lexer.l   |   4 +-
 scripts/kconfig/menu.c|   3 +-
 scripts/kconfig/parser.y  |  30 +-
 scripts/kconfig/qconf.cc  | 629 +-
 scripts/kconfig/qconf.h   |  89 +--
 scripts/kconfig/streamline_config.pl  |  21 +
 scripts/kconfig/symbol.c  |  16 +-
 .../kconfig/tests/rand_nested_choice/Kconfig  |  35 -
 .../tests/rand_nested_choice/__init__.py  |  17 -
 .../tests/rand_nested_choice/expected_stdout0 |   2 -
 .../tests/rand_nested_choice/expected_stdout1 |   4 -
 .../tests/rand_nested_choice/expected_stdout2 |   5 -
 17 files changed, 458 insertions(+), 488 deletions(-)
 delete mode 100644 scripts/kconfig/tests/rand_nested_choice/Kconfig
 delete mode 100644 scripts/kconfig/tests/rand_nested_choice/__init__.py
 delete mode 100644 scripts/kconfig/tests/rand_nested_choice/expected_stdout0
 delete mode 100644 scripts/kconfig/tests/rand_nested_choice/expected_stdout1
 delete mode 100644 scripts/kconfig/tests/rand_nested_choice/expected_stdout2

diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include
index 496d11c92..a5fe72c50 100644
--- a/scripts/Kconfig.include
+++ b/scripts/Kconfig.include
@@ -25,7 +25,7 @@ failure = $(if-success,$(1),n,y)
 
 # $(cc-option,)
 # Return y if the compiler supports , n otherwise
-cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -S -x c /dev/null -o 
/dev/null)
+cc-option = $(success,mkdir .tmp_; trap "rm -rf .tmp_" EXIT; $(CC) 
-Werror $(CLANG_FLAGS) $(1) -c -x c /dev/null -o .tmp_/tmp.o)
 
 # $(ld-option,)
 # Return y if the linker supports , n otherwise
@@ -42,9 +42,6 @@ $(error-if,$(failure,command -v $(LD)),linker '$(LD)' not 
found)
 # Fail if the linker is gold as it's not capable of linking the kernel proper
 $(error-if,$(success, $(LD) -v | grep -q gold), gold linker '$(LD)' not 
supported)
 
-# gcc version including patch level
-gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh $(CC))
-
 # machine bit flags
 #  $(m32-flag): -m32 if the compiler supports it, or an empty string otherwise.
 #  $(m64-flag): -m64 if the compiler supports it, or an empty string otherwise.
diff --git a/scripts/kconfig/.gitignore b/scripts/kconfig/.gitignore
index 12a67fdab..c3d537cd0 100644
--- a/scripts/kconfig/.gitignore
+++ b/scripts/kconfig/.gitignore
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
-*.moc
+/qconf-moc.cc
 *conf-cfg
 
 #
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index c9d0a4a8e..52b59bf9e 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -96,11 +96,13 @@ configfiles=$(wildcard $(srctree)/kernel/configs/$@ 
$(srctree)/arch/$(SRCARCH)/c
 
 PHONY += kvmconfig
 kvmconfig: kvm_guest.config
-   @:
+   @echo >&2 "WARNING: 'make $@' will be removed after Linux 5.10"
+   @echo >&2 " Please use 'make $<' instead."
 
 PHONY += xenconfig
 xenconfig: xen.config
-   @:
+   @echo >&2 "WARNING: 'make $@' will be removed after Linux 5.10"
+   @echo >&2 " Please use 'make $<' instead."
 
 PHONY += tinyconfig
 tinyconfig:
@@ -123,7 +125,9 @@ help:
@echo  '  gconfig - Update current config utilising a GTK+ 
based front-end'
@echo  '  oldconfig   - Update current config utilising a provided 
.config as base'
@echo  '  localmodconfig  - Update current config disabling modules not 
loaded'
+   @echo  'except those preserved by LMC_KEEP 
environment variable'
@echo  '  localyesconfig  - Update current config converting local mods 
to core'
+   @echo  'except those preserved by LMC_KEEP 
environment variable'
@echo  '  defconfig   - New config with default from ARCH supplied 
defconfig'
@echo  '  savedefconfig   - Save current config as ./defconfig (minimal 
config)'
@echo  '  allnoconfig - New config where all options are answered 
with no'
@@ -137,9 +141,6 @@ help:
@echo  '  helpnewconfig   - List new options and help text'
@echo  '  olddefconfig- Same as oldco

[PATCH 2/5] kvx,riscv: remove unused $(dtb-y) assignment

2020-08-18 Thread Masahiro Yamada
dtb-y is not defined in these Makefiles. Remove the meaningless code.

Signed-off-by: Masahiro Yamada 
---

 arch/kvx/dts/Makefile   | 1 -
 arch/riscv/dts/Makefile | 1 -
 2 files changed, 2 deletions(-)

diff --git a/arch/kvx/dts/Makefile b/arch/kvx/dts/Makefile
index 391783c1e..d4221d2c1 100644
--- a/arch/kvx/dts/Makefile
+++ b/arch/kvx/dts/Makefile
@@ -9,5 +9,4 @@ endif
 
 obj-$(CONFIG_BOARD_K200) += k200.dtb.o
 
-always := $(dtb-y)
 clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts
diff --git a/arch/riscv/dts/Makefile b/arch/riscv/dts/Makefile
index 509f236cc..6bd4e5a92 100644
--- a/arch/riscv/dts/Makefile
+++ b/arch/riscv/dts/Makefile
@@ -9,5 +9,4 @@ obj-$(CONFIG_BOARD_ERIZO_GENERIC) += erizo-generic.dtb.o
 # created.
 obj- += dummy.o
 
-always := $(dtb-y)
 clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 5/5] kbuild: introduce hostprogs-always-y and userprogs-always-y

2020-08-18 Thread Masahiro Yamada
Linux commit faabed2952aba2b67f2e7b309f2892d55004

You can use:

hostprogs-always-y += foo

as a shorthand for:

hostprogs += foo
always-y += foo

Likewise,

userprogs-always-y += foo

as a shorthand for:

userprogs += foo
always-y += foo

Signed-off-by: Masahiro Yamada 
---

 scripts/Makefile  | 55 ++-
 scripts/Makefile.build|  2 +-
 scripts/Makefile.clean|  9 ---
 scripts/Makefile.lib  | 11 
 scripts/basic/Makefile|  3 +--
 scripts/dtc/Makefile  |  3 +--
 scripts/imx/Makefile  |  6 ++---
 scripts/mod/Makefile  |  4 +--
 scripts/setupmbr/Makefile |  3 +--
 scripts/tegra/Makefile|  4 +--
 10 files changed, 51 insertions(+), 49 deletions(-)

diff --git a/scripts/Makefile b/scripts/Makefile
index 238460fe2..30b7ec540 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -1,50 +1,45 @@
 ###
 # scripts contains sources for various helper programs used throughout
 # barebox for the build process.
-# ---
-# kallsyms:  Find all symbols in barebox
 
-hostprogs-y  += bin2c
-hostprogs-y  += mkimage
-hostprogs-y  += fix_size
-hostprogs-y  += bareboxenv
-hostprogs-y  += bareboxcrc32
-hostprogs-y  += kernel-install
-hostprogs-$(CONFIG_CRYPTO_RSA_BUILTIN_KEYS) += rsatoc
+hostprogs-always-y += bin2c
+hostprogs-always-y += mkimage
+hostprogs-always-y += fix_size
+hostprogs-always-y += bareboxenv
+hostprogs-always-y += bareboxcrc32
+hostprogs-always-y += kernel-install
+hostprogs-always-$(CONFIG_CRYPTO_RSA_BUILTIN_KEYS) += rsatoc
 HOSTCFLAGS_rsatoc = `pkg-config --cflags openssl`
 HOSTLDLIBS_rsatoc = `pkg-config --libs openssl`
-hostprogs-$(CONFIG_IMD)  += bareboximd
-hostprogs-$(CONFIG_KALLSYMS) += kallsyms
-hostprogs-$(CONFIG_MIPS) += mips-relocs
-hostprogs-$(CONFIG_MVEBU_HOSTTOOLS) += kwbimage kwboot mvebuimg
-hostprogs-$(CONFIG_ARCH_OMAP)+= omap_signGP mk-omap-image
-hostprogs-$(CONFIG_ARCH_S5PCxx)  += s5p_cksum
-hostprogs-$(CONFIG_ARCH_DAVINCI) += mkublheader
+hostprogs-always-$(CONFIG_IMD) += bareboximd
+hostprogs-always-$(CONFIG_KALLSYMS)+= kallsyms
+hostprogs-always-$(CONFIG_MIPS)+= mips-relocs
+hostprogs-always-$(CONFIG_MVEBU_HOSTTOOLS) += kwbimage kwboot 
mvebuimg
+hostprogs-always-$(CONFIG_ARCH_OMAP)   += omap_signGP 
mk-omap-image
+hostprogs-always-$(CONFIG_ARCH_S5PCxx) += s5p_cksum
+hostprogs-always-$(CONFIG_ARCH_DAVINCI)+= mkublheader
 HOSTCFLAGS_zynq_mkimage.o = -I$(srctree) 
-I$(srctree)/arch/arm/mach-zynq/include
-hostprogs-$(CONFIG_ARCH_ZYNQ)   += zynq_mkimage
-hostprogs-$(CONFIG_ARCH_SOCFPGA) += socfpga_mkimage
-hostprogs-$(CONFIG_MXS_HOSTTOOLS)+= mxsimage mxsboot
-hostprogs-$(CONFIG_ARCH_LAYERSCAPE) += pblimage
-hostprogs-$(CONFIG_ARCH_STM32MP) += stm32image
+hostprogs-always-$(CONFIG_ARCH_ZYNQ)   += zynq_mkimage
+hostprogs-always-$(CONFIG_ARCH_SOCFPGA)+= 
socfpga_mkimage
+hostprogs-always-$(CONFIG_MXS_HOSTTOOLS)   += mxsimage mxsboot
+hostprogs-always-$(CONFIG_ARCH_LAYERSCAPE) += pblimage
+hostprogs-always-$(CONFIG_ARCH_STM32MP)+= stm32image
 KBUILD_HOSTCFLAGS += -I$(srctree)/scripts/include/
 HOSTLDLIBS_mxsimage  = `pkg-config --libs openssl`
 HOSTCFLAGS_omap3-usb-loader.o = `pkg-config --cflags libusb-1.0`
 HOSTLDLIBS_omap3-usb-loader  = `pkg-config --libs libusb-1.0`
-hostprogs-$(CONFIG_OMAP3_USB_LOADER)  += omap3-usb-loader
+hostprogs-always-$(CONFIG_OMAP3_USB_LOADER)+= omap3-usb-loader
 HOSTCFLAGS_omap4_usbboot.o = `pkg-config --cflags libusb-1.0`
 HOSTLDLIBS_omap4_usbboot = -lpthread `pkg-config --libs libusb-1.0`
-hostprogs-$(CONFIG_OMAP4_HOSTTOOL_USBBOOT) += omap4_usbboot
+hostprogs-always-$(CONFIG_OMAP4_HOSTTOOL_USBBOOT)  += omap4_usbboot
 
-userprogs-$(CONFIG_BAREBOXENV_TARGET)  += bareboxenv-target
-userprogs-$(CONFIG_KERNEL_INSTALL_TARGET)  += kernel-install-target
-userprogs-$(CONFIG_BAREBOXCRC32_TARGET)+= bareboxcrc32-target
-userprogs-$(CONFIG_IMD_TARGET) += bareboximd-target
+userprogs-always-$(CONFIG_BAREBOXENV_TARGET)   += bareboxenv-target
+userprogs-always-$(CONFIG_KERNEL_INSTALL_TARGET)   += kernel-install-target
+userprogs-always-$(CONFIG_BAREBOXCRC32_TARGET) += bareboxcrc32-target
+userprogs-always-$(CONFIG_IMD_TARGET)  += bareboximd-target
 
 userccflags += -I $(srctree)/$(src)/include
 
-userprogs

[PATCH 4/5] kbuild: sync the top level Kbuild file with Linux

2020-08-18 Thread Masahiro Yamada
 - Convert 'always' to 'always-y'

 - Remove redundant 'targets' assignment

 - Use filechk for the offset generation to avoid unneeded
   rebuilds when the content of asm-offsets.h is not changed

 - Remove the explicit build rule of asm-offsets.s because
   it can be built of the pattern rule in scripts/Makefile.build

Signed-off-by: Masahiro Yamada 
---

 Kbuild | 28 
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/Kbuild b/Kbuild
index 329609604..519be4a3c 100644
--- a/Kbuild
+++ b/Kbuild
@@ -1,14 +1,15 @@
-#
-# 1) Generate asm-offsets.h
+# SPDX-License-Identifier: GPL-2.0
 #
+# Kbuild for top-level directory of Barebox
+
+#
+# Generate asm-offsets.h
 
 offsets-file := include/generated/asm-offsets.h
 
-always  += $(offsets-file)
-targets += $(offsets-file)
+always-y += $(offsets-file)
 targets += arch/$(SRCARCH)/lib/asm-offsets.s
 
-
 # Default sed regexp - multiline due to syntax constraints
 define sed-y
"/^->/{s:->#\(.*\):/* \1 */:; \
@@ -17,9 +18,9 @@ define sed-y
s:->::; p;}"
 endef
 
-quiet_cmd_offsets = GEN $@
-define cmd_offsets
-   (set -e; \
+# Use filechk to avoid rebuilds when a header changes, but the resulting file
+# does not
+define filechk_offsets
 echo "#ifndef __ASM_OFFSETS_H__"; \
 echo "#define __ASM_OFFSETS_H__"; \
 echo "/*"; \
@@ -31,13 +32,8 @@ define cmd_offsets
 echo ""; \
 sed -ne $(sed-y) $<; \
 echo ""; \
-echo "#endif" ) > $@
+echo "#endif"
 endef
 
-# We use internal kbuild rules to avoid the "is up to date" message from make
-arch/$(SRCARCH)/lib/asm-offsets.s: arch/$(SRCARCH)/lib/asm-offsets.c FORCE
-   $(Q)mkdir -p $(dir $@)
-   $(call if_changed_dep,cc_s_c)
-
-$(obj)/$(offsets-file): arch/$(SRCARCH)/lib/asm-offsets.s Kbuild
-   $(call cmd,offsets)
+$(offsets-file): arch/$(SRCARCH)/lib/asm-offsets.s FORCE
+   $(call filechk,offsets)
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/5] scripts: remove redundant setupmbr addition to subdir-

2020-08-18 Thread Masahiro Yamada
This has already been added to subdir-$(CONFIG_X86) a few lines above.
'make mrproper' correctly descends into scripts/setupmbr/.

Remove the redundant addition.

Signed-off-by: Masahiro Yamada 
---

 scripts/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/Makefile b/scripts/Makefile
index 75e68822d..238460fe2 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -52,4 +52,4 @@ subdir-$(CONFIG_DTC)  += dtc
 subdir-$(CONFIG_ARCH_TEGRA)+= tegra
 
 # Let clean descend into subdirs
-subdir-+= basic kconfig setupmbr
+subdir-+= basic kconfig
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/5] sandbox: add sandbox.dtb to always-y

2020-08-18 Thread Masahiro Yamada
Unlike Linux, Barebox does not support 'make dtbs_install'.
There is no good reason to use dtb-y, which is not natively
supported by the Barebox build system.

Sandbox is the special architecture that compiles DTB as a
separate file. Add .dtb to always-y directly.

CONFIG_OFTREE is a bool option. Use a more Kbuild-ish style
instead of ifeq ($(CONFIG_OFTREE),y).

Signed-off-by: Masahiro Yamada 
---

 arch/sandbox/dts/Makefile | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/sandbox/dts/Makefile b/arch/sandbox/dts/Makefile
index 6f6838857..6f4344da6 100644
--- a/arch/sandbox/dts/Makefile
+++ b/arch/sandbox/dts/Makefile
@@ -1,11 +1,8 @@
-ifeq ($(CONFIG_OFTREE),y)
-dtb-y += \
+always-$(CONFIG_OFTREE) += \
sandbox.dtb
-endif
 
 # just to build a built-in.o. Otherwise compilation fails when no devicetree is
 # created.
 obj- += dummy.o
 
-always := $(dtb-y)
 clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] treewide: remove stale instances of struct device

2020-08-03 Thread Masahiro Yamada
On Tue, Aug 4, 2020 at 6:22 AM Sascha Hauer  wrote:
>
> On Tue, Jul 21, 2020 at 08:15:23AM +0200, Ahmad Fatoum wrote:
> > We call it struct device_d, any instances of struct device are likely
> > left-over code after porting from Linux.
> >
> > Signed-off-by: Ahmad Fatoum 
> > ---
> >  drivers/crypto/caam/intern.h   | 5 -
> >  drivers/crypto/caam/jr.h   | 2 --
> >  drivers/gpio/gpio-sx150x.c | 1 -
> >  drivers/usb/musb/musb_gadget.c | 9 -
> >  4 files changed, 17 deletions(-)
>
> Applied, thanks
>
> Sascha


Why doesn't barebox use (struct device)?

(Of course its implementation is much simpler
than that of Linux).




-- 
Best Regards
Masahiro Yamada

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/3] scripts: use 'userprogs' to build programs for target

2020-06-22 Thread Masahiro Yamada
Use 'userprogs' syntax to build standalone programs for the target
architecture (i.e. the same architecture as the barebox).

This changes the compiler flags passed to the target programs.

Previously, it used $(KBUILD_CFLAGS), which contains the same compiler
flags as used for the barebox space.

Going forward, it will use $(KBUILD_USERCFLAGS), which contains smaller
set of compiler flags because there is no need to add low-level options
for userspace builds.

The shortlog will be annotated with [U].

  CC [U]  scripts/bareboxenv-target
  CC [U]  scripts/kernel-install-target
  CC [U]  scripts/bareboxcrc32-target
  CC [U]  scripts/bareboximd-target

Signed-off-by: Masahiro Yamada 
---

 scripts/Makefile| 29 ++---
 scripts/bareboxcrc32-target.c   |  1 +
 scripts/bareboxenv-target.c |  1 +
 scripts/bareboximd-target.c |  1 +
 scripts/kernel-install-target.c |  1 +
 5 files changed, 14 insertions(+), 19 deletions(-)
 create mode 100644 scripts/bareboxcrc32-target.c
 create mode 100644 scripts/bareboxenv-target.c
 create mode 100644 scripts/bareboximd-target.c
 create mode 100644 scripts/kernel-install-target.c

diff --git a/scripts/Makefile b/scripts/Makefile
index f3b9aece9..75e68822d 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -35,30 +35,21 @@ HOSTCFLAGS_omap4_usbboot.o = `pkg-config --cflags 
libusb-1.0`
 HOSTLDLIBS_omap4_usbboot = -lpthread `pkg-config --libs libusb-1.0`
 hostprogs-$(CONFIG_OMAP4_HOSTTOOL_USBBOOT) += omap4_usbboot
 
+userprogs-$(CONFIG_BAREBOXENV_TARGET)  += bareboxenv-target
+userprogs-$(CONFIG_KERNEL_INSTALL_TARGET)  += kernel-install-target
+userprogs-$(CONFIG_BAREBOXCRC32_TARGET)+= bareboxcrc32-target
+userprogs-$(CONFIG_IMD_TARGET) += bareboximd-target
+
+userccflags += -I $(srctree)/$(src)/include
+
+userprogs  := $(userprogs-y)
+always-y   := $(hostprogs-y) $(hostprogs-m) $(userprogs-y)
+
 subdir-y   += mod
 subdir-y   += imx
 subdir-$(CONFIG_X86)   += setupmbr
 subdir-$(CONFIG_DTC)   += dtc
 subdir-$(CONFIG_ARCH_TEGRA)+= tegra
 
-targetprogs-$(CONFIG_BAREBOXENV_TARGET) += bareboxenv-target
-targetprogs-$(CONFIG_KERNEL_INSTALL_TARGET) += kernel-install-target
-targetprogs-$(CONFIG_BAREBOXCRC32_TARGET) += bareboxcrc32-target
-targetprogs-$(CONFIG_IMD_TARGET) += bareboximd-target
-
 # Let clean descend into subdirs
 subdir-+= basic kconfig setupmbr
-
-quiet_cmd_csingle  = CC  $@
-  cmd_csingle  = $(CC) -Wp,-MD,$(depfile) $(TARGETCFLAGS) 
$(KBUILD_CFLAGS) -o $@ $<
-
-__targetprogs  := $(sort $(targetprogs-y) $(targetprogs-m))
-target-csingle := $(foreach m,$(__targetprogs),$(if $($(m)-objs),,$(m)))
-__targetprogs  := $(addprefix $(obj)/,$(__targetprogs))
-target-csingle := $(addprefix $(obj)/,$(target-csingle))
-TARGETCFLAGS += -I$(srctree)/scripts/include/
-
-always := $(hostprogs-y) $(hostprogs-m) $(targetprogs-y)
-
-$(target-csingle): %-target: %.c FORCE
-   $(call if_changed_dep,csingle)
diff --git a/scripts/bareboxcrc32-target.c b/scripts/bareboxcrc32-target.c
new file mode 100644
index 0..6c09c9f76
--- /dev/null
+++ b/scripts/bareboxcrc32-target.c
@@ -0,0 +1 @@
+#include "bareboxcrc32.c"
diff --git a/scripts/bareboxenv-target.c b/scripts/bareboxenv-target.c
new file mode 100644
index 0..caf175920
--- /dev/null
+++ b/scripts/bareboxenv-target.c
@@ -0,0 +1 @@
+#include "bareboxenv.c"
diff --git a/scripts/bareboximd-target.c b/scripts/bareboximd-target.c
new file mode 100644
index 0..903adee53
--- /dev/null
+++ b/scripts/bareboximd-target.c
@@ -0,0 +1 @@
+#include "bareboximd.c"
diff --git a/scripts/kernel-install-target.c b/scripts/kernel-install-target.c
new file mode 100644
index 0..845a96d29
--- /dev/null
+++ b/scripts/kernel-install-target.c
@@ -0,0 +1 @@
+#include "kernel-install.c"
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/3] kbuild: add infrastructure to build userspace programs

2020-06-22 Thread Masahiro Yamada
Import Linux commit 7f3a59db274c3e3d884c785e363a054110f1c266

Signed-off-by: Masahiro Yamada 
---

 Makefile   | 13 ---
 scripts/Makefile.build |  6 +
 scripts/Makefile.clean |  2 +-
 scripts/Makefile.userprogs | 45 ++
 4 files changed, 62 insertions(+), 4 deletions(-)
 create mode 100644 scripts/Makefile.userprogs

diff --git a/Makefile b/Makefile
index a4aac3db4..0da032532 100644
--- a/Makefile
+++ b/Makefile
@@ -363,9 +363,12 @@ HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
 
 HOSTCC   = gcc
 HOSTCXX  = g++
-KBUILD_HOSTCFLAGS   := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 \
-   -fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS) \
-   $(HOSTCFLAGS)
+
+export KBUILD_USERCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
+ -O2 -fomit-frame-pointer -std=gnu89
+export KBUILD_USERLDFLAGS :=
+
+KBUILD_HOSTCFLAGS   := $(KBUILD_USERCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS)
 KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
 KBUILD_HOSTLDFLAGS  := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
 KBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
@@ -608,6 +611,10 @@ KBUILD_CFLAGS += $(call cc-option, 
-fno-delete-null-pointer-checks,)
 
 KBUILD_CFLAGS   += $(call cc-disable-warning, address-of-packed-member)
 
+# Align the bit size of userspace programs with the kernel
+KBUILD_USERCFLAGS  += $(filter -m32 -m64, $(KBUILD_CFLAGS))
+KBUILD_USERLDFLAGS += $(filter -m32 -m64, $(KBUILD_CFLAGS))
+
 # arch Makefile may override CC so keep this after arch Makefile is included
 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
 CHECKFLAGS += $(NOSTDINC_FLAGS)
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 00f627791..a3dfe261a 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -49,6 +49,12 @@ ifneq ($(hostprogs)$(hostprogs-y)$(hostprogs-m),)
 include scripts/Makefile.host
 endif
 
+# Do not include userprogs rules unless needed.
+userprogs := $(sort $(userprogs))
+ifneq ($(userprogs),)
+include scripts/Makefile.userprogs
+endif
+
 ifndef obj
 $(warning kbuild: Makefile.build is included improperly)
 endif
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
index 6e6c9ef7c..97fd2ef48 100644
--- a/scripts/Makefile.clean
+++ b/scripts/Makefile.clean
@@ -37,7 +37,7 @@ subdir-ymn:= $(addprefix $(obj)/,$(subdir-ymn))
 
 __clean-files  := $(extra-y) $(extra-m) $(extra-)   \
   $(always) $(always-y) $(always-m) $(always-) $(targets) 
$(clean-files)   \
-  $(hostprogs) $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
+  $(hostprogs) $(hostprogs-y) $(hostprogs-m) $(hostprogs-) 
$(userprogs)
 
 # as clean-files is given relative to the current directory, this adds
 # a $(obj) prefix, except for absolute paths
diff --git a/scripts/Makefile.userprogs b/scripts/Makefile.userprogs
new file mode 100644
index 0..fb4152973
--- /dev/null
+++ b/scripts/Makefile.userprogs
@@ -0,0 +1,45 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Build userspace programs for the target system
+#
+
+# Executables compiled from a single .c file
+user-csingle   := $(foreach m, $(userprogs), $(if $($(m)-objs),,$(m)))
+
+# Executables linked based on several .o files
+user-cmulti:= $(foreach m, $(userprogs), $(if $($(m)-objs),$(m)))
+
+# Objects compiled from .c files
+user-cobjs := $(sort $(foreach m, $(userprogs), $($(m)-objs)))
+
+user-csingle   := $(addprefix $(obj)/, $(user-csingle))
+user-cmulti:= $(addprefix $(obj)/, $(user-cmulti))
+user-cobjs := $(addprefix $(obj)/, $(user-cobjs))
+
+user_ccflags   = -Wp,-MMD,$(depfile) $(KBUILD_USERCFLAGS) $(userccflags) \
+   $($(target-stem)-userccflags)
+user_ldflags   = $(KBUILD_USERLDFLAGS) $(userldflags) 
$($(target-stem)-userldflags)
+
+# Create an executable from a single .c file
+quiet_cmd_user_cc_c = CC [U]  $@
+  cmd_user_cc_c = $(CC) $(user_ccflags) $(user_ldflags) -o $@ $< \
+ $($(target-stem)-userldlibs)
+$(user-csingle): $(obj)/%: $(src)/%.c FORCE
+   $(call if_changed_dep,user_cc_c)
+
+# Link an executable based on list of .o files
+quiet_cmd_user_ld = LD [U]  $@
+  cmd_user_ld = $(CC) $(user_ldflags) -o $@ \
+   $(addprefix $(obj)/, $($(target-stem)-objs)) \
+   $($(target-stem)-userldlibs)
+$(user-cmulti): FORCE
+   $(call if_changed,user_ld)
+$(call multi_depend, $(user-cmulti), , -objs)
+
+# Create .o file from a .c file
+quiet_cmd_user_cc_o_c = CC [U]  $@
+  cmd_user_cc_o_c = $(CC) $(user_ccflags) -c -o $@ $<
+$(user-cobjs): $(obj)/%.o: $(src)/%.c FORCE
+   $(call if_changed_dep,user_cc_o_c)
+
+targets += $(user-csingle) $(user-cmulti) $(user-cobjs)
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.or

[PATCH 1/3] kbuild: add -Wmissing-prototypes and -std=gnu89 to KBUILD_HOSTCFLAGS

2020-06-22 Thread Masahiro Yamada
Align with Linux kernel.

Signed-off-by: Masahiro Yamada 
---

 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index da01ca5b0..a4aac3db4 100644
--- a/Makefile
+++ b/Makefile
@@ -363,8 +363,8 @@ HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
 
 HOSTCC   = gcc
 HOSTCXX  = g++
-KBUILD_HOSTCFLAGS   := -Wall -Wstrict-prototypes -O2 \
-   -fomit-frame-pointer $(HOST_LFS_CFLAGS) \
+KBUILD_HOSTCFLAGS   := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 \
+   -fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS) \
$(HOSTCFLAGS)
 KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
 KBUILD_HOSTLDFLAGS  := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [RFC PATCH 0/8] Module and ARM Module updates and fixes

2020-06-22 Thread Masahiro Yamada
On Thu, Jun 18, 2020 at 10:10 PM Sascha Hauer  wrote:
>
> On Wed, Jun 17, 2020 at 09:54:55PM -0400, David Dgien wrote:
> > Hi Sascha,
> >
> > On Wed, Jun 17, 2020 at 03:45:38PM +0200, Sascha Hauer wrote:
> > > Hi David,
> > >
> > > On Tue, Jun 16, 2020 at 11:43:56PM -0400, David Dgien wrote:
> > > > This series fixes various bugs and bit-rot issues with the module
> > > > loading code. It also ports a couple of modules features from the Linux
> > > > kernel: arch specific section fixups, and module PLTs for ARM modules,
> > > > to contain veneers for 'bl' instructions.
> > > >
> > > > There are two things in this series I'm looking for feedback on:
> > > > Linux implements module_frob_arch_sections as a weak symbol for the
> > > > default case. I didn't see any other "weak" functions in barebox, so I
> > > > wasn't sure if using that was acceptable.
> > >
> > > For things that are really mutually exclusive like different
> > > implementations on different architectures I think weak functions are
> > > ok. They are not ok as a quick hack for hooking something into something
> > > though.
> > >
> >
> > I'll make the change to a weak function here in a v2, since it will be a
> > bit cleaner.
> >
> > > > Since the Kconfig
> > > > HAVE_MOD_ARCH_SPECIFIC already exists as part of the change, I just used
> > > > that to define a static inline default implementation, but using a weak
> > > > function would make that slightly cleaner.
> > > >
> > > > And in the patch that added the init macros to module.h, I wasn't sure
> > > > if it would be okay to pollute init.h with the #ifndef MODULE
> > > > directives, so instead I just #undef'd all of the initcalls before
> > > > redefining them in module.h.  If it's okay to add the #ifndef MODULE to
> > > > init.h, that would be significantly cleaner than the current
> > > > implementation.
> > >
> > > I think it's ok to add #ifndef MODULE to init.h
> >
> > Same as above.
> >
> > >
> > > Anyway, what do you need modules for? Do you have a good reason or is it
> > > just for the fun of it?
> >
> > I'm working on a project that wants to use barebox as a very lightweight
> > OS replacement.
> > We're using modules to allow loading user code with
> > controlled access to hw interfaces via exported driver symbols.
>
> So barebOS again, we had that as an April fools joke once :)
>
> You'll probably miss things like interrupts, paging and multitasking
> very soon.
>
> Sascha


Does it make sense to choose y/m
depending on how often they are used?

- commands and drivers that are used quite often   ->  built-in
- commands and drivers that are sometimes used ->  modules



-- 
Best Regards
Masahiro Yamada

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] kbuild: remove package targets

2020-06-16 Thread Masahiro Yamada
This hunk is already out of sync from upstream Linux.

Barebox does not support package targets, so let's delete this
rotten code.

Signed-off-by: Masahiro Yamada 
---

 Makefile | 12 
 1 file changed, 12 deletions(-)

diff --git a/Makefile b/Makefile
index efb5fc9ee..da01ca5b0 100644
--- a/Makefile
+++ b/Makefile
@@ -1123,18 +1123,6 @@ distclean: mrproper
-o -name 'core' \) \
-type f -print | xargs rm -f
 
-
-# Packaging of the kernel to various formats
-# ---
-# rpm target kept for backward compatibility
-package-dir:= $(srctree)/scripts/package
-
-%pkg: include/config/kernel.release FORCE
-   $(Q)$(MAKE) $(build)=$(package-dir) $@
-rpm: include/config/kernel.release FORCE
-   $(Q)$(MAKE) $(build)=$(package-dir) $@
-
-
 # Brief documentation of the typical targets used
 # ---
 
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] kbuild: remove AS variable

2020-06-16 Thread Masahiro Yamada
The assembler files in the barebox are *.S instead of *.s, so they must
be preprocessed. Since 'as' of GNU binutils is not able to preprocess,
we always use $(CC) as an assembler driver.

Remove AS variable.

Linux also removed AS. See Linux commits:

 aa824e0c962b ("kbuild: remove AS variable")
 1ca0c2f61211 ("kbuild: remove unused AS assignment")

Signed-off-by: Masahiro Yamada 
---

 Makefile  | 3 +--
 arch/arm/Makefile | 2 --
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index d483302fe..efb5fc9ee 100644
--- a/Makefile
+++ b/Makefile
@@ -372,7 +372,6 @@ KBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
 
 # Make variables (CC, etc...)
 
-AS = $(CROSS_COMPILE)as
 LD = $(CROSS_COMPILE)ld
 CC = $(CROSS_COMPILE)gcc
 CPP= $(CC) -E
@@ -425,7 +424,7 @@ LDFLAGS_barebox := -Map barebox.map
 LDFLAGS_barebox += $(call ld-option, --no-dynamic-linker)
 LDFLAGS_pbl += $(call ld-option, --no-dynamic-linker)
 
-export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE 
AS LD CC
+export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE 
LD CC
 export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL PYTHON3 
UTS_MACHINE
 export LEX YACC
 export HOSTCXX CHECK CHECKFLAGS
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 6c7373c20..46dfe1f62 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -10,11 +10,9 @@ endif
 
 ifeq ($(CONFIG_CPU_BIG_ENDIAN),y)
 KBUILD_CPPFLAGS+= -mbig-endian
-AS += -EB
 LD += -EB
 else
 KBUILD_CPPFLAGS+= -mlittle-endian
-AS += -EL
 LD += -EL
 endif
 
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] powerpc: move ddr-8xxx/ to the relevant Makefile

2020-05-21 Thread Masahiro Yamada
Directory descending upward is ugly. Move it to the correct Makefile.

No functional change is intended because FSL_DDR{2,3} depend on
ARCH_MPC85XX.

Signed-off-by: Masahiro Yamada 
---

 arch/powerpc/Kbuild| 2 ++
 arch/powerpc/mach-mpc85xx/Makefile | 2 --
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/Kbuild b/arch/powerpc/Kbuild
index 503ce631c..65e249338 100644
--- a/arch/powerpc/Kbuild
+++ b/arch/powerpc/Kbuild
@@ -1,2 +1,4 @@
 obj-$(CONFIG_ARCH_MPC85XX) += cpu-85xx/
 obj-y += lib/
+obj-$(CONFIG_FSL_DDR2) += ddr-8xxx/
+obj-$(CONFIG_FSL_DDR3) += ddr-8xxx/
diff --git a/arch/powerpc/mach-mpc85xx/Makefile 
b/arch/powerpc/mach-mpc85xx/Makefile
index de4f5efde..9886c7da4 100644
--- a/arch/powerpc/mach-mpc85xx/Makefile
+++ b/arch/powerpc/mach-mpc85xx/Makefile
@@ -9,6 +9,4 @@ obj-y   += fsl_i2c.o
 obj-$(CONFIG_MP)   += mp.o
 obj-$(CONFIG_OFTREE)   += fdt.o
 obj-$(CONFIG_DRIVER_NET_GIANFAR) += eth-devices.o
-obj-$(CONFIG_FSL_DDR2) += ../ddr-8xxx/
-obj-$(CONFIG_FSL_DDR3) += ../ddr-8xxx/
 extra-y += barebox.lds
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] fixup! kbuild: unify barebox and pbl build commands

2020-05-21 Thread Masahiro Yamada
Signed-off-by: Masahiro Yamada 
---

Sascha,

Some redundant code slipped in.

Could you please squash this into the preivous
"kbuild: unify barebox and pbl build commands" ?


 scripts/Makefile.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 31341d23c..ed2bb28c5 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -117,7 +117,7 @@ cmd_cc_i_c   = $(CPP) $(c_flags)   -o $@ $<
 # (See cmd_cc_o_c + relevant part of rule_cc_o_c)
 
 quiet_cmd_cc_o_c = CC $(quiet_modtag)  $@
-  cmd_cc_o_c = $(CC) $(c_flags) $(if $(part-of-pbl),-D__PBL__ 
$(PBL_CPPFLAGS)) -c -o $@ $<
+  cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
 
 define rule_cc_o_c
$(call cmd,checksrc)
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 6/8] kbuild: unify barebox and pbl build commands

2020-05-19 Thread Masahiro Yamada
Just some typos.


On Tue, May 19, 2020 at 4:14 PM Masahiro Yamada  wrote:
>
> The current Linux uses the unified build command for built-in objects
> and module objects. This is possible because part-of-module is set to
> y when the target is being built for a module. If so, quiet_modtag is
> set to [M], and modkern_cflags is set to KBUILD_CFLAGS_MODULE instead
> of KBUILD_CFLAGS_KERNEL.
>
> Currently, barebox uses a separate build command for pbl, but the
> difference between cmd_cc_o_c and cmd_pbl_cc_o_c is just
> "-D__PBL__ $(PBL_CPPFLAGS)".
>
> By using the same approach as Linux, it can be unified.

it can be unified  -> they can be unified


>
> Set pbl-of-pbl flag to y when the target is being built for pbl.


pbl-of-pbl  ->  part-of-pbl




> Merge cmd_as_o_S and cmd_link_o_target as well.
>
> This also changes the shortlog style as follows:
>
>   PBLCC  ->  CC [P]
>   PBLAS  ->  AS [P]
>   PBLLD  ->  LD [P]
>
> This is more consistent with the policy in the Linux build system.
>
> In Linux, a capital letter enclosed square blackets indicates which
> target the object is being built for.
>
>   CC  object built for built-in
>   CC [M]  object built for modules
>   CC [U]  object built for userspace (proposed for Linux 5.8-rc1)
>
> The idea behind this is we use the same compiler $(CC) for them.
> Only the difference is the compiler flags. On the other hand, host
> programs are compiled by a different tool, $(HOSTCC), hence the
> shortlog is 'HOSTCC'.
>
> Barebox supports module builds (it seems), but the [P] notation does
> not conflict with [M] because pbl has a limited memory footprint.
> We never expect pbl can support the module feature.
>
> Signed-off-by: Masahiro Yamada 
> ---
>
>  scripts/Makefile.build | 35 ---
>  scripts/Makefile.lib   |  9 ++---
>  2 files changed, 14 insertions(+), 30 deletions(-)
>
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index f575a07fd..31341d23c 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -117,25 +117,18 @@ cmd_cc_i_c   = $(CPP) $(c_flags)   -o $@ $<
>  # (See cmd_cc_o_c + relevant part of rule_cc_o_c)
>
>  quiet_cmd_cc_o_c = CC $(quiet_modtag)  $@
> -  cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
> -quiet_cmd_pbl_cc_o_c = PBLCC   $@
> -  cmd_pbl_cc_o_c = $(CC) -D__PBL__ $(c_flags) $(PBL_CPPFLAGS) -c -o $@ $<
> +  cmd_cc_o_c = $(CC) $(c_flags) $(if $(part-of-pbl),-D__PBL__ 
> $(PBL_CPPFLAGS)) -c -o $@ $<
>
>  define rule_cc_o_c
> $(call cmd,checksrc)
> $(call cmd_and_fixdep,cc_o_c)
>  endef
>
> -define rule_pbl_cc_o_c
> -   $(call cmd,checksrc)
> -   $(call cmd_and_fixdep,pbl_cc_o_c)
> -endef
> -
>  # Built-in and composite module parts
>
>  %.pbl.o: %.c FORCE
> $(call cmd,force_checksrc)
> -   $(call if_changed_rule,pbl_cc_o_c)
> +   $(call if_changed_rule,cc_o_c)
>
>  %.o: %.c FORCE
> $(call cmd,force_checksrc)
> @@ -168,11 +161,8 @@ cmd_as_s_S   = $(CPP) $(a_flags)   -o $@ $<
>  quiet_cmd_as_o_S = AS $(quiet_modtag)  $@
>  cmd_as_o_S   = $(CC) $(a_flags) -c -o $@ $<
>
> -quiet_cmd_pbl_as_o_S = PBLAS   $@
> -cmd_pbl_as_o_S   = $(CC) -D__PBL__ $(a_flags) $(PBL_CPPFLAGS) -c -o $@ $<
> -
>  %.pbl.o: %.S FORCE
> -   $(call if_changed_dep,pbl_as_o_S)
> +   $(call if_changed_dep,as_o_S)
>
>  %.o: %.S FORCE
> $(call if_changed_dep,as_o_S)
> @@ -198,31 +188,22 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ;
>  #
>  # Rule to compile a set of .o files into one .o file
>  #
> -ifdef builtin-target
> -quiet_cmd_link_o_target = LD  $@
> +
>  # If the list of objects to link is empty, just create an empty built-in.o
> -cmd_link_o_target = $(if $(strip $(obj-y)),\
> - $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\
> +quiet_cmd_link_o_target = LD $(quiet_modtag)  $@
> +cmd_link_o_target = $(if $(strip $(real-prereqs)),\
> + $(LD) $(ld_flags) -r -o $@ $(real-prereqs),\
>   rm -f $@; $(AR) rcs $@)
>
>  $(builtin-target): $(obj-y) FORCE
> $(call if_changed,link_o_target)
>
>  targets += $(builtin-target)
> -endif # builtin-target
> -
> -ifdef pbl-target
> -quiet_cmd_pbl_link_o_target = PBLLD   $@
> -# If the list of objects to link is empty, just create an empty 
> built-in-pbl.o
> -cmd_pbl_link_o_target = $(if $(strip $(pbl-y)),\
> - $(LD) $(ld_flags) -r -o $@ $(filter $(pbl-y), $^),\
> - rm -f $@; $(AR) rcs $@)
>
>  $(pbl-target): $(pbl-y) FORCE
> -   $(call if_ch

[PATCH 6/8] kbuild: unify barebox and pbl build commands

2020-05-19 Thread Masahiro Yamada
The current Linux uses the unified build command for built-in objects
and module objects. This is possible because part-of-module is set to
y when the target is being built for a module. If so, quiet_modtag is
set to [M], and modkern_cflags is set to KBUILD_CFLAGS_MODULE instead
of KBUILD_CFLAGS_KERNEL.

Currently, barebox uses a separate build command for pbl, but the
difference between cmd_cc_o_c and cmd_pbl_cc_o_c is just
"-D__PBL__ $(PBL_CPPFLAGS)".

By using the same approach as Linux, it can be unified.

Set pbl-of-pbl flag to y when the target is being built for pbl.
Merge cmd_as_o_S and cmd_link_o_target as well.

This also changes the shortlog style as follows:

  PBLCC  ->  CC [P]
  PBLAS  ->  AS [P]
  PBLLD  ->  LD [P]

This is more consistent with the policy in the Linux build system.

In Linux, a capital letter enclosed square blackets indicates which
target the object is being built for.

  CC  object built for built-in
  CC [M]  object built for modules
  CC [U]  object built for userspace (proposed for Linux 5.8-rc1)

The idea behind this is we use the same compiler $(CC) for them.
Only the difference is the compiler flags. On the other hand, host
programs are compiled by a different tool, $(HOSTCC), hence the
shortlog is 'HOSTCC'.

Barebox supports module builds (it seems), but the [P] notation does
not conflict with [M] because pbl has a limited memory footprint.
We never expect pbl can support the module feature.

Signed-off-by: Masahiro Yamada 
---

 scripts/Makefile.build | 35 ---
 scripts/Makefile.lib   |  9 ++---
 2 files changed, 14 insertions(+), 30 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index f575a07fd..31341d23c 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -117,25 +117,18 @@ cmd_cc_i_c   = $(CPP) $(c_flags)   -o $@ $<
 # (See cmd_cc_o_c + relevant part of rule_cc_o_c)
 
 quiet_cmd_cc_o_c = CC $(quiet_modtag)  $@
-  cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
-quiet_cmd_pbl_cc_o_c = PBLCC   $@
-  cmd_pbl_cc_o_c = $(CC) -D__PBL__ $(c_flags) $(PBL_CPPFLAGS) -c -o $@ $<
+  cmd_cc_o_c = $(CC) $(c_flags) $(if $(part-of-pbl),-D__PBL__ 
$(PBL_CPPFLAGS)) -c -o $@ $<
 
 define rule_cc_o_c
$(call cmd,checksrc)
$(call cmd_and_fixdep,cc_o_c)
 endef
 
-define rule_pbl_cc_o_c
-   $(call cmd,checksrc)
-   $(call cmd_and_fixdep,pbl_cc_o_c)
-endef
-
 # Built-in and composite module parts
 
 %.pbl.o: %.c FORCE
$(call cmd,force_checksrc)
-   $(call if_changed_rule,pbl_cc_o_c)
+   $(call if_changed_rule,cc_o_c)
 
 %.o: %.c FORCE
$(call cmd,force_checksrc)
@@ -168,11 +161,8 @@ cmd_as_s_S   = $(CPP) $(a_flags)   -o $@ $<
 quiet_cmd_as_o_S = AS $(quiet_modtag)  $@
 cmd_as_o_S   = $(CC) $(a_flags) -c -o $@ $<
 
-quiet_cmd_pbl_as_o_S = PBLAS   $@
-cmd_pbl_as_o_S   = $(CC) -D__PBL__ $(a_flags) $(PBL_CPPFLAGS) -c -o $@ $<
-
 %.pbl.o: %.S FORCE
-   $(call if_changed_dep,pbl_as_o_S)
+   $(call if_changed_dep,as_o_S)
 
 %.o: %.S FORCE
$(call if_changed_dep,as_o_S)
@@ -198,31 +188,22 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ;
 #
 # Rule to compile a set of .o files into one .o file
 #
-ifdef builtin-target
-quiet_cmd_link_o_target = LD  $@
+
 # If the list of objects to link is empty, just create an empty built-in.o
-cmd_link_o_target = $(if $(strip $(obj-y)),\
- $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\
+quiet_cmd_link_o_target = LD $(quiet_modtag)  $@
+cmd_link_o_target = $(if $(strip $(real-prereqs)),\
+ $(LD) $(ld_flags) -r -o $@ $(real-prereqs),\
  rm -f $@; $(AR) rcs $@)
 
 $(builtin-target): $(obj-y) FORCE
$(call if_changed,link_o_target)
 
 targets += $(builtin-target)
-endif # builtin-target
-
-ifdef pbl-target
-quiet_cmd_pbl_link_o_target = PBLLD   $@
-# If the list of objects to link is empty, just create an empty built-in-pbl.o
-cmd_pbl_link_o_target = $(if $(strip $(pbl-y)),\
- $(LD) $(ld_flags) -r -o $@ $(filter $(pbl-y), $^),\
- rm -f $@; $(AR) rcs $@)
 
 $(pbl-target): $(pbl-y) FORCE
-   $(call if_changed,pbl_link_o_target)
+   $(call if_changed,link_o_target)
 
 targets += $(pbl-target)
-endif # pbl-target
 
 #
 # Rule to compile a set of .o files into one .a file
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index a6cba747f..55d251844 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -154,7 +154,10 @@ __cpp_flags =  $(call 
flags,_cpp_flags)
 endif
 
 part-of-module = $(if $(filter $(basename $@).o, $(real-obj-m)),y)
-quiet_modtag = $(if $(part-of-module),[M],   )
+part-of-pbl= $(if $(filter $(basename $@).o, $(pbl-y) $(pbl-target)),y)
+quiet_modtag = $(if $(part-of-pbl),[P],$(if $(part-of-module),[M],   ))
+
+pbl_cppflags = $(if $(part-of-

[PATCH 3/8] kbuild: resync mkdir code with Linux 5.7-rc6

2020-05-19 Thread Masahiro Yamada
Kbuild automatically creates the output directories for O= builds.
Previously it called mkdir too much. Linux optimized this a lot.
Let's import the outcome so it works faster.

Signed-off-by: Masahiro Yamada 
---

 scripts/Makefile.build | 25 -
 scripts/Makefile.host  |  2 --
 scripts/Makefile.lib   |  4 
 3 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index f4e771980..d94ad488d 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -49,15 +49,6 @@ ifneq ($(hostprogs)$(hostprogs-y)$(hostprogs-m),)
 include scripts/Makefile.host
 endif
 
-ifdef building_out_of_srctree
-# Create output directory if not already present
-_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
-
-# Create directories for object files if directory does not exist
-# Needed when obj-y := dir/file.o syntax is used
-_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
-endif
-
 ifndef obj
 $(warning kbuild: Makefile.build is included improperly)
 endif
@@ -332,11 +323,19 @@ FORCE:
 # optimization, we don't need to read them if the target does not
 # exist, we will rebuild anyway in that case.
 
-targets := $(wildcard $(sort $(targets)))
-cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
+existing-targets := $(wildcard $(sort $(targets)))
 
-ifneq ($(cmd_files),)
-  include $(cmd_files)
+-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
+
+ifdef building_out_of_srctree
+# Create directories for object files if they do not exist
+obj-dirs := $(sort $(obj) $(patsubst %/,%, $(dir $(targets
+# If targets exist, their directories apparently exist. Skip mkdir.
+existing-dirs := $(sort $(patsubst %/,%, $(dir $(existing-targets
+obj-dirs := $(strip $(filter-out $(existing-dirs), $(obj-dirs)))
+ifneq ($(obj-dirs),)
+$(shell mkdir -p $(obj-dirs))
+endif
 endif
 
 .PHONY: $(PHONY)
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index 55b565ce3..038b3054a 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -76,8 +76,6 @@ host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
 host-cxxobjs   := $(addprefix $(obj)/,$(host-cxxobjs))
 host-objdirs:= $(addprefix $(obj)/,$(host-objdirs))
 
-obj-dirs += $(host-objdirs)
-
 #
 # Handle options to gcc. Support building with separate output directory
 
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 604bedfc5..70303adb5 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -77,9 +77,6 @@ __subdir-obj-y := $(filter %/built-in-pbl.o, $(pbl-y))
 subdir-obj-y := $(filter %/built-in.o, $(obj-y))
 subdir-obj-y += $(__subdir-obj-y)
 
-# $(obj-dirs) is a list of directories that contain object files
-obj-dirs := $(dir $(multi-objs) $(obj-y) $(pbl-y))
-
 # Replace multi-part objects by their individual parts, look at local dir only
 real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if 
$(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) 
$(extra-y)
 real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) 
$($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
@@ -104,7 +101,6 @@ multi-used-m:= $(addprefix $(obj)/,$(multi-used-m))
 multi-objs-y   := $(addprefix $(obj)/,$(multi-objs-y))
 multi-objs-m   := $(addprefix $(obj)/,$(multi-objs-m))
 subdir-ym  := $(addprefix $(obj)/,$(subdir-ym))
-obj-dirs   := $(addprefix $(obj)/,$(obj-dirs))
 bbenv-y:= $(addprefix $(obj)/,$(bbenv-y))
 
 # target with $(obj)/ and its suffix stripped
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 5/8] kbuild: resync modkern_{c, a}flags and quiet_modtag with Linux 5.7-rc6

2020-05-19 Thread Masahiro Yamada
The latest Linux calculates them more simply; part-of-module is set
when the target is being built for a module.

Also, rename real-objs-{y,m} to real-obj-{y,m}.

Signed-off-by: Masahiro Yamada 
---

 scripts/Makefile.build | 24 ++--
 scripts/Makefile.lib   | 23 ++-
 2 files changed, 20 insertions(+), 27 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index d94ad488d..f575a07fd 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -88,22 +88,6 @@ endif
 # Compile C sources (.c)
 # ---
 
-# Default is built-in, unless we know otherwise
-modkern_cflags := $(CFLAGS_KERNEL)
-quiet_modtag := $(empty)   $(empty)
-
-$(real-objs-m): modkern_cflags := $(CFLAGS_MODULE)
-$(real-objs-m:.o=.i)  : modkern_cflags := $(CFLAGS_MODULE)
-$(real-objs-m:.o=.s)  : modkern_cflags := $(CFLAGS_MODULE)
-$(real-objs-m:.o=.lst): modkern_cflags := $(CFLAGS_MODULE)
-
-$(real-objs-m): quiet_modtag := [M]
-$(real-objs-m:.o=.i)  : quiet_modtag := [M]
-$(real-objs-m:.o=.s)  : quiet_modtag := [M]
-$(real-objs-m:.o=.lst): quiet_modtag := [M]
-
-$(obj-m)  : quiet_modtag := [M]
-
 # Default for not multi-part modules
 modname = $(basetarget)
 
@@ -175,11 +159,6 @@ quiet_cmd_cc_lst_c = MKLST   $@
 # Compile assembler sources (.S)
 # ---
 
-modkern_aflags := $(AFLAGS_KERNEL)
-
-$(real-objs-m)  : modkern_aflags := $(AFLAGS_MODULE)
-$(real-objs-m:.o=.s): modkern_aflags := $(AFLAGS_MODULE)
-
 quiet_cmd_as_s_S = CPP $(quiet_modtag) $@
 cmd_as_s_S   = $(CPP) $(a_flags)   -o $@ $<
 
@@ -198,7 +177,8 @@ cmd_pbl_as_o_S   = $(CC) -D__PBL__ $(a_flags) 
$(PBL_CPPFLAGS) -c -o $@ $<
 %.o: %.S FORCE
$(call if_changed_dep,as_o_S)
 
-targets += $(real-objs-y) $(real-objs-m) $(lib-y) $(pbl-y)
+targets += $(filter-out $(subdir-obj-y), $(real-obj-y)) $(real-obj-m) $(lib-y)
+targets += $(pbl-y)
 targets += $(extra-y) $(always-y) $(MAKECMDGOALS)
 
 # Linker scripts preprocessor (.lds.S -> .lds)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index ef723c0ca..a6cba747f 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -82,9 +82,10 @@ extra-y += $(patsubst 
%,%.bbenv$(DEFAULT_COMPRESSION_SUFFIX),$(bbenv-y))
 extra-y += $(patsubst %,%.bbenv$(DEFAULT_COMPRESSION_SUFFIX).S,$(bbenv-y))
 extra-y += $(patsubst %,%.bbenv$(DEFAULT_COMPRESSION_SUFFIX).o,$(bbenv-y))
 
-# Replace multi-part objects by their individual parts, look at local dir only
-real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if 
$(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) 
$(extra-y)
-real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) 
$($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
+# Replace multi-part objects by their individual parts,
+# including built-in.a from subdirectories
+real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) 
$($(m:.o=-y)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
+real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) 
$($(m:.o=-y)) $($(m:.o=-m)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)) 
$($(m:.o=-m)),$(m)))
 
 always-y += $(always-m)
 
@@ -98,8 +99,8 @@ obj-m := $(addprefix $(obj)/,$(obj-m))
 lib-y  := $(addprefix $(obj)/,$(lib-y))
 pbl-y  := $(addprefix $(obj)/,$(pbl-y))
 subdir-obj-y   := $(addprefix $(obj)/,$(subdir-obj-y))
-real-objs-y:= $(addprefix $(obj)/,$(real-objs-y))
-real-objs-m:= $(addprefix $(obj)/,$(real-objs-m))
+real-obj-y := $(addprefix $(obj)/,$(real-obj-y))
+real-obj-m := $(addprefix $(obj)/,$(real-obj-m))
 single-used-m  := $(addprefix $(obj)/,$(single-used-m))
 multi-used-y   := $(addprefix $(obj)/,$(multi-used-y))
 multi-used-m   := $(addprefix $(obj)/,$(multi-used-m))
@@ -152,6 +153,18 @@ __a_flags  =  $(call 
flags,_a_flags)
 __cpp_flags =  $(call flags,_cpp_flags)
 endif
 
+part-of-module = $(if $(filter $(basename $@).o, $(real-obj-m)),y)
+quiet_modtag = $(if $(part-of-module),[M],   )
+
+modkern_cflags =  \
+   $(if $(part-of-module),   \
+   $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
+   $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL) $(modfile_flags))
+
+modkern_aflags = $(if $(part-of-module),   \
+   $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE),   \
+   $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL))
+
 c_flags= -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
 $(__c_flags) $(modkern_cflags) \
 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
-- 
2.25.1


___
barebox mailing list
barebox@

[PATCH 8/8] Revert "ARM: socfpga: generate smaller images when multiple boards are selected"

2020-05-19 Thread Masahiro Yamada
This reverts commit a83c97f2a4065ef7209f123b837fa5103f984c6a.

The dead code elimination with thin archive can cope with the same
symbol names. Revert the workaround.

Signed-off-by: Masahiro Yamada 
---

 .../altera-socdk/iocsr_config_cyclone5.c  |   8 +-
 arch/arm/boards/altera-socdk/lowlevel.c   |   2 -
 arch/arm/boards/altera-socdk/pinmux_config.c  |   2 +-
 .../altera-socdk/sequencer_auto_ac_init.c |   2 +-
 .../ebv-socrates/iocsr_config_cyclone5.c  |   8 +-
 arch/arm/boards/ebv-socrates/lowlevel.c   |   2 -
 arch/arm/boards/ebv-socrates/pinmux_config.c  |   4 +-
 .../ebv-socrates/sequencer_auto_ac_init.c |   2 +-
 .../iocsr_config_cyclone5.c   |   8 +-
 .../boards/terasic-de0-nano-soc/lowlevel.c|   2 -
 .../terasic-de0-nano-soc/pinmux_config.c  |   2 +-
 .../sequencer_auto_ac_init.c  |   2 +-
 .../terasic-sockit/iocsr_config_cyclone5.c|   8 +-
 arch/arm/boards/terasic-sockit/lowlevel.c |   2 -
 .../arm/boards/terasic-sockit/pinmux_config.c |   2 +-
 .../terasic-sockit/sequencer_auto_ac_init.c   |   2 +-
 .../include/mach/cyclone5-sequencer.c | 122 +-
 arch/arm/mach-socfpga/include/mach/lowlevel.h |   4 +-
 18 files changed, 88 insertions(+), 96 deletions(-)

diff --git a/arch/arm/boards/altera-socdk/iocsr_config_cyclone5.c 
b/arch/arm/boards/altera-socdk/iocsr_config_cyclone5.c
index a199e4da1..9777d15df 100644
--- a/arch/arm/boards/altera-socdk/iocsr_config_cyclone5.c
+++ b/arch/arm/boards/altera-socdk/iocsr_config_cyclone5.c
@@ -29,7 +29,7 @@
 
 #include 
 
-static const unsigned long 
SECT(iocsr_scan_chain0_table)[((CONFIG_HPS_IOCSR_SCANCHAIN0_LENGTH / 32) + 1)]
+static const unsigned long 
iocsr_scan_chain0_table[((CONFIG_HPS_IOCSR_SCANCHAIN0_LENGTH / 32) + 1)]
 = {
0x,
0x,
@@ -57,7 +57,7 @@ static const unsigned long 
SECT(iocsr_scan_chain0_table)[((CONFIG_HPS_IOCSR_SCAN
0x1000,
 };
 
-static const unsigned long 
SECT(iocsr_scan_chain1_table)[((CONFIG_HPS_IOCSR_SCANCHAIN1_LENGTH / 32) + 1)]
+static const unsigned long 
iocsr_scan_chain1_table[((CONFIG_HPS_IOCSR_SCANCHAIN1_LENGTH / 32) + 1)]
 = {
0x000C0300,
0x1004,
@@ -115,7 +115,7 @@ static const unsigned long 
SECT(iocsr_scan_chain1_table)[((CONFIG_HPS_IOCSR_SCAN
0x0080,
 };
 
-static const unsigned long 
SECT(iocsr_scan_chain2_table)[((CONFIG_HPS_IOCSR_SCANCHAIN2_LENGTH / 32) + 1)]
+static const unsigned long 
iocsr_scan_chain2_table[((CONFIG_HPS_IOCSR_SCANCHAIN2_LENGTH / 32) + 1)]
 = {
0x80040100,
0x,
@@ -149,7 +149,7 @@ static const unsigned long 
SECT(iocsr_scan_chain2_table)[((CONFIG_HPS_IOCSR_SCAN
0x0800,
 };
 
-static const unsigned long 
SECT(iocsr_scan_chain3_table)[((CONFIG_HPS_IOCSR_SCANCHAIN3_LENGTH / 32) + 1)]
+static const unsigned long 
iocsr_scan_chain3_table[((CONFIG_HPS_IOCSR_SCANCHAIN3_LENGTH / 32) + 1)]
 = {
0x0C420D80,
0x082000FF,
diff --git a/arch/arm/boards/altera-socdk/lowlevel.c 
b/arch/arm/boards/altera-socdk/lowlevel.c
index 36dbc55b9..822c3d8ee 100644
--- a/arch/arm/boards/altera-socdk/lowlevel.c
+++ b/arch/arm/boards/altera-socdk/lowlevel.c
@@ -1,5 +1,3 @@
-#define SECT(name) __attribute__((section("socfpga_socdk_" #name))) name
-
 #include "sdram_config.h"
 #include "pinmux_config.c"
 #include "pll_config.h"
diff --git a/arch/arm/boards/altera-socdk/pinmux_config.c 
b/arch/arm/boards/altera-socdk/pinmux_config.c
index 8bdaaedb8..ff784bbec 100644
--- a/arch/arm/boards/altera-socdk/pinmux_config.c
+++ b/arch/arm/boards/altera-socdk/pinmux_config.c
@@ -30,7 +30,7 @@
 #include 
 
 /* pin MUX configuration data */
-static unsigned long SECT(sys_mgr_init_table)[] = {
+static unsigned long sys_mgr_init_table[] = {
0,  /* EMACIO0 */
2,  /* EMACIO1 */
2,  /* EMACIO2 */
diff --git a/arch/arm/boards/altera-socdk/sequencer_auto_ac_init.c 
b/arch/arm/boards/altera-socdk/sequencer_auto_ac_init.c
index c9011b2e2..653138380 100644
--- a/arch/arm/boards/altera-socdk/sequencer_auto_ac_init.c
+++ b/arch/arm/boards/altera-socdk/sequencer_auto_ac_init.c
@@ -28,7 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
 static const uint32_t ac_rom_init_size = 36;
-static const uint32_t SECT(ac_rom_init)[36] = {
+static const uint32_t ac_rom_init[36] = {
0x2070,
0x2078,
0x10080431,
diff --git a/arch/arm/boards/ebv-socrates/iocsr_config_cyclone5.c 
b/arch/arm/boards/ebv-socrates/iocsr_config_cyclone5.c
index 6153de900..9a814cba7 100644
--- a/arch/arm/boards/ebv-socrates/iocsr_config_cyclone5.c
+++ b/arch/arm/boards/ebv-socrates/iocsr_config_cyclone5.c
@@ -29,7 +29,7 @@
 
 #include 
 
-static const unsigned long 
SECT(iocsr_scan_chain0_table)[((CONFIG_HPS_IOCSR_SCANCHAIN0_LENGTH / 32) + 1)] 
= {
+static cons

[PATCH 7/8] kbuild: switch over to thin archive

2020-05-19 Thread Masahiro Yamada
Starting v4.13, Linux always uses thin archive instead of relocatable
ELF to combine builtin objects.

The thin archive is basically a text file that only contains paths to
object files.

As Linux commit 98ced886dd79 mentioned, this has a lot of benefits:

 - save disk space for builds

 - speed-up building a little

 - fix some issues when liking a giant executable (for example,
   allyesconfig on ARM Linux)

 - work better with dead code elimination

The last one is important for barebox because pbl highly relies on the
dead code elimination (-f{function,data}-sections and --gc-sections)
dropping symbols that are unreachable from the linker's entry point.
The dead code elimination does not work if the same symbol names are
used in the pevious incremental link mechanism because the same name
symbols all go into the same section.

Commit a83c97f2a406 ("ARM: socfpga: generate smaller images when
multiple boards are selected") worked around it by giving a dedicate
section to each of the same name symbols. This workaround can go away.

built-in.o was renamed to built-in.a since it is now an archive.
built-in-pbl.o was renamed to built-in.pbl.a for consistency.

Signed-off-by: Masahiro Yamada 
---

 Makefile   | 10 +-
 arch/kvx/Makefile  |  2 +-
 arch/mips/Makefile |  2 +-
 arch/mips/pbl/Makefile |  2 +-
 arch/sandbox/Makefile  |  2 +-
 arch/x86/Makefile  |  4 ++--
 images/Makefile|  4 ++--
 scripts/Makefile.build | 20 
 scripts/Makefile.lib   | 12 ++--
 9 files changed, 27 insertions(+), 31 deletions(-)

diff --git a/Makefile b/Makefile
index 9f30fafdd..c4a2519a1 100644
--- a/Makefile
+++ b/Makefile
@@ -664,8 +664,8 @@ barebox-alldirs := $(sort $(barebox-dirs) $(patsubst 
%/,%,$(filter %/, \
 $(core-n) $(core-) $(drivers-n) $(drivers-) \
 $(net-n)  $(net-)  $(libs-n)$(libs-
 
-pbl-common-y   := $(patsubst %/, %/built-in-pbl.o, $(common-y))
-common-y   := $(patsubst %/, %/built-in.o, $(common-y))
+pbl-common-y   := $(patsubst %/, %/built-in.pbl.a, $(common-y))
+common-y   := $(patsubst %/, %/built-in.a, $(common-y))
 
 ifeq ($(CONFIG_DEFAULT_COMPRESSION_GZIP),y)
 DEFAULT_COMPRESSION_SUFFIX := .gz
@@ -687,7 +687,7 @@ export DEFAULT_COMPRESSION_SUFFIX
 # Build barebox
 # ---
 # barebox is built from the objects selected by $(barebox-init) and
-# $(barebox-main). Most are built-in.o files from top-level directories
+# $(barebox-main). Most are built-in.a files from top-level directories
 # in the kernel tree, others are specified in arch/$(SRCARCH)/Makefile.
 # Ordering when linking is important, and $(barebox-init) must be first.
 #
@@ -700,7 +700,7 @@ export DEFAULT_COMPRESSION_SUFFIX
 #   |   +--< init/version.o + more
 #   |
 #   +--< $(barebox-main)
-#   |+--< driver/built-in.o mm/built-in.o + more
+#   |+--< driver/built-in.a mm/built-in.a + more
 #   |
 #   +-< kallsyms.o (see description in CONFIG_KALLSYMS section)
 #
@@ -719,7 +719,7 @@ BAREBOX_LDS:= $(lds-y)
 quiet_cmd_barebox__ ?= LD  $@
   cmd_barebox__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_barebox) -o $@ \
   -T $(BAREBOX_LDS) \
-  --start-group $(BAREBOX_OBJS) --end-group  \
+  --whole-archive $(BAREBOX_OBJS) --no-whole-archive  \
   $(filter-out $(BAREBOX_LDS) $(BAREBOX_OBJS) FORCE ,$^)
 
 # Generate new barebox version
diff --git a/arch/kvx/Makefile b/arch/kvx/Makefile
index 7abaed651..9e7c8c07f 100644
--- a/arch/kvx/Makefile
+++ b/arch/kvx/Makefile
@@ -30,6 +30,6 @@ lds-y += arch/kvx/cpu/barebox.lds
 
 cmd_barebox__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_barebox) -o $@ \
   -T $(BAREBOX_LDS) \
-  --start-group $(BAREBOX_OBJS) --end-group \
+  --whole-archive $(BAREBOX_OBJS) --no-while-archive \
   -L$(LIBGCC_PATH) -lgcc \
   $(filter-out $(BAREBOX_LDS) $(BAREBOX_OBJS) FORCE ,$^)
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 5604a0a10..4eb6ba772 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -102,7 +102,7 @@ lds-$(CONFIG_GENERIC_LINKER_SCRIPT)   := 
arch/mips/lib/barebox.lds
 
 cmd_barebox__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_barebox) -o $@ \
   -T $(BAREBOX_LDS) \
-  --start-group $(BAREBOX_OBJS) --end-group  \
+  --whole-archive $(BAREBOX_OBJS) --no-whole-archive\
   $(filter-out $(BAREBOX_LDS) $(BAREBOX_OBJS) FORCE ,$^);  \
$(objtree)/scripts/mips-relocs $@
 
diff --git a/arch/mips/pbl/Makefile b/arch/mips/pbl/Makefile
index 535bb4bf5..3bd0df165 100644
--- a/arch/mips/pbl/Makefile
+++ b/arch/mips/pbl/Makefile
@@ -31,7 +31,7 @@ zbarebox-lds := $(obj)/zbarebox.lds
 quiet_cmd_zbarebox__ ?= LD  $@
   cmd_zbarebox__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_zbarebox) -o

[PATCH 4/8] kbuild: append $(bbenv-y) to obj-y earlier

2020-05-19 Thread Masahiro Yamada
You can save one line.

Signed-off-by: Masahiro Yamada 
---

 scripts/Makefile.lib | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 70303adb5..ef723c0ca 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -77,6 +77,11 @@ __subdir-obj-y := $(filter %/built-in-pbl.o, $(pbl-y))
 subdir-obj-y := $(filter %/built-in.o, $(obj-y))
 subdir-obj-y += $(__subdir-obj-y)
 
+obj-y += $(patsubst %,%.bbenv$(DEFAULT_COMPRESSION_SUFFIX).o,$(bbenv-y))
+extra-y += $(patsubst %,%.bbenv$(DEFAULT_COMPRESSION_SUFFIX),$(bbenv-y))
+extra-y += $(patsubst %,%.bbenv$(DEFAULT_COMPRESSION_SUFFIX).S,$(bbenv-y))
+extra-y += $(patsubst %,%.bbenv$(DEFAULT_COMPRESSION_SUFFIX).o,$(bbenv-y))
+
 # Replace multi-part objects by their individual parts, look at local dir only
 real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if 
$(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) 
$(extra-y)
 real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) 
$($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
@@ -101,7 +106,6 @@ multi-used-m:= $(addprefix $(obj)/,$(multi-used-m))
 multi-objs-y   := $(addprefix $(obj)/,$(multi-objs-y))
 multi-objs-m   := $(addprefix $(obj)/,$(multi-objs-m))
 subdir-ym  := $(addprefix $(obj)/,$(subdir-ym))
-bbenv-y:= $(addprefix $(obj)/,$(bbenv-y))
 
 # target with $(obj)/ and its suffix stripped
 target-stem = $(basename $(patsubst $(obj)/%,%,$@))
@@ -295,11 +299,6 @@ $(obj)/%.dtb: $(src)/%.dts FORCE
 
 dtc-tmp = $(subst $(comma),_,$(dot-target).dts)
 
-obj-y += $(patsubst %,%.bbenv$(DEFAULT_COMPRESSION_SUFFIX).o,$(bbenv-y))
-extra-y += $(patsubst %,%.bbenv$(DEFAULT_COMPRESSION_SUFFIX),$(bbenv-y))
-extra-y += $(patsubst %,%.bbenv$(DEFAULT_COMPRESSION_SUFFIX).S,$(bbenv-y))
-extra-y += $(patsubst %,%.bbenv$(DEFAULT_COMPRESSION_SUFFIX).o,$(bbenv-y))
-
 quiet_cmd_env_S = ENV.S   $@
 cmd_env_S =\
 (  \
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/8] kbuild: remove obj-dtb-y, pbl-dtb-y, lwl-dtb-y syntax

2020-05-19 Thread Masahiro Yamada
The embedded DTBs are compiled by the chain of pattern rules as follows:

  %.dts -> %.dtb -> %.dtb.S -> %.dtb.o   for barebox proper
  %.dts -> %.dtb -> %.dtb.S -> %.dtb.pbl.o   for pbl

Barebox introduced {obj,pbl,lwl}-dtb-y syntax to put the intermediate
files into extra-y. The purposes of doing so were:

 [1] prevent GNU Make from deleting the intermediate files
 [2] include .*.cmd files

In contrast, Linux does not use a special syntax for embedding DTBs
into the kernel.

For example, as you see in arch/sh/boot/dts/Makefile of Linux 5.6,

   obj-y += .dtb.o

... just works.

This is because scripts/Kbuild.include specifies .SECONDARY to cater
to [1], and scripts/Makefile.build adds the intermediates to 'targets'
to deal with [2].

Barebox had already imported the same code from Linux, so you can use
obj-y instead of obj-dtb-y, like Linux.

pbl-dtb-y and lwl-dtb-y are barebox-specific cases, so I added the
%.dtb.pbl.o pattern to intermediate_targets.

Going forward, please use obj-y, pbl-y, or lwl-y.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/dts/Makefile   | 212 
 arch/kvx/dts/Makefile   |   4 +-
 arch/mips/dts/Makefile  |  24 ++---
 arch/riscv/dts/Makefile |   4 +-
 scripts/Makefile.build  |   2 +
 scripts/Makefile.lib|  14 +--
 6 files changed, 126 insertions(+), 134 deletions(-)

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 1aeaa61e0..d61a05231 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -2,49 +2,49 @@
 # created.
 obj- += dummy.o
 
-lwl-dtb-$(CONFIG_MACH_ADVANTECH_ROM_742X) += imx6dl-advantech-rom-7421.dtb.o
-lwl-dtb-$(CONFIG_MACH_AFI_GF) += am335x-afi-gf.dtb.o
-lwl-dtb-$(CONFIG_MACH_BEAGLEBONE) += am335x-bone.dtb.o am335x-boneblack.dtb.o 
am335x-bone-common.dtb.o
-lwl-dtb-$(CONFIG_MACH_CANON_A1100) += canon-a1100.dtb.o
-lwl-dtb-$(CONFIG_MACH_CM_FX6) += imx6dl-cm-fx6.dtb.o imx6q-cm-fx6.dtb.o 
imx6q-utilite.dtb.o
-lwl-dtb-$(CONFIG_MACH_DFI_FS700_M60) += imx6q-dfi-fs700-m60-6q.dtb.o 
imx6dl-dfi-fs700-m60-6s.dtb.o
-lwl-dtb-$(CONFIG_MACH_DUCKBILL) += imx28-duckbill.dtb.o
-lwl-dtb-$(CONFIG_MACH_KINDLE_MX50) += imx50-kindle-d01100.dtb.o 
imx50-kindle-d01200.dtb.o imx50-kindle-ey21.dtb.o
-lwl-dtb-$(CONFIG_MACH_EFIKA_MX_SMARTBOOK) += imx51-genesi-efika-sb.dtb.o
-lwl-dtb-$(CONFIG_MACH_ELTEC_HIPERCAM) += imx6dl-eltec-hipercam.dtb.o
-lwl-dtb-$(CONFIG_MACH_EMBEST_MARSBOARD) += imx6q-marsboard.dtb.o
-lwl-dtb-$(CONFIG_MACH_EMBEST_RIOTBOARD) += imx6s-riotboard.dtb.o
-lwl-dtb-$(CONFIG_MACH_EMBEDSKY_E9) += imx6q-embedsky-e9.dtb.o
-lwl-dtb-$(CONFIG_MACH_FREESCALE_MX51_PDK) += imx51-babbage.dtb.o
-lwl-dtb-$(CONFIG_MACH_FREESCALE_MX53_LOCO) += imx53-qsb.dtb.o imx53-qsrb.dtb.o
-lwl-dtb-$(CONFIG_MACH_TX53) += imx53-tx53-xx30.dtb.o imx53-tx53-1011.dtb.o
-lwl-dtb-$(CONFIG_MACH_CCMX51) += imx51-ccxmx51.dtb.o
-lwl-dtb-$(CONFIG_MACH_CCMX53) += imx53-ccxmx53.dtb.o
-lwl-dtb-$(CONFIG_MACH_DIGI_CCIMX6ULSBCPRO) += imx6ul-ccimx6ulsbcpro.dtb.o
-lwl-dtb-$(CONFIG_MACH_FREESCALE_MX53_VMX53) += imx53-voipac-bsb.dtb.o
-lwl-dtb-$(CONFIG_MACH_FREESCALE_MX7_SABRESD) += imx7d-sdb.dtb.o
-lwl-dtb-$(CONFIG_MACH_GK802) += imx6q-gk802.dtb.o
-lwl-dtb-$(CONFIG_MACH_GLOBALSCALE_GURUPLUG) += 
kirkwood-guruplug-server-plus-bb.dtb.o
-lwl-dtb-$(CONFIG_MACH_GLOBALSCALE_MIRABOX) += armada-370-mirabox-bb.dtb.o
-lwl-dtb-$(CONFIG_MACH_GRINN_LITEBOARD) += imx6ul-liteboard.dtb.o
-lwl-dtb-$(CONFIG_MACH_GUF_SANTARO) += imx6q-guf-santaro.dtb.o
-lwl-dtb-$(CONFIG_MACH_GUF_VINCELL) += imx53-guf-vincell.dtb.o 
imx53-guf-vincell-lt.dtb.o
-lwl-dtb-$(CONFIG_MACH_GW_VENTANA) += imx6q-gw54xx.dtb.o
-lwl-dtb-$(CONFIG_MACH_KONTRON_SAMX6I) += imx6q-samx6i.dtb.o \
+lwl-$(CONFIG_MACH_ADVANTECH_ROM_742X) += imx6dl-advantech-rom-7421.dtb.o
+lwl-$(CONFIG_MACH_AFI_GF) += am335x-afi-gf.dtb.o
+lwl-$(CONFIG_MACH_BEAGLEBONE) += am335x-bone.dtb.o am335x-boneblack.dtb.o 
am335x-bone-common.dtb.o
+lwl-$(CONFIG_MACH_CANON_A1100) += canon-a1100.dtb.o
+lwl-$(CONFIG_MACH_CM_FX6) += imx6dl-cm-fx6.dtb.o imx6q-cm-fx6.dtb.o 
imx6q-utilite.dtb.o
+lwl-$(CONFIG_MACH_DFI_FS700_M60) += imx6q-dfi-fs700-m60-6q.dtb.o 
imx6dl-dfi-fs700-m60-6s.dtb.o
+lwl-$(CONFIG_MACH_DUCKBILL) += imx28-duckbill.dtb.o
+lwl-$(CONFIG_MACH_KINDLE_MX50) += imx50-kindle-d01100.dtb.o 
imx50-kindle-d01200.dtb.o imx50-kindle-ey21.dtb.o
+lwl-$(CONFIG_MACH_EFIKA_MX_SMARTBOOK) += imx51-genesi-efika-sb.dtb.o
+lwl-$(CONFIG_MACH_ELTEC_HIPERCAM) += imx6dl-eltec-hipercam.dtb.o
+lwl-$(CONFIG_MACH_EMBEST_MARSBOARD) += imx6q-marsboard.dtb.o
+lwl-$(CONFIG_MACH_EMBEST_RIOTBOARD) += imx6s-riotboard.dtb.o
+lwl-$(CONFIG_MACH_EMBEDSKY_E9) += imx6q-embedsky-e9.dtb.o
+lwl-$(CONFIG_MACH_FREESCALE_MX51_PDK) += imx51-babbage.dtb.o
+lwl-$(CONFIG_MACH_FREESCALE_MX53_LOCO) += imx53-qsb.dtb.o imx53-qsrb.dtb.o
+lwl-$(CONFIG_MACH_TX53) += imx53-tx53-xx30.dtb.o imx53-tx53-1011.dtb.o
+lwl-$(CONFIG_MACH_CCMX51) += imx51-ccxmx51.dtb.o
+lwl-$(CONFIG_MACH_CCMX53) += imx53-ccxmx53.dtb.o
+lwl-$(CONFIG_MACH_DIGI_CCIMX6ULSBCPRO) += imx6

[PATCH 1/8] kbuild: rename pbl object pbl-*.o to *.pbl.o

2020-05-19 Thread Masahiro Yamada
Currently, pbl objects are output to:

  /pbl-.o

This commit changes as follows:

  /.pbl.o

The motivation is not only to get rid of the ugly code introduced by
commit 257abdaa36c8 ("Do not rm the path from pbl-y target"), but also
to make it easier to remove obj-dtb-y, pbl-dtb-y, lwl-dtb-y syntax in
the next commit.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/boards/nvidia-beaver/Makefile   |  2 +-
 arch/arm/boards/nvidia-jetson-tk1/Makefile   |  2 +-
 arch/arm/boards/toradex-colibri-t20/Makefile |  2 +-
 arch/arm/boards/toshiba-ac100/Makefile   |  2 +-
 arch/arm/cpu/Makefile| 12 ++--
 arch/arm/mach-tegra/Makefile |  2 +-
 lib/Makefile |  5 ++---
 scripts/Makefile.build   |  4 ++--
 scripts/Makefile.lib |  4 ++--
 9 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/arch/arm/boards/nvidia-beaver/Makefile 
b/arch/arm/boards/nvidia-beaver/Makefile
index f0eb7b2de..1b90eb13f 100644
--- a/arch/arm/boards/nvidia-beaver/Makefile
+++ b/arch/arm/boards/nvidia-beaver/Makefile
@@ -1,4 +1,4 @@
-CFLAGS_pbl-entry.o := -mcpu=arm7tdmi -march=armv4t
+CFLAGS_entry.pbl.o := -mcpu=arm7tdmi -march=armv4t
 soc := tegra30
 lwl-y += entry.o
 obj-y += board.o
diff --git a/arch/arm/boards/nvidia-jetson-tk1/Makefile 
b/arch/arm/boards/nvidia-jetson-tk1/Makefile
index 5487f0289..d38001c15 100644
--- a/arch/arm/boards/nvidia-jetson-tk1/Makefile
+++ b/arch/arm/boards/nvidia-jetson-tk1/Makefile
@@ -1,4 +1,4 @@
-CFLAGS_pbl-entry.o := -mcpu=arm7tdmi -march=armv4t
+CFLAGS_entry.pbl.o := -mcpu=arm7tdmi -march=armv4t
 soc := tegra124
 lwl-y += entry.o
 obj-y += board.o
diff --git a/arch/arm/boards/toradex-colibri-t20/Makefile 
b/arch/arm/boards/toradex-colibri-t20/Makefile
index 644a8e526..cdce48d1f 100644
--- a/arch/arm/boards/toradex-colibri-t20/Makefile
+++ b/arch/arm/boards/toradex-colibri-t20/Makefile
@@ -1,4 +1,4 @@
-CFLAGS_pbl-entry.o := -mcpu=arm7tdmi -march=armv4t
+CFLAGS_entry.pbl.o := -mcpu=arm7tdmi -march=armv4t
 soc := tegra20
 lwl-y += entry.o
 obj-y += board.o
diff --git a/arch/arm/boards/toshiba-ac100/Makefile 
b/arch/arm/boards/toshiba-ac100/Makefile
index 4ef18c0ce..e8158cb25 100644
--- a/arch/arm/boards/toshiba-ac100/Makefile
+++ b/arch/arm/boards/toshiba-ac100/Makefile
@@ -1,3 +1,3 @@
-CFLAGS_pbl-entry.o := -mcpu=arm7tdmi -march=armv4t
+CFLAGS_entry.pbl.o := -mcpu=arm7tdmi -march=armv4t
 lwl-y += entry.o
 obj-y += board.o
diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile
index 63cf35c29..f7f9c3041 100644
--- a/arch/arm/cpu/Makefile
+++ b/arch/arm/cpu/Makefile
@@ -6,7 +6,7 @@ obj-pbl-y += lowlevel$(S64).o
 obj-pbl-$(CONFIG_MMU) += mmu-early$(S64).o
 obj-pbl-$(CONFIG_CPU_32v7) += hyp.o
 AFLAGS_hyp.o :=-Wa,-march=armv7-a -Wa,-mcpu=all
-AFLAGS_pbl-hyp.o :=-Wa,-march=armv7-a -Wa,-mcpu=all
+AFLAGS_hyp.pbl.o :=-Wa,-march=armv7-a -Wa,-mcpu=all
 
 obj-y += start.o entry.o entry_ll$(S64).o
 
@@ -32,20 +32,20 @@ obj-$(CONFIG_ARM_PSCI) += psci.o
 obj-$(CONFIG_ARM_PSCI_OF) += psci-of.o
 obj-pbl-$(CONFIG_ARM_SMCCC) += smccc-call$(S64).o
 AFLAGS_smccc-call$(S64).o :=-Wa,-march=armv$(if $(S64),8,7)-a
-AFLAGS_pbl-smccc-call$(S64).o :=-Wa,-march=armv$(if $(S64),8,7)-a
+AFLAGS_smccc-call$(S64).pbl.o :=-Wa,-march=armv$(if $(S64),8,7)-a
 obj-$(CONFIG_ARM_SECURE_MONITOR) += sm.o sm_as.o
 AFLAGS_sm_as.o :=-Wa,-march=armv7-a
 
 obj-pbl-$(CONFIG_CPU_32v4T) += cache-armv4.o
 obj-pbl-$(CONFIG_CPU_32v5) += cache-armv5.o
 obj-pbl-$(CONFIG_CPU_32v6) += cache-armv6.o
-AFLAGS_cache-armv7.o   :=-Wa,-march=armv7-a
 obj-pbl-$(CONFIG_CPU_32v7) += cache-armv7.o
-AFLAGS_pbl-cache-armv7.o   :=-Wa,-march=armv7-a
+AFLAGS_cache-armv7.o   :=-Wa,-march=armv7-a
+AFLAGS_cache-armv7.pbl.o   :=-Wa,-march=armv7-a
 obj-$(CONFIG_CACHE_L2X0) += cache-l2x0.o
-AFLAGS_cache-armv8.o   :=-Wa,-march=armv8-a
 obj-pbl-$(CONFIG_CPU_64v8) += cache-armv8.o
-AFLAGS_pbl-cache-armv8.o   :=-Wa,-march=armv8-a
+AFLAGS_cache-armv8.o   :=-Wa,-march=armv8-a
+AFLAGS-cache-armv8.pbl.o   :=-Wa,-march=armv8-a
 
 pbl-y += entry.o entry_ll$(S64).o
 pbl-y += uncompress.o
diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile
index 754795175..60aae41ea 100644
--- a/arch/arm/mach-tegra/Makefile
+++ b/arch/arm/mach-tegra/Makefile
@@ -1,5 +1,5 @@
 CFLAGS_tegra_avp_init.o := -mcpu=arm7tdmi -march=armv4t
-CFLAGS_pbl-tegra_avp_init.o := -mcpu=arm7tdmi -march=armv4t
+CFLAGS_tegra_avp_init.pbl.o := -mcpu=arm7tdmi -march=armv4t
 lwl-y += tegra_avp_init.o
 lwl-y += tegra_maincomplex_init.o
 obj-y += tegra20.o
diff --git a/lib/Makefile b/lib/Makefile
index 56040a0d5..f370d167b 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -86,8 +86,7 @@ UBSAN_SANITIZE_ubsan.o := n
 libfdt_files = fdt.o fdt_ro.o fdt_wip.o fdt_rw.o fdt_sw.o fdt_strerror.o \
  fdt_empty_tree.o
 $(foreach file, $(libfdt_files), \
-   $(eval CFLAGS_$(file) = -I $(srctree)/scripts/

Re: [PATCH 1/2] kconfig: add 'option modules' to allow tristate options to become m

2020-05-18 Thread Masahiro Yamada
On Tue, May 19, 2020 at 2:55 AM Masahiro Yamada  wrote:
>
> Since commit 18895514dc5e ("kconfig: update to v3.18-rc6"), tristate
> symbols cannot become 'm'.
>
> In old days of Linux, CONFIG_MODULES was the special hard-coded in
> Kconfig.


Please reword this paragraph as follows:


In old days of Linux, CONFIG_MODULES was the special option hard-coded
in Kconfig.



>
> The current Kconfig does not know which option is it. You need to
> specify 'option modules' to teach Kconfig that it is the module
> support switch.
>
> Add 'option modules' to revive the module builds.
>
> Fixes: 18895514dc5e ("kconfig: update to v3.18-rc6")
> Signed-off-by: Masahiro Yamada 
> ---
>
> The module feature has been broken for 8 years,
> and nobody has pointed it out...
>
>  common/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/common/Kconfig b/common/Kconfig
> index 460ac487c..7a99d20bf 100644
> --- a/common/Kconfig
> +++ b/common/Kconfig
> @@ -316,6 +316,7 @@ config MODULES
> depends on HAS_MODULES
> depends on EXPERIMENTAL
> bool "module support"
> +   option modules
> help
>   This option enables support for loadable modules via insmod. Module
>   support is quite experimental at the moment. There is no convenient
> --
> 2.25.1
>


-- 
Best Regards
Masahiro Yamada

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/2] kbuild: build modules by 'make'

2020-05-18 Thread Masahiro Yamada
In Linux, 'make' and 'make all' work equivalently; it builds both
vmlinux and modules.

In barebox, strangely, 'make all' builds both barebox and modules,
but 'make' builds only barebox because KBUILD_MODULES is unset.

The check for 'ifeq ($(MAKECMDGOALS),)' is missing since the day-one.

Fixes: b02e0966412c ("add additional linking stage for modules")
Signed-off-by: Masahiro Yamada 
---

 Makefile | 4 
 1 file changed, 4 insertions(+)

diff --git a/Makefile b/Makefile
index d477494d6..9f30fafdd 100644
--- a/Makefile
+++ b/Makefile
@@ -533,6 +533,10 @@ ifneq ($(filter all _all modules,$(MAKECMDGOALS)),)
   KBUILD_MODULES := 1
 endif
 
+ifeq ($(MAKECMDGOALS),)
+  KBUILD_MODULES := 1
+endif
+
 export KBUILD_MODULES KBUILD_BUILTIN
 
 ifdef need-config
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/2] kconfig: add 'option modules' to allow tristate options to become m

2020-05-18 Thread Masahiro Yamada
Since commit 18895514dc5e ("kconfig: update to v3.18-rc6"), tristate
symbols cannot become 'm'.

In old days of Linux, CONFIG_MODULES was the special hard-coded in
Kconfig.

The current Kconfig does not know which option is it. You need to
specify 'option modules' to teach Kconfig that it is the module
support switch.

Add 'option modules' to revive the module builds.

Fixes: 18895514dc5e ("kconfig: update to v3.18-rc6")
Signed-off-by: Masahiro Yamada 
---

The module feature has been broken for 8 years,
and nobody has pointed it out...

 common/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/Kconfig b/common/Kconfig
index 460ac487c..7a99d20bf 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -316,6 +316,7 @@ config MODULES
depends on HAS_MODULES
depends on EXPERIMENTAL
bool "module support"
+   option modules
help
  This option enables support for loadable modules via insmod. Module
  support is quite experimental at the moment. There is no convenient
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] kbuild: add -std=gnu89 to KBUILD_CFLAGS

2020-05-18 Thread Masahiro Yamada
Barebox imports lots of code from Linux, so should use the same
language standard as Linux.

Signed-off-by: Masahiro Yamada 
---

 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 7a620b504..d477494d6 100644
--- a/Makefile
+++ b/Makefile
@@ -416,7 +416,7 @@ KBUILD_CPPFLAGS:= -D__KERNEL__ -D__BAREBOX__ 
$(LINUXINCLUDE) -fno-builti
 KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
   -fno-strict-aliasing -fno-common \
-Werror=implicit-function-declaration -Werror=implicit-int \
-   -Os -pipe -Wmissing-prototypes
+   -Os -pipe -Wmissing-prototypes -std=gnu89
 KBUILD_AFLAGS  := -D__ASSEMBLY__
 
 LDFLAGS_barebox:= -Map barebox.map
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] arch: include from

2020-05-17 Thread Masahiro Yamada
Many architectures duplicate the same fixed type definitions
as in .

Include  from , and remove
the duplicated code.

Note:
Linux commit 0c79a8e29b5f ("asm/types.h: Remove
include/asm-generic/int-l64.h") unified the kernel space
definition into int-ll64.h. Barebox also adopts int-ll64.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/include/asm/types.h  | 48 +--
 arch/nios2/include/asm/int-ll64.h | 78 ---
 arch/nios2/include/asm/types.h|  2 +-
 arch/openrisc/include/asm/types.h | 48 +--
 arch/powerpc/include/asm/types.h  | 35 +-
 arch/riscv/include/asm/types.h| 42 +
 arch/sandbox/include/asm/types.h  | 42 +
 arch/x86/include/asm/types.h  | 42 +
 8 files changed, 11 insertions(+), 326 deletions(-)
 delete mode 100644 arch/nios2/include/asm/int-ll64.h

diff --git a/arch/arm/include/asm/types.h b/arch/arm/include/asm/types.h
index 9c2106688..22b964265 100644
--- a/arch/arm/include/asm/types.h
+++ b/arch/arm/include/asm/types.h
@@ -1,52 +1,6 @@
 #ifndef __ASM_ARM_TYPES_H
 #define __ASM_ARM_TYPES_H
 
-#ifndef __ASSEMBLY__
-
-/*
- * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
- * header files exported to user space
- */
-
-typedef __signed__ char __s8;
-typedef unsigned char __u8;
-
-typedef __signed__ short __s16;
-typedef unsigned short __u16;
-
-typedef __signed__ int __s32;
-typedef unsigned int __u32;
-
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
-typedef __signed__ long long __s64;
-typedef unsigned long long __u64;
-#endif
-
-#endif /* __ASSEMBLY__ */
-
-/*
- * These aren't exported outside the kernel to avoid name space clashes
- */
-#ifdef __KERNEL__
-
-#include 
-
-#ifndef __ASSEMBLY__
-
-typedef signed char s8;
-typedef unsigned char u8;
-
-typedef signed short s16;
-typedef unsigned short u16;
-
-typedef signed int s32;
-typedef unsigned int u32;
-
-typedef signed long long s64;
-typedef unsigned long long u64;
-
-#endif /* __ASSEMBLY__ */
-
-#endif /* __KERNEL__ */
+#include 
 
 #endif
diff --git a/arch/nios2/include/asm/int-ll64.h 
b/arch/nios2/include/asm/int-ll64.h
deleted file mode 100644
index f394147c0..0
--- a/arch/nios2/include/asm/int-ll64.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * asm-generic/int-ll64.h
- *
- * Integer declarations for architectures which use "long long"
- * for 64-bit types.
- */
-
-#ifndef _ASM_GENERIC_INT_LL64_H
-#define _ASM_GENERIC_INT_LL64_H
-
-#include 
-
-#ifndef __ASSEMBLY__
-/*
- * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
- * header files exported to user space
- */
-
-typedef __signed__ char __s8;
-typedef unsigned char __u8;
-
-typedef __signed__ short __s16;
-typedef unsigned short __u16;
-
-typedef __signed__ int __s32;
-typedef unsigned int __u32;
-
-#ifdef __GNUC__
-__extension__ typedef __signed__ long long __s64;
-__extension__ typedef unsigned long long __u64;
-#else
-typedef __signed__ long long __s64;
-typedef unsigned long long __u64;
-#endif
-
-#endif /* __ASSEMBLY__ */
-
-#ifdef __KERNEL__
-
-#ifndef __ASSEMBLY__
-
-typedef signed char s8;
-typedef unsigned char u8;
-
-typedef signed short s16;
-typedef unsigned short u16;
-
-typedef signed int s32;
-typedef unsigned int u32;
-
-typedef signed long long s64;
-typedef unsigned long long u64;
-
-#define S8_C(x)  x
-#define U8_C(x)  x ## U
-#define S16_C(x) x
-#define U16_C(x) x ## U
-#define S32_C(x) x
-#define U32_C(x) x ## U
-#define S64_C(x) x ## LL
-#define U64_C(x) x ## ULL
-
-#else /* __ASSEMBLY__ */
-
-#define S8_C(x)  x
-#define U8_C(x)  x
-#define S16_C(x) x
-#define U16_C(x) x
-#define S32_C(x) x
-#define U32_C(x) x
-#define S64_C(x) x
-#define U64_C(x) x
-
-#endif /* __ASSEMBLY__ */
-
-#endif /* __KERNEL__ */
-
-#endif /* _ASM_GENERIC_INT_LL64_H */
diff --git a/arch/nios2/include/asm/types.h b/arch/nios2/include/asm/types.h
index 0067ea83c..380ad340c 100644
--- a/arch/nios2/include/asm/types.h
+++ b/arch/nios2/include/asm/types.h
@@ -1,6 +1,6 @@
 #ifndef __ASM_TYPES_H
 #define __ASM_TYPES_H
 
-#include 
+#include 
 
 #endif
diff --git a/arch/openrisc/include/asm/types.h 
b/arch/openrisc/include/asm/types.h
index 8ee6bb00f..21a45b74c 100644
--- a/arch/openrisc/include/asm/types.h
+++ b/arch/openrisc/include/asm/types.h
@@ -16,52 +16,6 @@
 #ifndef _ASM_TYPES_H
 #define _ASM_TYPES_H
 
-/*
- * This file is never included by application software unless
- * explicitly requested (e.g., via linux/types.h) in which case the
- * application is Linux specific so (user-) name space pollution is
- * not a major issue.  However, for interoperability, libraries still
- * need to be careful to avoid a name clashes.
- */
-
-/*
- * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
- * header files exported to user space
- */
-
-typedef __signed__ char __s8;
-typedef unsigned char __u8;
-
-typedef __signed__ short __s16;
-typedef unsig

Re: [PATCH] clocksource: kvx: remove unused variable np.

2020-05-17 Thread Masahiro Yamada
On Sat, May 16, 2020 at 12:40 AM Clement Leger  wrote:


No period at the end of the patch subject, please.

(Maybe, Sascha can fix it up, though)


> Remove unused variable np from probe function.
>
> Signed-off-by: Clement Leger 
> ---
>  drivers/clocksource/kvx_timer.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/drivers/clocksource/kvx_timer.c b/drivers/clocksource/kvx_timer.c
> index f16d77b9d..4125ddbee 100644
> --- a/drivers/clocksource/kvx_timer.c
> +++ b/drivers/clocksource/kvx_timer.c
> @@ -27,7 +27,6 @@ static int kvx_timer_probe(struct device_d *dev)
>  {
> struct clk *clk;
> uint32_t clk_freq;
> -   struct device_node *np = dev->device_node;
>
> /* Get clock frequency */
> clk = clk_get(dev, NULL);
> --
> 2.17.1
>
>
> ___
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox



-- 
Best Regards
Masahiro Yamada

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] kvx: do not include empty

2020-05-15 Thread Masahiro Yamada
 is per-board config file, which is only allowed for old
boards.

For new boards, the top Makefile creates an empty include/config.h

kvx does not have config.h, so #include  is useless.

Also, remove meaningless board-$(CONFIG_GENERIC).

Signed-off-by: Masahiro Yamada 
---

 arch/kvx/Makefile  | 2 --
 arch/kvx/cpu/barebox.lds.S | 1 -
 arch/kvx/cpu/start.S   | 1 -
 3 files changed, 4 deletions(-)

diff --git a/arch/kvx/Makefile b/arch/kvx/Makefile
index c97cff345..7abaed651 100644
--- a/arch/kvx/Makefile
+++ b/arch/kvx/Makefile
@@ -2,8 +2,6 @@ KBUILD_DEFCONFIG := generic_defconfig
 
 KBUILD_CPPFLAGS += -fno-strict-aliasing
 
-board-$(CONFIG_GENERIC) := generic
-
 KALLSYMS += --symbol-prefix=_
 
 ifeq ($(CROSS_COMPILE),)
diff --git a/arch/kvx/cpu/barebox.lds.S b/arch/kvx/cpu/barebox.lds.S
index 8d1944afb..bf92564cf 100644
--- a/arch/kvx/cpu/barebox.lds.S
+++ b/arch/kvx/cpu/barebox.lds.S
@@ -3,7 +3,6 @@
  * Copyright (C) 2019 Kalray Inc.
  */
 
-#include 
 #include 
 #include 
 #include 
diff --git a/arch/kvx/cpu/start.S b/arch/kvx/cpu/start.S
index a02900fb9..d90272c71 100644
--- a/arch/kvx/cpu/start.S
+++ b/arch/kvx/cpu/start.S
@@ -3,7 +3,6 @@
  * Copyright (C) 2019 Kalray Inc.
  */
 
-#include 
 #include 
 #include 
 #include 
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] .gitignore: drop stale ignore pattern include/asm

2020-05-15 Thread Masahiro Yamada
In old days, Linux created a symlink include/asm -> include/asm-*,
but all the asm headers were moved to arch/*/include/asm, which
is the same for Barebox too.

Remove the bitrotten ignore pattern.

Signed-off-by: Masahiro Yamada 
---

 include/.gitignore | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/.gitignore b/include/.gitignore
index f28372a3d..18e58a752 100644
--- a/include/.gitignore
+++ b/include/.gitignore
@@ -1,2 +1 @@
-asm
 /config.h
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/2] kbuild: resync top Makefile, mkmakefile, tags.sh with Linux 5.7-rc4

2020-05-10 Thread Masahiro Yamada
The prologue of the build system is not specific to Linux or Barebox.
Paritially resync with Linux 5.7-rc4

- In Linux, $(objtree) is always '.', and $(srctree) might be relative.
  I am keeping both absolute for now to avoid unexpected breakage.

- I did not resync single target for now. We need to touch
  Makefile.build a lot if we want to resync it.

- 'export CDPATH=' is Barebox-only code, which was added by
  commit 6cc8d0544658 ("Makefile: disable CDPATH"). Keep it.

- KBUILD_SRC no longer exists in the upstream Linux. I replaced it
  with building_out_of_srctree.

- scripts/mkmakefile does not contain anything specific to Linux or
  Barebox. Resync it with Linux 5.7-rc4

- scripts/tags was imported from Linux 3.6 with some cherry-picks on
  top of that. Resync it with Linux 5.7-rc4

Signed-off-by: Masahiro Yamada 
---

 Makefile   | 605 +++--
 firmware/Makefile  |   2 +-
 scripts/Makefile.build |   2 +-
 scripts/Makefile.host  |   2 +-
 scripts/Makefile.lib   |   2 +-
 scripts/mkmakefile |  43 +--
 scripts/tags.sh| 282 ---
 7 files changed, 538 insertions(+), 400 deletions(-)

diff --git a/Makefile b/Makefile
index be9f2a211..837ae47e2 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
 VERSION = 2020
 PATCHLEVEL = 04
 SUBLEVEL = 0
@@ -10,11 +11,9 @@ NAME = None
 # Comments in this file are targeted only to the developer, do not
 # expect to learn how to build the kernel reading this file.
 
-# Do not:
-# o  use make's built-in rules and variables
-#(this increases performance and avoids hard-to-debug behaviour);
-# o  print "Entering directory ...";
-MAKEFLAGS += -rR --no-print-directory
+# That's our default target when none is given on the command line
+PHONY := _all
+_all:
 
 # We are using a recursive build, so we need to do a little thinking
 # to get the ordering right.
@@ -22,8 +21,8 @@ MAKEFLAGS += -rR --no-print-directory
 # Most importantly: sub-Makefiles should only ever modify files in
 # their own directory. If in some directory we have a dependency on
 # a file in another dir (which doesn't happen often, but it's often
-# unavoidable when linking the built-in.o targets which finally
-# turn into barebox), we will call a sub make in that other dir, and
+# unavoidable when linking the built-in.a targets which finally
+# turn into vmlinux), we will call a sub make in that other dir, and
 # after that we are sure that everything which is in that other dir
 # is now up to date.
 #
@@ -32,6 +31,45 @@ MAKEFLAGS += -rR --no-print-directory
 # descending is started. They are now explicitly listed as the
 # prepare rule.
 
+ifneq ($(sub_make_done),1)
+
+# Do not use make's built-in rules and variables
+# (this increases performance and avoids hard-to-debug behaviour)
+MAKEFLAGS += -rR
+
+# Avoid funny character set dependencies
+unexport LC_ALL
+LC_COLLATE=C
+LC_NUMERIC=C
+export LC_COLLATE LC_NUMERIC
+
+# Avoid interference with shell env settings
+unexport GREP_OPTIONS
+
+# Beautify output
+# ---
+#
+# Normally, we echo the whole command before executing it. By making
+# that echo $($(quiet)$(cmd)), we now have the possibility to set
+# $(quiet) to choose other forms of output instead, e.g.
+#
+# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
+# cmd_cc_o_c   = $(CC) $(c_flags) -c -o $@ $<
+#
+# If $(quiet) is empty, the whole command will be printed.
+# If it is set to "quiet_", only the short version will be printed.
+# If it is set to "silent_", nothing will be printed at all, since
+# the variable $(silent_cmd_cc_o_c) doesn't exist.
+#
+# A simple variant is to prefix commands with $(Q) - that's useful
+# for commands that shall be hidden in non-verbose mode.
+#
+#  $(Q)ln $@ :<
+#
+# If KBUILD_VERBOSE equals 0 then the above command will be hidden.
+# If KBUILD_VERBOSE equals 1 then the above command is displayed.
+# If KBUILD_VERBOSE equals 2 then give the reason why each target is rebuilt.
+#
 # To put more focus on warnings, be less verbose as default
 # Use 'make V=1' to see the full commands
 
@@ -42,6 +80,119 @@ ifndef KBUILD_VERBOSE
   KBUILD_VERBOSE = 0
 endif
 
+ifeq ($(KBUILD_VERBOSE),1)
+  quiet =
+  Q =
+else
+  quiet=quiet_
+  Q = @
+endif
+
+# If the user is running make -s (silent mode), suppress echoing of
+# commands
+
+ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
+  quiet=silent_
+endif
+
+export quiet Q KBUILD_VERBOSE
+
+# Kbuild will save output files in the current working directory.
+# This does not need to match to the root of the kernel source tree.
+#
+# For example, you can do this:
+#
+#  cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile
+#
+# If you want to save output files in a different location, there are
+

[PATCH 1/2] arch: remove KBUILD_SRC checks from arch Makefile

2020-05-10 Thread Masahiro Yamada
You can always add $(srctree)/ to the mach include path.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/Makefile| 4 
 arch/mips/Makefile   | 4 
 arch/powerpc/Makefile| 4 
 arch/riscv/Makefile  | 4 
 arch/sandbox/Makefile| 4 
 arch/sandbox/os/Makefile | 4 
 arch/x86/Makefile| 4 
 7 files changed, 28 deletions(-)

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 62b397a73..6c7373c20 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -127,11 +127,7 @@ board-$(CONFIG_MACH_TINY6410)  += 
friendlyarm-tiny6410
 
 machdirs := $(patsubst %,arch/arm/mach-%/,$(machine-y))
 
-ifeq ($(KBUILD_SRC),)
-KBUILD_CPPFLAGS += $(patsubst %,-I%include,$(machdirs))
-else
 KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs))
-endif
 
 TEXT_BASE = $(CONFIG_TEXT_BASE)
 
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index abfa82504..5604a0a10 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -82,11 +82,7 @@ machine-$(CONFIG_MACH_MIPS_LOONGSON) := loongson
 machine-$(CONFIG_MACH_MIPS_XBURST) := xburst
 machdirs := $(patsubst %,arch/mips/mach-%/,$(machine-y))
 
-ifeq ($(KBUILD_SRC),)
-KBUILD_CPPFLAGS += $(patsubst %,-I%include,$(machdirs))
-else
 KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs))
-endif
 
 ifneq ($(machine-y),)
 MACH  := arch/mips/mach-$(machine-y)/
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 148377791..aa7626049 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -36,11 +36,7 @@ endif
 
 machdirs := $(patsubst %,arch/powerpc/mach-%/,$(machine-y))
 
-ifeq ($(KBUILD_SRC),)
-KBUILD_CPPFLAGS += $(patsubst %,-I%include,$(machdirs))
-else
 KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs))
-endif
 
 archprepare: maketools
 
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 5096bde0d..c71319507 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -27,11 +27,7 @@ KBUILD_BINARY := barebox.bin
 
 machdirs := $(patsubst %,arch/riscv/mach-%/,$(machine-y))
 
-ifeq ($(KBUILD_SRC),)
-KBUILD_CPPFLAGS += $(patsubst %,-I%include,$(machdirs))
-else
 KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs))
-endif
 
 archprepare: maketools
 
diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
index c205f47ff..3d2eb5bc1 100644
--- a/arch/sandbox/Makefile
+++ b/arch/sandbox/Makefile
@@ -29,11 +29,7 @@ KBUILD_CFLAGS += -Dmalloc=barebox_malloc 
-Dcalloc=barebox_calloc \
 
 machdirs := $(patsubst %,arch/sandbox/mach-%/,$(machine-y))
 
-ifeq ($(KBUILD_SRC),)
-KBUILD_CPPFLAGS += $(patsubst %,-I%include,$(machdirs))
-else
 KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs))
-endif
 
 archprepare: maketools
 
diff --git a/arch/sandbox/os/Makefile b/arch/sandbox/os/Makefile
index 40306b5ff..c012c9cf0 100644
--- a/arch/sandbox/os/Makefile
+++ b/arch/sandbox/os/Makefile
@@ -2,11 +2,7 @@ machine-y := sandbox
 
 machdirs := $(patsubst %,arch/sandbox/mach-%/,$(machine-y))
 
-ifeq ($(KBUILD_SRC),)
-KBUILD_CPPFLAGS := $(patsubst %,-I%include,$(machdirs))
-else
 KBUILD_CPPFLAGS = $(patsubst %,-I$(srctree)/%include,$(machdirs))
-endif
 
 KBUILD_CPPFLAGS += -DCONFIG_MALLOC_SIZE=$(CONFIG_MALLOC_SIZE)
 
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index c93a680e4..97f6d85f2 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -46,11 +46,7 @@ endif
 
 machdirs := $(patsubst %,arch/x86/mach-%/,$(machine-y))
 
-ifeq ($(KBUILD_SRC),)
-KBUILD_CPPFLAGS += $(patsubst %,-I%include,$(machdirs))
-else
 KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs))
-endif
 
 ifneq ($(board-y),)
 BOARD  := arch/x86/boards/$(board-y)/
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2] module.h: split out the EXPORT_SYMBOL into export.h

2020-05-08 Thread Masahiro Yamada
Do as Linux commit f50169324df4ad942e544386d136216c8617636a

Signed-off-by: Masahiro Yamada 
---

Changes in v2:
  - move THIS_MODULE

 include/linux/export.h | 39 +++
 include/module.h   | 28 +---
 2 files changed, 40 insertions(+), 27 deletions(-)
 create mode 100644 include/linux/export.h

diff --git a/include/linux/export.h b/include/linux/export.h
new file mode 100644
index 0..88d318bd8
--- /dev/null
+++ b/include/linux/export.h
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef _LINUX_EXPORT_H
+#define _LINUX_EXPORT_H
+
+#define THIS_MODULE0
+
+#ifdef CONFIG_MODULES
+
+struct kernel_symbol
+{
+   unsigned long value;
+   const char *name;
+};
+
+/* For every exported symbol, place a struct in the __ksymtab section */
+#define __EXPORT_SYMBOL(sym, sec)  \
+   extern typeof(sym) sym; \
+   static const char __ustrtab_##sym[] \
+   __attribute__((section("__usymtab_strings")))   \
+   = MODULE_SYMBOL_PREFIX #sym;\
+   static const struct kernel_symbol __usymtab_##sym   \
+   __used \
+   __attribute__((section("__usymtab" sec), unused))   \
+   = { (unsigned long)&sym, __ustrtab_##sym }
+
+#define EXPORT_SYMBOL(sym) \
+   __EXPORT_SYMBOL(sym, "")
+
+#define EXPORT_SYMBOL_GPL(sym) \
+   __EXPORT_SYMBOL(sym, "")
+
+#else
+
+#define EXPORT_SYMBOL(sym)
+#define EXPORT_SYMBOL_GPL(sym)
+
+#endif /* CONFIG_MODULES */
+
+#endif /* _LINUX_EXPORT_H */
diff --git a/include/module.h b/include/module.h
index abf740a78..cea8c2e18 100644
--- a/include/module.h
+++ b/include/module.h
@@ -4,6 +4,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #ifndef MODULE_SYMBOL_PREFIX
@@ -11,36 +12,12 @@
 #endif
 
 #define MODULE_NAME_LEN (64 - sizeof(unsigned long))
-#define THIS_MODULE0
 
 #ifdef CONFIG_MODULES
 #include 
 
-struct kernel_symbol
-{
-   unsigned long value;
-   const char *name;
-};
-
 struct module * load_module(void *mod_image, unsigned long len);
 
-/* For every exported symbol, place a struct in the __ksymtab section */
-#define __EXPORT_SYMBOL(sym, sec)  \
-   extern typeof(sym) sym; \
-   static const char __ustrtab_##sym[] \
-   __attribute__((section("__usymtab_strings")))   \
-   = MODULE_SYMBOL_PREFIX #sym;\
-   static const struct kernel_symbol __usymtab_##sym   \
-   __used \
-   __attribute__((section("__usymtab" sec), unused))   \
-   = { (unsigned long)&sym, __ustrtab_##sym }
-
-#define EXPORT_SYMBOL(sym) \
-   __EXPORT_SYMBOL(sym, "")
-
-#define EXPORT_SYMBOL_GPL(sym) \
-   __EXPORT_SYMBOL(sym, "")
-
 struct module {
/* Unique handle for this module */
char name[MODULE_NAME_LEN];
@@ -74,9 +51,6 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
   unsigned int symindex,
   unsigned int relsec,
   struct module *mod);
-#else
-#define EXPORT_SYMBOL(sym)
-#define EXPORT_SYMBOL_GPL(sym)
 #endif /* CONFIG_MODULES */
 
 extern struct list_head module_list;
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] module.h: split out the EXPORT_SYMBOL into export.h

2020-05-08 Thread Masahiro Yamada
Do as Linux commit f50169324df4ad942e544386d136216c8617636a

Signed-off-by: Masahiro Yamada 
---

 include/linux/export.h | 37 +
 include/module.h   | 28 +---
 2 files changed, 38 insertions(+), 27 deletions(-)
 create mode 100644 include/linux/export.h

diff --git a/include/linux/export.h b/include/linux/export.h
new file mode 100644
index 0..55640a2c6
--- /dev/null
+++ b/include/linux/export.h
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef _LINUX_EXPORT_H
+#define _LINUX_EXPORT_H
+
+#ifdef CONFIG_MODULES
+
+struct kernel_symbol
+{
+   unsigned long value;
+   const char *name;
+};
+
+/* For every exported symbol, place a struct in the __ksymtab section */
+#define __EXPORT_SYMBOL(sym, sec)  \
+   extern typeof(sym) sym; \
+   static const char __ustrtab_##sym[] \
+   __attribute__((section("__usymtab_strings")))   \
+   = MODULE_SYMBOL_PREFIX #sym;\
+   static const struct kernel_symbol __usymtab_##sym   \
+   __used \
+   __attribute__((section("__usymtab" sec), unused))   \
+   = { (unsigned long)&sym, __ustrtab_##sym }
+
+#define EXPORT_SYMBOL(sym) \
+   __EXPORT_SYMBOL(sym, "")
+
+#define EXPORT_SYMBOL_GPL(sym) \
+   __EXPORT_SYMBOL(sym, "")
+
+#else
+
+#define EXPORT_SYMBOL(sym)
+#define EXPORT_SYMBOL_GPL(sym)
+
+#endif /* CONFIG_MODULES */
+
+#endif /* _LINUX_EXPORT_H */
diff --git a/include/module.h b/include/module.h
index abf740a78..cea8c2e18 100644
--- a/include/module.h
+++ b/include/module.h
@@ -4,6 +4,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #ifndef MODULE_SYMBOL_PREFIX
@@ -11,36 +12,12 @@
 #endif
 
 #define MODULE_NAME_LEN (64 - sizeof(unsigned long))
-#define THIS_MODULE0
 
 #ifdef CONFIG_MODULES
 #include 
 
-struct kernel_symbol
-{
-   unsigned long value;
-   const char *name;
-};
-
 struct module * load_module(void *mod_image, unsigned long len);
 
-/* For every exported symbol, place a struct in the __ksymtab section */
-#define __EXPORT_SYMBOL(sym, sec)  \
-   extern typeof(sym) sym; \
-   static const char __ustrtab_##sym[] \
-   __attribute__((section("__usymtab_strings")))   \
-   = MODULE_SYMBOL_PREFIX #sym;\
-   static const struct kernel_symbol __usymtab_##sym   \
-   __used \
-   __attribute__((section("__usymtab" sec), unused))   \
-   = { (unsigned long)&sym, __ustrtab_##sym }
-
-#define EXPORT_SYMBOL(sym) \
-   __EXPORT_SYMBOL(sym, "")
-
-#define EXPORT_SYMBOL_GPL(sym) \
-   __EXPORT_SYMBOL(sym, "")
-
 struct module {
/* Unique handle for this module */
char name[MODULE_NAME_LEN];
@@ -74,9 +51,6 @@ int apply_relocate_add(Elf_Shdr *sechdrs,
   unsigned int symindex,
   unsigned int relsec,
   struct module *mod);
-#else
-#define EXPORT_SYMBOL(sym)
-#define EXPORT_SYMBOL_GPL(sym)
 #endif /* CONFIG_MODULES */
 
 extern struct list_head module_list;
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/2] kbuild: add -Wall to KBUILD_HOSTCXXFLAGS

2020-05-08 Thread Masahiro Yamada
[ Linux commit 735aab1e008b6d9ba8057caa647b6619bf73460f ]

Add -Wall to catch more warnings for C++ host programs.

Signed-off-by: Masahiro Yamada 
---

 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index a732e24d3..be9f2a211 100644
--- a/Makefile
+++ b/Makefile
@@ -198,7 +198,7 @@ HOSTCXX  = g++
 KBUILD_HOSTCFLAGS   := -Wall -Wstrict-prototypes -O2 \
-fomit-frame-pointer $(HOST_LFS_CFLAGS) \
$(HOSTCFLAGS)
-KBUILD_HOSTCXXFLAGS := -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
+KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
 KBUILD_HOSTLDFLAGS  := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
 KBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
 
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/2] kbuild: add -Werror={strict-prototypes, implicit-int} to KBUILD_CFLAGS

2020-05-08 Thread Masahiro Yamada
- Turn Wstrict-prototypes into an error
- Add -Werror=implicit-int
- Use the standard form -Werror=... for implicit-function-declaration

This commit imports the following Linux commits. They should work for
barebox too.

80970472179a Makefile: enable -Werror=implicit-int and 
-Werror=strict-prototypes by default
eeb5687a7139 kbuild: add -Werror=strict-prototypes flag unconditionally
61a0902a06d6 kbuild: add -Werror=implicit-int flag unconditionally
b89f25ea7892 kbuild: use -Werror=implicit-... instead of -Werror-implicit-...

Signed-off-by: Masahiro Yamada 
---

 Makefile | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 9485f5551..a732e24d3 100644
--- a/Makefile
+++ b/Makefile
@@ -318,9 +318,10 @@ LINUXINCLUDE:= -Iinclude -I$(srctree)/dts/include \
 
 KBUILD_CPPFLAGS:= -D__KERNEL__ -D__BAREBOX__ $(LINUXINCLUDE) 
-fno-builtin -ffreestanding
 
-KBUILD_CFLAGS  := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-   -Werror-implicit-function-declaration \
-   -fno-strict-aliasing -fno-common -Os -pipe 
-Wmissing-prototypes
+KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
+  -fno-strict-aliasing -fno-common \
+   -Werror=implicit-function-declaration -Werror=implicit-int \
+   -Os -pipe -Wmissing-prototypes
 KBUILD_AFLAGS  := -D__ASSEMBLY__
 
 LDFLAGS_barebox:= -Map barebox.map
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/4] common.h: remove unused region_overlap()

2020-05-04 Thread Masahiro Yamada
This is not used at all.

Signed-off-by: Masahiro Yamada 
---

 include/common.h | 9 -
 1 file changed, 9 deletions(-)

diff --git a/include/common.h b/include/common.h
index d73fc3d13..3570e6aba 100644
--- a/include/common.h
+++ b/include/common.h
@@ -142,15 +142,6 @@ void barebox_set_hostname_no_overwrite(const char *);
 /*
  * Check if two regions overlap. returns true if they do, false otherwise
  */
-static inline bool region_overlap(unsigned long starta, unsigned long lena,
-   unsigned long startb, unsigned long lenb)
-{
-   if (starta + lena <= startb)
-   return 0;
-   if (startb + lenb <= starta)
-   return 0;
-   return 1;
-}
 
 static inline bool lregion_overlap(loff_t starta, loff_t lena,
   loff_t startb, loff_t lenb)
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/4] nios2: include from asm/io.h

2020-05-04 Thread Masahiro Yamada
 is a collection of default of various accessors.

All the other architectures include  as a fallback.
Do likewise for NIOS2.

Signed-off-by: Masahiro Yamada 
---

 arch/nios2/include/asm/io.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/nios2/include/asm/io.h b/arch/nios2/include/asm/io.h
index 360d786ea..a964c695e 100644
--- a/arch/nios2/include/asm/io.h
+++ b/arch/nios2/include/asm/io.h
@@ -46,4 +46,6 @@
 #define writel(val, addr)\
asm volatile("stwio %0, 0(%1)" : : "r" (val), "r" (addr))
 
+#include 
+
 #endif /* __ASM_NIOS2_IO_H_ */
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 4/4] common.h: move the generic IOMEM definition to asm-generic/io.h

2020-05-04 Thread Masahiro Yamada
arch/mips/include/asm/io.h defines arch-specific IOMEM().

The generic definition of IOMEM() should go to asm-generic/io.h
because it is a collection of fallback defaults when there is no
specific definition in .

Signed-off-by: Masahiro Yamada 
---

 include/asm-generic/io.h | 4 
 include/common.h | 4 
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 973b8b954..76e6d0dc1 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -420,4 +420,8 @@ static inline void iowrite64be(u64 value, volatile void 
__iomem *addr)
 #endif
 #endif /* CONFIG_64BIT */
 
+#ifndef IOMEM
+#define IOMEM(addr)((void __force __iomem *)(addr))
+#endif
+
 #endif /* __ASM_GENERIC_IO_H */
diff --git a/include/common.h b/include/common.h
index 0bf819a6f..ce16ff83a 100644
--- a/include/common.h
+++ b/include/common.h
@@ -135,8 +135,4 @@ const char *barebox_get_hostname(void);
 void barebox_set_hostname(const char *);
 void barebox_set_hostname_no_overwrite(const char *);
 
-#ifndef IOMEM
-#define IOMEM(addr)((void __force __iomem *)(addr))
-#endif
-
 #endif /* __COMMON_H_ */
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/4] common.h: move and rename lregion_overlap()

2020-05-04 Thread Masahiro Yamada
lregion_overlap() is only used by common/startup.c

There is no need to define it in include/common.h

While I was here, I also renamed it to region_overlap(), and got rid
of the 'inline' keyword.

Signed-off-by: Masahiro Yamada 
---

 common/startup.c | 14 --
 include/common.h | 14 --
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/common/startup.c b/common/startup.c
index 2c3a999e1..511675ed5 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -74,6 +74,16 @@ fs_initcall(mount_root);
 #endif
 
 #ifdef CONFIG_ENV_HANDLING
+static bool region_overlap(loff_t starta, loff_t lena,
+  loff_t startb, loff_t lenb)
+{
+   if (starta + lena <= startb)
+   return 0;
+   if (startb + lenb <= starta)
+   return 0;
+   return 1;
+}
+
 static int check_overlap(const char *path)
 {
struct cdev *cenv, *cdisk, *cpart;
@@ -104,8 +114,8 @@ static int check_overlap(const char *path)
if (cpart == cenv)
continue;
 
-   if (lregion_overlap(cpart->offset, cpart->size,
-   cenv->offset, cenv->size))
+   if (region_overlap(cpart->offset, cpart->size,
+  cenv->offset, cenv->size))
goto conflict;
}
 
diff --git a/include/common.h b/include/common.h
index 3570e6aba..0bf819a6f 100644
--- a/include/common.h
+++ b/include/common.h
@@ -139,18 +139,4 @@ void barebox_set_hostname_no_overwrite(const char *);
 #define IOMEM(addr)((void __force __iomem *)(addr))
 #endif
 
-/*
- * Check if two regions overlap. returns true if they do, false otherwise
- */
-
-static inline bool lregion_overlap(loff_t starta, loff_t lena,
-  loff_t startb, loff_t lenb)
-{
-   if (starta + lena <= startb)
-   return 0;
-   if (startb + lenb <= starta)
-   return 0;
-   return 1;
-}
-
 #endif /* __COMMON_H_ */
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] kbuild: add $(always-y) to 'targets'

2020-05-04 Thread Masahiro Yamada
On Thu, Apr 30, 2020 at 1:43 PM Masahiro Yamada  wrote:
>
> I missed to sync this line in commit 421108c51da4 ("kbuild: rename
> hostprogs-y/always to hostprogs/always-y").
>
> Since then, the files in always(-y) are needlessly rebuilt.

This line is not precise because the files in $(always) are fine.
If it is not too late, could you please reword this line as follows ?


Since then, the files in $(always-y) are needlessly rebuilt.








>
> Fixes: 421108c51da4 ("kbuild: rename hostprogs-y/always to 
> hostprogs/always-y")
> Signed-off-by: Masahiro Yamada 
> ---
>
>  scripts/Makefile.build | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 8c28ccb8e..acb0d68b8 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -243,7 +243,7 @@ pbl-%.o: %.S FORCE
> $(call if_changed_dep,as_o_S)
>
>  targets += $(real-objs-y) $(real-objs-m) $(lib-y) $(pbl-y)
> -targets += $(extra-y) $(MAKECMDGOALS) $(always)
> +targets += $(extra-y) $(always-y) $(MAKECMDGOALS)
>
>  # Linker scripts preprocessor (.lds.S -> .lds)
>  # -------
> --
> 2.25.1
>


-- 
Best Regards
Masahiro Yamada

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/4] kbuild: sync if_changed and friends with Linux 5.7-rc2

2020-04-29 Thread Masahiro Yamada
Resync cmd, if_change, if_changed_dep, and if_changed_rule.

Clean up the users of if_changed_rule.

I deleted the modversions rule. It is dead code because barebox
does not define CONFIG_MODVERSIONS. It does not work without
scripts/genksyms/ anyway.

Signed-off-by: Masahiro Yamada 
---

 Makefile   | 14 ++---
 scripts/Kbuild.include | 47 +++---
 scripts/Makefile.build | 66 +-
 3 files changed, 34 insertions(+), 93 deletions(-)

diff --git a/Makefile b/Makefile
index 59e041fed..9485f5551 100644
--- a/Makefile
+++ b/Makefile
@@ -626,24 +626,18 @@ quiet_cmd_barebox_version = GEN .version
$(MAKE) $(build)=common
 
 # Generate System.map
-quiet_cmd_sysmap = SYSMAP
-  cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap
+quiet_cmd_sysmap = SYSMAP  System.map
+  cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap $@ System.map
 
 # Link of barebox
 # If CONFIG_KALLSYMS is set .version is already updated
 # Generate System.map and verify that the content is consistent
 # Use + in front of the barebox_version rule to silent warning with make -j2
-# First command is ':' to allow us to use + in front of the rule
 define rule_barebox__
-   :
$(if $(CONFIG_KALLSYMS),,+$(call cmd,barebox_version))
$(call cmd,barebox__)
-
$(Q)echo 'cmd_$@ := $(cmd_barebox__)' > $(@D)/.$(@F).cmd
-
-   $(Q)$(if $($(quiet)cmd_sysmap),  \
- echo '  $($(quiet)cmd_sysmap)  System.map' &&) \
-   $(cmd_sysmap) $@ System.map
+   $(call cmd,sysmap)
 endef
 
 ifdef CONFIG_KALLSYMS
@@ -684,10 +678,8 @@ endef
 
 # Update barebox version before link
 # Use + in front of this rule to silent warning about make -j1
-# First command is ':' to allow us to use + in front of this rule
 cmd_ksym_ld = $(cmd_barebox__)
 define rule_ksym_ld
-   :
+$(call cmd,barebox_version)
$(call cmd,barebox__)
$(Q)echo 'cmd_$@ := $(cmd_barebox__)' > $(@D)/.$(@F).cmd
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 983329e40..074d2db04 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -165,7 +165,7 @@ echo-cmd = $(if $($(quiet)cmd_$(1)),\
echo '  $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';)
 
 # printing commands
-cmd = @$(echo-cmd) $(cmd_$(1))
+cmd = @set -e; $(echo-cmd) $(cmd_$(1))
 
 # Add $(obj)/ for paths that are not absolute
 objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
@@ -176,15 +176,15 @@ objectify = $(foreach o,$(1),$(if $(filter 
/%,$(o)),$(o),$(obj)/$(o)))
 # if_changed_dep  - as if_changed, but uses fixdep to reveal dependencies
 #   including used config symbols
 # if_changed_rule - as if_changed but execute rule instead
-# See Documentation/kbuild/makefiles.txt for more info
+# See Documentation/kbuild/makefiles.rst for more info
 
 ifneq ($(KBUILD_NOCMDDEP),1)
-# Check if both arguments are the same including their order. Result is empty
+# Check if both commands are the same including their order. Result is empty
 # string if equal. User may override this check using make KBUILD_NOCMDDEP=1
-arg-check = $(filter-out $(subst $(space),$(space_escape),$(strip $(cmd_$@))), 
\
+cmd-check = $(filter-out $(subst $(space),$(space_escape),$(strip $(cmd_$@))), 
\
  $(subst $(space),$(space_escape),$(strip $(cmd_$1
 else
-arg-check = $(if $(strip $(cmd_$@)),,1)
+cmd-check = $(if $(strip $(cmd_$@)),,1)
 endif
 
 # Replace >$< with >$$< to preserve $ when reloading the .cmd file
@@ -195,34 +195,33 @@ endif
 # (needed for the shell)
 make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst 
$$,,$(cmd_$(1)
 
-# Find any prerequisites that is newer than target or that does not exist.
+# Find any prerequisites that are newer than target or that do not exist.
+# (This is not true for now; $? should contain any non-existent prerequisites,
+# but it does not work as expected when .SECONDARY is present. This seems a bug
+# of GNU Make.)
 # PHONY targets skipped in both cases.
-any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
+newer-prereqs = $(filter-out $(PHONY),$?)
 
 # Execute command if command has changed or prerequisite(s) are updated.
-#
-if_changed = $(if $(strip $(any-prereq) $(arg-check)),   \
-   @set -e; \
-   $(echo-cmd) $(cmd_$(1)); \
-   printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd)
+if_changed = $(if $(newer-prereqs)$(cmd-check),  \
+   $(cmd);  \
+   printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot

[PATCH 4/4] kbuild: sync scripts/Kbuild.include with Linux 5.7-rc2

2020-04-29 Thread Masahiro Yamada
More random cherry-picks for scripts/Kbuild.include

Signed-off-by: Masahiro Yamada 
---

 scripts/Kbuild.include | 42 ++
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 074d2db04..838ab11e7 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -1,3 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
 
 # kbuild: Generic definitions
 
@@ -23,10 +24,18 @@ depfile = $(subst $(comma),_,$(dot-target).d)
 # filename of target with directory and extension stripped
 basetarget = $(basename $(notdir $@))
 
+###
+# real prerequisites without phony targets
+real-prereqs = $(filter-out $(PHONY), $^)
+
 ###
 # Escape single quote for use in echo statements
 escsq = $(subst $(squote),'\$(squote)',$1)
 
+###
+# Quote a string to pass it to C files. foo => '"foo"'
+stringify = $(squote)$(quote)$1$(quote)$(squote)
+
 ###
 # Easy method for doing a status message
kecho := :
@@ -62,18 +71,19 @@ endef
 
 ##
 # gcc support functions
-# See documentation in Documentation/kbuild/makefiles.txt
+# See documentation in Documentation/kbuild/makefiles.rst
 
 # cc-cross-prefix
 # Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-)
-# Return first prefix where a prefix$(CC) is found in PATH.
-# If no $(CC) found in PATH with listed prefixes return nothing
-cc-cross-prefix =  \
-   $(word 1, $(foreach c,$(1),   \
-   $(shell set -e;   \
-   if (which $(strip $(c))$(CC)) > /dev/null 2>&1 ; then \
-   echo $(c);\
-   fi)))
+# Return first  where a gcc is found in PATH.
+# If no gcc found in PATH with listed prefixes return nothing
+#
+# Note: '2>/dev/null' is here to force Make to invoke a shell. Otherwise, it
+# would try to directly execute the shell builtin 'command'. This workaround
+# should be kept for a long time since this issue was fixed only after the
+# GNU Make 4.2.1 release.
+cc-cross-prefix = $(firstword $(foreach c, $(1), \
+   $(if $(shell command -v -- $(c)gcc 2>/dev/null), $(c
 
 # output directory for tests below
 TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
@@ -138,18 +148,13 @@ ld-option = $(call try-run,\
 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
 # Usage:
 # $(Q)$(MAKE) $(build)=dir
-build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
+build := -f $(srctree)/scripts/Makefile.build obj
 
 ###
-# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj=
-# Usage:
-# $(Q)$(MAKE) $(modbuiltin)=dir
-modbuiltin := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.modbuiltin obj
-
-# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=dir
+# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=
 # Usage:
 # $(Q)$(MAKE) $(clean)=dir
-clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
+clean := -f $(srctree)/scripts/Makefile.clean obj
 
 # Prefix -I with $(srctree) if it is not an absolute path.
 # skip if -I has no parameter
@@ -167,9 +172,6 @@ echo-cmd = $(if $($(quiet)cmd_$(1)),\
 # printing commands
 cmd = @set -e; $(echo-cmd) $(cmd_$(1))
 
-# Add $(obj)/ for paths that are not absolute
-objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
-
 ###
 # if_changed  - execute command if any prerequisite is newer than
 #   target, or command line has changed
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/4] kbuild: do not delete $@ explicitly on failure

2020-04-29 Thread Masahiro Yamada
The .DELETE_ON_ERROR special target is specified in scripts/Kbuild.include

You do not need to delete $@ explicitly when the command fails.
GNU Make automatically does it.

Signed-off-by: Masahiro Yamada 
---

 Makefile| 6 +-
 arch/arm/tools/Makefile | 2 +-
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index de9b40ade..967c27909 100644
--- a/Makefile
+++ b/Makefile
@@ -643,11 +643,7 @@ define rule_barebox__
 
$(Q)$(if $($(quiet)cmd_sysmap),  \
  echo '  $($(quiet)cmd_sysmap)  System.map' &&) \
-   $(cmd_sysmap) $@ System.map; \
-   if [ $$? -ne 0 ]; then   \
-   rm -f $@;\
-   false;   \
-   fi;
+   $(cmd_sysmap) $@ System.map
 endef
 
 ifdef CONFIG_KALLSYMS
diff --git a/arch/arm/tools/Makefile b/arch/arm/tools/Makefile
index 67ae9e701..bff825e58 100644
--- a/arch/arm/tools/Makefile
+++ b/arch/arm/tools/Makefile
@@ -7,4 +7,4 @@
 include/generated/mach-types.h: $(src)/gen-mach-types $(src)/mach-types
$(Q)$(kecho) '  Generating $@'
$(Q)mkdir -p $(dir $@)
-   $(Q)$(AWK) -f $^ > $@ || { rm -f $@; /bin/false; }
+   $(Q)$(AWK) -f $^ > $@
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/2] mips: remove unused INCDIR and BOARD variables in Makefile

2020-04-29 Thread Masahiro Yamada
The variable INCDIR is not used by anyone.

The variable BOARD is not set by anyone, so $(BOARD) is always empty.

Signed-off-by: Masahiro Yamada 
---

 arch/mips/Makefile | 13 -
 1 file changed, 13 deletions(-)

diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 4717f49a4..abfa82504 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -88,25 +88,12 @@ else
 KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs))
 endif
 
-ifeq ($(incdir-y),)
-incdir-y := $(machine-y)
-endif
-INCDIR   := arch-$(incdir-y)
-
-ifeq ($(KBUILD_SRC),)
-KBUILD_CPPFLAGS += -I$(BOARD)/include
-else
-KBUILD_CPPFLAGS += -I$(srctree)/$(BOARD)/include
-endif
-
 ifneq ($(machine-y),)
 MACH  := arch/mips/mach-$(machine-y)/
 else
 MACH  :=
 endif
 
-common-y += $(BOARD)
-
 common-y += $(MACH)
 common-y += arch/mips/lib/
 common-y += arch/mips/boot/
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/2] mips: remove unused board/debug_ll.h

2020-04-29 Thread Masahiro Yamada
There is no way to include . These three files
are dead code.

Signed-off-by: Masahiro Yamada 
---

 .../loongson-ls1b/include/board/debug_ll.h| 22 ---
 .../netgear-wg102/include/board/debug_ll.h| 21 --
 .../qemu-malta/include/board/debug_ll.h   | 18 ---
 3 files changed, 61 deletions(-)
 delete mode 100644 arch/mips/boards/loongson-ls1b/include/board/debug_ll.h
 delete mode 100644 arch/mips/boards/netgear-wg102/include/board/debug_ll.h
 delete mode 100644 arch/mips/boards/qemu-malta/include/board/debug_ll.h

diff --git a/arch/mips/boards/loongson-ls1b/include/board/debug_ll.h 
b/arch/mips/boards/loongson-ls1b/include/board/debug_ll.h
deleted file mode 100644
index 05420f73a..0
--- a/arch/mips/boards/loongson-ls1b/include/board/debug_ll.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Copyright (C) 2014 Antony Pavlov 
- */
-
-/** @file
- *  This File contains declaration for early output support
- */
-#ifndef __LOONGSON_TECH_LS1B_DEBUG_LL_H__
-#define __LOONGSON_TECH_LS1B_DEBUG_LL_H__
-
-#include 
-#include 
-
-#define DEBUG_LL_UART_ADDR KSEG1ADDR(LS1X_UART2_BASE)
-#define DEBUG_LL_UART_SHIFT0
-
-#define DEBUG_LL_UART_CLK   (8300 / 16)
-#define DEBUG_LL_UART_BPS   CONFIG_BAUDRATE
-#define DEBUG_LL_UART_DIVISOR   (DEBUG_LL_UART_CLK / DEBUG_LL_UART_BPS)
-
-#endif /* __LOONGSON_TECH_LS1B_DEBUG_LL_H__ */
diff --git a/arch/mips/boards/netgear-wg102/include/board/debug_ll.h 
b/arch/mips/boards/netgear-wg102/include/board/debug_ll.h
deleted file mode 100644
index cc3b1d74b..0
--- a/arch/mips/boards/netgear-wg102/include/board/debug_ll.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (C) 2013 Oleksij Rempel 
- */
-
-/** @file
- *  This File contains declaration for early output support
- */
-#ifndef __NETGEAR_WG102_DEBUG_LL_H__
-#define __NETGEAR_WG102_DEBUG_LL_H__
-
-#include 
-
-#define DEBUG_LL_UART_ADDR KSEG1ADDR(AR2312_UART0)
-#define DEBUG_LL_UART_SHIFTAR2312_UART_SHIFT
-
-#define DEBUG_LL_UART_CLK   (4500 / 16)
-#define DEBUG_LL_UART_BPS   CONFIG_BAUDRATE
-#define DEBUG_LL_UART_DIVISOR   (DEBUG_LL_UART_CLK / DEBUG_LL_UART_BPS)
-
-#endif /* __NETGEAR_WG102_DEBUG_LL_H__ */
diff --git a/arch/mips/boards/qemu-malta/include/board/debug_ll.h 
b/arch/mips/boards/qemu-malta/include/board/debug_ll.h
deleted file mode 100644
index 5b112b8ae..0
--- a/arch/mips/boards/qemu-malta/include/board/debug_ll.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Copyright (C) 2013 Antony Pavlov 
- */
-
-#ifndef __INCLUDE_BOARD_DEBUG_LL_QEMU_MALTA_H__
-#define __INCLUDE_BOARD_DEBUG_LL_QEMU_MALTA_H__
-
-#include 
-
-#define DEBUG_LL_UART_ADDR MALTA_PIIX4_UART0
-#define DEBUG_LL_UART_SHIFT0
-
-#define DEBUG_LL_UART_CLK   1843200
-#define DEBUG_LL_UART_BPS   CONFIG_BAUDRATE
-#define DEBUG_LL_UART_DIVISOR   (DEBUG_LL_UART_CLK / DEBUG_LL_UART_BPS)
-
-#endif /* __INCLUDE_BOARD_DEBUG_LL_QEMU_MALTA_H__ */
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] arm: remove empty config.h

2020-04-29 Thread Masahiro Yamada
These are not included by anyone because these boards are not added
to board-y. The top Makefile creates the empty include/config.h if
a board-specific config.h deos not exist.

Signed-off-by: Masahiro Yamada 
---

 arch/arm/boards/afi-gf/config.h   | 22 ---
 arch/arm/boards/altera-socdk/config.h |  1 -
 arch/arm/boards/ebv-socrates/config.h |  1 -
 arch/arm/boards/solidrun-cubox/config.h   |  4 
 arch/arm/boards/terasic-de0-nano-soc/config.h |  1 -
 arch/arm/boards/terasic-sockit/config.h   |  1 -
 6 files changed, 30 deletions(-)
 delete mode 100644 arch/arm/boards/afi-gf/config.h
 delete mode 100644 arch/arm/boards/altera-socdk/config.h
 delete mode 100644 arch/arm/boards/ebv-socrates/config.h
 delete mode 100644 arch/arm/boards/solidrun-cubox/config.h
 delete mode 100644 arch/arm/boards/terasic-de0-nano-soc/config.h
 delete mode 100644 arch/arm/boards/terasic-sockit/config.h

diff --git a/arch/arm/boards/afi-gf/config.h b/arch/arm/boards/afi-gf/config.h
deleted file mode 100644
index aeeda3695..0
--- a/arch/arm/boards/afi-gf/config.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2012 Jan Luebbe 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef __CONFIG_H
-#define __CONFIG_H
-
-#endif /* __CONFIG_H */
diff --git a/arch/arm/boards/altera-socdk/config.h 
b/arch/arm/boards/altera-socdk/config.h
deleted file mode 100644
index da84fa5f6..0
--- a/arch/arm/boards/altera-socdk/config.h
+++ /dev/null
@@ -1 +0,0 @@
-/* nothing */
diff --git a/arch/arm/boards/ebv-socrates/config.h 
b/arch/arm/boards/ebv-socrates/config.h
deleted file mode 100644
index da84fa5f6..0
--- a/arch/arm/boards/ebv-socrates/config.h
+++ /dev/null
@@ -1 +0,0 @@
-/* nothing */
diff --git a/arch/arm/boards/solidrun-cubox/config.h 
b/arch/arm/boards/solidrun-cubox/config.h
deleted file mode 100644
index ca1513681..0
--- a/arch/arm/boards/solidrun-cubox/config.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef __CONFIG_H
-#define __CONFIG_H
-
-#endif /* __CONFIG_H */
diff --git a/arch/arm/boards/terasic-de0-nano-soc/config.h 
b/arch/arm/boards/terasic-de0-nano-soc/config.h
deleted file mode 100644
index da84fa5f6..0
--- a/arch/arm/boards/terasic-de0-nano-soc/config.h
+++ /dev/null
@@ -1 +0,0 @@
-/* nothing */
diff --git a/arch/arm/boards/terasic-sockit/config.h 
b/arch/arm/boards/terasic-sockit/config.h
deleted file mode 100644
index da84fa5f6..0
--- a/arch/arm/boards/terasic-sockit/config.h
+++ /dev/null
@@ -1 +0,0 @@
-/* nothing */
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] kbuild: add $(always-y) to 'targets'

2020-04-29 Thread Masahiro Yamada
I missed to sync this line in commit 421108c51da4 ("kbuild: rename
hostprogs-y/always to hostprogs/always-y").

Since then, the files in always(-y) are needlessly rebuilt.

Fixes: 421108c51da4 ("kbuild: rename hostprogs-y/always to hostprogs/always-y")
Signed-off-by: Masahiro Yamada 
---

 scripts/Makefile.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 8c28ccb8e..acb0d68b8 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -243,7 +243,7 @@ pbl-%.o: %.S FORCE
$(call if_changed_dep,as_o_S)
 
 targets += $(real-objs-y) $(real-objs-m) $(lib-y) $(pbl-y)
-targets += $(extra-y) $(MAKECMDGOALS) $(always)
+targets += $(extra-y) $(always-y) $(MAKECMDGOALS)
 
 # Linker scripts preprocessor (.lds.S -> .lds)
 # ---
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/5] ppc: add arch/ppc/Kbuild

2020-04-29 Thread Masahiro Yamada
Add arch/ppc/Kbuild to clean up arch/ppc/Makefile.

The variable, CPU is used only for determining if Kbuild should
descend to cpu-85xx/.

  obj-$(CONFIG_ARCH_MPC85XX) += cpu-85xx/

is preferred.

Signed-off-by: Masahiro Yamada 
---

 arch/ppc/Kbuild   |  2 ++
 arch/ppc/Makefile | 11 +--
 2 files changed, 3 insertions(+), 10 deletions(-)
 create mode 100644 arch/ppc/Kbuild

diff --git a/arch/ppc/Kbuild b/arch/ppc/Kbuild
new file mode 100644
index 0..503ce631c
--- /dev/null
+++ b/arch/ppc/Kbuild
@@ -0,0 +1,2 @@
+obj-$(CONFIG_ARCH_MPC85XX) += cpu-85xx/
+obj-y += lib/
diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile
index 3d8ddf377..5eacd42e3 100644
--- a/arch/ppc/Makefile
+++ b/arch/ppc/Makefile
@@ -23,8 +23,6 @@ board-$(CONFIG_DA923RC)   := 
owc-da923rc
 machine-$(CONFIG_ARCH_MPC5200) := mpc5xxx
 machine-$(CONFIG_ARCH_MPC85XX) := mpc85xx
 
-cpu-$(CONFIG_ARCH_MPC85XX) := 85xx
-
 TEXT_BASE = $(CONFIG_TEXT_BASE)
 
 KBUILD_CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE)
@@ -60,14 +58,7 @@ else
 MACH  :=
 endif
 
-ifneq ($(cpu-y),)
-CPU  := arch/ppc/cpu-$(cpu-y)/
-else
-CPU  :=
-endif
-
-common-y += $(BOARD) $(CPU) $(MACH)
-common-y += arch/ppc/lib/
+common-y += $(BOARD) $(MACH) arch/ppc/
 
 ifdef CONFIG_MPC85xx
 lds-y += $(MACH)/barebox.lds
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 0/5] move arch/ppc to arch/powerpc

2020-04-29 Thread Masahiro Yamada


This needs to go for-next/kbuild branch.



Masahiro Yamada (5):
  ppc: remove unneeded -D CONFIG_PPC
  ppc: pass -mno-spe and -mspe=no to cc-option
  ppc: add arch/ppc/Kbuild
  image: support 'powerpc' for mkimage architecture
  ppc: rename arch/ppc/ to arch/powerpc/

 Makefile  |  5 
 arch/powerpc/Kbuild   |  2 ++
 arch/{ppc => powerpc}/Kconfig |  4 +--
 arch/{ppc => powerpc}/Makefile| 25 +++
 arch/{ppc => powerpc}/boards/.gitignore   |  0
 .../boards/freescale-p1010rdb/Makefile|  0
 .../boards/freescale-p1010rdb/config.h|  0
 .../boards/freescale-p1010rdb/ddr.c   |  0
 .../defaultenv-freescale-p1010rdb/bin/init|  0
 .../defaultenv-freescale-p1010rdb/config  |  0
 .../boards/freescale-p1010rdb/law.c   |  0
 .../boards/freescale-p1010rdb/p1010rdb.c  |  0
 .../boards/freescale-p1010rdb/p1010rdb.h  |  0
 .../boards/freescale-p1010rdb/tlb.c   |  0
 .../boards/freescale-p1022ds/Makefile |  0
 .../boards/freescale-p1022ds/config.h |  0
 .../boards/freescale-p1022ds/ddr.c|  0
 .../defaultenv-freescale-p1022ds/bin/init |  0
 .../defaultenv-freescale-p1022ds/config   |  0
 .../boards/freescale-p1022ds/ics307_clk.c |  0
 .../boards/freescale-p1022ds/law.c|  0
 .../boards/freescale-p1022ds/p1022ds.c|  0
 .../boards/freescale-p1022ds/p1022ds.h|  0
 .../boards/freescale-p1022ds/tlb.c|  0
 .../boards/freescale-p2020rdb/Makefile|  0
 .../boards/freescale-p2020rdb/config.h|  0
 .../defaultenv-freescale-p2020rdb/bin/init|  0
 .../defaultenv-freescale-p2020rdb/config  |  0
 .../boards/freescale-p2020rdb/law.c   |  0
 .../boards/freescale-p2020rdb/p2020rdb.c  |  0
 .../boards/freescale-p2020rdb/tlb.c   |  0
 .../boards/owc-da923rc/Makefile   |  0
 .../boards/owc-da923rc/config.h   |  0
 .../boards/owc-da923rc/da923rc.c  |  0
 .../{ppc => powerpc}/boards/owc-da923rc/ddr.c |  0
 .../defaultenv-owc-da923rc/bin/boot   |  0
 .../defaultenv-owc-da923rc/bin/init   |  0
 .../owc-da923rc/defaultenv-owc-da923rc/config |  0
 .../{ppc => powerpc}/boards/owc-da923rc/law.c |  0
 .../boards/owc-da923rc/nand.c |  0
 .../boards/owc-da923rc/product_data.c |  0
 .../boards/owc-da923rc/product_data.h |  0
 .../{ppc => powerpc}/boards/owc-da923rc/tlb.c |  0
 arch/{ppc => powerpc}/boards/pcm030/Makefile  |  0
 .../boards/pcm030/barebox.lds.S   |  2 +-
 arch/{ppc => powerpc}/boards/pcm030/config.h  |  0
 arch/{ppc => powerpc}/boards/pcm030/eeprom.c  |  0
 .../boards/pcm030/env/init/mtdparts-nor   |  0
 .../pcm030/env/nv/linux.bootargs.console  |  0
 .../boards/pcm030/mt46v32m16-75.h |  0
 arch/{ppc => powerpc}/boards/pcm030/pcm030.c  |  0
 .../configs/owc_da923rc_defconfig |  0
 .../configs/p1010rdb_defconfig|  0
 .../configs/p1022ds_defconfig |  0
 .../configs/p2020rdb_defconfig|  0
 .../{ppc => powerpc}/configs/pcm030_defconfig |  2 +-
 arch/{ppc => powerpc}/cpu-85xx/Makefile   |  0
 arch/{ppc => powerpc}/cpu-85xx/fixed_ivor.S   |  0
 arch/{ppc => powerpc}/cpu-85xx/mmu.c  |  0
 arch/{ppc => powerpc}/cpu-85xx/resetvec.S |  0
 arch/{ppc => powerpc}/cpu-85xx/start.S|  0
 arch/{ppc => powerpc}/cpu-85xx/tlb.c  |  0
 arch/{ppc => powerpc}/cpu-85xx/traps.c|  0
 arch/{ppc => powerpc}/ddr-8xxx/Makefile   |  0
 .../ddr-8xxx/common_timing_params.h   |  0
 arch/{ppc => powerpc}/ddr-8xxx/ctrl_regs.c|  0
 arch/{ppc => powerpc}/ddr-8xxx/ddr.h  |  0
 .../ddr-8xxx/ddr2_dimm_params.c   |  0
 .../ddr-8xxx/ddr3_dimm_params.c   |  0
 arch/{ppc => powerpc}/ddr-8xxx/ddr_setctrl.c  |  0
 .../ddr-8xxx/lc_common_dimm_params.c  |  0
 arch/{ppc => powerpc}/ddr-8xxx/main.c |  0
 arch/{ppc => powerpc}/ddr-8xxx/options.c  |  0
 arch/{ppc => powerpc}/ddr-8xxx/util.c |  0
 arch/{ppc => powerpc}/include/asm/atomic.h|  0
 arch/{ppc => powerpc}/include/asm/bitops.h|  0
 .../include/asm/bitsperlong.h |  0
 arch/{ppc => powerpc}/include/asm/byteorder.h |  0
 arch/{ppc => powerpc}/include/asm/cache.h |  0
 arch/{ppc => powerpc}/include/asm/common.h|  0
 arch/{ppc => powerpc}/include/asm/config.h|  0
 arch/{ppc => powerpc}/include/asm/dma.h   |  0
 arch/{ppc => powerpc}/include/asm/elf.h   |  0
 .../include/asm/fsl_ddr_dimm_params.h |  0
 .../include/asm/fsl_ddr_sdram.h   |  0
 arch/{ppc => powerpc}/include/asm/fsl_ifc.h   |  0
 arch/{ppc => powerpc}/include/asm/fsl_law.h   |  0
 arch/{ppc => powerpc}/include/asm/fsl_lbc.

[PATCH 5/5] ppc: rename arch/ppc/ to arch/powerpc/

2020-04-29 Thread Masahiro Yamada
In old days, Linux supported PowerPC with two arch directories,
arch/ppc/ and arch/ppc64/.

Linux commit 564ee7a5668e ("[PATCH] powerpc: Move arch/ppc*/kernel/vecemu.c
to arch/powerpc") started the migration to arch/powerpc/, and
commit 917f0af9e5a9 ("powerpc: Remove arch/ppc and include/asm-ppc")
finished it.

This commit aligns the directory name with the current Linux.

I did 'git mv arch/ppc/ arch/powerpc/', and fixed up some hard-coded
arch/ppc paths.

Barebox has stuck to arch/ppc/ for a long time. To keep the backward
compatibility, I added the following to the top Makefile.

  # Support ARCH=ppc for backward compatibility
  ifeq ($(ARCH),ppc)
 SRCARCH := powerpc
  endif

Both ARCH=ppc and ARCH=powerpc work in the same way.

Signed-off-by: Masahiro Yamada 
---

 Makefile  | 5 +
 arch/{ppc => powerpc}/Kbuild  | 0
 arch/{ppc => powerpc}/Kconfig | 4 ++--
 arch/{ppc => powerpc}/Makefile| 8 
 arch/{ppc => powerpc}/boards/.gitignore   | 0
 arch/{ppc => powerpc}/boards/freescale-p1010rdb/Makefile  | 0
 arch/{ppc => powerpc}/boards/freescale-p1010rdb/config.h  | 0
 arch/{ppc => powerpc}/boards/freescale-p1010rdb/ddr.c | 0
 .../defaultenv-freescale-p1010rdb/bin/init| 0
 .../defaultenv-freescale-p1010rdb/config  | 0
 arch/{ppc => powerpc}/boards/freescale-p1010rdb/law.c | 0
 .../{ppc => powerpc}/boards/freescale-p1010rdb/p1010rdb.c | 0
 .../{ppc => powerpc}/boards/freescale-p1010rdb/p1010rdb.h | 0
 arch/{ppc => powerpc}/boards/freescale-p1010rdb/tlb.c | 0
 arch/{ppc => powerpc}/boards/freescale-p1022ds/Makefile   | 0
 arch/{ppc => powerpc}/boards/freescale-p1022ds/config.h   | 0
 arch/{ppc => powerpc}/boards/freescale-p1022ds/ddr.c  | 0
 .../defaultenv-freescale-p1022ds/bin/init | 0
 .../freescale-p1022ds/defaultenv-freescale-p1022ds/config | 0
 .../boards/freescale-p1022ds/ics307_clk.c | 0
 arch/{ppc => powerpc}/boards/freescale-p1022ds/law.c  | 0
 arch/{ppc => powerpc}/boards/freescale-p1022ds/p1022ds.c  | 0
 arch/{ppc => powerpc}/boards/freescale-p1022ds/p1022ds.h  | 0
 arch/{ppc => powerpc}/boards/freescale-p1022ds/tlb.c  | 0
 arch/{ppc => powerpc}/boards/freescale-p2020rdb/Makefile  | 0
 arch/{ppc => powerpc}/boards/freescale-p2020rdb/config.h  | 0
 .../defaultenv-freescale-p2020rdb/bin/init| 0
 .../defaultenv-freescale-p2020rdb/config  | 0
 arch/{ppc => powerpc}/boards/freescale-p2020rdb/law.c | 0
 .../{ppc => powerpc}/boards/freescale-p2020rdb/p2020rdb.c | 0
 arch/{ppc => powerpc}/boards/freescale-p2020rdb/tlb.c | 0
 arch/{ppc => powerpc}/boards/owc-da923rc/Makefile | 0
 arch/{ppc => powerpc}/boards/owc-da923rc/config.h | 0
 arch/{ppc => powerpc}/boards/owc-da923rc/da923rc.c| 0
 arch/{ppc => powerpc}/boards/owc-da923rc/ddr.c| 0
 .../boards/owc-da923rc/defaultenv-owc-da923rc/bin/boot| 0
 .../boards/owc-da923rc/defaultenv-owc-da923rc/bin/init| 0
 .../boards/owc-da923rc/defaultenv-owc-da923rc/config  | 0
 arch/{ppc => powerpc}/boards/owc-da923rc/law.c| 0
 arch/{ppc => powerpc}/boards/owc-da923rc/nand.c   | 0
 arch/{ppc => powerpc}/boards/owc-da923rc/product_data.c   | 0
 arch/{ppc => powerpc}/boards/owc-da923rc/product_data.h   | 0
 arch/{ppc => powerpc}/boards/owc-da923rc/tlb.c| 0
 arch/{ppc => powerpc}/boards/pcm030/Makefile  | 0
 arch/{ppc => powerpc}/boards/pcm030/barebox.lds.S | 2 +-
 arch/{ppc => powerpc}/boards/pcm030/config.h  | 0
 arch/{ppc => powerpc}/boards/pcm030/eeprom.c  | 0
 arch/{ppc => powerpc}/boards/pcm030/env/init/mtdparts-nor | 0
 .../boards/pcm030/env/nv/linux.bootargs.console   | 0
 arch/{ppc => powerpc}/boards/pcm030/mt46v32m16-75.h   | 0
 arch/{ppc => powerpc}/boards/pcm030/pcm030.c  | 0
 arch/{ppc => powerpc}/configs/owc_da923rc_defconfig   | 0
 arch/{ppc => powerpc}/configs/p1010rdb_defconfig  | 0
 arch/{ppc => powerpc}/configs/p1022ds_defconfig   | 0
 arch/{ppc => powerpc}/configs/p2020rdb_defconfig  | 0
 arch/{ppc => powerpc}/configs/pcm030_defconfig| 2 +-
 arch/{ppc => powerpc}/cpu-85xx/Makefile   | 0
 arch/{ppc => powerpc}/cpu-85xx/fixed_ivor.S   | 0
 arch/{ppc => powerpc}/cpu-85xx/mmu.c  | 0
 arch/{ppc => powerpc}/cpu-85xx/resetvec.S | 0
 arch/{ppc => powerpc}/cpu-85xx/start.S| 0
 arch/{ppc => powerpc}/cpu-85xx/tlb.c  | 0
 arch/{ppc => powerpc}/cpu-85xx/traps.c| 0
 arch/{ppc => powerpc}/ddr-8x

[PATCH 1/5] ppc: remove unneeded -D CONFIG_PPC

2020-04-29 Thread Masahiro Yamada
CONFIG_PPC is defined by arch/ppc/Kconfig.

There is no need to define it explicitly.

Signed-off-by: Masahiro Yamada 
---

 arch/ppc/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile
index 10f8ae3fe..276b1f6bf 100644
--- a/arch/ppc/Makefile
+++ b/arch/ppc/Makefile
@@ -1,7 +1,7 @@
 KBUILD_DEFCONFIG := p2020rdb_defconfig
 
 KBUILD_CPPFLAGS += -ffixed-r14 -m32\
-   -meabi -D __PPC__ -D CONFIG_PPC \
+   -meabi -D __PPC__ \
-fno-strict-aliasing -mno-spe -mspe=no
 
 ifdef CONFIG_RELOCATABLE
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/5] ppc: pass -mno-spe and -mspe=no to cc-option

2020-04-29 Thread Masahiro Yamada
My compiler does not understand -mno-spe or -msped=n.

powerpc-linux-gcc: error: unrecognized command line option '-mno-spe'; did you 
mean '-fno-see'?
powerpc-linux-gcc: error: unrecognized command line option '-mspe=no'

Pass them to cc-option becasue this is what Linux does.

Also, assign the compiler flags to CFLAGS, AFLAGS, and CPPFLAGS properly.

Signed-off-by: Masahiro Yamada 
---

 arch/ppc/Makefile | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile
index 276b1f6bf..3d8ddf377 100644
--- a/arch/ppc/Makefile
+++ b/arch/ppc/Makefile
@@ -1,8 +1,10 @@
 KBUILD_DEFCONFIG := p2020rdb_defconfig
 
-KBUILD_CPPFLAGS += -ffixed-r14 -m32\
-   -meabi -D __PPC__ \
-   -fno-strict-aliasing -mno-spe -mspe=no
+KBUILD_CFLAGS += -ffixed-r14 -m32 -meabi -fno-strict-aliasing
+KBUILD_CFLAGS += $(call cc-option,-mno-spe)
+KBUILD_CFLAGS += $(call cc-option,-mspe=no)
+KBUILD_AFLAGS += -m32
+KBUILD_CPPFLAGS += -D __PPC__
 
 ifdef CONFIG_RELOCATABLE
 KBUILD_CPPFLAGS += -fPIC -mrelocatable
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 4/5] image: support 'powerpc' for mkimage architecture

2020-04-29 Thread Masahiro Yamada
Currently, the -A option of mkimage is determined based on $(SRCARCH).

I want to rename arch/ppc/ to arch/powerpc/.

Support 'powerpc' for the -A option of mkimage beforehand, otherwise
the barebox.uimage build would be broken.

common/image.c in U-Boot supports both 'powerpc' and 'ppc' for the
name of IH_ARCH_PPC. Let's do likewise in barebox.

Signed-off-by: Masahiro Yamada 
---

 common/image.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/image.c b/common/image.c
index 39732c57d..8199e2df1 100644
--- a/common/image.c
+++ b/common/image.c
@@ -47,6 +47,7 @@ static table_entry_t arch_name[] = {
{ IH_ARCH_MIPS64,   "mips64",   "MIPS 64 Bit",  },
{ IH_ARCH_NIOS, "nios", "NIOS", },
{ IH_ARCH_NIOS2,"nios2","NIOS II",  },
+   { IH_ARCH_PPC,  "powerpc",  "PowerPC",  },
{ IH_ARCH_PPC,  "ppc",  "PowerPC",  },
{ IH_ARCH_S390, "s390", "IBM S390", },
{ IH_ARCH_SH,   "sh",   "SuperH",   },
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

2020-04-24 Thread 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 
---

 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) - 0x20)))
 # 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 

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

2020-04-24 Thread 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 
---

 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


[PATCH 4/6] kbuild: make DEFCONFIG_LIST work

2020-04-24 Thread 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 
---

 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


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

2020-04-24 Thread 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 
---

 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 
 #include 
 #include 
@@ -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


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

2020-04-24 Thread 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").

Signed-off-by: Masahiro Yamada 
---

 Makefile | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/Makefile b/Makefile
index 626318624..797ed214a 100644
--- a/Makefile
+++ b/Makefile
@@ -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),\
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

2020-04-24 Thread 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 
---

 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


[PATCH] kconfig: update to Linux 5.7-rc2

2020-04-21 Thread Masahiro Yamada
The previous sync was Linux 5.5. This updates Kconfig to Linux 5.7-rc2.

Highlights:

 - add yes2modconfig and mod2yesconfig, which are useful for coping with
   syzbot configs in Linux

 - remove include/config/tristate.conf

 - show more precise help

 - fix various issues of 'make xconfig'

Signed-off-by: Masahiro Yamada 
---

 Makefile |   6 +-
 scripts/kconfig/.gitignore   |   4 +-
 scripts/kconfig/Makefile |  38 +++---
 scripts/kconfig/conf.c   |  16 +++
 scripts/kconfig/confdata.c   |  62 +++--
 scripts/kconfig/expr.c   |   3 +-
 scripts/kconfig/expr.h   |   2 +-
 scripts/kconfig/gconf.c  |   1 +
 scripts/kconfig/lkc.h|   4 +-
 scripts/kconfig/mconf.c  |   1 +
 scripts/kconfig/menu.c   | 185 ---
 scripts/kconfig/nconf.c  |   1 +
 scripts/kconfig/parser.y |  21 ++-
 scripts/kconfig/qconf.cc |  92 +
 scripts/kconfig/qconf.h  |   2 +
 scripts/kconfig/streamline_config.pl |   4 +-
 scripts/kconfig/symbol.c |  31 +
 17 files changed, 253 insertions(+), 220 deletions(-)

diff --git a/Makefile b/Makefile
index 6fc822da4..626318624 100644
--- a/Makefile
+++ b/Makefile
@@ -176,6 +176,9 @@ SRCARCH := $(ARCH)
 
 KCONFIG_CONFIG ?= .config
 
+# Default file for 'make defconfig'. This may be overridden by arch-Makefile.
+export KBUILD_DEFCONFIG := defconfig
+
 # SHELL used by kbuild
 CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
  else if [ -x /bin/bash ]; then echo /bin/bash; \
@@ -468,7 +471,8 @@ $(KCONFIG_CONFIG):
 #
 # This exploits the 'multi-target pattern rule' trick.
 # The syncconfig should be executed only once to make all the targets.
-%/auto.conf %/auto.conf.cmd %/tristate.conf: $(KCONFIG_CONFIG)
+# (Note: use the grouped target '&:' when we bump to GNU Make 4.3)
+%/auto.conf %/auto.conf.cmd: $(KCONFIG_CONFIG)
$(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
 endif # $(dot-config)
 
diff --git a/scripts/kconfig/.gitignore b/scripts/kconfig/.gitignore
index b5bf92f66..12a67fdab 100644
--- a/scripts/kconfig/.gitignore
+++ b/scripts/kconfig/.gitignore
@@ -1,6 +1,4 @@
-#
-# Generated files
-#
+# SPDX-License-Identifier: GPL-2.0-only
 *.moc
 *conf-cfg
 
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 2f1a59fa5..c9d0a4a8e 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -12,10 +12,6 @@ else
 Kconfig := Kconfig
 endif
 
-ifndef KBUILD_DEFCONFIG
-KBUILD_DEFCONFIG := defconfig
-endif
-
 ifeq ($(quiet),silent_)
 silent := -s
 endif
@@ -47,16 +43,16 @@ build_gconfig: $(obj)/gconf
 build_xconfig: $(obj)/qconf
 
 localyesconfig localmodconfig: $(obj)/conf
-   $(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) 
$(Kconfig) > .tmp.config
-   $(Q)if [ -f .config ]; then \
-   cmp -s .tmp.config .config ||   \
-   (mv -f .config .config.old.1;   \
-mv -f .tmp.config .config; \
-$< $(silent) --oldconfig $(Kconfig);   \
-mv -f .config.old.1 .config.old)   \
-   else\
-   mv -f .tmp.config .config;  \
-   $< $(silent) --oldconfig $(Kconfig);\
+   $(Q)$(PERL) $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) 
$(Kconfig) > .tmp.config
+   $(Q)if [ -f .config ]; then \
+   cmp -s .tmp.config .config ||   \
+   (mv -f .config .config.old.1;   \
+mv -f .tmp.config .config; \
+$< $(silent) --oldconfig $(Kconfig);   \
+mv -f .config.old.1 .config.old)   \
+   else\
+   mv -f .tmp.config .config;  \
+   $< $(silent) --oldconfig $(Kconfig);\
fi
$(Q)rm -f .tmp.config
 
@@ -67,7 +63,7 @@ localyesconfig localmodconfig: $(obj)/conf
 #  deprecated for external use
 simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
alldefconfig randconfig listnewconfig olddefconfig syncconfig \
-   helpnewconfig
+   helpnewconfig yes2modconfig mod2yesconfig
 
 PHONY += $(simple-targets)
 
@@ -135,6 +131,8 @@ help:
@echo  '  allmodconfig- New config selecting modules when possible'
@echo  '  alldefconfig- New config with all symbols set to default'
@echo  '  randconfig  - New config with 

[PATCH v2 3/4] kbuild: support ccflags-y, asflags-y, cppflags-y, and ldflags-y

2020-04-21 Thread Masahiro Yamada
Some Makefiles use ccflags-y, but it is not actually supported.
Support ccflags-y, asflags-y, cppflags-y, and ldflags-y like Linux.

Remove the workaround in drivers/pci/Makefile.

Signed-off-by: Masahiro Yamada 
---

Changes in v2:
  - add ldflags-y

 drivers/pci/Makefile |  2 --
 scripts/Makefile.lib | 12 
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile
index 3ca670865..d227619ed 100644
--- a/drivers/pci/Makefile
+++ b/drivers/pci/Makefile
@@ -5,8 +5,6 @@ obj-y   += pci.o bus.o pci_iomap.o
 
 ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG
 
-CPPFLAGS += $(ccflags-y)
-
 obj-$(CONFIG_PCI_MVEBU)+= pci-mvebu.o pci-mvebu-phy.o
 obj-$(CONFIG_PCI_TEGRA) += pci-tegra.o
 obj-$(CONFIG_PCIE_DW) += pcie-designware.o pcie-designware-host.o
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index d4c2ed15b..5a5d6a3a6 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -1,5 +1,9 @@
 # SPDX-License-Identifier: GPL-2.0
 # Backward compatibility
+asflags-y  += $(EXTRA_AFLAGS)
+ccflags-y  += $(EXTRA_CFLAGS)
+cppflags-y += $(EXTRA_CPPFLAGS)
+ldflags-y  += $(EXTRA_LDFLAGS)
 always-y   += $(always)
 hostprogs  += $(hostprogs-y) $(hostprogs-m)
 
@@ -128,9 +132,9 @@ basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call 
name-fix,$(basetarget)))"
 modname_flags  = $(if $(filter 1,$(words $(modname))),\
  -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
 
-_c_flags   = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(target-stem).o)
-_a_flags   = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(target-stem).o)
-_cpp_flags = $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CPPFLAGS_$(target-stem).lds)
+_c_flags   = $(CFLAGS) $(ccflags-y) $(CFLAGS_$(target-stem).o)
+_a_flags   = $(AFLAGS) $(asflags-y) $(AFLAGS_$(target-stem).o)
+_cpp_flags = $(CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(target-stem).lds)
 
 ifeq ($(CONFIG_UBSAN),y)
 _CFLAGS_UBSAN   = $(eval _CFLAGS_UBSAN := $(CFLAGS_UBSAN))$(_CFLAGS_UBSAN)
@@ -167,7 +171,7 @@ a_flags= -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) 
$(CPPFLAGS) \
 
 cpp_flags  = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(__cpp_flags)
 
-ld_flags   = $(LDFLAGS) $(EXTRA_LDFLAGS)
+ld_flags   = $(LDFLAGS) $(ldflags-y)
 
 dtc_cpp_flags  = -Wp,-MD,$(depfile).pre -nostdinc\
 -I$(srctree)/arch/$(SRCARCH)/dts/include\
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 1/4] riscv: remove meaningless LDFLAGS addition

2020-04-21 Thread Masahiro Yamada
No one sets ldflags-y. This line is meaningless.

Signed-off-by: Masahiro Yamada 
---

Changes in v2:
 - new patch

 arch/riscv/Makefile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index fa8a173d8..b71a52ad1 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -10,7 +10,6 @@ cflags-y += -fno-pic -pipe
 cflags-y += -Wall -Wstrict-prototypes \
-Wno-uninitialized -Wno-format -Wno-main -mcmodel=medany
 
-LDFLAGS += $(ldflags-y)
 LDFLAGS_barebox += -nostdlib
 
 machine-$(CONFIG_MACH_ERIZO)   := erizo
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 2/4] mips: rename ldflags-y to mips-ldflags-y

2020-04-21 Thread Masahiro Yamada
The next commit will add ldflags-y to scripts/Makefile.lib like Linux,
but barebox includes scripts/Makefile.lib from the top Makefile.

arch/mips/Makefile uses ldflags-y for a different meaning.

To avoid unpleasant side-effect, this commit rename it.

Signed-off-by: Masahiro Yamada 
---

Changes in v2:
  - new patch

 arch/mips/Makefile | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index ee3364d27..932fdab0a 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -34,17 +34,17 @@ predef-le += -DMIPSEL -D_MIPSEL -D__MIPSEL -D__MIPSEL__
 
 ifdef CONFIG_CPU_BIG_ENDIAN
 cflags-y += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo -EB 
$(undef-all) $(predef-be))
-ldflags-y += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo -EB )
+mips-ldflags-y += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo 
-EB )
 endif
 
 ifdef CONFIG_CPU_LITTLE_ENDIAN
 cflags-y += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL 
$(undef-all) $(predef-le))
-ldflags-y += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL )
+mips-ldflags-y += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo 
-EL )
 endif
 
-LDFLAGS += $(ldflags-y) -m $(ld-emul)
-LDFLAGS_barebox += $(ldflags-y)
-LDFLAGS_pbl += $(ldflags-y)
+LDFLAGS += $(mips-ldflags-y) -m $(ld-emul)
+LDFLAGS_barebox += $(mips-ldflags-y)
+LDFLAGS_pbl += $(mips-ldflags-y)
 
 #
 # CPU-dependent compiler/assembler options for optimization.
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 4/4] kbuild: prefix compiler flag variables with KBUILD_

2020-04-21 Thread Masahiro Yamada
In old days, Linux also used to use well-known variables such CFLAGS,
CPPFLAGS, etc.

They were prefixed with KBUILD_ presumably for preventing users from
overriding them accidentally.

Rename as follows:
  CFLAGS  ->  KBUILD_CFLAGS
  AFLAGS  ->  KBUILD_AFLAGS
  CPPFLAGS->  KBUILD_CPPFLAGS
  LDFLAGS ->  KBUILD_LDFLAGS
  HOSTCFLAGS  ->  KBUILD_HOSTCFLAGS
  HOSTCXXFLAGS->  KBUILD_HOSTCXXFLAGS
  HOSTLDFLAGS ->  KBUILD_HOSTLDFLAGS
  HOST_LOADLIBES  ->  KBUILD_HOSTLDLIBS

HOSTCFLAGS, HOSTCXXFLAGS, HOSTLDFLAGS, HOSTLDLIBS are re-used to allow
users to pass-in additional flags to the host compiler.

Signed-off-by: Masahiro Yamada 
---

Changes in v2: None

 Makefile | 51 +---
 arch/arm/Makefile| 34 +--
 arch/kvx/Makefile| 12 +-
 arch/mips/Makefile   | 22 -
 arch/mips/pbl/Makefile   |  2 +-
 arch/nios2/Makefile  |  2 +-
 arch/openrisc/Makefile   |  2 +-
 arch/ppc/Makefile| 14 +--
 arch/riscv/Makefile  | 14 +--
 arch/sandbox/Makefile| 10 
 arch/sandbox/os/Makefile |  8 +++
 arch/x86/Makefile| 32 -
 arch/x86/boot/Makefile   |  2 +-
 scripts/Kbuild.include   | 10 
 scripts/Makefile |  4 ++--
 scripts/Makefile.build   |  2 +-
 scripts/Makefile.host| 12 +-
 scripts/Makefile.lib | 14 +--
 scripts/Makefile.modpost |  2 +-
 19 files changed, 126 insertions(+), 123 deletions(-)

diff --git a/Makefile b/Makefile
index aa9b9806e..6fc822da4 100644
--- a/Makefile
+++ b/Makefile
@@ -187,10 +187,12 @@ HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
 
 HOSTCC   = gcc
 HOSTCXX  = g++
-HOSTCFLAGS   = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer 
$(HOST_LFS_CFLAGS)
-HOSTCXXFLAGS = -O2 $(HOST_LFS_CFLAGS)
-HOSTLDFLAGS = $(HOST_LFS_LDFLAGS)
-HOST_LOADLIBES = $(HOST_LFS_LIBS)
+KBUILD_HOSTCFLAGS   := -Wall -Wstrict-prototypes -O2 \
+   -fomit-frame-pointer $(HOST_LFS_CFLAGS) \
+   $(HOSTCFLAGS)
+KBUILD_HOSTCXXFLAGS := -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
+KBUILD_HOSTLDFLAGS  := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
+KBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
 
 # Decide whether to build built-in, modular, or both.
 # Normally, just do built-in.
@@ -306,12 +308,12 @@ LINUXINCLUDE:= -Iinclude -I$(srctree)/dts/include \
   -I$(objtree)/arch/$(ARCH)/include \
-include $(srctree)/include/linux/kconfig.h
 
-CPPFLAGS:= -D__KERNEL__ -D__BAREBOX__ $(LINUXINCLUDE) -fno-builtin 
-ffreestanding
+KBUILD_CPPFLAGS:= -D__KERNEL__ -D__BAREBOX__ $(LINUXINCLUDE) 
-fno-builtin -ffreestanding
 
-CFLAGS  := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
+KBUILD_CFLAGS  := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-Werror-implicit-function-declaration \
-fno-strict-aliasing -fno-common -Os -pipe 
-Wmissing-prototypes
-AFLAGS  := -D__ASSEMBLY__
+KBUILD_AFLAGS  := -D__ASSEMBLY__
 
 LDFLAGS_barebox:= -Map barebox.map
 
@@ -324,14 +326,15 @@ KERNELRELEASE = $(shell cat include/config/kernel.release 
2> /dev/null)
 KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 
 export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
-export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
+export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD 
CC
 export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL PYTHON3 
UTS_MACHINE
 export LEX YACC
-export HOSTCXX HOSTCXXFLAGS HOSTLDFLAGS HOST_LOADLIBES LDFLAGS_MODULE CHECK 
CHECKFLAGS
+export HOSTCXX CHECK CHECKFLAGS
+export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
 
-export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
-export CFLAGS CFLAGS_KERNEL
-export AFLAGS AFLAGS_KERNEL
+export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
+export KBUILD_CFLAGS CFLAGS_KERNEL
+export KBUILD_AFLAGS AFLAGS_KERNEL
 export LDFLAGS_barebox
 export LDFLAGS_pbl
 
@@ -471,33 +474,33 @@ endif # $(dot-config)
 
 include $(srctree)/arch/$(ARCH)/Makefile
 
-CFLAGS += -ggdb3
+KBUILD_CFLAGS  += -ggdb3
 
 # Force gcc to behave correct even for buggy distributions
-CFLAGS  += $(call cc-option, -fno-stack-protector)
+KBUILD_CFLAGS  += $(call cc-option, -fno-stack-protector)
 
 # This warning generated too much noise in a regular build.
 # Use make W=1 to enable this warning (see scripts/Makefile.build)
-CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
+KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
 
-CFLAGS += $(call cc-disable-warning, trampolines)
+KBUILD_CFLAGS += $(call cc-disable-warning, trampolines)
 
-CFLAGS += $(call cc-option, -

[PATCH 1/2] kbuild: support ccflags-y, asflags-y, and cppflags-y

2020-04-15 Thread Masahiro Yamada
Some Makefiles use ccflags-y, but it is not actually supported.
Support ccflags-y, asflags-y, and cppflags-y now.

Remove the workaround in drivers/pci/Makefile.

I did not add ldflags-y for now because arch/mips/Makefile is using
it for a different meaning.

Signed-off-by: Masahiro Yamada 
---

 drivers/pci/Makefile | 2 --
 scripts/Makefile.lib | 9 ++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile
index 3ca670865..d227619ed 100644
--- a/drivers/pci/Makefile
+++ b/drivers/pci/Makefile
@@ -5,8 +5,6 @@ obj-y   += pci.o bus.o pci_iomap.o
 
 ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG
 
-CPPFLAGS += $(ccflags-y)
-
 obj-$(CONFIG_PCI_MVEBU)+= pci-mvebu.o pci-mvebu-phy.o
 obj-$(CONFIG_PCI_TEGRA) += pci-tegra.o
 obj-$(CONFIG_PCIE_DW) += pcie-designware.o pcie-designware-host.o
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index d4c2ed15b..6ab30c486 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -1,5 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
 # Backward compatibility
+asflags-y  += $(EXTRA_AFLAGS)
+ccflags-y  += $(EXTRA_CFLAGS)
+cppflags-y += $(EXTRA_CPPFLAGS)
 always-y   += $(always)
 hostprogs  += $(hostprogs-y) $(hostprogs-m)
 
@@ -128,9 +131,9 @@ basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call 
name-fix,$(basetarget)))"
 modname_flags  = $(if $(filter 1,$(words $(modname))),\
  -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
 
-_c_flags   = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(target-stem).o)
-_a_flags   = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(target-stem).o)
-_cpp_flags = $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CPPFLAGS_$(target-stem).lds)
+_c_flags   = $(CFLAGS) $(ccflags-y) $(CFLAGS_$(target-stem).o)
+_a_flags   = $(AFLAGS) $(asflags-y) $(AFLAGS_$(target-stem).o)
+_cpp_flags = $(CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(target-stem).lds)
 
 ifeq ($(CONFIG_UBSAN),y)
 _CFLAGS_UBSAN   = $(eval _CFLAGS_UBSAN := $(CFLAGS_UBSAN))$(_CFLAGS_UBSAN)
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/2] kbuild: prefix compiler flag variables with KBUILD_

2020-04-15 Thread Masahiro Yamada
Linux also used to use well-known variables such CFLAGS, CPPFLAGS, etc.

They were prefixed with KBUILD_ presumably for preventing users from
overriding them accidentally.

Rename as follows:
  CFLAGS  ->  KBUILD_CFLAGS
  AFLAGS  ->  KBUILD_AFLAGS
  CPPFLAGS->  KBUILD_CPPFLAGS
  LDFLAGS ->  KBUILD_LDFLAGS
  HOSTCFLAGS  ->  KBUILD_HOSTCFLAGS
  HOSTCXXFLAGS->  KBUILD_HOSTCXXFLAGS
  HOSTLDFLAGS ->  KBUILD_HOSTLDFLAGS
  HOST_LOADLIBES  ->  KBUILD_HOSTLDLIBS

HOSTCFLAGS, HOSTCXXFLAGS, HOSTLDFLAGS, HOSTLDLIBS are re-used to allow
users to pass-in additional flags to the host compiler.

Signed-off-by: Masahiro Yamada 
---

 Makefile | 51 +---
 arch/arm/Makefile| 34 +--
 arch/kvx/Makefile| 12 +-
 arch/mips/Makefile   | 22 -
 arch/mips/pbl/Makefile   |  2 +-
 arch/nios2/Makefile  |  2 +-
 arch/openrisc/Makefile   |  2 +-
 arch/ppc/Makefile| 14 +--
 arch/riscv/Makefile  | 16 ++---
 arch/sandbox/Makefile| 10 
 arch/sandbox/os/Makefile |  8 +++
 arch/x86/Makefile| 32 -
 arch/x86/boot/Makefile   |  2 +-
 scripts/Kbuild.include   | 10 
 scripts/Makefile |  4 ++--
 scripts/Makefile.build   |  2 +-
 scripts/Makefile.host| 12 +-
 scripts/Makefile.lib | 14 +--
 scripts/Makefile.modpost |  2 +-
 19 files changed, 127 insertions(+), 124 deletions(-)

diff --git a/Makefile b/Makefile
index aa9b9806e..6fc822da4 100644
--- a/Makefile
+++ b/Makefile
@@ -187,10 +187,12 @@ HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
 
 HOSTCC   = gcc
 HOSTCXX  = g++
-HOSTCFLAGS   = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer 
$(HOST_LFS_CFLAGS)
-HOSTCXXFLAGS = -O2 $(HOST_LFS_CFLAGS)
-HOSTLDFLAGS = $(HOST_LFS_LDFLAGS)
-HOST_LOADLIBES = $(HOST_LFS_LIBS)
+KBUILD_HOSTCFLAGS   := -Wall -Wstrict-prototypes -O2 \
+   -fomit-frame-pointer $(HOST_LFS_CFLAGS) \
+   $(HOSTCFLAGS)
+KBUILD_HOSTCXXFLAGS := -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
+KBUILD_HOSTLDFLAGS  := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
+KBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
 
 # Decide whether to build built-in, modular, or both.
 # Normally, just do built-in.
@@ -306,12 +308,12 @@ LINUXINCLUDE:= -Iinclude -I$(srctree)/dts/include \
   -I$(objtree)/arch/$(ARCH)/include \
-include $(srctree)/include/linux/kconfig.h
 
-CPPFLAGS:= -D__KERNEL__ -D__BAREBOX__ $(LINUXINCLUDE) -fno-builtin 
-ffreestanding
+KBUILD_CPPFLAGS:= -D__KERNEL__ -D__BAREBOX__ $(LINUXINCLUDE) 
-fno-builtin -ffreestanding
 
-CFLAGS  := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
+KBUILD_CFLAGS  := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-Werror-implicit-function-declaration \
-fno-strict-aliasing -fno-common -Os -pipe 
-Wmissing-prototypes
-AFLAGS  := -D__ASSEMBLY__
+KBUILD_AFLAGS  := -D__ASSEMBLY__
 
 LDFLAGS_barebox:= -Map barebox.map
 
@@ -324,14 +326,15 @@ KERNELRELEASE = $(shell cat include/config/kernel.release 
2> /dev/null)
 KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 
 export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
-export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
+export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD 
CC
 export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL PYTHON3 
UTS_MACHINE
 export LEX YACC
-export HOSTCXX HOSTCXXFLAGS HOSTLDFLAGS HOST_LOADLIBES LDFLAGS_MODULE CHECK 
CHECKFLAGS
+export HOSTCXX CHECK CHECKFLAGS
+export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
 
-export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
-export CFLAGS CFLAGS_KERNEL
-export AFLAGS AFLAGS_KERNEL
+export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
+export KBUILD_CFLAGS CFLAGS_KERNEL
+export KBUILD_AFLAGS AFLAGS_KERNEL
 export LDFLAGS_barebox
 export LDFLAGS_pbl
 
@@ -471,33 +474,33 @@ endif # $(dot-config)
 
 include $(srctree)/arch/$(ARCH)/Makefile
 
-CFLAGS += -ggdb3
+KBUILD_CFLAGS  += -ggdb3
 
 # Force gcc to behave correct even for buggy distributions
-CFLAGS  += $(call cc-option, -fno-stack-protector)
+KBUILD_CFLAGS  += $(call cc-option, -fno-stack-protector)
 
 # This warning generated too much noise in a regular build.
 # Use make W=1 to enable this warning (see scripts/Makefile.build)
-CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
+KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
 
-CFLAGS += $(call cc-disable-warning, trampolines)
+KBUILD_CFLAGS += $(call cc-disable-warning, trampolines)
 
-CFLAGS += $(call cc-option, -fno-delete-null-pointer-checks,)
+KBU

Re: [PATCH] libfdt: update and to Linux 5.7-rc1

2020-04-15 Thread Masahiro Yamada
On Wed, Apr 15, 2020 at 6:40 PM Sascha Hauer  wrote:
>
> On Wed, Apr 15, 2020 at 04:59:17PM +0900, Masahiro Yamada wrote:
> > Fix the relative include path in 
> >
> > Including  is too much.  is enough
> > for INT_MAX.
> >
> > Define INT32_MAX and UINT32_MAX in the same way as Linux does.
> >
> > Signed-off-by: Masahiro Yamada 
> > ---
> >
> >  include/linux/libfdt.h | 2 +-
> >  include/linux/libfdt_env.h | 7 ---
> >  2 files changed, 5 insertions(+), 4 deletions(-)
>
> Applied, thanks.
>
> >
> > diff --git a/include/linux/libfdt.h b/include/linux/libfdt.h
> > index ef2467213..90ed4ebfa 100644
> > --- a/include/linux/libfdt.h
> > +++ b/include/linux/libfdt.h
> > @@ -3,6 +3,6 @@
> >  #define _INCLUDE_LIBFDT_H_
> >
> >  #include 
> > -#include "../scripts/dtc/libfdt/libfdt.h"
> > +#include "../../scripts/dtc/libfdt/libfdt.h"
>
> I wonder why this obviously wrong path worked before.


This is because the $(srctree)/include/
is added to the header search paths.


The top Makefile defines it as follows:

LINUXINCLUDE:= -Iinclude -I$(srctree)/dts/include \
   $(if $(KBUILD_SRC), -I$(srctree)/include) \
   -I$(srctree)/arch/$(ARCH)/include \
   -I$(objtree)/arch/$(ARCH)/include \
       -include $(srctree)/include/linux/kconfig.h



The previous "../scripts/dtc/libfdt/libfdt.h"
works because it is relative to $(srctree)/include/


---
Best Regards
Masahiro Yamada

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] libfdt: update and to Linux 5.7-rc1

2020-04-15 Thread Masahiro Yamada
Fix the relative include path in 

Including  is too much.  is enough
for INT_MAX.

Define INT32_MAX and UINT32_MAX in the same way as Linux does.

Signed-off-by: Masahiro Yamada 
---

 include/linux/libfdt.h | 2 +-
 include/linux/libfdt_env.h | 7 ---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/include/linux/libfdt.h b/include/linux/libfdt.h
index ef2467213..90ed4ebfa 100644
--- a/include/linux/libfdt.h
+++ b/include/linux/libfdt.h
@@ -3,6 +3,6 @@
 #define _INCLUDE_LIBFDT_H_
 
 #include 
-#include "../scripts/dtc/libfdt/libfdt.h"
+#include "../../scripts/dtc/libfdt/libfdt.h"
 
 #endif /* _INCLUDE_LIBFDT_H_ */
diff --git a/include/linux/libfdt_env.h b/include/linux/libfdt_env.h
index bac4670d6..cea8574a2 100644
--- a/include/linux/libfdt_env.h
+++ b/include/linux/libfdt_env.h
@@ -2,11 +2,14 @@
 #ifndef LIBFDT_ENV_H
 #define LIBFDT_ENV_H
 
-#include   /* For INT_MAX */
+#include   /* For INT_MAX */
 #include 
 
 #include 
 
+#define INT32_MAX  S32_MAX
+#define UINT32_MAX U32_MAX
+
 typedef __be16 fdt16_t;
 typedef __be32 fdt32_t;
 typedef __be64 fdt64_t;
@@ -16,6 +19,4 @@ typedef __be64 fdt64_t;
 #define fdt64_to_cpu(x) be64_to_cpu(x)
 #define cpu_to_fdt64(x) cpu_to_be64(x)
 
-#define INT32_MAX  2147483647
-
 #endif /* LIBFDT_ENV_H */
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/3] kbuild: rename hostprogs-y/always to hostprogs/always-y

2020-04-15 Thread Masahiro Yamada
[ Linux commit 5f2fb52fac15a8a8e10ce020dd532504a8abfc4e ]

In old days, the "host-progs" syntax was used for specifying host
programs. It was renamed to the current "hostprogs-y" in 2004.

It is typically useful in scripts/Makefile because it allows Kbuild to
selectively compile host programs based on the kernel configuration.

This commit renames like follows:

  always   ->  always-y
  hostprogs-y  ->  hostprogs

So, scripts/Makefile will look like this:

  always-$(CONFIG_BUILD_BIN2C) += ...
  always-$(CONFIG_KALLSYMS)+= ...
  ...
  hostprogs := $(always-y) $(always-m)

I think this makes more sense because a host program is always a host
program, irrespective of the kernel configuration. We want to specify
which ones to compile by CONFIG options, so always-y will be handier.

The "always", "hostprogs-y", "hostprogs-m" will be kept for backward
compatibility for a while.

Signed-off-by: Masahiro Yamada 
---

 scripts/Makefile.build | 6 --
 scripts/Makefile.clean | 4 ++--
 scripts/Makefile.host  | 8 
 scripts/Makefile.lib   | 9 -
 4 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index db687d5f9..a6ed83e6d 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -16,6 +16,8 @@ lib-y :=
 lib-m :=
 pbl-y :=
 always :=
+always-y :=
+always-m :=
 targets :=
 subdir-y :=
 subdir-m :=
@@ -43,7 +45,7 @@ include $(if $(wildcard $(kbuild-dir)/Kbuild), 
$(kbuild-dir)/Kbuild, $(kbuild-di
 include scripts/Makefile.lib
 
 # Do not include host rules unless needed
-ifneq ($(hostprogs-y)$(hostprogs-m),)
+ifneq ($(hostprogs)$(hostprogs-y)$(hostprogs-m),)
 include scripts/Makefile.host
 endif
 
@@ -80,7 +82,7 @@ endif
 
 __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(pbl-target) 
$(extra-y)) \
 $(if $(KBUILD_MODULES),$(obj-m)) \
-$(subdir-ym) $(always)
+$(subdir-ym) $(always-y)
@:
 
 # Linus' kernel sanity checking tool
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
index d1e4a7800..6e6c9ef7c 100644
--- a/scripts/Makefile.clean
+++ b/scripts/Makefile.clean
@@ -36,8 +36,8 @@ subdir-ymn:= $(addprefix $(obj)/,$(subdir-ymn))
 # directory
 
 __clean-files  := $(extra-y) $(extra-m) $(extra-)   \
-  $(always) $(targets) $(clean-files)   \
-  $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
+  $(always) $(always-y) $(always-m) $(always-) $(targets) 
$(clean-files)   \
+  $(hostprogs) $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
 
 # as clean-files is given relative to the current directory, this adds
 # a $(obj) prefix, except for absolute paths
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index 170952f68..61f0a7714 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -6,21 +6,21 @@
 # Both C and C++ are supported, but preferred language is C for such utilities.
 #
 # Sample syntax (see Documentation/kbuild/makefiles.txt for reference)
-# hostprogs-y := bin2hex
+# hostprogs := bin2hex
 # Will compile bin2hex.c and create an executable named bin2hex
 #
-# hostprogs-y:= lxdialog
+# hostprogs := lxdialog
 # lxdialog-objs := checklist.o lxdialog.o
 # Will compile lxdialog.c and checklist.c, and then link the executable
 # lxdialog, based on checklist.o and lxdialog.o
 #
-# hostprogs-y  := qconf
+# hostprogs   := qconf
 # qconf-cxxobjs   := qconf.o
 # qconf-objs  := menu.o
 # Will compile qconf as a C++ program, and menu as a C program.
 # They are linked as C++ code to the executable qconf
 
-__hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
+__hostprogs := $(sort $(hostprogs))
 
 # C code
 # Executables compiled from a single .c file
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index a94e16fe0..2b64b5432 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -1,3 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0
+# Backward compatibility
+always-y   += $(always)
+hostprogs  += $(hostprogs-y) $(hostprogs-m)
+
 # Figure out what we need to build from the various variables
 # ===
 
@@ -85,10 +90,12 @@ obj-dirs := $(dir $(multi-objs) $(obj-y) $(pbl-y))
 real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if 
$(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) 
$(extra-y)
 real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) 
$($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
 
+always-y += $(always-m)
+
 # Add subdir path
 
 extra-y:= $(addprefix $(obj)/,$(extra-y))
-always := $(addprefix $(obj)/,$(always))
+always-y   := $(addprefix $(obj)/,$(always-y))
 targets:= $(addprefix $(obj)/,$(targets))
 obj-y  := $(addprefix $(obj)/,$(obj-y))
 obj-m  := $(addprefix $(obj)/,$(obj-m))
-- 
2.2

[PATCH 3/3] fixdep: update to Linux 5.7-rc1

2020-04-15 Thread Masahiro Yamada
scripts/basic/ works for barebox as drop-in.

Update scripts/basic/ to Linux 5.7-rc1.

Signed-off-by: Masahiro Yamada 
---

 scripts/basic/.gitignore |  2 +-
 scripts/basic/Makefile   | 19 -
 scripts/basic/fixdep.c   | 61 
 3 files changed, 49 insertions(+), 33 deletions(-)

diff --git a/scripts/basic/.gitignore b/scripts/basic/.gitignore
index dc24f5f4c..98ae1f509 100644
--- a/scripts/basic/.gitignore
+++ b/scripts/basic/.gitignore
@@ -1,2 +1,2 @@
-docproc
+# SPDX-License-Identifier: GPL-2.0-only
 fixdep
diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile
index 9e92d899a..290dd27d2 100644
--- a/scripts/basic/Makefile
+++ b/scripts/basic/Makefile
@@ -1,15 +1,6 @@
-###
-# Makefile.basic list the most basic programs used during the build process.
-# The programs listed herein is what is needed to do the basic stuff,
-# such as fix dependency file.
-# This initial step is needed to avoid files to be recompiled
-# when barebox configuration changes (which is what happens when
-# .config is included by main Makefile.
-# ---
-# fixdep:   Used to generate dependency information during build process
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# fixdep: used to generate dependency information during build process
 
-hostprogs-y:= fixdep
-always := $(hostprogs-y)
-
-# fixdep is needed to compile other host programs
-$(addprefix $(obj)/,$(filter-out fixdep,$(always))): $(obj)/fixdep
+hostprogs  := fixdep
+always-y   := $(hostprogs)
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index facbd603a..877ca2c88 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -77,11 +77,6 @@
  * dependencies on include/config/my/option.h for every
  * CONFIG_MY_OPTION encountered in any of the prerequisites.
  *
- * It will also filter out all the dependencies on *.ver. We need
- * to make sure that the generated version checksum are globally up
- * to date before even starting the recursive build, so it's too late
- * at this point anyway.
- *
  * We don't even try to really parse the header files, but
  * merely grep, i.e. if CONFIG_FOO is mentioned in a comment, it will
  * be picked up as well. It's not a problem with respect to
@@ -99,6 +94,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -109,6 +105,36 @@ static void usage(void)
exit(1);
 }
 
+/*
+ * In the intended usage of this program, the stdout is redirected to .*.cmd
+ * files. The return value of printf() and putchar() must be checked to catch
+ * any error, e.g. "No space left on device".
+ */
+static void xprintf(const char *format, ...)
+{
+   va_list ap;
+   int ret;
+
+   va_start(ap, format);
+   ret = vprintf(format, ap);
+   if (ret < 0) {
+   perror("fixdep");
+   exit(1);
+   }
+   va_end(ap);
+}
+
+static void xputchar(int c)
+{
+   int ret;
+
+   ret = putchar(c);
+   if (ret == EOF) {
+   perror("fixdep");
+   exit(1);
+   }
+}
+
 /*
  * Print out a dependency path from a symbol name
  */
@@ -116,7 +142,7 @@ static void print_dep(const char *m, int slen, const char 
*dir)
 {
int c, prev_c = '/', i;
 
-   printf("$(wildcard %s/", dir);
+   xprintf("$(wildcard %s/", dir);
for (i = 0; i < slen; i++) {
c = m[i];
if (c == '_')
@@ -124,10 +150,10 @@ static void print_dep(const char *m, int slen, const char 
*dir)
else
c = tolower(c);
if (c != '/' || prev_c != '/')
-   putchar(c);
+   xputchar(c);
prev_c = c;
}
-   printf(".h) \\\n");
+   xprintf(".h) \\\n");
 }
 
 struct item {
@@ -220,7 +246,7 @@ static void parse_config_file(const char *p)
}
p += 7;
q = p;
-   while (*q && (isalnum(*q) || *q == '_'))
+   while (isalnum(*q) || *q == '_')
q++;
if (str_ends_with(p, q - p, "_MODULE"))
r = q - 7;
@@ -268,8 +294,7 @@ static void *read_file(const char *filename)
 static int is_ignored_file(const char *s, int len)
 {
return str_ends_with(s, len, "include/generated/autoconf.h") ||
-  str_ends_with(s, len, "include/generated/autoksyms.h") ||
-  str_ends_with(s, len, ".ver");
+  str_ends_with(s, len, "include/generated/autoksyms.h");
 }
 
 /*
@@ -324,13 +349,13 @@ static void parse_dep_file(char *m, const char *target)
 */

[PATCH 2/3] kbuild: update flex and bison rules to Linux 5.7-rc1

2020-04-15 Thread Masahiro Yamada
Import the following commits from Linux, and re-sync.

- 6ba7dc6616ce
  "kbuild: make bison create C file and header in a single pattern rule"

- cf8dfd15e5fb
  "kbuild: move flex and bison rules to Makefile.host"

Signed-off-by: Masahiro Yamada 
---

 scripts/Makefile.host | 20 +++-
 scripts/Makefile.lib  | 22 --
 2 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index 61f0a7714..8f4d62f22 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -1,3 +1,21 @@
+# SPDX-License-Identifier: GPL-2.0
+
+# LEX
+# ---
+quiet_cmd_flex = LEX $@
+  cmd_flex = $(LEX) -o$@ -L $<
+
+$(obj)/%.lex.c: $(src)/%.l FORCE
+   $(call if_changed,flex)
+
+# YACC
+# ---
+quiet_cmd_bison = YACC$(basename $@).[ch]
+  cmd_bison = $(YACC) -o $(basename $@).c --defines=$(basename $@).h -t -l 
$<
+
+$(obj)/%.tab.c $(obj)/%.tab.h: $(src)/%.y FORCE
+   $(call if_changed,bison)
+
 # ==
 # Building binaries on the host system
 # Binaries are used during the compilation of the kernel, for example
@@ -5,7 +23,7 @@
 #
 # Both C and C++ are supported, but preferred language is C for such utilities.
 #
-# Sample syntax (see Documentation/kbuild/makefiles.txt for reference)
+# Sample syntax (see Documentation/kbuild/makefiles.rst for reference)
 # hostprogs := bin2hex
 # Will compile bin2hex.c and create an executable named bin2hex
 #
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 2b64b5432..d4c2ed15b 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -195,28 +195,6 @@ $(foreach m, $(notdir $1), \
$(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s)))
 endef
 
-# LEX
-# ---
-quiet_cmd_flex = LEX $@
-  cmd_flex = $(LEX) -o$@ -L $<
-
-$(obj)/%.lex.c: $(src)/%.l FORCE
-   $(call if_changed,flex)
-
-# YACC
-# ---
-quiet_cmd_bison = YACC$@
-  cmd_bison = $(YACC) -o$@ -t -l $<
-
-$(obj)/%.tab.c: $(src)/%.y FORCE
-   $(call if_changed,bison)
-
-quiet_cmd_bison_h = YACC$@
-  cmd_bison_h = $(YACC) -o/dev/null --defines=$@ -t -l $<
-
-$(obj)/%.tab.h: $(src)/%.y FORCE
-   $(call if_changed,bison_h)
-
 # Shipped files
 # ===
 
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] ppc,riscv: set something to KBUILD_DEFCONFIG

2020-04-14 Thread Masahiro Yamada
'make ARCH=riscv defconfig' ends up with endless recursion.
Users may get upset with it.

In Linux, every architecture does something for 'make defconfig'.
Set something to KBUILD_DEFCONFIG to make it work for riscv and ppc.

There is only one file in arch/riscv/configs/, so there is no choice
but erizo_generic_defconfig for riscv.

There are some choices for ppc, but I am not sure what is appropriate.
I just picked something.

Signed-off-by: Masahiro Yamada 
---

 arch/ppc/Makefile   | 1 +
 arch/riscv/Makefile | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile
index 2fb9b1442..ebf60eded 100644
--- a/arch/ppc/Makefile
+++ b/arch/ppc/Makefile
@@ -1,3 +1,4 @@
+KBUILD_DEFCONFIG := p2020rdb_defconfig
 
 CPPFLAGS += -ffixed-r14 -m32   \
-meabi -D __PPC__ -D CONFIG_PPC \
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 643c0bc8e..fa8a173d8 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -1,3 +1,5 @@
+KBUILD_DEFCONFIG := erizo_generic_defconfig
+
 CPPFLAGS += -fno-strict-aliasing
 
 ifeq ($(CONFIG_ARCH_RV32I),y)
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] mfd: double-quote the menu prompt of MFD

2020-04-14 Thread Masahiro Yamada
Linux commit 801b27db4638 ("kconfig: drop T_WORD from the RHS of
'prompt' symbol") requires every prompt to be quoted even if it is
a single word.

This is the only place with no quoting. It must be surrounded by
double-quotes in order to sync Kconfig to Linux 5.6-rc1 or later.

While I was here, I reworded "MFD" to "Multifunction device drivers"
to be consistent with Linux.

Signed-off-by: Masahiro Yamada 
---

 drivers/mfd/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index ddf117712..32a2c661f 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1,4 +1,4 @@
-menu MFD
+menu "Multifunction device drivers"
 
 config MFD_ACT8846
depends on I2C
-- 
2.25.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/3] kconfig: update to Linux 5.5

2020-03-24 Thread Masahiro Yamada
The previous sync was Linux 5.3-rc3. This updates Kconfig to Linux 5.5.

Signed-off-by: Masahiro Yamada 
---
 scripts/kconfig/Makefile| 10 +++---
 scripts/kconfig/conf.c  | 13 -
 scripts/kconfig/expr.c  |  7 +++
 scripts/kconfig/mconf-cfg.sh|  3 +++
 scripts/kconfig/merge_config.sh | 12 ++--
 scripts/kconfig/nconf-cfg.sh|  3 +++
 scripts/kconfig/parser.y|  1 -
 7 files changed, 38 insertions(+), 11 deletions(-)

diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index ef2f2336c469..2f1a59fa5169 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -66,7 +66,9 @@ localyesconfig localmodconfig: $(obj)/conf
 #  syncconfig has become an internal implementation detail and is now
 #  deprecated for external use
 simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
-   alldefconfig randconfig listnewconfig olddefconfig syncconfig
+   alldefconfig randconfig listnewconfig olddefconfig syncconfig \
+   helpnewconfig
+
 PHONY += $(simple-targets)
 
 $(simple-targets): $(obj)/conf
@@ -134,17 +136,19 @@ help:
@echo  '  alldefconfig- New config with all symbols set to default'
@echo  '  randconfig  - New config with random answer to all 
options'
@echo  '  listnewconfig   - List new options'
+   @echo  '  helpnewconfig   - List new options and help text'
@echo  '  olddefconfig- Same as oldconfig but sets new symbols to 
their'
@echo  'default value without prompting'
@echo  '  kvmconfig   - Enable additional options for kvm guest 
kernel support'
-   @echo  '  xenconfig   - Enable additional options for xen dom0 and 
guest kernel support'
+   @echo  '  xenconfig   - Enable additional options for xen dom0 and 
guest kernel'
+   @echo  'support'
@echo  '  tinyconfig  - Configure the tiniest possible kernel'
@echo  '  testconfig  - Run Kconfig unit tests (requires python3 
and pytest)'
 
 # ===
 # object files used by all kconfig flavours
 common-objs:= confdata.o expr.o lexer.lex.o parser.tab.o preprocess.o \
-  symbol.o
+  symbol.o util.o
 
 $(obj)/lexer.lex.o: $(obj)/parser.tab.h
 HOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src)
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 40e16e871ae2..1f89bf1558ce 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -32,6 +32,7 @@ enum input_mode {
defconfig,
savedefconfig,
listnewconfig,
+   helpnewconfig,
olddefconfig,
 };
 static enum input_mode input_mode = oldaskconfig;
@@ -434,6 +435,11 @@ static void check_conf(struct menu *menu)
printf("%s%s=%s\n", CONFIG_, 
sym->name, str);
}
}
+   } else if (input_mode == helpnewconfig) {
+   printf("-\n");
+   print_help(menu);
+   printf("-\n");
+
} else {
if (!conf_cnt++)
printf("*\n* Restart config...\n*\n");
@@ -459,6 +465,7 @@ static struct option long_opts[] = {
{"alldefconfig",no_argument,   NULL, alldefconfig},
{"randconfig",  no_argument,   NULL, randconfig},
{"listnewconfig",   no_argument,   NULL, listnewconfig},
+   {"helpnewconfig",   no_argument,   NULL, helpnewconfig},
{"olddefconfig",no_argument,   NULL, olddefconfig},
{NULL, 0, NULL, 0}
 };
@@ -469,6 +476,7 @@ static void conf_usage(const char *progname)
printf("Usage: %s [-s] [option] \n", progname);
printf("[option] is _one_ of the following:\n");
printf("  --listnewconfig List new options\n");
+   printf("  --helpnewconfig List new options and help text\n");
printf("  --oldaskconfig  Start a new configuration using a 
line-oriented program\n");
printf("  --oldconfig Update a configuration using a 
provided .config as base\n");
printf("  --syncconfigSimilar to oldconfig but generates 
configuration in\n"
@@ -543,6 +551,7 @@ int main(int ac, char **av)
case allmodconfig:
case alldefconfig:
case listnewconfig:
+   case helpnewconfig:
case olddefconfig:
 

[PATCH 2/3] kbuild: change *FLAGS_.o to take the path relative to $(obj)

2020-03-24 Thread Masahiro Yamada
[ Linux commit 54b8ae66ae1a3454a7645d159a482c31cd89ab33 ]

Kbuild provides per-file compiler flag addition/removal:

  CFLAGS_.o
  CFLAGS_REMOVE_.o
  AFLAGS_.o
  AFLAGS_REMOVE_.o
  CPPFLAGS_.lds
  HOSTCFLAGS_.o
  HOSTCXXFLAGS_.o

The  is the filename of the target with its directory and
suffix stripped.

This syntax comes into a trouble when two files with the same basename
appear in one Makefile, for example:

  obj-y += foo.o
  obj-y += dir/foo.o
  CFLAGS_foo.o := 

Here, the  applies to both foo.o and dir/foo.o

The real world problem is:

  scripts/kconfig/util.c
  scripts/kconfig/lxdialog/util.c

Both files are compiled into scripts/kconfig/mconf, but only the
latter should be given with the ncurses flags.

It is more sensible to use the relative path to the Makefile, like this:

  obj-y += foo.o
  CFLAGS_foo.o := 
  obj-y += dir/foo.o
  CFLAGS_dir/foo.o := 

At first, I attempted to replace $(basetarget) with $*. The $* variable
is replaced with the stem ('%') part in a pattern rule. This works with
most of cases, but does not for explicit rules.

For example, arch/ia64/lib/Makefile reuses rule_as_o_S in its own
explicit rules, so $* will be empty, resulting in ignoring the per-file
AFLAGS.

I introduced a new variable, target-stem, which can be used also from
explicit rules.

Signed-off-by: Masahiro Yamada 
---
 scripts/Makefile.host| 14 +++---
 scripts/Makefile.lib |  9 ++---
 scripts/kconfig/Makefile |  8 
 3 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index 8a88cbc9aec9..170952f6885a 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -64,9 +64,9 @@ obj-dirs += $(host-objdirs)
 # Handle options to gcc. Support building with separate output directory
 
 _hostc_flags   = $(HOSTCFLAGS)   $(HOST_EXTRACFLAGS)   \
- $(HOSTCFLAGS_$(basetarget).o)
+ $(HOSTCFLAGS_$(target-stem).o)
 _hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
- $(HOSTCXXFLAGS_$(basetarget).o)
+ $(HOSTCXXFLAGS_$(target-stem).o)
 
 ifeq ($(KBUILD_SRC),)
 __hostc_flags  = $(_hostc_flags)
@@ -86,7 +86,7 @@ hostcxx_flags  = -Wp,-MD,$(depfile) $(__hostcxx_flags)
 # host-csingle -> Executable
 quiet_cmd_host-csingle = HOSTCC  $@
   cmd_host-csingle = $(HOSTCC) $(hostc_flags) $(HOSTLDFLAGS) -o $@ $< \
-   $(HOST_LOADLIBES) $(HOSTLDLIBS_$(@F))
+   $(HOST_LOADLIBES) $(HOSTLDLIBS_$(target-stem))
 $(host-csingle): $(obj)/%: $(src)/%.c FORCE
$(call if_changed_dep,host-csingle)
 
@@ -94,8 +94,8 @@ $(host-csingle): $(obj)/%: $(src)/%.c FORCE
 # host-cmulti -> executable
 quiet_cmd_host-cmulti  = HOSTLD  $@
   cmd_host-cmulti  = $(HOSTCC) $(HOSTLDFLAGS) -o $@ \
- $(addprefix $(obj)/,$($(@F)-objs)) \
- $(HOST_LOADLIBES) $(HOSTLDLIBS_$(@F))
+ $(addprefix $(obj)/, $($(target-stem)-objs)) \
+ $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(target-stem))
 $(host-cmulti): FORCE
$(call if_changed,host-cmulti)
 $(call multi_depend, $(host-cmulti), , -objs)
@@ -112,8 +112,8 @@ $(host-cobjs): $(obj)/%.o: $(src)/%.c FORCE
 quiet_cmd_host-cxxmulti= HOSTLD  $@
   cmd_host-cxxmulti= $(HOSTCXX) $(HOSTLDFLAGS) -o $@ \
  $(foreach o,objs cxxobjs,\
- $(addprefix $(obj)/,$($(@F)-$(o \
- $(HOST_LOADLIBES) $(HOSTLDLIBS_$(@F))
+ $(addprefix $(obj)/, $($(target-stem)-$(o \
+ $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(target-stem))
 $(host-cxxmulti): FORCE
$(call if_changed,host-cxxmulti)
 $(call multi_depend, $(host-cxxmulti), , -objs -cxxobjs)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 9aa8be535f30..a94e16fe017f 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -106,6 +106,9 @@ subdir-ym   := $(addprefix $(obj)/,$(subdir-ym))
 obj-dirs   := $(addprefix $(obj)/,$(obj-dirs))
 bbenv-y:= $(addprefix $(obj)/,$(bbenv-y))
 
+# target with $(obj)/ and its suffix stripped
+target-stem = $(basename $(patsubst $(obj)/%,%,$@))
+
 # These flags are needed for modversions and compiling, so we define them here
 # already
 # $(modname_flags) #defines KBUILD_MODNAME as the name of the module it will
@@ -118,9 +121,9 @@ basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call 
name-fix,$(basetarget)))"
 modname_flags  = $(if $(filter 1,$(words $(modname))),\
  -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
 
-_c_flags   = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(basetarget).o)
-_a_flags   = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
-_cpp_flags = $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CPPFLAGS_$(@F))
+_c_flags   = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(target-stem).o)
+_a_flags   = $(AFLAGS) $(

[PATCH 1/3] kbuild: remove clean-dirs syntax

2020-03-24 Thread Masahiro Yamada
[ Linux comit 1634f2bfdb846ed0a8b73131a9dff7c420fb3fe1 ]

The only the difference between clean-files and clean-dirs is the -r
option passed to the 'rm' command.

You can always pass -r, and then remove the clean-dirs syntax.

Signed-off-by: Masahiro Yamada 
---
 scripts/Makefile.clean   | 15 +--
 scripts/kconfig/Makefile |  2 +-
 2 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
index 41712f89751c..d1e4a7800ee7 100644
--- a/scripts/Makefile.clean
+++ b/scripts/Makefile.clean
@@ -46,27 +46,14 @@ __clean-files   := $(wildcard   
\
$(addprefix $(obj)/, $(filter-out /%, $(__clean-files))) \
   $(filter /%, $(__clean-files)))
 
-# as clean-dirs is given relative to the current directory, this adds
-# a $(obj) prefix, except for absolute paths
-
-__clean-dirs:= $(wildcard   \
-   $(addprefix $(obj)/, $(filter-out /%, $(clean-dirs)))\
-  $(filter /%, $(clean-dirs)))
-
 # ==
 
 quiet_cmd_clean= CLEAN   $(obj)
-  cmd_clean= rm -f $(__clean-files)
-quiet_cmd_cleandir = CLEAN   $(__clean-dirs)
-  cmd_cleandir = rm -rf $(__clean-dirs)
-
+  cmd_clean= rm -rf $(__clean-files)
 
 __clean: $(subdir-ymn)
 ifneq ($(strip $(__clean-files)),)
+$(call cmd,clean)
-endif
-ifneq ($(strip $(__clean-dirs)),)
-   +$(call cmd,cleandir)
 endif
@:
 
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 7656e1137b6b..bed7a5a2fbe9 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -114,7 +114,7 @@ testconfig: $(obj)/conf
$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \
-o cache_dir=$(abspath $(obj)/tests/.cache) \
$(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
-clean-dirs += tests/.cache
+clean-files += tests/.cache
 
 # Help text used by make help
 help:
-- 
2.17.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 4/5] kbuild: rename barebox-{common, lds} to BAREBOX_{OBJS, LDS}

2020-03-10 Thread Masahiro Yamada
The previous commit renamed barebox-pbl-common because you cannot
export a variable that contain hyphens.

These variables are not exported for now. I am just renaming them for
consistency.

  barebox-common -> BAREBOX_OBJS
  barebox-lds-> BAREBOX_LDS

If barebox moves the link rules into scripts/link-barebox.sh like
Linux did, these two must be exported anyway.

Signed-off-by: Masahiro Yamada 
---

 Makefile  | 22 +++---
 arch/mips/Makefile|  6 +++---
 arch/sandbox/Makefile |  4 ++--
 arch/x86/Makefile |  4 ++--
 4 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/Makefile b/Makefile
index 20fa85ed8be4..40d146e511ac 100644
--- a/Makefile
+++ b/Makefile
@@ -583,18 +583,18 @@ export DEFAULT_COMPRESSION_SUFFIX
 #
 # System.map is generated to document addresses of all kernel symbols
 
-barebox-common := $(common-y)
+BAREBOX_OBJS := $(common-y)
 export BAREBOX_PBL_OBJS := $(pbl-common-y)
-barebox-all:= $(barebox-common)
-barebox-lds:= $(lds-y)
+barebox-all:= $(BAREBOX_OBJS)
+BAREBOX_LDS:= $(lds-y)
 
 # Rule to link barebox
 # May be overridden by arch/$(ARCH)/Makefile
 quiet_cmd_barebox__ ?= LD  $@
   cmd_barebox__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_barebox) -o $@ \
-  -T $(barebox-lds) \
-  --start-group $(barebox-common) --end-group  \
-  $(filter-out $(barebox-lds) $(barebox-common) FORCE ,$^)
+  -T $(BAREBOX_LDS) \
+  --start-group $(BAREBOX_OBJS) --end-group  \
+  $(filter-out $(BAREBOX_LDS) $(BAREBOX_OBJS) FORCE ,$^)
 
 # Generate new barebox version
 quiet_cmd_barebox_version = GEN .version
@@ -691,13 +691,13 @@ quiet_cmd_kallsyms = KSYM$@
$(call cmd,kallsyms)
 
 # .tmp_barebox1 must be complete except kallsyms, so update barebox version
-.tmp_barebox1: $(barebox-lds) $(barebox-all) FORCE
+.tmp_barebox1: $(BAREBOX_LDS) $(barebox-all) FORCE
$(call if_changed_rule,ksym_ld)
 
-.tmp_barebox2: $(barebox-lds) $(barebox-all) .tmp_kallsyms1.o FORCE
+.tmp_barebox2: $(BAREBOX_LDS) $(barebox-all) .tmp_kallsyms1.o FORCE
$(call if_changed,barebox__)
 
-.tmp_barebox3: $(barebox-lds) $(barebox-all) .tmp_kallsyms2.o FORCE
+.tmp_barebox3: $(BAREBOX_LDS) $(barebox-all) .tmp_kallsyms2.o FORCE
$(call if_changed,barebox__)
 
 # Needs to visit scripts/ before $(KALLSYMS) can be used.
@@ -767,7 +767,7 @@ barebox.S barebox.s: barebox FORCE
 endif
 
 # barebox image
-barebox: $(barebox-lds) $(barebox-common) $(kallsyms.o) FORCE
+barebox: $(BAREBOX_LDS) $(BAREBOX_OBJS) $(kallsyms.o) FORCE
$(call if_changed_rule,barebox__)
$(Q)rm -f .old_version
 
@@ -776,7 +776,7 @@ barebox.srec: barebox
 
 # The actual objects are generated when descending,
 # make sure no implicit rule kicks in
-$(sort $(barebox-common) ) $(barebox-lds) $(BAREBOX_PBL_OBJS): $(barebox-dirs) 
;
+$(sort $(BAREBOX_OBJS)) $(BAREBOX_LDS) $(BAREBOX_PBL_OBJS): $(barebox-dirs) ;
 
 # Handle descending into subdirectories listed in $(barebox-dirs)
 # Preset locale variables to speed up the build process. Limit locale
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 486dfd82533c..ee3364d27a89 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -118,9 +118,9 @@ CFLAGS += $(cflags-y)
 lds-$(CONFIG_GENERIC_LINKER_SCRIPT)   := arch/mips/lib/barebox.lds
 
 cmd_barebox__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_barebox) -o $@ \
-  -T $(barebox-lds) \
-  --start-group $(barebox-common) --end-group  \
-  $(filter-out $(barebox-lds) $(barebox-common) FORCE ,$^);\
+  -T $(BAREBOX_LDS) \
+  --start-group $(BAREBOX_OBJS) --end-group  \
+  $(filter-out $(BAREBOX_LDS) $(BAREBOX_OBJS) FORCE ,$^);  \
$(objtree)/scripts/mips-relocs $@
 
 
diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
index b127560a2b8c..b7470c3330eb 100644
--- a/arch/sandbox/Makefile
+++ b/arch/sandbox/Makefile
@@ -56,8 +56,8 @@ ifeq ($(CONFIG_UBSAN),y)
 SANITIZER_LIBS += -fsanitize=undefined
 endif
 
-cmd_barebox__ = $(CC) -o $@ -Wl,-T,$(barebox-lds) \
-   -Wl,--start-group $(barebox-common) -Wl,--end-group \
+cmd_barebox__ = $(CC) -o $@ -Wl,-T,$(BAREBOX_LDS) \
+   -Wl,--start-group $(BAREBOX_OBJS) -Wl,--end-group \
-lrt -lpthread $(SDL_LIBS) $(FTDI1_LIBS) \
$(SANITIZER_LIBS)
 
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 0751e6364999..4d471c2f8ae0 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -77,9 +77,9 @@ lds-$(CONFIG_X86_64)   := arch/x86/mach-efi/elf_x86_64_efi.lds
 cmd_barebox__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_barebox) -o $@ \
-T $(lds-y) \
-shared -Bsymbolic -nostdlib -znocombreloc  \
-   --start-group $(barebox-common) \
+   --start-group $(BAREBO

[PATCH 3/5] kbuild: rename barebox-pbl-common to BAREBOX_PBL_OBJS

2020-03-10 Thread Masahiro Yamada
'export barebox-pbl-common' does not work reliably because hyphens
are disallowed in shell variables.

This caused a problem in Linux in the past. See Linux commit 2bfbe7881ee0
("kbuild: Do not use hyphen in exported variable name").

The same problem occurs when you build barebox with O= and the directory
path to the source tree contains a shell special character like '~'.

The maintainer of GNU Make stated that there is no consistent way to
export variables that do not meet the shell's naming criteria.
(https://savannah.gnu.org/bugs/?55719)

Consequently, you cannot use hyphens in exported variables.

Rename barebox-pbl-common to BAREBOX_PBL_OBJS.

I named it after KBUILD_VMLINUX_OBJS in the Linux top Makefile.

Signed-off-by: Masahiro Yamada 
---

 Makefile   | 5 ++---
 arch/mips/pbl/Makefile | 2 +-
 images/Makefile| 4 ++--
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index e9e412af0815..20fa85ed8be4 100644
--- a/Makefile
+++ b/Makefile
@@ -584,8 +584,7 @@ export DEFAULT_COMPRESSION_SUFFIX
 # System.map is generated to document addresses of all kernel symbols
 
 barebox-common := $(common-y)
-barebox-pbl-common := $(pbl-common-y)
-export barebox-pbl-common
+export BAREBOX_PBL_OBJS := $(pbl-common-y)
 barebox-all:= $(barebox-common)
 barebox-lds:= $(lds-y)
 
@@ -777,7 +776,7 @@ barebox.srec: barebox
 
 # The actual objects are generated when descending,
 # make sure no implicit rule kicks in
-$(sort $(barebox-common) ) $(barebox-lds) $(barebox-pbl-common): 
$(barebox-dirs) ;
+$(sort $(barebox-common) ) $(barebox-lds) $(BAREBOX_PBL_OBJS): $(barebox-dirs) 
;
 
 # Handle descending into subdirectories listed in $(barebox-dirs)
 # Preset locale variables to speed up the build process. Limit locale
diff --git a/arch/mips/pbl/Makefile b/arch/mips/pbl/Makefile
index 44ce3d1c922e..8f9e9fe5931c 100644
--- a/arch/mips/pbl/Makefile
+++ b/arch/mips/pbl/Makefile
@@ -25,7 +25,7 @@ $(obj)/zbarebox.S: $(obj)/zbarebox FORCE
 PBL_CPPFLAGS   += -fdata-sections -ffunction-sections
 LDFLAGS_zbarebox   := -Map $(obj)/zbarebox.map
 LDFLAGS_zbarebox   += -static --gc-sections
-zbarebox-common := $(barebox-pbl-common) $(obj)/$(piggy_o)
+zbarebox-common := $(BAREBOX_PBL_OBJS) $(obj)/$(piggy_o)
 zbarebox-lds := $(obj)/zbarebox.lds
 
 quiet_cmd_zbarebox__ ?= LD  $@
diff --git a/images/Makefile b/images/Makefile
index 650baf170f1b..fe29c75e27b1 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -57,12 +57,12 @@ quiet_cmd_elf__ ?= LD  $@
   cmd_elf__ ?= $(LD) $(LDFLAGS_pbl) --gc-sections  \
-e $(2) -Map $@.map $(LDFLAGS_$(@F)) -o $@  \
-T $(pbl-lds)   \
-   --start-group $(barebox-pbl-common) $(obj)/piggy.o  \
+   --start-group $(BAREBOX_PBL_OBJS) $(obj)/piggy.o\
$(obj)/sha_sum.o --end-group
 
 PBL_CPPFLAGS   += -fdata-sections -ffunction-sections
 
-$(obj)/%.pbl: $(pbl-lds) $(barebox-pbl-common) $(obj)/piggy.o $(obj)/sha_sum.o 
FORCE
+$(obj)/%.pbl: $(pbl-lds) $(BAREBOX_PBL_OBJS) $(obj)/piggy.o $(obj)/sha_sum.o 
FORCE
$(call if_changed,elf__,$(*F))
 
 $(obj)/%.pblb: $(obj)/%.pbl FORCE
-- 
2.17.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 5/5] kbuild: replace barebox-all with BAREBOX_OBJS

2020-03-10 Thread Masahiro Yamada
Replace $(barebox-all) with $(BAREBOX_OBJS), then delete barebox-all.

Signed-off-by: Masahiro Yamada 
---

 Makefile | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 40d146e511ac..c18244e761f9 100644
--- a/Makefile
+++ b/Makefile
@@ -585,7 +585,6 @@ export DEFAULT_COMPRESSION_SUFFIX
 
 BAREBOX_OBJS := $(common-y)
 export BAREBOX_PBL_OBJS := $(pbl-common-y)
-barebox-all:= $(BAREBOX_OBJS)
 BAREBOX_LDS:= $(lds-y)
 
 # Rule to link barebox
@@ -691,13 +690,13 @@ quiet_cmd_kallsyms = KSYM$@
$(call cmd,kallsyms)
 
 # .tmp_barebox1 must be complete except kallsyms, so update barebox version
-.tmp_barebox1: $(BAREBOX_LDS) $(barebox-all) FORCE
+.tmp_barebox1: $(BAREBOX_LDS) $(BAREBOX_OBJS) FORCE
$(call if_changed_rule,ksym_ld)
 
-.tmp_barebox2: $(BAREBOX_LDS) $(barebox-all) .tmp_kallsyms1.o FORCE
+.tmp_barebox2: $(BAREBOX_LDS) $(BAREBOX_OBJS) .tmp_kallsyms1.o FORCE
$(call if_changed,barebox__)
 
-.tmp_barebox3: $(BAREBOX_LDS) $(barebox-all) .tmp_kallsyms2.o FORCE
+.tmp_barebox3: $(BAREBOX_LDS) $(BAREBOX_OBJS) .tmp_kallsyms2.o FORCE
$(call if_changed,barebox__)
 
 # Needs to visit scripts/ before $(KALLSYMS) can be used.
-- 
2.17.1


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  1   2   3   >