mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 00/15] Makefile: sync with linux v4.13 and add thin archives support
@ 2018-11-29 11:30 Steffen Trumtrar
  2018-11-29 11:30 ` [PATCH 01/15] Makefile: replace LINUXINCLUDE with BAREBOXINCLUDE Steffen Trumtrar
                   ` (14 more replies)
  0 siblings, 15 replies; 23+ messages in thread
From: Steffen Trumtrar @ 2018-11-29 11:30 UTC (permalink / raw)
  To: Barebox List

Hi!

This series synchronizes parts of the Makefile with Linux v4.13 and adds
scripts/link-barebox.sh. Finally support for thin archives is added.

This support is mainly needed for socfpga-xload, because now all unneeded
objects are discarded and the xloader files do not blow up in size once
multiple boards are selected at the same time.
As is also speeds up the build time a little bit and shouldn't break
anything (hopefully), it is selected for all ARM platforms.

Compile tested for socfpga(-xload)_defconfig and imx_v7_defconfig
Tested on the socrates board.

Please test if this breaks anything for your hardware or not.

Steffen Trumtrar (15):
  Makefile: replace LINUXINCLUDE with BAREBOXINCLUDE
  Makefile: Correctly deal with make options which contain an "s"
  scripts/Kbuild.include: Fix portability problem of "echo -e"
  scripts/Kbuild.include: replace KBUILD_CPPFLAGS with CPPFLAGS
  debug: Add CONFIG_DEBUG_READABLE_ASM
  Makefile: improve line wrapping
  Makefile: link of barebox moved to script
  scripts: link-barebox: fix bash-ism
  scripts: link-barebox: force error on kallsyms failure
  scripts: link-barebox: allow architectures to use thin archives
    instead of ld -r
  scripts: link-barebox: kallsyms allow 3-pass generation
  scripts: link-barebox: minor improvement for thin archives build
  scripts: link-barebox: close thin archives --whole-archives option
  scripts: link-barebox: thin archives use P option to ar
  ARM: Kconfig: select THIN_ARCHIVES for ARM

 Makefile                | 221 +++++++---------------------------
 arch/arm/Kconfig        |   1 +
 common/Kconfig          |  14 +++
 scripts/Kbuild.include  |   8 +-
 scripts/Makefile.build  |  30 ++++-
 scripts/link-barebox.sh | 259 ++++++++++++++++++++++++++++++++++++++++
 6 files changed, 345 insertions(+), 188 deletions(-)
 create mode 100755 scripts/link-barebox.sh

-- 
2.19.2


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

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

* [PATCH 01/15] Makefile: replace LINUXINCLUDE with BAREBOXINCLUDE
  2018-11-29 11:30 [PATCH 00/15] Makefile: sync with linux v4.13 and add thin archives support Steffen Trumtrar
@ 2018-11-29 11:30 ` Steffen Trumtrar
  2018-11-29 11:30 ` [PATCH 02/15] Makefile: Correctly deal with make options which contain an "s" Steffen Trumtrar
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Steffen Trumtrar @ 2018-11-29 11:30 UTC (permalink / raw)
  To: Barebox List

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 10e1b74a6d60..dedb16d60069 100644
--- a/Makefile
+++ b/Makefile
@@ -295,15 +295,15 @@ LDFLAGS_MODULE  = -T common/module.lds
 # even be read-only.
 export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions
 
-# Use LINUXINCLUDE when you must reference the include/ directory.
+# Use BAREBOXINCLUDE when you must reference the include/ directory.
 # Needed to be compatible with the O= option
-LINUXINCLUDE    := -Iinclude -I$(srctree)/dts/include \
+BAREBOXINCLUDE    := -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
 
-CPPFLAGS        := -D__KERNEL__ -D__BAREBOX__ $(LINUXINCLUDE) -fno-builtin -ffreestanding
+CPPFLAGS        := -D__KERNEL__ -D__BAREBOX__ $(BAREBOXINCLUDE) -fno-builtin -ffreestanding
 
 CFLAGS          := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
                    -Werror-implicit-function-declaration \
@@ -324,7 +324,7 @@ export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
 export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE
 export HOSTCXX HOSTCXXFLAGS HOSTLDFLAGS HOST_LOADLIBES LDFLAGS_MODULE CHECK CHECKFLAGS
 
-export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
+export CPPFLAGS NOSTDINC_FLAGS BAREBOXINCLUDE OBJCOPYFLAGS LDFLAGS
 export CFLAGS CFLAGS_KERNEL
 export AFLAGS AFLAGS_KERNEL
 export LDFLAGS_barebox
-- 
2.19.2


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

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

* [PATCH 02/15] Makefile: Correctly deal with make options which contain an "s"
  2018-11-29 11:30 [PATCH 00/15] Makefile: sync with linux v4.13 and add thin archives support Steffen Trumtrar
  2018-11-29 11:30 ` [PATCH 01/15] Makefile: replace LINUXINCLUDE with BAREBOXINCLUDE Steffen Trumtrar
@ 2018-11-29 11:30 ` Steffen Trumtrar
  2018-12-09 23:07   ` Roland Hieber
  2018-11-29 11:30 ` [PATCH 03/15] scripts/Kbuild.include: Fix portability problem of "echo -e" Steffen Trumtrar
                   ` (12 subsequent siblings)
  14 siblings, 1 reply; 23+ messages in thread
From: Steffen Trumtrar @ 2018-11-29 11:30 UTC (permalink / raw)
  To: Barebox List

Based on linux v3.2 patch: e6ac89fabd030704eac691dab7783ebe06e6b2c1

    kbuild: Correctly deal with make options which contain an "s"

    When using remake, which is based on gnumake, if you invoke
    an example build as shown below, the build will become silent
    due to the top level make file incorrectly guessing that
    the end user wants a silent build because an argument that
    contained an "s" was used.  Here are two examples one with remake
    and one with straight gnumake.

    remake --no-extended-errors
    make --warn-undefined-variables

    Fix up the top level Makefile to use filter to parse the options
    that mean silent instead of findstring catching other random
    arguments containing an "s".

    Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
    CC: Michal Marek <mmarek@suse.cz>
    CC: Andrew Morton <akpm@linux-foundation.org>
    CC: linux-kbuild@vger.kernel.org
    Signed-off-by: Michal Marek <mmarek@suse.cz>

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index dedb16d60069..cddff1267972 100644
--- a/Makefile
+++ b/Makefile
@@ -252,7 +252,7 @@ endif
 # If the user is running make -s (silent mode), suppress echoing of
 # commands
 
-ifneq ($(findstring s,$(MAKEFLAGS)),)
+ifneq ($(filter s% -s%,$(MAKEFLAGS)),)
   quiet=silent_
 endif
 
-- 
2.19.2


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

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

* [PATCH 03/15] scripts/Kbuild.include: Fix portability problem of "echo -e"
  2018-11-29 11:30 [PATCH 00/15] Makefile: sync with linux v4.13 and add thin archives support Steffen Trumtrar
  2018-11-29 11:30 ` [PATCH 01/15] Makefile: replace LINUXINCLUDE with BAREBOXINCLUDE Steffen Trumtrar
  2018-11-29 11:30 ` [PATCH 02/15] Makefile: Correctly deal with make options which contain an "s" Steffen Trumtrar
@ 2018-11-29 11:30 ` Steffen Trumtrar
  2018-11-29 11:30 ` [PATCH 04/15] scripts/Kbuild.include: replace KBUILD_CPPFLAGS with CPPFLAGS Steffen Trumtrar
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Steffen Trumtrar @ 2018-11-29 11:30 UTC (permalink / raw)
  To: Barebox List

Based on Linux v3.3 patch: 875de98623fa2b29f0cb19915fe3292ab6daa1cb

    scripts/Kbuild.include: Fix portability problem of "echo -e"

    "echo -e" is a GNU extension. When cross-compiling the kernel on a
    BSD-like operating system (Mac OS X in my case), this doesn't work.

    One could install a GNU version of echo, put that in the $PATH before
    the system echo and use "/usr/bin/env echo", but the solution with
    printf is simpler.

    Since it is no disadvantage on Linux, I hope that gets accepted even if
    cross-compiling the Linux kernel on another Unix operating system is
    quite a rare use case.

    Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
    Andreas Bießmann <andreas@biessmann.de>
    Signed-off-by: Michal Marek <mmarek@suse.cz>

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 scripts/Kbuild.include | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 512d217324c1..e62bd35692d0 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -105,7 +105,7 @@ as-option = $(call try-run,\
 # Usage: cflags-y += $(call as-instr,instr,option1,option2)
 
 as-instr = $(call try-run,\
-	/bin/echo -e "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -xassembler -o "$$TMP" -,$(2),$(3))
+	printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
 
 # cc-option
 # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
-- 
2.19.2


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

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

* [PATCH 04/15] scripts/Kbuild.include: replace KBUILD_CPPFLAGS with CPPFLAGS
  2018-11-29 11:30 [PATCH 00/15] Makefile: sync with linux v4.13 and add thin archives support Steffen Trumtrar
                   ` (2 preceding siblings ...)
  2018-11-29 11:30 ` [PATCH 03/15] scripts/Kbuild.include: Fix portability problem of "echo -e" Steffen Trumtrar
@ 2018-11-29 11:30 ` Steffen Trumtrar
  2018-12-05 12:22   ` Masahiro Yamada
  2018-11-29 11:30 ` [PATCH 05/15] debug: Add CONFIG_DEBUG_READABLE_ASM Steffen Trumtrar
                   ` (10 subsequent siblings)
  14 siblings, 1 reply; 23+ messages in thread
From: Steffen Trumtrar @ 2018-11-29 11:30 UTC (permalink / raw)
  To: Barebox List

The barebox Makefiles do not use KBUILD_CPPFLAGS but CPPFLAGS as variable name.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 scripts/Kbuild.include | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index e62bd35692d0..0cb3a70a6a42 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -111,12 +111,12 @@ as-instr = $(call try-run,\
 # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
 
 cc-option = $(call try-run,\
-	$(CC) $(KBUILD_CPPFLAGS) $(CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",$(1),$(2))
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",$(1),$(2))
 
 # cc-option-yn
 # Usage: flag := $(call cc-option-yn,-march=winchip-c6)
 cc-option-yn = $(call try-run,\
-	$(CC) $(KBUILD_CPPFLAGS) $(CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",y,n)
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",y,n)
 
 # cc-option-align
 # Prefix align with either -falign or -malign
@@ -126,7 +126,7 @@ cc-option-align = $(subst -functions=0,,\
 # cc-disable-warning
 # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
 cc-disable-warning = $(call try-run,\
-	$(CC) $(KBUILD_CPPFLAGS) $(CFLAGS) -W$(strip $(1)) -c -xc /dev/null -o "$$TMP",-Wno-$(strip $(1)))
+	$(CC) $(CPPFLAGS) $(CFLAGS) -W$(strip $(1)) -c -xc /dev/null -o "$$TMP",-Wno-$(strip $(1)))
 
 # cc-version
 # Usage gcc-ver := $(call cc-version)
-- 
2.19.2


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

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

* [PATCH 05/15] debug: Add CONFIG_DEBUG_READABLE_ASM
  2018-11-29 11:30 [PATCH 00/15] Makefile: sync with linux v4.13 and add thin archives support Steffen Trumtrar
                   ` (3 preceding siblings ...)
  2018-11-29 11:30 ` [PATCH 04/15] scripts/Kbuild.include: replace KBUILD_CPPFLAGS with CPPFLAGS Steffen Trumtrar
@ 2018-11-29 11:30 ` Steffen Trumtrar
  2018-11-29 11:30 ` [PATCH 06/15] Makefile: improve line wrapping Steffen Trumtrar
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Steffen Trumtrar @ 2018-11-29 11:30 UTC (permalink / raw)
  To: Barebox List

Based on linux v3.3 patch: 1873e870fd63ee4b87dbe0125ca373e420fb4987

    debug: Add CONFIG_READABLE_ASM

    Add a config option to disable various gcc compiler optimizations that
    make assembler listings much harder to read. This is everything that reorders
    code significantly or creates partial functions.

    This is mainly to keep kernel hackers sane.

    Signed-off-by: Andi Kleen <ak@linux.intel.com>
    Link: http://lkml.kernel.org/r/1332960678-11879-2-git-send-email-andi@firstfloor.org
    Signed-off-by: H. Peter Anvin <hpa@zytor.com>

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 Makefile       | 11 +++++++++++
 common/Kconfig |  8 ++++++++
 2 files changed, 19 insertions(+)

diff --git a/Makefile b/Makefile
index cddff1267972..ee6c8fc82d5a 100644
--- a/Makefile
+++ b/Makefile
@@ -478,6 +478,17 @@ CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
 # disable pointer signed / unsigned warnings in gcc 4.0
 CFLAGS += $(call cc-option,-Wno-pointer-sign,)
 
+ifdef CONFIG_DEBUG_READABLE_ASM
+# Disable optimizations that make assembler listings hard to read.
+# reorder blocks reorders the control in the function
+# ipa clone creates specialized cloned functions
+# partial inlining inlines only parts of functions
+CFLAGS += $(call cc-option,-fno-reorder-blocks,) \
+          $(call cc-option,-fno-ipa-cp-clone,) \
+          $(call cc-option,-fno-partial-inlining)
+endif
+
+
 # KBUILD_IMAGE: Default barebox image to build
 # Depending on the architecture, this can be either compressed or not.
 # It will also include any necessary headers to be bootable.
diff --git a/common/Kconfig b/common/Kconfig
index 2ad92158c145..c97beea81513 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1228,6 +1228,14 @@ config DEBUG_INITCALLS
 	help
 	  If enabled this will print initcall traces.
 
+config DEBUG_READABLE_ASM
+        bool "Generate readable assembler code"
+        help
+          Disable some compiler optimizations that tend to generate human unreadable
+          assembler output. This may make the kernel slightly slower, but it helps
+          to keep kernel developers who have to stare a lot at assembler listings
+          sane.
+
 endmenu
 
 config HAS_DEBUG_LL
-- 
2.19.2


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

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

* [PATCH 06/15] Makefile: improve line wrapping
  2018-11-29 11:30 [PATCH 00/15] Makefile: sync with linux v4.13 and add thin archives support Steffen Trumtrar
                   ` (4 preceding siblings ...)
  2018-11-29 11:30 ` [PATCH 05/15] debug: Add CONFIG_DEBUG_READABLE_ASM Steffen Trumtrar
@ 2018-11-29 11:30 ` Steffen Trumtrar
  2018-11-29 11:30 ` [PATCH 07/15] Makefile: link of barebox moved to script Steffen Trumtrar
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Steffen Trumtrar @ 2018-11-29 11:30 UTC (permalink / raw)
  To: Barebox List

Based on linux v3.4 patch: 450c6076a79ebb053cf53e43f948de5ab077c573

    Makefile: improve line wrapping

    Break a few lines that go way over the usual 80 column limit that we prefer.
    Also adjust the placement of a few line continuations.

    Signed-off-by: Jesper Juhl <jj@chaosbits.net>
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 Makefile | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index ee6c8fc82d5a..ca9ee925cbef 100644
--- a/Makefile
+++ b/Makefile
@@ -331,8 +331,10 @@ export LDFLAGS_barebox
 
 # Files to ignore in find ... statements
 
-RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg -o -name .git \) -prune -o
-export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS --exclude .pc --exclude .hg --exclude .git
+RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \
+		  -o -name .pc -o -name .hg -o -name .git \) -prune -o
+export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
+			--exclude CVS --exclude .pc --exclude .hg --exclude .git
 
 # ===========================================================================
 # Rules shared between *config targets and build targets
@@ -820,7 +822,7 @@ prepare3: include/config/kernel.release
 ifneq ($(KBUILD_SRC),)
 	@echo '  Using $(srctree) as source for barebox'
 	$(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \
-		echo "  $(srctree) is not clean, please run 'make mrproper'";\
+		echo "  $(srctree) is not clean, please run 'make mrproper'"; \
 		echo "  in the '$(srctree)' directory.";\
 		false; \
 	fi;
@@ -880,8 +882,8 @@ define filechk_utsrelease.h
 endef
 
 define filechk_version.h
-	(echo \#define LINUX_VERSION_CODE $(shell                             \
-	expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL));     \
+	(echo \#define LINUX_VERSION_CODE $(shell                       \
+	expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \
 	echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';)
 endef
 
-- 
2.19.2


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

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

* [PATCH 07/15] Makefile: link of barebox moved to script
  2018-11-29 11:30 [PATCH 00/15] Makefile: sync with linux v4.13 and add thin archives support Steffen Trumtrar
                   ` (5 preceding siblings ...)
  2018-11-29 11:30 ` [PATCH 06/15] Makefile: improve line wrapping Steffen Trumtrar
@ 2018-11-29 11:30 ` Steffen Trumtrar
  2018-11-30  7:17   ` Sascha Hauer
  2018-12-03  4:49   ` Sam Ravnborg
  2018-11-29 11:30 ` [PATCH 08/15] scripts: link-barebox: fix bash-ism Steffen Trumtrar
                   ` (7 subsequent siblings)
  14 siblings, 2 replies; 23+ messages in thread
From: Steffen Trumtrar @ 2018-11-29 11:30 UTC (permalink / raw)
  To: Barebox List

Adoption of the linux v3.4 patch: 1f2bfbd00e466ff3489b2ca5cc75b1cccd14c123

    Move the final link of vmlinux to a script to improve
    readability and maintainability of the code.

    The Makefile fragments used to link vmlinux has over the
    years seen far too many changes and the logic had become
    hard to follow.

    As the process by nature is serialized there was
    nothing gained including this in the Makefile.

    "um" has special link requirments - and the
    only way to handle this was to hard-code the linking
    of "um" in the script.
    This was better than trying to modularize it only for the
    benefit of "um" anyway.

    The shell script has been improved after input from:
    Arnaud Lacombe <lacombar@gmail.com>
    Nick Bowler <nbowler@elliptictech.com>

    Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
    Cc: Arnaud Lacombe <lacombar@gmail.com>
    Cc: Nick Bowler <nbowler@elliptictech.com>
    Cc: Richard Weinberger <richard@nod.at>
    Signed-off-by: Michal Marek <mmarek@suse.cz>

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 Makefile                | 187 ++++-----------------------------
 scripts/link-barebox.sh | 223 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 242 insertions(+), 168 deletions(-)
 create mode 100755 scripts/link-barebox.sh

diff --git a/Makefile b/Makefile
index ca9ee925cbef..8b8fb9caa887 100644
--- a/Makefile
+++ b/Makefile
@@ -217,6 +217,7 @@ endif
 
 export KBUILD_MODULES KBUILD_BUILTIN
 export KBUILD_CHECKSRC KBUILD_SRC
+export KCONFIG_CONFIG
 
 # Beautify output
 # ---------------------------------------------------------------------------
@@ -326,6 +327,7 @@ export HOSTCXX HOSTCXXFLAGS HOSTLDFLAGS HOST_LOADLIBES LDFLAGS_MODULE CHECK CHEC
 
 export CPPFLAGS NOSTDINC_FLAGS BAREBOXINCLUDE OBJCOPYFLAGS LDFLAGS
 export CFLAGS CFLAGS_KERNEL
+
 export AFLAGS AFLAGS_KERNEL
 export LDFLAGS_barebox
 
@@ -551,164 +553,11 @@ DEFAULT_COMPRESSION_SUFFIX :=
 endif
 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
-# in the kernel tree, others are specified in arch/$(ARCH)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
-#
-# barebox
-#   ^
-#   |
-#   +-< $(barebox-init)
-#   |   +--< init/version.o + more
-#   |
-#   +--< $(barebox-main)
-#   |    +--< driver/built-in.o mm/built-in.o + more
-#   |
-#   +-< kallsyms.o (see description in CONFIG_KALLSYMS section)
-#
-# barebox version cannot be updated during normal
-# descending-into-subdirs phase since we do not yet know if we need to
-# update barebox.
-#
-# 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
-barebox-all    := $(barebox-common)
-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 ,$^)
-
-# Generate new barebox version
-quiet_cmd_barebox_version = GEN     .version
-      cmd_barebox_version = set -e;                     \
-	if [ ! -r .version ]; then			\
-	  rm -f .version;				\
-	  echo 1 >.version;				\
-	else						\
-	  mv .version .old_version;			\
-	  expr 0$$(cat .old_version) + 1 >.version;	\
-	fi;						\
-	$(MAKE) $(build)=common
-
-# Generate System.map
-quiet_cmd_sysmap = SYSMAP
-      cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap
-
-# 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;                                         \
-	if [ $$? -ne 0 ]; then                                               \
-		rm -f $@;                                                    \
-		false;                                                       \
-	fi;
-endef
-
-ifdef CONFIG_KALLSYMS
-# Generate section listing all symbols and add it into barebox $(kallsyms.o)
-# It's a three stage process:
-# o .tmp_barebox1 has all symbols and sections, but __kallsyms is
-#   empty
-#   Running kallsyms on that gives us .tmp_kallsyms1.o with
-#   the right size - barebox version is updated during this step
-# o .tmp_barebox2 now has a __kallsyms section of the right size,
-#   but due to the added section, some addresses have shifted.
-#   From here, we generate a correct .tmp_kallsyms2.o
-# o The correct .tmp_kallsyms2.o is linked into the final barebox.
-# o Verify that the System.map from barebox matches the map from
-#   .tmp_barebox2, just in case we did not generate kallsyms correctly.
-# o If CONFIG_KALLSYMS_EXTRA_PASS is set, do an extra pass using
-#   .tmp_barebox3 and .tmp_kallsyms3.o.  This is only meant as a
-#   temporary bypass to allow the kernel to be built while the
-#   maintainers work out what went wrong with kallsyms.
-
-ifdef CONFIG_KALLSYMS_EXTRA_PASS
-last_kallsyms := 3
-else
-last_kallsyms := 2
-endif
-
-kallsyms.o := .tmp_kallsyms$(last_kallsyms).o
-
-define verify_kallsyms
-	$(Q)$(if $($(quiet)cmd_sysmap),                                      \
-	  echo '  $($(quiet)cmd_sysmap)  .tmp_System.map' &&)                \
-	  $(cmd_sysmap) .tmp_barebox$(last_kallsyms) .tmp_System.map
-	$(Q)cmp -s System.map .tmp_System.map ||                             \
-		(echo Inconsistent kallsyms data;                            \
-		 echo Try setting CONFIG_KALLSYMS_EXTRA_PASS;                \
-		 rm .tmp_kallsyms* ; false )
-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
-endef
-
-# Generate .S file with all kernel symbols
-quiet_cmd_kallsyms = KSYM    $@
-      cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) --all-symbols > $@
-
-.tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms3.o: %.o: %.S scripts FORCE
-	$(call if_changed_dep,as_o_S)
-
-.tmp_kallsyms%.S: .tmp_barebox% $(KALLSYMS)
-	$(call cmd,kallsyms)
-
-# .tmp_barebox1 must be complete except kallsyms, so update barebox version
-.tmp_barebox1: $(barebox-lds) $(barebox-all) FORCE
-	$(call if_changed_rule,ksym_ld)
-
-.tmp_barebox2: $(barebox-lds) $(barebox-all) .tmp_kallsyms1.o FORCE
-	$(call if_changed,barebox__)
-
-.tmp_barebox3: $(barebox-lds) $(barebox-all) .tmp_kallsyms2.o FORCE
-	$(call if_changed,barebox__)
-
-# Needs to visit scripts/ before $(KALLSYMS) can be used.
-$(KALLSYMS): scripts ;
-
-# Generate some data for debugging strange kallsyms problems
-debug_kallsyms: .tmp_map$(last_kallsyms)
-
-.tmp_map%: .tmp_barebox% FORCE
-	($(OBJDUMP) -h $< | $(AWK) '/^ +[0-9]/{print $$4 " 0 " $$2}'; $(NM) $<) | sort > $@
-
-.tmp_map3: .tmp_map2
-
-.tmp_map2: .tmp_map1
-
-endif # ifdef CONFIG_KALLSYMS
+barebox-all := $(barebox-common)
+barebox-lds := $(lds-y)
 
 # Do modpost on a prelinked vmlinux. The finally linked vmlinux has
 # relevant sections renamed as per the linker script.
@@ -775,10 +624,20 @@ barebox.S barebox.s: barebox FORCE
 endif
 
 # barebox image
-barebox: $(barebox-lds) $(barebox-head) $(barebox-common) $(kallsyms.o) FORCE
+export barebox-deps := $(barebox-lds) $(barebox-head) $(barebox-common) $(kallsyms.o)
+
+# Final link of barebox
+      cmd_link-barebox = $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_barebox)
+quiet_cmd_link-barebox = LINK    $@
+
+export BAREBOX_LDS := $(barebox-lds)
+export BAREBOX_COMMON := $(barebox-common)
+export KALLSYMS
+
+barebox: scripts/link-barebox.sh $(barebox-deps) FORCE
 	$(call barebox-modpost)
-	$(call if_changed_rule,barebox__)
-	$(Q)rm -f .old_version
+	+$(call if_changed,link-barebox)
+
 
 barebox.srec: barebox
 	$(OBJCOPY) -O srec $< $@
@@ -979,9 +838,7 @@ endif # CONFIG_MODULES
 
 # Directories & files removed with 'make clean'
 CLEAN_DIRS  += $(MODVERDIR)
-CLEAN_FILES +=	barebox System.map include/generated/barebox_default_env.h \
-                .tmp_version .tmp_barebox* barebox.bin barebox.map barebox.S \
-		.tmp_kallsyms* barebox.ldr \
+CLEAN_FILES +=	include/generated/barebox_default_env.h \
 		scripts/bareboxenv-target barebox-flash-image \
 		barebox.srec barebox.s5p barebox.ubl barebox.zynq \
 		barebox.uimage barebox.spi barebox.kwb barebox.kwbuart \
@@ -1005,6 +862,7 @@ $(clean-dirs):
 	$(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
 
 clean: archclean $(clean-dirs)
+	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-barebox.sh clean
 	$(call cmd,rmdirs)
 	$(call cmd,rmfiles)
 	@find . $(RCS_FIND_IGNORE) \
@@ -1169,13 +1027,6 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN   $(wildcard $(rm-files))
       cmd_rmfiles = rm -f $(rm-files)
 
 
-a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) \
-	  $(NOSTDINC_FLAGS) $(CPPFLAGS) \
-	  $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
-
-quiet_cmd_as_o_S = AS      $@
-cmd_as_o_S       = $(CC) $(a_flags) -c -o $@ $<
-
 # read all saved command lines
 
 targets := $(wildcard $(sort $(targets)))
diff --git a/scripts/link-barebox.sh b/scripts/link-barebox.sh
new file mode 100755
index 000000000000..2d920bc44b8e
--- /dev/null
+++ b/scripts/link-barebox.sh
@@ -0,0 +1,223 @@
+#!/bin/sh
+#
+# Link barebox
+# ---------------------------------------------------------------------------
+# 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.
+# Ordering when linking is important, and $(barebox-init) must be first.
+#
+# FIXME: This picture is wrong for barebox. We have no init, driver, mm
+#
+# barebox
+#   ^
+#   |
+#   +-< $(barebox-init)
+#   |   +--< init/version.o + more
+#   |
+#   +--< $(barebox-main)
+#   |    +--< driver/built-in.o mm/built-in.o + more
+#   |
+#   +-< kallsyms.o (see description in CONFIG_KALLSYMS section)
+#
+# barebox version cannot be updated during normal
+# descending-into-subdirs phase since we do not yet know if we need to
+# update barebox.
+#
+# System.map is generated to document addresses of all kernel symbols
+
+# Error out on error
+set -e
+
+# Nice output in kbuild format
+# Will be supressed by "make -s"
+info()
+{
+	if [ "${quiet}" != "silent_" ]; then
+		printf "  %-7s %s\n" ${1} ${2}
+	fi
+}
+
+# Thin archive build here makes a final archive with
+# symbol table and indexes from barebox objects, which can be
+# used as input to linker.
+#
+# Traditional incremental style of link does not require this step
+#
+# built-in.o output file
+#
+archive_builtin()
+{
+	if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then
+		info AR built-in.o
+		rm -f built-in.o;
+		${AR} rcsT built-in.o ${BAREBOX_COMMON}
+	fi
+}
+
+# Thin archive build here makes a final archive with
+# symbol table and indexes from barebox objects, which can be
+# used as input to linker.
+#
+# Traditional incremental style of link does not require this step
+#
+# built-in-pbl.o output file
+#
+archive_builtin_pbl()
+{
+	if [ -n "${CONFIG_THIN_ARCHIVES}" ] &&  [ -n "${CONFIG_PBL_IMAGE}" ]; then
+		info PBLAR built-in-pbl.o
+		rm -f built-in-pbl.o;
+		${AR} rcsT built-in-pbl.o ${BAREBOX_PBL_COMMON}
+	fi
+}
+
+# Link of barebox
+# ${1} - optional extra .o files
+# ${2} - output file
+barebox_link()
+{
+	${LD} ${LDFLAGS} ${LDFLAGS_barebox} -o ${2}                \
+		-T ${BAREBOX_LDS} --start-group ${BAREBOX_COMMON} --end-group ${1}
+}
+
+# Create ${2} .o file with all symbols from the ${1} object file
+kallsyms()
+{
+	info KSYM ${2}
+	local kallsymopt;
+
+	if [ -n "${CONFIG_KALLSYMS}" ]; then
+		kallsymopt=--all-symbols
+	fi
+
+	local aflags="${AFLAGS} ${AFLAGS_KERNEL}			\
+		      ${NOSTDINC_FLAGS} ${BAREBOXINCLUDE} ${CPPFLAGS}"
+
+	${NM} -n ${1} | \
+		${KALLSYMS} ${kallsymopt} | \
+		${CC} ${aflags} -c -o ${2} -x assembler-with-cpp -
+}
+
+# Create map file with all symbols from ${1}
+# See mksymap for additional details
+mksysmap()
+{
+	${CONFIG_SHELL} "${srctree}/scripts/mksysmap" ${1} ${2}
+}
+
+# Delete output files in case of error
+trap cleanup SIGHUP SIGINT SIGQUIT SIGTERM ERR
+cleanup()
+{
+	rm -f include/generated/barebox_default_env.h
+	rm -f .old_version
+	rm -f .tmp_System.map
+	rm -f .tmp_kallsyms*
+	rm -f .tmp_version
+	rm -f .tmp_barebox*
+	rm -f System.map
+	rm -f barebox.S
+	rm -f barebox.bin
+	rm -f barebox
+}
+
+#
+#
+# Use "make V=1" to debug this script
+case "${KBUILD_VERBOSE}" in
+	*1*)
+		set -x
+		;;
+esac
+
+if [ "$1" = "clean" ]; then
+	cleanup
+	exit 0
+fi
+
+# We need access to CONFIG_ symbols
+case "${KCONFIG_CONFIG}" in
+	*/*)
+		. "${KCONFIG_CONFIG}"
+		;;
+	*)
+		# Force using a file from the current directory
+		. "./${KCONFIG_CONFIG}"
+esac
+
+# Update version
+info GEN .version
+if [ ! -r .version ]; then
+	rm -f .version;
+	echo 1 >.version;
+else
+	mv .version .old_version;
+	expr 0$(cat .old_version) + 1 >.version;
+fi;
+
+kallsymso=""
+kallsyms_barebox=""
+if [ -n "${CONFIG_KALLSYMS}" ]; then
+
+	# kallsyms support
+	# Generate section listing all symbols and add it into vmlinux
+	# It's a three step process:
+	# 1)  Link .tmp_barebo1 so it has all symbols and sections,
+	#     but __kallsyms is empty.
+	#     Running kallsyms on that gives us .tmp_kallsyms1.o with
+	#     the right size
+	# 2)  Link .tmp_barebox2 so it now has a __kallsyms section of
+	#     the right size, but due to the added section, some
+	#     addresses have shifted.
+	#     From here, we generate a correct .tmp_barebox2.o
+	# 2a) We may use an extra pass as this has been necessary to
+	#     woraround some alignment related bugs.
+	#     KALLSYMS_EXTRA_PASS=1 is used to trigger this.
+	# 3)  The correct ${kallsymso} is linked into the final barebox.
+	#
+	# a)  Verify that the System.map from barebox matches the map from
+	#     ${kallsymso}.
+
+	kallsymso=.tmp_kallsyms2.o
+	kallsyms_barebox=.tmp_barebox2
+
+	# step 1
+	barebox_link "" .tmp_barebox1
+	kallsyms .tmp_barebox1 .tmp_kallsyms1.o
+
+	# step 2
+	barebox_link .tmp_kallsyms1.o .tmp_barebox2
+	kallsyms .tmp_barebox2 .tmp_kallsyms2.o
+
+	# step 2a
+	if [ -n "${CONFIG_KALLSYMS_EXTRA_PASS}" ]; then
+		kallsymso=.tmp_kallsyms3.o
+		kallsyms_barebox=.tmp_barebox3
+
+		barebox_link .tmp_kallsyms2.o .tmp_barebox3
+
+		kallsyms .tmp_barebox3 .tmp_kallsyms3.o
+	fi
+fi
+
+info LD barebox
+barebox_link "${kallsymso}" barebox
+
+info SYSMAP System.map
+mksysmap barebox System.map
+
+# step a (see comment above)
+if [ -n "${CONFIG_KALLSYMS}" ]; then
+	mksysmap ${kallsyms_barebox} .tmp_System.map
+
+	if ! cmp -s System.map .tmp_System.map; then
+		echo Inconsistent kallsyms data
+		echo echo Try "make KALLSYMS_EXTRA_PASS=1" as a workaround
+		cleanup
+		exit 1
+	fi
+fi
+
+# We made a new barebox - delete old version file
+rm -f .old_version
-- 
2.19.2


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

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

* [PATCH 08/15] scripts: link-barebox: fix bash-ism
  2018-11-29 11:30 [PATCH 00/15] Makefile: sync with linux v4.13 and add thin archives support Steffen Trumtrar
                   ` (6 preceding siblings ...)
  2018-11-29 11:30 ` [PATCH 07/15] Makefile: link of barebox moved to script Steffen Trumtrar
@ 2018-11-29 11:30 ` Steffen Trumtrar
  2018-11-29 11:30 ` [PATCH 09/15] scripts: link-barebox: force error on kallsyms failure Steffen Trumtrar
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Steffen Trumtrar @ 2018-11-29 11:30 UTC (permalink / raw)
  To: Barebox List

Based on linux v4.1 patch: ab160dbbc4ba71a4e339382d37b31ea44fd43e86

    scripts: fix link-vmlinux.sh bash-ism

    While building linux with dash shell:
      LINK    vmlinux
    trap: SIGHUP: bad trap
    /src/linux-4.0/Makefile:933: recipe for target 'vmlinux' failed
    make[1]: *** [vmlinux] Error 1

    See the following document for behavior of posix shell trap instruction:
    http://pubs.opengroup.org/onlinepubs/000095399/utilities/trap.html

    Cc: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Sylvain BERTRAND <sylvain.bertrand@gmail.com>
    Signed-off-by: Michal Marek <mmarek@suse.cz>

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 scripts/link-barebox.sh | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/scripts/link-barebox.sh b/scripts/link-barebox.sh
index 2d920bc44b8e..bff2363a19d5 100755
--- a/scripts/link-barebox.sh
+++ b/scripts/link-barebox.sh
@@ -107,7 +107,6 @@ mksysmap()
 }
 
 # Delete output files in case of error
-trap cleanup SIGHUP SIGINT SIGQUIT SIGTERM ERR
 cleanup()
 {
 	rm -f include/generated/barebox_default_env.h
@@ -122,6 +121,20 @@ cleanup()
 	rm -f barebox
 }
 
+on_exit()
+{
+	if [ $? -ne 0 ]; then
+		cleanup
+	fi
+}
+trap on_exit EXIT
+
+on_signals()
+{
+	exit 1
+}
+trap on_signals HUP INT QUIT TERM
+
 #
 #
 # Use "make V=1" to debug this script
-- 
2.19.2


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

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

* [PATCH 09/15] scripts: link-barebox: force error on kallsyms failure
  2018-11-29 11:30 [PATCH 00/15] Makefile: sync with linux v4.13 and add thin archives support Steffen Trumtrar
                   ` (7 preceding siblings ...)
  2018-11-29 11:30 ` [PATCH 08/15] scripts: link-barebox: fix bash-ism Steffen Trumtrar
@ 2018-11-29 11:30 ` Steffen Trumtrar
  2018-11-29 11:30 ` [PATCH 10/15] scripts: link-barebox: allow architectures to use thin archives instead of ld -r Steffen Trumtrar
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Steffen Trumtrar @ 2018-11-29 11:30 UTC (permalink / raw)
  To: Barebox List

Based on linux v4.5 patch: a043934207c5eb271deeaed2e9bd019c3be92cad

    scripts/link-vmlinux.sh: force error on kallsyms failure

    Since the output of the invocation of scripts/kallsyms is piped directly
    into the assembler, error messages it emits are visible on stderr, but
    a non-zero return code is ignored, and the build simply proceeds in that
    case. However, the resulting kernel is most likely broken, and will crash
    at boot.

    So instead, capture the output of kallsyms in a separate .S file, and pass
    that to the assembler in a separate step.

    Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Michal Marek <mmarek@suse.com>

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 scripts/link-barebox.sh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/scripts/link-barebox.sh b/scripts/link-barebox.sh
index bff2363a19d5..20375792a7f7 100755
--- a/scripts/link-barebox.sh
+++ b/scripts/link-barebox.sh
@@ -94,9 +94,10 @@ kallsyms()
 	local aflags="${AFLAGS} ${AFLAGS_KERNEL}			\
 		      ${NOSTDINC_FLAGS} ${BAREBOXINCLUDE} ${CPPFLAGS}"
 
-	${NM} -n ${1} | \
-		${KALLSYMS} ${kallsymopt} | \
-		${CC} ${aflags} -c -o ${2} -x assembler-with-cpp -
+	local afile="`basename ${2} .o`.S"
+
+	${NM} -n ${1} | ${KALLSYMS} ${kallsymopt} > ${afile}
+	${CC} ${aflags} -c -o ${2} -x assembler-with-cpp ${afile}
 }
 
 # Create map file with all symbols from ${1}
-- 
2.19.2


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

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

* [PATCH 10/15] scripts: link-barebox: allow architectures to use thin archives instead of ld -r
  2018-11-29 11:30 [PATCH 00/15] Makefile: sync with linux v4.13 and add thin archives support Steffen Trumtrar
                   ` (8 preceding siblings ...)
  2018-11-29 11:30 ` [PATCH 09/15] scripts: link-barebox: force error on kallsyms failure Steffen Trumtrar
@ 2018-11-29 11:30 ` Steffen Trumtrar
  2018-11-29 11:30 ` [PATCH 11/15] scripts: link-barebox: kallsyms allow 3-pass generation Steffen Trumtrar
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Steffen Trumtrar @ 2018-11-29 11:30 UTC (permalink / raw)
  To: Barebox List

Based on linux v4.8 patch: a5967db9af51a84f5e181600954714a9e4c69f1f

    kbuild: allow architectures to use thin archives instead of ld -r

    ld -r is an incremental link used to create built-in.o files in build
    subdirectories. It produces relocatable object files containing all
    its input files, and these are are then pulled together and relocated
    in the final link. Aside from the bloat, this constrains the final
    link relocations, which has bitten large powerpc builds with
    unresolvable relocations in the final link.

    Alan Modra has recommended the kernel use thin archives for linking.
    This is an alternative and means that the linker has more information
    available to it when it links the kernel.

    This patch enables a config option architectures can select, which
    causes all built-in.o files to be built as thin archives. built-in.o
    files in subdirectories do not get symbol table or index attached,
    which improves speed and size. The final link pass creates a
    built-in.o archive in the root output directory which includes the
    symbol table and index. The linker then uses takes this file to link.

    The --whole-archive linker option is required, because the linker now
    has visibility to every individual object file, and it will otherwise
    just completely avoid including those without external references
    (consider a file with EXPORT_SYMBOL or initcall or hardware exceptions
    as its only entry points). The traditional built works "by luck" as
    built-in.o files are large enough that they're going to get external
    references. However this optimisation is unpredictable for the kernel
    (due to above external references), ineffective at culling unused, and
    costly because the .o files have to be searched for references.
    Superior alternatives for link-time culling should be used instead.

    Build characteristics for inclink vs thinarc, on a small powerpc64le
    pseries VM with a modest .config:

                                      inclink       thinarc
    sizes
    vmlinux                        15 618 680    15 625 028
    sum of all built-in.o          56 091 808     1 054 334
    sum excluding root built-in.o                   151 430

    find -name built-in.o | xargs rm ; time make vmlinux
    real                              22.772s       21.143s
    user                              13.280s       13.430s
    sys                                4.310s        2.750s

    - Final kernel pulled in only about 6K more, which shows how
      ineffective the object file culling is.
    - Build performance looks improved due to less pagecache activity.
      On IO constrained systems it could be a bigger win.
    - Build size saving is significant.

    Side note, the toochain understands archives, so there's some tricks,
    $ ar t built-in.o          # list all files you linked with
    $ size built-in.o          # and their sizes
    $ objdump -d built-in.o    # disassembly (unrelocated) with filenames

    Implementation by sfr, minor tweaks by npiggin.

    Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
    Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
    Signed-off-by: Michal Marek <mmarek@suse.com>

For barebox using the *_defconfig

    sizes
    barebox-socfpga-de0_nano_soc.img                 225087        225045
    barebox-socfpga-sockit.img                       226239        226197
    barebox-socfpga-socrates.img                     225247        225205
    barebox-solidrun-hummingboard2-microsom-i4.img   635596        635109
    barebox-tq-mba53-512mib.img                      618856        618445

With socfpga_defconfig build times speed up a little, too:

    time make barebox
    real                                             32.22s        29.42s
    user                                             28.47s        26.33s
    sys                                               4.10s         3.94s

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 Makefile                |  1 +
 common/Kconfig          |  6 ++++++
 scripts/Makefile.build  | 30 ++++++++++++++++++++++++------
 scripts/link-barebox.sh | 14 +++++++++++++-
 4 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 8b8fb9caa887..4688ee7c126b 100644
--- a/Makefile
+++ b/Makefile
@@ -632,6 +632,7 @@ quiet_cmd_link-barebox = LINK    $@
 
 export BAREBOX_LDS := $(barebox-lds)
 export BAREBOX_COMMON := $(barebox-common)
+export BAREBOX_PBL_COMMON := $(barebox-pbl-common)
 export KALLSYMS
 
 barebox: scripts/link-barebox.sh $(barebox-deps) FORCE
diff --git a/common/Kconfig b/common/Kconfig
index c97beea81513..ed7a03246495 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -365,6 +365,12 @@ config RELOCATABLE
 	  allowing it to relocate to the end of the available RAM. This
 	  way you have the whole memory in a single piece.
 
+config THIN_ARCHIVES
+       bool
+       help
+         Select this if the architecture wants to use thin archives
+	 instead of ld -r to create the built-in.o files.
+
 config PANIC_HANG
 	bool "hang the system in case of a fatal error"
 	help
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 56ee07206516..a46e073f8250 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -311,11 +311,24 @@ $(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      $@
+
+ifdef CONFIG_THIN_ARCHIVES
+  # FIXME: it should be possible to use 's' instead of 'S' here, but this breaks the
+  # pbl build process, with a missing index. Usage of 's' *can* speed up the build,
+  # but as the buildtime of barebox is rather short, keep the 's' for the time being
+  cmd_make_builtin = rm -f $@; $(AR) rcsT$(ARFLAGS)
+  cmd_make_empty_builtin = rm -f $@; $(AR) rcST$(ARFLAGS)
+  quiet_cmd_link_o_target = AR      $@
+else
+  cmd_make_builtin = $(LD) $(ld_flags) -r -o
+  cmd_make_empty_builtin = rm -f $@; $(AR) rcs$(ARFLAGS)
+  quiet_cmd_link_o_target = LD      $@
+endif
+
 # 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), $^),\
-		      rm -f $@; $(AR) rcs $@)
+		      $(cmd_make_builtin) $@ $(filter $(obj-y), $^),\
+		      $(cmd_make_empty_builtin) $@)
 
 $(builtin-target): $(obj-y) FORCE
 	$(call if_changed,link_o_target)
@@ -327,8 +340,8 @@ 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 $@)
+		      $(cmd_make_builtin) $@ $(filter $(pbl-y), $^),\
+		      $(cmd_make_empty_builtin) $@)
 
 $(pbl-target): $(pbl-y) FORCE
 	$(call if_changed,pbl_link_o_target)
@@ -341,7 +354,12 @@ endif # pbl-target
 #
 ifdef lib-target
 quiet_cmd_link_l_target = AR      $@
-cmd_link_l_target = rm -f $@; $(AR) $(EXTRA_ARFLAGS) rcs $@ $(lib-y)
+
+ifdef CONFIG_THIN_ARCHIVES
+  cmd_link_l_target = rm -f $@; $(AR) rcsT$(ARFLAGS) $@ $(lib-y)
+else
+  cmd_link_l_target = rm -f $@; $(AR) rcs$(ARFLAGS) $@ $(lib-y)
+endif
 
 $(lib-target): $(lib-y) FORCE
 	$(call if_changed,link_l_target)
diff --git a/scripts/link-barebox.sh b/scripts/link-barebox.sh
index 20375792a7f7..a783dd6d5532 100755
--- a/scripts/link-barebox.sh
+++ b/scripts/link-barebox.sh
@@ -77,8 +77,16 @@ archive_builtin_pbl()
 # ${2} - output file
 barebox_link()
 {
+	local objects
+
+	if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then
+		objects="--whole-archive built-in.o ${1}"
+	else
+		objects="--start-group ${BAREBOX_COMMON} --end-group ${1}"
+	fi
+
 	${LD} ${LDFLAGS} ${LDFLAGS_barebox} -o ${2}                \
-		-T ${BAREBOX_LDS} --start-group ${BAREBOX_COMMON} --end-group ${1}
+		-T ${BAREBOX_LDS} ${objects}
 }
 
 # Create ${2} .o file with all symbols from the ${1} object file
@@ -116,6 +124,7 @@ cleanup()
 	rm -f .tmp_kallsyms*
 	rm -f .tmp_version
 	rm -f .tmp_barebox*
+	rm -f built-in.o
 	rm -f System.map
 	rm -f barebox.S
 	rm -f barebox.bin
@@ -160,6 +169,9 @@ case "${KCONFIG_CONFIG}" in
 		. "./${KCONFIG_CONFIG}"
 esac
 
+archive_builtin
+archive_builtin_pbl
+
 # Update version
 info GEN .version
 if [ ! -r .version ]; then
-- 
2.19.2


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

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

* [PATCH 11/15] scripts: link-barebox: kallsyms allow 3-pass generation
  2018-11-29 11:30 [PATCH 00/15] Makefile: sync with linux v4.13 and add thin archives support Steffen Trumtrar
                   ` (9 preceding siblings ...)
  2018-11-29 11:30 ` [PATCH 10/15] scripts: link-barebox: allow architectures to use thin archives instead of ld -r Steffen Trumtrar
@ 2018-11-29 11:30 ` Steffen Trumtrar
  2018-11-29 11:30 ` [PATCH 12/15] scripts: link-barebox: minor improvement for thin archives build Steffen Trumtrar
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Steffen Trumtrar @ 2018-11-29 11:30 UTC (permalink / raw)
  To: Barebox List

Based on linux v4.10 patch: 7e2b37c971a2a20ec8a311a195a626c16c774031

    kbuild: kallsyms allow 3-pass generation if symbols size has changed

    kallsyms generation is not foolproof, due to some linkers adding
    symbols (e.g., branch trampolines) when a binary size changes.
    Have it attempt a 3rd pass automatically if the kallsyms size changes
    in the 2nd pass.

    This allows powerpc64 allyesconfig to build without adding another
    pass when it's not required.

    This can be solved other ways by directing the linker not to add labels
    on branch stubs, or to move kallsyms near the end of the image. The
    former is undesirable for debugging/tracing, and the latter is a more
    significant change that requires more testing and review.

    Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
    Signed-off-by: Michal Marek <mmarek@suse.com>

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 scripts/link-barebox.sh | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/scripts/link-barebox.sh b/scripts/link-barebox.sh
index a783dd6d5532..34fa1944002c 100755
--- a/scripts/link-barebox.sh
+++ b/scripts/link-barebox.sh
@@ -200,7 +200,14 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
 	# 2a) We may use an extra pass as this has been necessary to
 	#     woraround some alignment related bugs.
 	#     KALLSYMS_EXTRA_PASS=1 is used to trigger this.
-	# 3)  The correct ${kallsymso} is linked into the final barebox.
+	# 3)  That link may have expanded the kernel image enough that
+	#     more linker branch stubs / trampolines had to be added, which
+	#     introduces new names, which further expands kallsyms. Do another
+	#     pass if that is the case. In theory it's possible this results
+	#     in even more stubs, but unlikely.
+	#     KALLSYMS_EXTRA_PASS=1 may also used to debug or work around
+	#     other bugs.
+	# 4)  The correct ${kallsymso} is linked into the final vmlinux.
 	#
 	# a)  Verify that the System.map from barebox matches the map from
 	#     ${kallsymso}.
@@ -216,8 +223,11 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
 	barebox_link .tmp_kallsyms1.o .tmp_barebox2
 	kallsyms .tmp_barebox2 .tmp_kallsyms2.o
 
-	# step 2a
-	if [ -n "${CONFIG_KALLSYMS_EXTRA_PASS}" ]; then
+	# step 3
+	size1=$(stat -c "%s" .tmp_kallsyms1.o)
+	size2=$(stat -c "%s" .tmp_kallsyms2.o)
+
+	if [ $size1 -ne $size2 ] || [ -n "${CONFIG_KALLSYMS_EXTRA_PASS}" ]; then
 		kallsymso=.tmp_kallsyms3.o
 		kallsyms_barebox=.tmp_barebox3
 
-- 
2.19.2


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

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

* [PATCH 12/15] scripts: link-barebox: minor improvement for thin archives build
  2018-11-29 11:30 [PATCH 00/15] Makefile: sync with linux v4.13 and add thin archives support Steffen Trumtrar
                   ` (10 preceding siblings ...)
  2018-11-29 11:30 ` [PATCH 11/15] scripts: link-barebox: kallsyms allow 3-pass generation Steffen Trumtrar
@ 2018-11-29 11:30 ` Steffen Trumtrar
  2018-11-29 11:30 ` [PATCH 13/15] scripts: link-barebox: close thin archives --whole-archives option Steffen Trumtrar
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 23+ messages in thread
From: Steffen Trumtrar @ 2018-11-29 11:30 UTC (permalink / raw)
  To: Barebox List

Based on linux v4.10 patch: abac4c89731c02f28820d3e1bc66e85bca4baa20

    kbuild: minor improvement for thin archives build

    The root built-in.o archive is currently generated before all object
    files are built for the final link, due to final build of init/ after
    version update. In practice it seems like it doesn't matter because
    the archive symbol table does not change, but it is more logical to
    create the final archive as the last step.

    Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
    Signed-off-by: Michal Marek <mmarek@suse.com>

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 scripts/link-barebox.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/link-barebox.sh b/scripts/link-barebox.sh
index 34fa1944002c..6a134d2dd198 100755
--- a/scripts/link-barebox.sh
+++ b/scripts/link-barebox.sh
@@ -169,9 +169,6 @@ case "${KCONFIG_CONFIG}" in
 		. "./${KCONFIG_CONFIG}"
 esac
 
-archive_builtin
-archive_builtin_pbl
-
 # Update version
 info GEN .version
 if [ ! -r .version ]; then
@@ -182,6 +179,9 @@ else
 	expr 0$(cat .old_version) + 1 >.version;
 fi;
 
+archive_builtin
+archive_builtin_pbl
+
 kallsymso=""
 kallsyms_barebox=""
 if [ -n "${CONFIG_KALLSYMS}" ]; then
-- 
2.19.2


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

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

* [PATCH 13/15] scripts: link-barebox: close thin archives --whole-archives option
  2018-11-29 11:30 [PATCH 00/15] Makefile: sync with linux v4.13 and add thin archives support Steffen Trumtrar
                   ` (11 preceding siblings ...)
  2018-11-29 11:30 ` [PATCH 12/15] scripts: link-barebox: minor improvement for thin archives build Steffen Trumtrar
@ 2018-11-29 11:30 ` Steffen Trumtrar
  2018-11-29 11:30 ` [PATCH 14/15] scripts: link-barebox: thin archives use P option to ar Steffen Trumtrar
  2018-11-29 11:30 ` [PATCH 15/15] ARM: Kconfig: select THIN_ARCHIVES for ARM Steffen Trumtrar
  14 siblings, 0 replies; 23+ messages in thread
From: Steffen Trumtrar @ 2018-11-29 11:30 UTC (permalink / raw)
  To: Barebox List

Based on linux v4.13 patch : 1328a1ae0e9048ff4b7f6b60c497db7a2799e1b1

    kbuild: thin archives final link close --whole-archives option

    Close the --whole-archives option with --no-whole-archive. Some
    architectures end up including additional .o and files multiple
    times after this, and they get duplicate symbols when they are
    brought under the --whole-archives option.

    This matches more closely with the incremental final link.

    Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
    Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 scripts/link-barebox.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/link-barebox.sh b/scripts/link-barebox.sh
index 6a134d2dd198..9e2bc2afd04b 100755
--- a/scripts/link-barebox.sh
+++ b/scripts/link-barebox.sh
@@ -80,7 +80,7 @@ barebox_link()
 	local objects
 
 	if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then
-		objects="--whole-archive built-in.o ${1}"
+		objects="--whole-archive built-in.o --no-whole-archive ${1}"
 	else
 		objects="--start-group ${BAREBOX_COMMON} --end-group ${1}"
 	fi
-- 
2.19.2


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

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

* [PATCH 14/15] scripts: link-barebox: thin archives use P option to ar
  2018-11-29 11:30 [PATCH 00/15] Makefile: sync with linux v4.13 and add thin archives support Steffen Trumtrar
                   ` (12 preceding siblings ...)
  2018-11-29 11:30 ` [PATCH 13/15] scripts: link-barebox: close thin archives --whole-archives option Steffen Trumtrar
@ 2018-11-29 11:30 ` Steffen Trumtrar
  2018-11-29 11:30 ` [PATCH 15/15] ARM: Kconfig: select THIN_ARCHIVES for ARM Steffen Trumtrar
  14 siblings, 0 replies; 23+ messages in thread
From: Steffen Trumtrar @ 2018-11-29 11:30 UTC (permalink / raw)
  To: Barebox List

Based on linux v4.13 patch: 9a6cfca4f4130444cb02536a4fdf7b6e285c713e

    kbuild: thin archives use P option to ar

    The P option makes ar do full path name matching and can prevent ar
    from discarding files with duplicate names in some cases of creating
    thin archives from thin archives. The sh architecture in particular
    loses some object files from its kernel/cpu/sh*/ directories without
    this option.

    This could be a bug in binutils ar, but the P option should not cause
    any negative effects so it is safe to use to work around this with.

    Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
    Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 scripts/link-barebox.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/link-barebox.sh b/scripts/link-barebox.sh
index 9e2bc2afd04b..74516f65b74f 100755
--- a/scripts/link-barebox.sh
+++ b/scripts/link-barebox.sh
@@ -51,7 +51,7 @@ archive_builtin()
 	if [ -n "${CONFIG_THIN_ARCHIVES}" ]; then
 		info AR built-in.o
 		rm -f built-in.o;
-		${AR} rcsT built-in.o ${BAREBOX_COMMON}
+		${AR} rcsTP built-in.o ${BAREBOX_COMMON}
 	fi
 }
 
@@ -68,7 +68,7 @@ archive_builtin_pbl()
 	if [ -n "${CONFIG_THIN_ARCHIVES}" ] &&  [ -n "${CONFIG_PBL_IMAGE}" ]; then
 		info PBLAR built-in-pbl.o
 		rm -f built-in-pbl.o;
-		${AR} rcsT built-in-pbl.o ${BAREBOX_PBL_COMMON}
+		${AR} rcsTP built-in-pbl.o ${BAREBOX_PBL_COMMON}
 	fi
 }
 
-- 
2.19.2


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

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

* [PATCH 15/15] ARM: Kconfig: select THIN_ARCHIVES for ARM
  2018-11-29 11:30 [PATCH 00/15] Makefile: sync with linux v4.13 and add thin archives support Steffen Trumtrar
                   ` (13 preceding siblings ...)
  2018-11-29 11:30 ` [PATCH 14/15] scripts: link-barebox: thin archives use P option to ar Steffen Trumtrar
@ 2018-11-29 11:30 ` Steffen Trumtrar
  14 siblings, 0 replies; 23+ messages in thread
From: Steffen Trumtrar @ 2018-11-29 11:30 UTC (permalink / raw)
  To: Barebox List

Use thin archives for all ARM platforms.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 arch/arm/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 3b486f7b8bb8..d66d5e909ff0 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -4,6 +4,7 @@ config ARM
 	select HAS_CACHE
 	select HAVE_CONFIGURABLE_TEXT_BASE if !RELOCATABLE
 	select HAVE_IMAGE_COMPRESSION
+	select THIN_ARCHIVES
 	default y
 
 config ARM_LINUX
-- 
2.19.2


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

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

* Re: [PATCH 07/15] Makefile: link of barebox moved to script
  2018-11-29 11:30 ` [PATCH 07/15] Makefile: link of barebox moved to script Steffen Trumtrar
@ 2018-11-30  7:17   ` Sascha Hauer
  2018-12-03  4:49   ` Sam Ravnborg
  1 sibling, 0 replies; 23+ messages in thread
From: Sascha Hauer @ 2018-11-30  7:17 UTC (permalink / raw)
  To: Steffen Trumtrar; +Cc: Barebox List

Hi Steffen,

Nice work overall. I thought the compile test would break earlier, but
we came up to the seventh patch already ;)

On Thu, Nov 29, 2018 at 12:30:40PM +0100, Steffen Trumtrar wrote:
> Adoption of the linux v3.4 patch: 1f2bfbd00e466ff3489b2ca5cc75b1cccd14c123
> 
>     Move the final link of vmlinux to a script to improve
>     readability and maintainability of the code.
> 
>     The Makefile fragments used to link vmlinux has over the
>     years seen far too many changes and the logic had become
>     hard to follow.
> 
>     As the process by nature is serialized there was
>     nothing gained including this in the Makefile.
> 
>     "um" has special link requirments - and the
>     only way to handle this was to hard-code the linking
>     of "um" in the script.
>     This was better than trying to modularize it only for the
>     benefit of "um" anyway.
> 
>     The shell script has been improved after input from:
>     Arnaud Lacombe <lacombar@gmail.com>
>     Nick Bowler <nbowler@elliptictech.com>
> 
>     Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
>     Cc: Arnaud Lacombe <lacombar@gmail.com>
>     Cc: Nick Bowler <nbowler@elliptictech.com>
>     Cc: Richard Weinberger <richard@nod.at>
>     Signed-off-by: Michal Marek <mmarek@suse.cz>
> 
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> ---
>  Makefile                | 187 ++++-----------------------------
>  scripts/link-barebox.sh | 223 ++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 242 insertions(+), 168 deletions(-)
>  create mode 100755 scripts/link-barebox.sh

This one breaks two defconfigs. efi_defconfig failes with:

arch/x86/mach-efi/built-in.o: In function `_start':
(.text+0x94): undefined reference to `_DYNAMIC'

And sandbox_defconfig:

ld: warning: cannot find entry symbol _start; defaulting to
0000000000401000
ld: arch/sandbox/os/built-in.o: in function `rawmode':
common.c:(.text+0x11): undefined reference to `tcgetattr'
ld: common.c:(.text+0xdd): undefined reference to `tcsetattr'
ld: arch/sandbox/os/built-in.o: in function `cookmode':
common.c:(.text+0xeb): undefined reference to `stdout'
ld: common.c:(.text+0xf3): undefined reference to `fflush'
ld: common.c:(.text+0x109): undefined reference to `tcsetattr'
ld: arch/sandbox/os/built-in.o: in function `linux_tstc':
(.text+0x1cd): undefined reference to `select'
ld: arch/sandbox/os/built-in.o: in function `linux_get_time':
(.text+0x236): undefined reference to `clock_gettime'
ld: arch/sandbox/os/built-in.o: in function `linux_exit':
(.text+0x265): undefined reference to `exit'
ld: arch/sandbox/os/built-in.o: in function `linux_read':
(.text+0x29e): undefined reference to `read'
ld: (.text+0x2bf): undefined reference to `printf'
ld: (.text+0x2d0): undefined reference to `__errno_location'
...

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

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

* Re: [PATCH 07/15] Makefile: link of barebox moved to script
  2018-11-29 11:30 ` [PATCH 07/15] Makefile: link of barebox moved to script Steffen Trumtrar
  2018-11-30  7:17   ` Sascha Hauer
@ 2018-12-03  4:49   ` Sam Ravnborg
  2018-12-04  7:56     ` Sascha Hauer
  1 sibling, 1 reply; 23+ messages in thread
From: Sam Ravnborg @ 2018-12-03  4:49 UTC (permalink / raw)
  To: Steffen Trumtrar; +Cc: Barebox List

Hi Steffen.

In general - nice patch series.

On Thu, Nov 29, 2018 at 12:30:40PM +0100, Steffen Trumtrar wrote:
> Adoption of the linux v3.4 patch: 1f2bfbd00e466ff3489b2ca5cc75b1cccd14c123

It would be simpler if you just synchronized the current state of the
link script - it has seen many improvements since the introduction.

	Sam

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

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

* Re: [PATCH 07/15] Makefile: link of barebox moved to script
  2018-12-03  4:49   ` Sam Ravnborg
@ 2018-12-04  7:56     ` Sascha Hauer
  0 siblings, 0 replies; 23+ messages in thread
From: Sascha Hauer @ 2018-12-04  7:56 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Barebox List, Steffen Trumtrar

On Mon, Dec 03, 2018 at 05:49:52AM +0100, Sam Ravnborg wrote:
> Hi Steffen.
> 
> In general - nice patch series.
> 
> On Thu, Nov 29, 2018 at 12:30:40PM +0100, Steffen Trumtrar wrote:
> > Adoption of the linux v3.4 patch: 1f2bfbd00e466ff3489b2ca5cc75b1cccd14c123
> 
> It would be simpler if you just synchronized the current state of the
> link script - it has seen many improvements since the introduction.

The script differs from the Kernel version (s/linux/barebox/ for
example) in several ways, so I think a plain "move to script" makes
sense and then do the update to the recent kernel version as a separate
step.

I wouldn't care much if Steffen used the recent kernel version in the
first place, but now that he already made it this way already, we could
just add a "update to recent kernel version" patch as a followup.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

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

* Re: [PATCH 04/15] scripts/Kbuild.include: replace KBUILD_CPPFLAGS with CPPFLAGS
  2018-11-29 11:30 ` [PATCH 04/15] scripts/Kbuild.include: replace KBUILD_CPPFLAGS with CPPFLAGS Steffen Trumtrar
@ 2018-12-05 12:22   ` Masahiro Yamada
  2018-12-05 12:26     ` Masahiro Yamada
  2018-12-06  7:54     ` Sascha Hauer
  0 siblings, 2 replies; 23+ messages in thread
From: Masahiro Yamada @ 2018-12-05 12:22 UTC (permalink / raw)
  To: Steffen Trumtrar; +Cc: barebox

On Thu, Nov 29, 2018 at 8:31 PM Steffen Trumtrar
<s.trumtrar@pengutronix.de> wrote:
>
> The barebox Makefiles do not use KBUILD_CPPFLAGS but CPPFLAGS as variable name.
>
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> ---


This might be a step backward.


In old days, Linux also used well-known CPPFLAGS.

Then Linux renamed CPPFLAGS -> KBUILD_CFLAGS

See the following commit:


commit 06c5040cdb13d27adad118f2fbfae905a1911b37
Author: Sam Ravnborg <sam@neptun.(none)>
Date:   Mon Oct 15 22:17:25 2007 +0200

    kbuild: enable 'make CPPFLAGS=...' to add additional options to CPP



Barebox forked from U-Boot around 2007,
so maybe Barebox is based on older Makefiles.






>  scripts/Kbuild.include | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
> index e62bd35692d0..0cb3a70a6a42 100644
> --- a/scripts/Kbuild.include
> +++ b/scripts/Kbuild.include
> @@ -111,12 +111,12 @@ as-instr = $(call try-run,\
>  # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
>
>  cc-option = $(call try-run,\
> -       $(CC) $(KBUILD_CPPFLAGS) $(CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",$(1),$(2))
> +       $(CC) $(CPPFLAGS) $(CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",$(1),$(2))
>
>  # cc-option-yn
>  # Usage: flag := $(call cc-option-yn,-march=winchip-c6)
>  cc-option-yn = $(call try-run,\
> -       $(CC) $(KBUILD_CPPFLAGS) $(CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",y,n)
> +       $(CC) $(CPPFLAGS) $(CFLAGS) $(1) -c -xc /dev/null -o "$$TMP",y,n)
>
>  # cc-option-align
>  # Prefix align with either -falign or -malign
> @@ -126,7 +126,7 @@ cc-option-align = $(subst -functions=0,,\
>  # cc-disable-warning
>  # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
>  cc-disable-warning = $(call try-run,\
> -       $(CC) $(KBUILD_CPPFLAGS) $(CFLAGS) -W$(strip $(1)) -c -xc /dev/null -o "$$TMP",-Wno-$(strip $(1)))
> +       $(CC) $(CPPFLAGS) $(CFLAGS) -W$(strip $(1)) -c -xc /dev/null -o "$$TMP",-Wno-$(strip $(1)))
>
>  # cc-version
>  # Usage gcc-ver := $(call cc-version)
> --
> 2.19.2
>
>
> _______________________________________________
> 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

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

* Re: [PATCH 04/15] scripts/Kbuild.include: replace KBUILD_CPPFLAGS with CPPFLAGS
  2018-12-05 12:22   ` Masahiro Yamada
@ 2018-12-05 12:26     ` Masahiro Yamada
  2018-12-06  7:54     ` Sascha Hauer
  1 sibling, 0 replies; 23+ messages in thread
From: Masahiro Yamada @ 2018-12-05 12:26 UTC (permalink / raw)
  To: Steffen Trumtrar; +Cc: barebox

On Wed, Dec 5, 2018 at 9:22 PM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> On Thu, Nov 29, 2018 at 8:31 PM Steffen Trumtrar
> <s.trumtrar@pengutronix.de> wrote:
> >
> > The barebox Makefiles do not use KBUILD_CPPFLAGS but CPPFLAGS as variable name.
> >
> > Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> > ---
>
>
> This might be a step backward.
>
>
> In old days, Linux also used well-known CPPFLAGS.
>
> Then Linux renamed CPPFLAGS -> KBUILD_CFLAGS

I mean CPPFLAGS -> KBUILD_CPPFLAGS


-- 
Best Regards
Masahiro Yamada

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

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

* Re: [PATCH 04/15] scripts/Kbuild.include: replace KBUILD_CPPFLAGS with CPPFLAGS
  2018-12-05 12:22   ` Masahiro Yamada
  2018-12-05 12:26     ` Masahiro Yamada
@ 2018-12-06  7:54     ` Sascha Hauer
  1 sibling, 0 replies; 23+ messages in thread
From: Sascha Hauer @ 2018-12-06  7:54 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: barebox, Steffen Trumtrar

On Wed, Dec 05, 2018 at 09:22:29PM +0900, Masahiro Yamada wrote:
> On Thu, Nov 29, 2018 at 8:31 PM Steffen Trumtrar
> <s.trumtrar@pengutronix.de> wrote:
> >
> > The barebox Makefiles do not use KBUILD_CPPFLAGS but CPPFLAGS as variable name.
> >
> > Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> > ---
> 
> 
> This might be a step backward.
> 
> 
> In old days, Linux also used well-known CPPFLAGS.
> 
> Then Linux renamed CPPFLAGS -> KBUILD_CFLAGS

I'm with you here. Steffen, why was this change necessary?

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

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

* Re: [PATCH 02/15] Makefile: Correctly deal with make options which contain an "s"
  2018-11-29 11:30 ` [PATCH 02/15] Makefile: Correctly deal with make options which contain an "s" Steffen Trumtrar
@ 2018-12-09 23:07   ` Roland Hieber
  0 siblings, 0 replies; 23+ messages in thread
From: Roland Hieber @ 2018-12-09 23:07 UTC (permalink / raw)
  To: Steffen Trumtrar; +Cc: Barebox List

By the way, the way of detecting make options has already changed in the
current incarnation of that line, which is from commit 6f0fa58e459642b16
(which also has a nice explanation, of course):

ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)

 - Roland

On Thu, Nov 29, 2018 at 12:30:35PM +0100, Steffen Trumtrar wrote:
> Based on linux v3.2 patch: e6ac89fabd030704eac691dab7783ebe06e6b2c1
> 
>     kbuild: Correctly deal with make options which contain an "s"
> 
>     When using remake, which is based on gnumake, if you invoke
>     an example build as shown below, the build will become silent
>     due to the top level make file incorrectly guessing that
>     the end user wants a silent build because an argument that
>     contained an "s" was used.  Here are two examples one with remake
>     and one with straight gnumake.
> 
>     remake --no-extended-errors
>     make --warn-undefined-variables
> 
>     Fix up the top level Makefile to use filter to parse the options
>     that mean silent instead of findstring catching other random
>     arguments containing an "s".
> 
>     Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
>     CC: Michal Marek <mmarek@suse.cz>
>     CC: Andrew Morton <akpm@linux-foundation.org>
>     CC: linux-kbuild@vger.kernel.org
>     Signed-off-by: Michal Marek <mmarek@suse.cz>
> 
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> ---
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index dedb16d60069..cddff1267972 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -252,7 +252,7 @@ endif
>  # If the user is running make -s (silent mode), suppress echoing of
>  # commands
>  
> -ifneq ($(findstring s,$(MAKEFLAGS)),)
> +ifneq ($(filter s% -s%,$(MAKEFLAGS)),)
>    quiet=silent_
>  endif
>  
> -- 
> 2.19.2
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Roland Hieber                     | r.hieber@pengutronix.de     |
Pengutronix e.K.                  | https://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim | Phone: +49-5121-206917-5086 |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |

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

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

end of thread, other threads:[~2018-12-09 23:07 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-29 11:30 [PATCH 00/15] Makefile: sync with linux v4.13 and add thin archives support Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 01/15] Makefile: replace LINUXINCLUDE with BAREBOXINCLUDE Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 02/15] Makefile: Correctly deal with make options which contain an "s" Steffen Trumtrar
2018-12-09 23:07   ` Roland Hieber
2018-11-29 11:30 ` [PATCH 03/15] scripts/Kbuild.include: Fix portability problem of "echo -e" Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 04/15] scripts/Kbuild.include: replace KBUILD_CPPFLAGS with CPPFLAGS Steffen Trumtrar
2018-12-05 12:22   ` Masahiro Yamada
2018-12-05 12:26     ` Masahiro Yamada
2018-12-06  7:54     ` Sascha Hauer
2018-11-29 11:30 ` [PATCH 05/15] debug: Add CONFIG_DEBUG_READABLE_ASM Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 06/15] Makefile: improve line wrapping Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 07/15] Makefile: link of barebox moved to script Steffen Trumtrar
2018-11-30  7:17   ` Sascha Hauer
2018-12-03  4:49   ` Sam Ravnborg
2018-12-04  7:56     ` Sascha Hauer
2018-11-29 11:30 ` [PATCH 08/15] scripts: link-barebox: fix bash-ism Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 09/15] scripts: link-barebox: force error on kallsyms failure Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 10/15] scripts: link-barebox: allow architectures to use thin archives instead of ld -r Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 11/15] scripts: link-barebox: kallsyms allow 3-pass generation Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 12/15] scripts: link-barebox: minor improvement for thin archives build Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 13/15] scripts: link-barebox: close thin archives --whole-archives option Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 14/15] scripts: link-barebox: thin archives use P option to ar Steffen Trumtrar
2018-11-29 11:30 ` [PATCH 15/15] ARM: Kconfig: select THIN_ARCHIVES for ARM Steffen Trumtrar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox