Skip to contentSkip to conversation

Big acceleration of Kbuild performance

PATCH Superseded Masahiro Yamada 4 participants 11 messages Feb 27, 2014 – Feb 28, 2014

Subsystems (9)
Arm (32-bit) x86 PowerPC Kbuild +5 more subsystems

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Big acceleration of Kbuild performance

Kbuild brought about many advantages for us but a significant performance regression was reported by Simon Glass.

After some discussions and analysis, it turned out its main cause is in $(call cc-option,...).

Historically, U-Boot parses all config.mk (arch/*/config.mk and board/*/config.mk)
every time descending into subdirectories.
That means cc-options are evaluated over and over again.

$(call cc-option,...) is useful but costly.
So we want to evaluate them only in ./Makefile and spl/Makefile and export compiler flags.

1/4 through 3/4 are preparation for 4/4.

4/4 is what we really want to do.
By applying it, I think Kbuild will get much faster.

Simon,
Could you post the result of "time" command?
I want to know how fast Kbuild will be on your computer.

How to apply this series ?
--------------------------

This series depends on my other patches.

[1] "Kbuild: A collection of trivial refactoring" series

8/8 is not applicable any more.
Please apply 1/8 thru 7/8.

[2] kbuild: consolidate PLATFORM_LIBS
http://patchwork.ozlabs.org/patch/324808/

Please apply above beforehand.

Instead, you can also try my local branch for easy test.

I pushed my local branch to my GitHub page. Please try the following.

(1) git clone git://github.com/masahir0y/u-boot-kbuild.git
(2) cd u-boot-kbuild
(3) git checkout optimize_v1

How to test this series?
------------------------

This series is not big patches, but it might be difficult to understand if Kbuild can build the equivalent outputs.

Are compiler options really handled the same as before? The answer is Yes.

I examined ".*.cmd" files carefully.

And also I used md5sum to prove this series still produces the same result as before.

You can double-check it by following the below steps. Use my local branch.

(1) git clone git://github.com/masahir0y/u-boot-kbuild.git
(2) cd u-boot-kbuild
(3) git checkout before_optimize_v1
(4) Run "./MAKEALL"
MD5SUM will be displayed. Dump all log to a file
(5) git checkout optimize_v1
(6) Run "./MAKEALL"
MD5SUM will be displayed. Dump all log to another file
(7) Compare files between (4) and (6)

Please notice commit 4542e50 (MAKEALL: Display MD5SUM) This commit modifies MAKEALL to display MD5SUM of
- ./u-boot.bin
- spl/u-boot-spl.bin
- tpl/u-boot-tpl.bin
- examples/standalone/hello_world.bin

Masahiro Yamada (4):
kbuild,blackfin: Add CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
kbuild: add CONFIG_ prefix to USE_PRIVATE_LIBS config.mk: specify the exact path to standalone linker script
kbuild: improve Kbuild speed

 Makefile                                | 13 +++++++------
 arch/arm/cpu/arm720t/tegra114/config.mk | 19 -------------------
 arch/arm/cpu/arm720t/tegra124/config.mk |  7 -------
 arch/arm/cpu/arm720t/tegra20/config.mk  | 10 ----------
 arch/arm/cpu/arm720t/tegra30/config.mk  | 19 -------------------
 arch/arm/lib/Makefile                   | 13 ++-----------
 arch/blackfin/config.mk                 |  1 +
 arch/mips/cpu/mips32/config.mk          |  3 ++-
 arch/mips/cpu/mips64/config.mk          |  3 ++-
 arch/mips/cpu/xburst/config.mk          |  3 ++-
 arch/mips/lib/Makefile                  |  7 +------
 arch/nds32/config.mk                    |  3 ++-
 arch/powerpc/lib/Makefile               |  6 +-----
 arch/sh/lib/Makefile                    | 14 ++------------
 arch/sparc/config.mk                    |  4 +++-
 arch/x86/config.mk                      |  2 +-
 board/bct-brettl2/config.mk             | 13 -------------
 board/bf518f-ezbrd/config.mk            | 13 -------------
 board/bf526-ezbrd/config.mk             | 13 -------------
 board/bf527-ad7160-eval/config.mk       | 13 -------------
 board/bf527-ezkit/config.mk             | 13 -------------
 board/bf527-sdp/config.mk               |  5 -----
 board/bf533-ezkit/config.mk             |  5 -----
 board/bf533-stamp/config.mk             |  5 -----
 board/bf537-stamp/config.mk             |  5 -----
 board/bf538f-ezkit/config.mk            |  5 -----
 board/bf548-ezkit/config.mk             |  5 -----
 board/bf561-acvilon/config.mk           |  5 -----
 board/bf561-ezkit/config.mk             |  5 -----
 board/br4/config.mk                     | 15 ---------------
 board/cm-bf527/config.mk                | 13 -------------
 board/cm-bf533/config.mk                |  5 -----
 board/cm-bf537e/config.mk               |  5 -----
 board/cm-bf537u/config.mk               |  5 -----
 board/cm-bf548/config.mk                |  5 -----
 board/cm-bf561/config.mk                |  5 -----
 board/ip04/config.mk                    |  5 -----
 board/pr1/config.mk                     | 15 ---------------
 board/tcm-bf518/config.mk               | 13 -------------
 board/tcm-bf537/config.mk               |  5 -----
 config.mk                               | 28 ++++++++++++++++++++--------
 examples/standalone/Makefile            |  5 ++---
 include/configs/bct-brettl2.h           |  2 +-
 include/configs/bf518f-ezbrd.h          |  2 +-
 include/configs/bf526-ezbrd.h           |  1 +
 include/configs/bf527-ad7160-eval.h     |  2 +-
 include/configs/bf527-ezkit.h           |  2 +-
 include/configs/bf527-sdp.h             |  2 +-
 include/configs/bf533-ezkit.h           |  2 +-
 include/configs/bf533-stamp.h           |  1 +
 include/configs/bf537-stamp.h           |  1 +
 include/configs/bf538f-ezkit.h          |  2 +-
 include/configs/bf548-ezkit.h           |  1 +
 include/configs/bf561-acvilon.h         |  2 +-
 include/configs/bf561-ezkit.h           |  1 +
 include/configs/br4.h                   |  2 +-
 include/configs/cm-bf527.h              |  2 +-
 include/configs/cm-bf533.h              |  2 +-
 include/configs/cm-bf537e.h             |  1 +
 include/configs/cm-bf537u.h             |  2 +-
 include/configs/cm-bf548.h              |  1 +
 include/configs/cm-bf561.h              |  2 +-
 include/configs/ip04.h                  |  1 +
 include/configs/pr1.h                   |  2 +-
 include/configs/tcm-bf518.h             |  2 +-
 include/configs/tcm-bf537.h             |  2 +-
 include/configs/tegra-common.h          |  4 ++++
 lib/Makefile                            |  2 ++
 scripts/Makefile.build                  | 10 +++++-----
 scripts/Makefile.lib                    |  7 +++----
 spl/Makefile                            |  9 ++++-----
 71 files changed, 90 insertions(+), 338 deletions(-)
 delete mode 100644 arch/arm/cpu/arm720t/tegra114/config.mk
 delete mode 100644 arch/arm/cpu/arm720t/tegra124/config.mk
 delete mode 100644 arch/arm/cpu/arm720t/tegra20/config.mk
 delete mode 100644 arch/arm/cpu/arm720t/tegra30/config.mk
 delete mode 100644 board/bct-brettl2/config.mk
 delete mode 100644 board/bf518f-ezbrd/config.mk
 delete mode 100644 board/bf526-ezbrd/config.mk
 delete mode 100644 board/bf527-ad7160-eval/config.mk
 delete mode 100644 board/bf527-ezkit/config.mk
 delete mode 100644 board/br4/config.mk
 delete mode 100644 board/cm-bf527/config.mk
 delete mode 100644 board/pr1/config.mk
 delete mode 100644 board/tcm-bf518/config.mk
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH 1/4 kbuild, blackfin: Add CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED

Many (but not all) of Blackfin boards give -O2 option to compile under lib/ directory.
That means lib/ should be speed-optimized, whereas other parts should be size-optimized.

We want to keep the same behavior,
but do not want to parse board/*/config.mk
again and again.
We've got no choice but to invent a new method.

CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED, if it is enabled, gives -O2 flag only for building under lib/ directory.

Dirty code which I had marked "FIX ME"
in board/${BOARD}/config.mk has been deleted. Instead, CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED has been defined in include/configs/${BOARD}.h.

---

 board/bct-brettl2/config.mk         | 13 -------------
 board/bf518f-ezbrd/config.mk        | 13 -------------
 board/bf526-ezbrd/config.mk         | 13 -------------
 board/bf527-ad7160-eval/config.mk   | 13 -------------
 board/bf527-ezkit/config.mk         | 13 -------------
 board/bf527-sdp/config.mk           |  5 -----
 board/bf533-ezkit/config.mk         |  5 -----
 board/bf533-stamp/config.mk         |  5 -----
 board/bf537-stamp/config.mk         |  5 -----
 board/bf538f-ezkit/config.mk        |  5 -----
 board/bf548-ezkit/config.mk         |  5 -----
 board/bf561-acvilon/config.mk       |  5 -----
 board/bf561-ezkit/config.mk         |  5 -----
 board/br4/config.mk                 | 15 ---------------
 board/cm-bf527/config.mk            | 13 -------------
 board/cm-bf533/config.mk            |  5 -----
 board/cm-bf537e/config.mk           |  5 -----
 board/cm-bf537u/config.mk           |  5 -----
 board/cm-bf548/config.mk            |  5 -----
 board/cm-bf561/config.mk            |  5 -----
 board/ip04/config.mk                |  5 -----
 board/pr1/config.mk                 | 15 ---------------
 board/tcm-bf518/config.mk           | 13 -------------
 board/tcm-bf537/config.mk           |  5 -----
 include/configs/bct-brettl2.h       |  2 +-
 include/configs/bf518f-ezbrd.h      |  2 +-
 include/configs/bf526-ezbrd.h       |  1 +
 include/configs/bf527-ad7160-eval.h |  2 +-
 include/configs/bf527-ezkit.h       |  2 +-
 include/configs/bf527-sdp.h         |  2 +-
 include/configs/bf533-ezkit.h       |  2 +-
 include/configs/bf533-stamp.h       |  1 +
 include/configs/bf537-stamp.h       |  1 +
 include/configs/bf538f-ezkit.h      |  2 +-
 include/configs/bf548-ezkit.h       |  1 +
 include/configs/bf561-acvilon.h     |  2 +-
 include/configs/bf561-ezkit.h       |  1 +
 include/configs/br4.h               |  2 +-
 include/configs/cm-bf527.h          |  2 +-
 include/configs/cm-bf533.h          |  2 +-
 include/configs/cm-bf537e.h         |  1 +
 include/configs/cm-bf537u.h         |  2 +-
 include/configs/cm-bf548.h          |  1 +
 include/configs/cm-bf561.h          |  2 +-
 include/configs/ip04.h              |  1 +
 include/configs/pr1.h               |  2 +-
 include/configs/tcm-bf518.h         |  2 +-
 include/configs/tcm-bf537.h         |  2 +-
 lib/Makefile                        |  2 ++
 49 files changed, 26 insertions(+), 212 deletions(-)
 delete mode 100644 board/bct-brettl2/config.mk
 delete mode 100644 board/bf518f-ezbrd/config.mk
 delete mode 100644 board/bf526-ezbrd/config.mk
 delete mode 100644 board/bf527-ad7160-eval/config.mk
 delete mode 100644 board/bf527-ezkit/config.mk
 delete mode 100644 board/br4/config.mk
 delete mode 100644 board/cm-bf527/config.mk
 delete mode 100644 board/pr1/config.mk
 delete mode 100644 board/tcm-bf518/config.mk
board/bct-brettl2/config.mk deleted +0 -13
deleted file mode 100644
index 0d3df2d..0000000
@@ -1,13 +0,0 @@
-#
-# Copyright (c) 2005-2008 Analog Device Inc.
-#
-# (C) Copyright 2001
-# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
-#
-# SPDX-License-Identifier:	GPL-2.0+
-#
-
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
board/bf518f-ezbrd/config.mk deleted +0 -13
deleted file mode 100644
index 0d3df2d..0000000
@@ -1,13 +0,0 @@
-#
-# Copyright (c) 2005-2008 Analog Device Inc.
-#
-# (C) Copyright 2001
-# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
-#
-# SPDX-License-Identifier:	GPL-2.0+
-#
-
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
board/bf526-ezbrd/config.mk deleted +0 -13
deleted file mode 100644
index 0d3df2d..0000000
@@ -1,13 +0,0 @@
-#
-# Copyright (c) 2005-2008 Analog Device Inc.
-#
-# (C) Copyright 2001
-# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
-#
-# SPDX-License-Identifier:	GPL-2.0+
-#
-
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
board/bf527-ad7160-eval/config.mk deleted +0 -13
deleted file mode 100644
index 0d3df2d..0000000
@@ -1,13 +0,0 @@
-#
-# Copyright (c) 2005-2008 Analog Device Inc.
-#
-# (C) Copyright 2001
-# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
-#
-# SPDX-License-Identifier:	GPL-2.0+
-#
-
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
board/bf527-ezkit/config.mk deleted +0 -13
deleted file mode 100644
index 0d3df2d..0000000
@@ -1,13 +0,0 @@
-#
-# Copyright (c) 2005-2008 Analog Device Inc.
-#
-# (C) Copyright 2001
-# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
-#
-# SPDX-License-Identifier:	GPL-2.0+
-#
-
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
board/bf527-sdp/config.mk +0 -5
index af299f5..1d46cfc 100644
@@ -7,10 +7,5 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
-
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 6
board/bf533-ezkit/config.mk +0 -5
index 97eaafe..7f9138b 100644
@@ -7,10 +7,5 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
-
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8
board/bf533-stamp/config.mk +0 -5
index 97eaafe..7f9138b 100644
@@ -7,10 +7,5 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
-
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8
board/bf537-stamp/config.mk +0 -5
index bc0e747..ab0fbec 100644
@@ -7,11 +7,6 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
-
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8
 LDR_FLAGS-BFIN_BOOT_UART := --port g --gpio 6
board/bf538f-ezkit/config.mk +0 -5
index 97eaafe..7f9138b 100644
@@ -7,10 +7,5 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
-
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8
board/bf548-ezkit/config.mk +0 -5
index 8d2c60f..7bb8e9c 100644
@@ -7,11 +7,6 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
-
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA       := --dma 6
 LDR_FLAGS-BFIN_BOOT_FIFO       := --dma 1
board/bf561-acvilon/config.mk +0 -5
index ce94715..854d7db 100644
@@ -7,10 +7,5 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
-
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16
board/bf561-ezkit/config.mk +0 -5
index ce94715..854d7db 100644
@@ -7,10 +7,5 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
-
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16
board/br4/config.mk deleted +0 -15
deleted file mode 100644
index 2436ec0..0000000
@@ -1,15 +0,0 @@
-#
-# Copyright (c) Switchfin Org. <[email protected]>
-#
-# Copyright (c) 2005-2008 Analog Device Inc.
-#
-# (C) Copyright 2001
-# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
-#
-# SPDX-License-Identifier:	GPL-2.0+
-#
-
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
board/cm-bf527/config.mk deleted +0 -13
deleted file mode 100644
index 0d3df2d..0000000
@@ -1,13 +0,0 @@
-#
-# Copyright (c) 2005-2008 Analog Device Inc.
-#
-# (C) Copyright 2001
-# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
-#
-# SPDX-License-Identifier:	GPL-2.0+
-#
-
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
board/cm-bf533/config.mk +0 -5
index 97eaafe..7f9138b 100644
@@ -7,10 +7,5 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
-
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8
board/cm-bf537e/config.mk +0 -5
index 97eaafe..7f9138b 100644
@@ -7,10 +7,5 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
-
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8
board/cm-bf537u/config.mk +0 -5
index 97eaafe..7f9138b 100644
@@ -7,10 +7,5 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
-
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8
board/cm-bf548/config.mk +0 -5
index 289c8a4..beb9834 100644
@@ -7,11 +7,6 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
-
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA       := --dma 6
 LDR_FLAGS-BFIN_BOOT_FIFO       := --dma 1
board/cm-bf561/config.mk +0 -5
index ce94715..854d7db 100644
@@ -7,10 +7,5 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
-
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16
board/ip04/config.mk +0 -5
index bc0e747..ab0fbec 100644
@@ -7,11 +7,6 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
-
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8
 LDR_FLAGS-BFIN_BOOT_UART := --port g --gpio 6
board/pr1/config.mk deleted +0 -15
deleted file mode 100644
index 2436ec0..0000000
@@ -1,15 +0,0 @@
-#
-# Copyright (c) Switchfin Org. <[email protected]>
-#
-# Copyright (c) 2005-2008 Analog Device Inc.
-#
-# (C) Copyright 2001
-# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
-#
-# SPDX-License-Identifier:	GPL-2.0+
-#
-
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
board/tcm-bf518/config.mk deleted +0 -13
deleted file mode 100644
index 0d3df2d..0000000
@@ -1,13 +0,0 @@
-#
-# Copyright (c) 2005-2008 Analog Device Inc.
-#
-# (C) Copyright 2001
-# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
-#
-# SPDX-License-Identifier:	GPL-2.0+
-#
-
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
board/tcm-bf537/config.mk +0 -5
index 97eaafe..7f9138b 100644
@@ -7,10 +7,5 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# FIX ME
-ifneq ($(filter lib lib/lzma lib/zlib, $(obj)),)
-ccflags-y := -O2
-endif
-
 # Set some default LDR flags based on boot mode.
 LDR_FLAGS-BFIN_BOOT_PARA := --bits 16 --dma 8
include/configs/bct-brettl2.h +1 -1
index 5b09b45..06f095c 100644
@@ -136,7 +136,7 @@
 #define CONFIG_MTD_DEVICE
 #define CONFIG_MTD_PARTITIONS
 #define CONFIG_SYS_HUSH_PARSER
-
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 /*
  * Pull in common ADI header for remaining command/environment setup
include/configs/bf518f-ezbrd.h +1 -1
index a97972b..9eb85eb 100644
@@ -155,7 +155,7 @@
 #define CONFIG_MISC_INIT_R
 #define CONFIG_RTC_BFIN
 #define CONFIG_UART_CONSOLE	0
-
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 /*
  * Pull in common ADI header for remaining command/environment setup
include/configs/bf526-ezbrd.h +1 -0
index 0031093..3065d22 100644
@@ -153,6 +153,7 @@
 #define CONFIG_MISC_INIT_R
 #define CONFIG_RTC_BFIN
 #define CONFIG_UART_CONSOLE	1
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 /* define to enable run status via led */
 /* #define CONFIG_STATUS_LED */
include/configs/bf527-ad7160-eval.h +1 -1
index fa05103..c0dfe26 100644
@@ -136,7 +136,7 @@
  */
 #define CONFIG_MISC_INIT_R
 #define CONFIG_UART_CONSOLE	0
-
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 /*
  * Pull in common ADI header for remaining command/environment setup
include/configs/bf527-ezkit.h +1 -1
index db1b613..748ddb3 100644
@@ -179,7 +179,7 @@
 #define CONFIG_MISC_INIT_R
 #define CONFIG_RTC_BFIN
 #define CONFIG_UART_CONSOLE	1
-
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 /*
  * Pull in common ADI header for remaining command/environment setup
include/configs/bf527-sdp.h +1 -1
index c0e8b5a..458868a 100644
@@ -112,7 +112,7 @@
  */
 #define CONFIG_MISC_INIT_R
 #define CONFIG_UART_CONSOLE	0
-
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 /*
  * Pull in common ADI header for remaining command/environment setup
include/configs/bf533-ezkit.h +1 -1
index beab127..b503528 100644
@@ -110,7 +110,7 @@
 #define CONFIG_MISC_INIT_R
 #define CONFIG_RTC_BFIN
 #define CONFIG_UART_CONSOLE	0
-
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 /*
  * Pull in common ADI header for remaining command/environment setup
include/configs/bf533-stamp.h +1 -0
index f5b9658..d82c5b2 100644
@@ -185,6 +185,7 @@
  */
 #define CONFIG_RTC_BFIN
 #define CONFIG_UART_CONSOLE	0
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 /* FLASH/ETHERNET uses the same async bank */
 #define SHARED_RESOURCES 	1
include/configs/bf537-stamp.h +1 -0
index 02945be..e1705ca 100644
@@ -254,6 +254,7 @@
 #define CONFIG_MISC_INIT_R
 #define CONFIG_RTC_BFIN
 #define CONFIG_UART_CONSOLE	0
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 /* Define if want to do post memory test */
 #undef CONFIG_POST
include/configs/bf538f-ezkit.h +1 -1
index ffb0caf..742c299 100644
@@ -134,7 +134,7 @@
  */
 #define CONFIG_RTC_BFIN
 #define CONFIG_UART_CONSOLE	0
-
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 /*
  * Pull in common ADI header for remaining command/environment setup
include/configs/bf548-ezkit.h +1 -0
index da5f029..1a245a2 100644
@@ -181,6 +181,7 @@
 #define CONFIG_RTC_BFIN
 #define CONFIG_UART_CONSOLE	1
 #define CONFIG_BFIN_SPI_IMG_SIZE 0x50000
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 #define CONFIG_ADI_GPIO2
 
include/configs/bf561-acvilon.h +1 -1
index 15ca1af..3db917e 100644
@@ -160,7 +160,7 @@
 #define CONFIG_UART_CONSOLE			0
 #define CONFIG_BAUDRATE				57600
 #define CONFIG_SYS_PROMPT "Acvilon> "
-
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 /*
  * Pull in common ADI header for remaining command/environment setup
include/configs/bf561-ezkit.h +1 -0
index fb6f948..0a309d9 100644
@@ -102,6 +102,7 @@
  * Misc Settings
  */
 #define CONFIG_UART_CONSOLE	0
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 /*
  * Run core 1 from L1 SRAM start address when init uboot on core 0
include/configs/br4.h +1 -1
index ef3752d..f8d3158 100644
@@ -135,7 +135,7 @@
 #define CONFIG_BOOTCOMMAND	"run nandboot"
 #define CONFIG_BOOTDELAY	2
 #define CONFIG_LOADADDR		0x2000000
-
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 /*
  * Pull in common ADI header for remaining command/environment setup
include/configs/cm-bf527.h +1 -1
index b15a1eb..384d871 100644
@@ -128,7 +128,7 @@
 #define FLASHBOOT_ENV_SETTINGS \
 	"flashboot=flread 20040000 1000000 300000;" \
 	"bootm 0x1000000\0"
-
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 /*
  * Pull in common ADI header for remaining command/environment setup
include/configs/cm-bf533.h +1 -1
index e2b954c..8bd499a 100644
@@ -97,7 +97,7 @@
 #define CONFIG_UART_CONSOLE	0
 #define CONFIG_BOOTCOMMAND	"run flashboot"
 #define FLASHBOOT_ENV_SETTINGS	"flashboot=bootm 0x20040000\0"
-
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 /*
  * Pull in common ADI header for remaining command/environment setup
include/configs/cm-bf537e.h +1 -0
index 2838012..67cf801 100644
@@ -146,6 +146,7 @@
 	"flashboot=flread 20040000 1000000 3c0000;" \
 	"bootm 0x1000000\0"
 #define CONFIG_BOARD_SIZE_LIMIT $$((384 * 1024))
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 /*
  * Pull in common ADI header for remaining command/environment setup
include/configs/cm-bf537u.h +1 -1
index da4cc67..34ce75b 100644
@@ -143,7 +143,7 @@
 	"flashboot=flread 20040000 1000000 300000;" \
 	"bootm 0x1000000\0"
 #define CONFIG_BOARD_SIZE_LIMIT $$((384 * 1024))
-
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 /*
  * Pull in common ADI header for remaining command/environment setup
include/configs/cm-bf548.h +1 -0
index 7f27eda..346e27f 100644
@@ -117,6 +117,7 @@
 #define CONFIG_UART_CONSOLE	1
 #define CONFIG_BOOTCOMMAND	"run flashboot"
 #define FLASHBOOT_ENV_SETTINGS	"flashboot=bootm 0x20040000\0"
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 #define CONFIG_ADI_GPIO2
 
include/configs/cm-bf561.h +1 -1
index 93e3c86..5265e5f 100644
@@ -99,7 +99,7 @@
 #define CONFIG_UART_CONSOLE	0
 #define CONFIG_BOOTCOMMAND	"run flashboot"
 #define FLASHBOOT_ENV_SETTINGS	"flashboot=bootm 0x20040000\0"
-
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 /*
  * Pull in common ADI header for remaining command/environment setup
include/configs/ip04.h +1 -0
index d36ae43..0efa2b7 100644
@@ -132,6 +132,7 @@
 #define CONFIG_BAUDRATE		115200
 #define CONFIG_MISC_INIT_R	/* needed for MAC address */
 #define CONFIG_UART_CONSOLE	0
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 #undef CONFIG_SHOW_BOOT_PROGRESS
 /* Enable this if bootretry required; currently it's disabled */
include/configs/pr1.h +1 -1
index 03d4269..e96ed4b 100644
@@ -135,7 +135,7 @@
 #define CONFIG_BOOTCOMMAND	"run nandboot"
 #define CONFIG_BOOTDELAY	2
 #define CONFIG_LOADADDR		0x2000000
-
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 /*
  * Pull in common ADI header for remaining command/environment setup
include/configs/tcm-bf518.h +1 -1
index 241f210..1ff34d5 100644
@@ -116,7 +116,7 @@
 #define CONFIG_UART_CONSOLE	0
 #define CONFIG_BOOTCOMMAND	"run flashboot"
 #define FLASHBOOT_ENV_SETTINGS	"flashboot=bootm 0x20040000\0"
-
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 /*
  * Pull in common ADI header for remaining command/environment setup
include/configs/tcm-bf537.h +1 -1
index 58bcdc8..370d97f 100644
@@ -145,7 +145,7 @@
 	"flashboot=flread 20040000 1000000 300000;" \
 	"bootm 0x1000000\0"
 #define CONFIG_BOARD_SIZE_LIMIT $$((384 * 1024))
-
+#define CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED
 
 /*
  * Pull in common ADI header for remaining command/environment setup
lib/Makefile +2 -0
index dedb97b..8814ff9 100644
@@ -65,3 +65,5 @@ obj-y += vsprintf.o
 obj-$(CONFIG_RANDOM_MACADDR) += rand.o
 obj-$(CONFIG_BOOTP_RANDOM_DELAY) += rand.o
 obj-$(CONFIG_CMD_LINK_LOCAL) += rand.o
+
+subdir-ccflags-$(CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED) += -O2
Signature · 1 line
1.8.3.2
#2 lore raw

PATCH 2/4 kbuild: add CONFIG_ prefix to USE_PRIVATE_LIBS

In reply to Masahiro Yamada

Before this commit, USE_PRIVATE_LIBS is defined in arch-specific config.mk and referenced in arch/$(ARCH)/lib/Makefile.

We are not happy about parsing config.mk again and again. We have to keep the same behavior with a different way.

By adding "CONFIG_" prefix, this macro appears
in include/autoconf.mk, include/spl-autoconf.mk.
(And treating USE_PRIVATE_LIBS as CONFIG macro
is reasonable enough.)

Tegra SoC family defined USE_PRIVATE_LIBS as "yes" in arch/arm/cpu/arm720t/tegra*/config.mk,
but did not define it in arch/arm/cpu/armv7/tegra*/config.mk.

It means Tegra turns on PRIVATE_LIBS only for SPL. We can describe the same behavior by adding

  #ifdef CONFIG_SPL_BUILD
  # define CONFIG_USE_PRIVATE_LIBGCC
  #endif

to include/configs/tegra-common.h.

Cc Tom Warren <[email protected]>
Cc Stephen Warren <[email protected]>
Cc Simon Glass <[email protected]>

---

 Makefile                                |  6 +++---
 arch/arm/cpu/arm720t/tegra114/config.mk | 19 -------------------
 arch/arm/cpu/arm720t/tegra124/config.mk |  7 -------
 arch/arm/cpu/arm720t/tegra20/config.mk  | 10 ----------
 arch/arm/cpu/arm720t/tegra30/config.mk  | 19 -------------------
 arch/arm/lib/Makefile                   | 13 ++-----------
 arch/mips/lib/Makefile                  |  7 +------
 arch/powerpc/lib/Makefile               |  6 +-----
 arch/sh/lib/Makefile                    | 14 ++------------
 arch/x86/config.mk                      |  2 +-
 include/configs/tegra-common.h          |  4 ++++
 spl/Makefile                            |  2 +-
 12 files changed, 15 insertions(+), 94 deletions(-)
 delete mode 100644 arch/arm/cpu/arm720t/tegra114/config.mk
 delete mode 100644 arch/arm/cpu/arm720t/tegra124/config.mk
 delete mode 100644 arch/arm/cpu/arm720t/tegra20/config.mk
 delete mode 100644 arch/arm/cpu/arm720t/tegra30/config.mk
Makefile +3 -3
index 89f1226..56ba1ef 100644
@@ -648,11 +648,11 @@ u-boot-main := $(libs-y)
 
 
 # Add GCC lib
-ifdef USE_PRIVATE_LIBGCC
-ifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
+ifdef CONFIG_USE_PRIVATE_LIBGCC
+ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y)
 PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a
 else
-PLATFORM_LIBGCC = -L $(USE_PRIVATE_LIBGCC) -lgcc
+PLATFORM_LIBGCC = -L $(CONFIG_USE_PRIVATE_LIBGCC) -lgcc
 endif
 else
 PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(c_flags) -print-libgcc-file-name`) -lgcc
arch/arm/cpu/arm720t/tegra114/config.mk deleted +0 -19
deleted file mode 100644
index 7947b50..0000000
@@ -1,19 +0,0 @@
-#
-# Copyright (c) 2010-2013, NVIDIA CORPORATION.  All rights reserved.
-#
-# (C) Copyright 2002
-# Gary Jennejohn, DENX Software Engineering, <[email protected]>
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms and conditions of the GNU General Public License,
-# version 2, as published by the Free Software Foundation.
-#
-# This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>.
-#
-USE_PRIVATE_LIBGCC = yes
arch/arm/cpu/arm720t/tegra124/config.mk deleted +0 -7
deleted file mode 100644
index 5e10701..0000000
@@ -1,7 +0,0 @@
-#
-# (C) Copyright 2010-2013
-# NVIDIA Corporation <www.nvidia.com>
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#/
-USE_PRIVATE_LIBGCC = yes
arch/arm/cpu/arm720t/tegra20/config.mk deleted +0 -10
deleted file mode 100644
index e073345..0000000
@@ -1,10 +0,0 @@
-#
-# (C) Copyright 2010,2011
-# NVIDIA Corporation <www.nvidia.com>
-#
-# (C) Copyright 2002
-# Gary Jennejohn, DENX Software Engineering, <[email protected]>
-#
-# SPDX-License-Identifier:	GPL-2.0+
-#
-USE_PRIVATE_LIBGCC = yes
arch/arm/cpu/arm720t/tegra30/config.mk deleted +0 -19
deleted file mode 100644
index 2388c56..0000000
@@ -1,19 +0,0 @@
-#
-# Copyright (c) 2010-2012, NVIDIA CORPORATION.  All rights reserved.
-#
-# (C) Copyright 2002
-# Gary Jennejohn, DENX Software Engineering, <[email protected]>
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms and conditions of the GNU General Public License,
-# version 2, as published by the Free Software Foundation.
-#
-# This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>.
-#
-USE_PRIVATE_LIBGCC = yes
arch/arm/lib/Makefile +2 -11
index 45febcf..9fc81cd 100644
@@ -5,17 +5,8 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-# Build private libgcc only when asked for
-ifdef USE_PRIVATE_LIBGCC
-lib-y	+= _ashldi3.o
-lib-y	+= _ashrdi3.o
-lib-y	+= _divsi3.o
-lib-y	+= _lshrdi3.o
-lib-y	+= _modsi3.o
-lib-y	+= _udivsi3.o
-lib-y	+= _umodsi3.o
-lib-y	+= div0.o
-endif
+lib-$(CONFIG_USE_PRIVATE_LIBGCC) += _ashldi3.o _ashrdi3.o _divsi3.o \
+			_lshrdi3.o _modsi3.o _udivsi3.o _umodsi3.o div0.o
 
 ifdef CONFIG_ARM64
 obj-y	+= crt0_64.o
arch/mips/lib/Makefile +1 -6
index 3705926..fabeb83 100644
@@ -8,9 +8,4 @@
 obj-y	+= board.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 
-# Build private libgcc only when asked for
-ifdef USE_PRIVATE_LIBGCC
-lib-y	+= ashldi3.o
-lib-y	+= ashrdi3.o
-lib-y	+= lshrdi3.o
-endif
+lib-$(CONFIG_USE_PRIVATE_LIBGCC) += ashldi3.o ashrdi3.o lshrdi3.o
arch/powerpc/lib/Makefile +1 -5
index e6d8be5..0f62982 100644
@@ -7,11 +7,7 @@
 
 ## Build a couple of necessary functions into a private libgcc
 ## if the user asked for it
-ifdef USE_PRIVATE_LIBGCC
-lib-y	+= _ashldi3.o
-lib-y	+= _ashrdi3.o
-lib-y	+= _lshrdi3.o
-endif
+lib-$(CONFIG_USE_PRIVATE_LIBGCC) += _ashldi3.o _ashrdi3.o _lshrdi3.o
 
 MINIMAL=
 
arch/sh/lib/Makefile +2 -12
index 5fc9d9d..8a84b24 100644
@@ -15,15 +15,5 @@ obj-y	+= time.o
 endif
 obj-$(CONFIG_CMD_SH_ZIMAGEBOOT) += zimageboot.o
 
-
-
-# Build private libgcc only when asked for
-ifdef USE_PRIVATE_LIBGCC
-lib-y	+= ashiftrt.o
-lib-y	+= ashiftlt.o
-lib-y	+= lshiftrt.o
-lib-y	+= ashldi3.o
-lib-y	+= ashrsi3.o
-lib-y	+= lshrdi3.o
-lib-y	+= movmem.o
-endif
+lib-$(CONFIG_USE_PRIVATE_LIBGCC) += ashiftrt.o ashiftlt.o lshiftrt.o \
+				    ashldi3.o ashrsi3.o lshrdi3.o movmem.o
arch/x86/config.mk +1 -1
index 58dff14..1e52a5e 100644
@@ -31,4 +31,4 @@ LDFLAGS_FINAL += --wrap=__moddi3 --wrap=__umoddi3
 export NORMAL_LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
 PREFIXED_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/$(shell basename $(NORMAL_LIBGCC))
 
-export USE_PRIVATE_LIBGCC=$(shell dirname $(PREFIXED_LIBGCC))
+CONFIG_USE_PRIVATE_LIBGCC=$(shell dirname $(PREFIXED_LIBGCC))
include/configs/tegra-common.h +4 -0
index 522cd41..0a07e30 100644
@@ -151,6 +151,10 @@
 #define CONFIG_SPL_SERIAL_SUPPORT
 #define CONFIG_SPL_GPIO_SUPPORT
 
+#ifdef CONFIG_SPL_BUILD
+# define CONFIG_USE_PRIVATE_LIBGCC
+#endif
+
 #define CONFIG_SYS_GENERIC_BOARD
 
 /* Misc utility code */
spl/Makefile +1 -1
index 57bd43b..e1a0601 100644
@@ -132,7 +132,7 @@ u-boot-spl-dirs	:= $(patsubst %/,%,$(filter %/, $(libs-y)))
 libs-y := $(patsubst %/, %/built-in.o, $(libs-y))
 
 # Add GCC lib
-ifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
+ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y)
 PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a
 PLATFORM_LIBS := $(filter-out %/lib.a, $(filter-out -lgcc, $(PLATFORM_LIBS))) $(PLATFORM_LIBGCC)
 endif
Signature · 1 line
1.8.3.2
#3 lore raw

PATCH 2/4 kbuild: add CONFIG_ prefix to USE_PRIVATE_LIBS

Quoted 3 lines · Masahiro Yamada

Before this commit, USE_PRIVATE_LIBS is defined in arch-specific config.mk and referenced in arch/$(ARCH)/lib/Makefile.

I think you need to s/USE_PRIVATE_LIBS/USE_PRIVATE_LIBGCC/ throughout the patch subject and description. With that change,

Quoted 1 line
Makefile +0 -0

....

Makefile u-boot-main := $(libs-y) · line 657

Quoted 7 lines
Makefile +3 -0
+ifdef CONFIG_USE_PRIVATE_LIBGCC
+ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y)
 PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a
 else
+PLATFORM_LIBGCC = -L $(CONFIG_USE_PRIVATE_LIBGCC) -lgcc
 endif
 else

Here, it seems that CONFIG_USE_PRIVATE_LIBGCC can be (a) unset (b) set to y, (c) set to a specific library path name.

arch/arm/lib/Makefile line 9

Quoted 4 lines
arch/arm/lib/Makefile +2 -0
 
+lib-$(CONFIG_USE_PRIVATE_LIBGCC) += _ashldi3.o _ashrdi3.o _divsi3.o \
+			_lshrdi3.o _modsi3.o _udivsi3.o _umodsi3.o div0.o

In case (c) above, that will set variable lib-$(the_library_path_name). I guess that variable simply won't be used, so that's OK, assuming that the path name doesn't contain any characters that are illegal as a make variable name. That's probably true though.

spl/Makefile u-boot-spl-dirs := $(patsubst %/,%,$(filter %/, $(libs-y))) · line 138

Quoted 7 lines
spl/Makefile +1 -0
 
 # Add GCC lib
+ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y)
 PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a
 PLATFORM_LIBS := $(filter-out %/lib.a, $(filter-out -lgcc, $(PLATFORM_LIBS))) $(PLATFORM_LIBGCC)
 endif

Should the SPL code here also handle case (c) above? I suppose that's a pre-existing issue, and not related to this patch though, so feel free to ignore it.

#4 lore raw

PATCH 2/4 kbuild: add CONFIG_ prefix to USE_PRIVATE_LIBS

Hello Stephen,

Quoted 2 lines

I think you need to s/USE_PRIVATE_LIBS/USE_PRIVATE_LIBGCC/ throughout the patch subject and description. With that change,

Oops. Good catch! Fixed in v2.

Quoted 5 lines

Here, it seems that CONFIG_USE_PRIVATE_LIBGCC can be (a) unset (b) set to y, (c) set to a specific library path name.

Quoted 1 line
arch/arm/lib/Makefile +0 -0
Quoted 7 lines

arch/arm/lib/Makefile line 9

Quoted 2 lines
arch/arm/lib/Makefile +2 -0
+lib-$(CONFIG_USE_PRIVATE_LIBGCC) += _ashldi3.o _ashrdi3.o _divsi3.o \
+			_lshrdi3.o _modsi3.o _udivsi3.o _umodsi3.o div0.o

In case (c) above, that will set variable lib-$(the_library_path_name). I guess that variable simply won't be used, so that's OK, assuming that the path name doesn't contain any characters that are illegal as a make variable name. That's probably true though.

Right. lib-$(the_library_path_name) is ignored harmlessly.

Quoted 11 lines

spl/Makefile u-boot-spl-dirs := $(patsubst %/,%,$(filter %/, $(libs-y))) · line 138

Quoted 7 lines
spl/Makefile +1 -0
 
 # Add GCC lib
+ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y)
 PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a
 PLATFORM_LIBS := $(filter-out %/lib.a, $(filter-out -lgcc, $(PLATFORM_LIBS))) $(PLATFORM_LIBGCC)
 endif

Should the SPL code here also handle case (c) above? I suppose that's a pre-existing issue, and not related to this patch though, so feel free to ignore it.

case (c) is used only by x86, which does not generate SPL image. That's why this issue has been dismissed so far.

Actually I noticed this issue when I was working on this series. But I want to post less invasive patches to solve our issue; slow Kbuild. So I did not touch it.

Best Regards
Masahiro Yamada

#5 lore raw

PATCH 3/4 config.mk: specify the exact path to standalone linker script

In reply to Masahiro Yamada

We want to change the build system to include config.mk only from ./Makefile and spl/Makefile.
We must prepare for that in this commit.

$(src) is a moving target and not handy for our purpose. We must replace it with a fixed path.

---

 arch/mips/cpu/mips32/config.mk | 3 ++-
 arch/mips/cpu/mips64/config.mk | 3 ++-
 arch/mips/cpu/xburst/config.mk | 3 ++-
 arch/nds32/config.mk           | 3 ++-
 arch/sparc/config.mk           | 2 +-
 5 files changed, 9 insertions(+), 5 deletions(-)
arch/mips/cpu/mips32/config.mk +2 -1
index 7ee7faa..cd4ce7a 100644
@@ -21,4 +21,5 @@ else
 PLATFORM_LDFLAGS  += -m elf32ltsmip
 endif
 
-CONFIG_STANDALONE_LOAD_ADDR ?= 0x80200000 -T $(srctree)/$(src)/mips.lds
+CONFIG_STANDALONE_LOAD_ADDR ?= 0x80200000 \
+			       -T $(srctree)/examples/standalone/mips.lds
arch/mips/cpu/mips64/config.mk +2 -1
index 02113a1..3c01136 100644
@@ -21,4 +21,5 @@ else
 PLATFORM_LDFLAGS  += -m elf64ltsmip
 endif
 
-CONFIG_STANDALONE_LOAD_ADDR ?= 0xffffffff80200000 -T $(srctree)/$(src)/mips64.lds
+CONFIG_STANDALONE_LOAD_ADDR ?= 0xffffffff80200000 \
+			       -T $(srctree)/examples/standalone/mips64.lds
arch/mips/cpu/xburst/config.mk +2 -1
index 00b0fd9..b8e53e5 100644
@@ -12,4 +12,5 @@ else
 PLATFORM_LDFLAGS  += -m elf32ltsmip
 endif
 
-CONFIG_STANDALONE_LOAD_ADDR ?= 0x80200000 -T $(srctree)/$(src)/mips.lds
+CONFIG_STANDALONE_LOAD_ADDR ?= 0x80200000 \
+			       -T $(srctree)/examples/standalone/mips.lds
arch/nds32/config.mk +2 -1
index 550f8a4..d0434a9 100644
@@ -10,7 +10,8 @@
 
 CROSS_COMPILE ?= nds32le-linux-
 
-CONFIG_STANDALONE_LOAD_ADDR = 0x300000 -T $(srctree)/$(src)/nds32.lds
+CONFIG_STANDALONE_LOAD_ADDR = 0x300000 \
+			      -T $(srctree)/examples/standalone/nds32.lds
 
 PLATFORM_RELFLAGS	+= -fno-strict-aliasing -fno-common -mrelax
 PLATFORM_RELFLAGS	+= -gdwarf-2
arch/sparc/config.mk +1 -1
index 9bb3724..154d00e 100644
@@ -8,6 +8,6 @@
 CROSS_COMPILE ?= sparc-elf-
 
 CONFIG_STANDALONE_LOAD_ADDR ?= 0x00000000 -L $(gcclibdir) \
-			-T $(srctree)/$(src)/sparc.lds
+			       -T $(srctree)/examples/standalone/sparc.lds
 
 PLATFORM_CPPFLAGS += -DCONFIG_SPARC -D__sparc__
Signature · 1 line
1.8.3.2
#6 lore raw

PATCH 4/4 kbuild: improve Kbuild speed

In reply to Masahiro Yamada

Kbuild brought about many advantages for us but a significant performance regression was reported by Simon Glass.

After some discussions and analysis, it turned out its main cause is in $(call cc-option,...).

Historically, U-Boot parses all config.mk (arch/*/config.mk and board/*/config.mk)
every time descending into subdirectories.
That means cc-options are evaluated over and over again.

$(call cc-option,...) is useful but costly.
So we want to evaluate them only in ./Makefile and spl/Makefile and export compiler flags.

This commit changes the build system as follows:

- Modify scripts/Makefile.build to not include config.mk.

    Instead, add $(PLATFORM_CPPFLAGS) to asflags-y, ccflags-y,
    cppflags-y.

- export many variables.
Going forward, Kbuild will not parse config.mk files when it descends into subdirectories.
If we want to set variables in config.mk and use them in subdirectories, they must be exported.

This is the list of variables to get exported:
PLATFORM_CPPFLAGS
CPUDIR
BOARDDIR
OBJCOPYFLAGS
LDFLAGS
LDFLAGS_FINAL
(to use it in nand_spl/board/*/*/Makefile)
CONFIG_STANDALONE_LOAD_ADDR
(to use it in examples/standalone/Makefile)
SYM_PREFIX
(to use it in examples/standalone/Makefile)
RELFLAGS
(to use it in examples/standalone/Makefile)

- Delete CPPFLAGS
This variable has been replaced with PLATFORM_CPPFLAGS

- Copy gcclibdir from example/standalone/Makefile to arch/sparc/config.mk.
The reference in CONFIG_STANDALONE_LOAD_ADDR must be resolved before it is exported.

---

 Makefile                     |  7 ++++---
 arch/blackfin/config.mk      |  1 +
 arch/sparc/config.mk         |  2 ++
 config.mk                    | 28 ++++++++++++++++++++--------
 examples/standalone/Makefile |  5 ++---
 scripts/Makefile.build       | 10 +++++-----
 scripts/Makefile.lib         |  7 +++----
 spl/Makefile                 |  7 +++----
 8 files changed, 40 insertions(+), 27 deletions(-)
Makefile +4 -3
index 56ba1ef..e49a240 100644
@@ -358,13 +358,13 @@ UBOOTRELEASE = $(shell cat include/config/uboot.release 2> /dev/null)
 UBOOTVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
 
 export VERSION PATCHLEVEL SUBLEVEL UBOOTRELEASE UBOOTVERSION
-export ARCH CPU BOARD VENDOR SOC
+export ARCH CPU BOARD VENDOR SOC CPUDIR BOARDDIR
 export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC
 export CPP AR NM LDR STRIP OBJCOPY OBJDUMP
 export MAKE AWK
 export DTC CHECK CHECKFLAGS
 
-export KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE
+export KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE OBJCOPYFLAGS LDFLAGS
 export KBUILD_CFLAGS KBUILD_AFLAGS
 
 # When compiling out-of-tree modules, put MODVERDIR in the module
@@ -567,7 +567,8 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
 CHECKFLAGS     += $(NOSTDINC_FLAGS)
 
 # FIX ME
-cpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
+cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \
+							$(NOSTDINC_FLAGS)
 c_flags := $(KBUILD_CFLAGS) $(cpp_flags)
 
 #########################################################################
arch/blackfin/config.mk +1 -0
index c752025..8510e1c 100644
@@ -41,6 +41,7 @@ CREATE_LDR_ENV =
 endif
 
 SYM_PREFIX = _
+export SYM_PREFIX
 
 LDR_FLAGS-y :=
 LDR_FLAGS-$(CONFIG_BFIN_BOOTROM_USES_EVT1) += -J
arch/sparc/config.mk +2 -0
index 154d00e..7daf4ef 100644
@@ -7,6 +7,8 @@
 
 CROSS_COMPILE ?= sparc-elf-
 
+gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
+
 CONFIG_STANDALONE_LOAD_ADDR ?= 0x00000000 -L $(gcclibdir) \
 			       -T $(srctree)/examples/standalone/sparc.lds
 
config.mk +20 -8
index e59697f..bb3da0d 100644
@@ -6,11 +6,18 @@
 #
 #########################################################################
 
-# clean the slate ...
-PLATFORM_RELFLAGS =
-PLATFORM_CPPFLAGS =
-PLATFORM_LDFLAGS =
-
+# This file is included from ./Makefile and spl/Makefile.
+# Clean the state to avoid the same flags added twice.
+#
+# (Tegra needs different flags for SPL.
+#  That's the reason why this file must be included from spl/Makefile too.
+#  If we did not have Tegra SoCs, build system would be much simpler...)
+PLATFORM_RELFLAGS :=
+PLATFORM_CPPFLAGS :=
+PLATFORM_LDFLAGS :=
+LDFLAGS :=
+LDFLAGS_FINAL :=
+OBJCOPYFLAGS :=
 #########################################################################
 
 # Some architecture config.mk files need to know what CPUDIR is set to,
@@ -39,12 +46,17 @@ endif
 
 #########################################################################
 
-RELFLAGS= $(PLATFORM_RELFLAGS)
+RELFLAGS := $(PLATFORM_RELFLAGS)
 
 OBJCOPYFLAGS += --gap-fill=0xff
 
-CPPFLAGS = $(RELFLAGS)
-CPPFLAGS += -pipe $(PLATFORM_CPPFLAGS)
+PLATFORM_CPPFLAGS += $(RELFLAGS)
+PLATFORM_CPPFLAGS += -pipe
 
 LDFLAGS += $(PLATFORM_LDFLAGS)
 LDFLAGS_FINAL += -Bstatic
+
+export PLATFORM_CPPFLAGS
+export RELFLAGS
+export LDFLAGS_FINAL
+export CONFIG_STANDALONE_LOAD_ADDR
examples/standalone/Makefile +2 -3
index 5b227cd..7e0e5b7 100644
@@ -44,9 +44,8 @@ gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
 # relocatable executable.  The relocation data is not needed, and
 # also causes the entry point of the standalone application to be
 # inconsistent.
-ifeq ($(ARCH),powerpc)
-# FIX ME
-CPPFLAGS := $(filter-out $(RELFLAGS), $(CPPFLAGS))
+ifeq ($(CONFIG_PPC),y)
+PLATFORM_CPPFLAGS := $(filter-out $(RELFLAGS),$(PLATFORM_CPPFLAGS))
 endif
 
 # We don't want gcc reordering functions if possible.  This ensures that an
scripts/Makefile.build +5 -5
index 59361f4..36346fd 100644
@@ -55,11 +55,6 @@ endif
 
 include scripts/Kbuild.include
 
-# Added for U-Boot
-# We must include config.mk after Kbuild.include
-# so that some config.mk can use cc-option.
-include config.mk
-
 # For backward compatibility check that these variables do not change
 save-cflags := $(CFLAGS)
 
@@ -68,6 +63,11 @@ kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
 kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
 include $(kbuild-file)
 
+# Added for U-Boot
+asflags-y  += $(PLATFORM_CPPFLAGS)
+ccflags-y  += $(PLATFORM_CPPFLAGS)
+cppflags-y += $(PLATFORM_CPPFLAGS)
+
 # If the save-* variables changed error out
 ifeq ($(KBUILD_NOPEDANTIC),)
         ifneq ("$(save-cflags)","$(CFLAGS)")
scripts/Makefile.lib +3 -4
index 02b17b1..d568fde 100644
@@ -101,13 +101,12 @@ 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)))")
 
-# U-Boot also uses $(CPPFLAGS)
-orig_c_flags   = $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \
+orig_c_flags   = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \
                  $(ccflags-y) $(CFLAGS_$(basetarget).o)
 _c_flags       = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))
-_a_flags       = $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(KBUILD_AFLAGS) $(KBUILD_SUBDIR_ASFLAGS) \
+_a_flags       = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(KBUILD_SUBDIR_ASFLAGS) \
                  $(asflags-y) $(AFLAGS_$(basetarget).o)
-_cpp_flags     = $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F))
+_cpp_flags     = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F))
 
 #
 # Enable gcov profiling flags for a file, directory or for all files depending
spl/Makefile +3 -4
index e1a0601..781abf6 100644
@@ -51,7 +51,9 @@ endif
 include $(TOPDIR)/config.mk
 
 # FIX ME
-c_flags := $(KBUILD_CFLAGS) $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
+cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \
+							$(NOSTDINC_FLAGS)
+c_flags := $(KBUILD_CFLAGS) $(cpp_flags)
 
 # Auto-generate the spl-autoconf.mk file (which is included by all makefiles for SPL)
 quiet_cmd_autoconf = GEN     $@
@@ -228,9 +230,6 @@ PHONY += $(u-boot-spl-dirs)
 $(u-boot-spl-dirs):
 	$(Q)$(MAKE) $(build)=$@
 
-# FIX ME
-cpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
-
 quiet_cmd_cpp_lds = LDS     $@
 cmd_cpp_lds = $(CPP) $(cpp_flags) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ \
 		-x assembler-with-cpp -P -o $@ $<
Signature · 1 line
1.8.3.2
#7 lore raw

PATCH 4/4 kbuild: improve Kbuild speed

Hi,

Quoted 8 lines · Masahiro Yamada

Kbuild brought about many advantages for us but a significant performance regression was reported by Simon Glass.

After some discussions and analysis, it turned out its main cause is in $(call cc-option,...).

This significantly improves performance for me on snow:

$ time crosfw -b snow -w
Configuring for snow board...

real 0m5.023s
user 0m34.440s
sys 0m4.050s

Without this series it is:

$ time crosfw -b snow -w
Configuring for snow board...

real 0m26.440s
user 0m46.770s
sys 0m10.170s

Prior to kbuild going in I got:

time crosfw -b snow -w
Configuring for snow board...

real 0m5.923s
user 0m37.110s
sys 0m5.240s

So I would say that we are at least as fast as pre-kbuild. Great!

Regards,
Simon

#8 lore raw

cover Big acceleration of Kbuild performance

In reply to Masahiro Yamada
Quoted 16 lines · Masahiro Yamada

Kbuild brought about many advantages for us but a significant performance regression was reported by Simon Glass.

After some discussions and analysis, it turned out its main cause is in $(call cc-option,...).

Historically, U-Boot parses all config.mk (arch/*/config.mk and board/*/config.mk)
every time descending into subdirectories.
That means cc-options are evaluated over and over again.

$(call cc-option,...) is useful but costly. So we want to evaluate them only in ./Makefile and spl/Makefile and export compiler flags.

Quoted 8 lines

1/4 through 3/4 are preparation for 4/4.

4/4 is what we really want to do.
By applying it, I think Kbuild will get much faster.

Simon,
Could you post the result of "time" command?
I want to know how fast Kbuild will be on your computer.

Locally, I see am335x_evm down to about 9 seconds, and it was 11 seconds or so before Kbuild and 23s on master. I think this speed up over pre-Kbuild is quite real as we've gone from ~2000 cc-option execs to 90.

I'd really love to see some run-time sanity check from the Tegra folks, even tho I did see Stephen ack that patch.

Thanks for getting this done so quick!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140227/733fb026/attachment.pgp>
#9 lore raw

cover Big acceleration of Kbuild performance

In reply to Masahiro Yamada
Quoted 6 lines · Masahiro Yamada

Kbuild brought about many advantages for us but a significant performance regression was reported by Simon Glass.

After some discussions and analysis, it turned out its main cause is in $(call cc-option,...).

...

Quoted 8 lines

Instead, you can also try my local branch for easy test.

I pushed my local branch to my GitHub page. Please try the following.

(1) git clone git://github.com/masahir0y/u-boot-kbuild.git
(2) cd u-boot-kbuild
(3) git checkout optimize_v1

I tried that since it was easier than applying all the patches. It built and ran on real HW OK, although the U-Boot banner is a bit broken:

U-Boot SPL __DUMMY__ (DUMMY - DUMMY)

__DUMMY__ (DUMMY - DUMMY)

TEGRA20
Board: NVIDIA Seaboard
...
Hit any key to stop autoboot: 0
Tegra20 (SeaBoard) #

#10 lore raw

cover Big acceleration of Kbuild performance

Hello Stephen,

Quoted 10 lines
Quoted 3 lines

(1) git clone git://github.com/masahir0y/u-boot-kbuild.git
(2) cd u-boot-kbuild
(3) git checkout optimize_v1

I tried that since it was easier than applying all the patches. It built and ran on real HW OK, although the U-Boot banner is a bit broken:

U-Boot SPL __DUMMY__ (DUMMY - DUMMY)

Quoted 7 lines

__DUMMY__ (DUMMY - DUMMY)

TEGRA20
Board: NVIDIA Seaboard
...
Hit any key to stop autoboot: 0
Tegra20 (SeaBoard) #

It's a known issue.
I intentionally inserted my own patch to disable timestamp and version information on my local branch.
This is just for checking md5sum of generated binaries and it will not be merged into the main line.

Thanks for your run test.
I added your Tested-by credit in 4/4 of v2.

Best Regards
Masahiro Yamada