[PATCH 1/1] Makefile: Speed up parallel build

Maxim Kochetkov fido_max at inbox.ru
Wed Sep 23 23:01:33 PDT 2026


Parallel build is extremely slow when using vars (O, I,
PLATFORM_DIR+PLATFORM). And all this is because the variables are
calculated continuously, with the simultaneous invocation of
the $(shell ...). So use "Simply expanded variables" to
calculate value and call $(shell ...) just once.

Signed-off-by: Maxim Kochetkov <fido_max at inbox.ru>
---
 Makefile | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 1b3333f3..da6751fd 100644
--- a/Makefile
+++ b/Makefile
@@ -22,18 +22,18 @@ endif
 # Find out source, build, and install directories
 src_dir=$(CURDIR)
 ifdef O
- build_dir=$(shell $(READLINK) -f $(O))
+ build_dir:=$(shell $(READLINK) -f $(O))
 else
- build_dir=$(CURDIR)/build
+ build_dir:=$(CURDIR)/build
 endif
 ifeq ($(build_dir),$(CURDIR))
 $(error Build directory is same as source directory.)
 endif
 install_root_dir_default=$(CURDIR)/install
 ifdef I
- install_root_dir=$(shell $(READLINK) -f $(I))
+ install_root_dir:=$(shell $(READLINK) -f $(I))
 else
- install_root_dir=$(install_root_dir_default)/usr
+ install_root_dir:=$(install_root_dir_default)/usr
 endif
 ifeq ($(install_root_dir),$(CURDIR))
 $(error Install root directory is same as source directory.)
@@ -42,12 +42,12 @@ ifeq ($(install_root_dir),$(build_dir))
 $(error Install root directory is same as build directory.)
 endif
 ifdef PLATFORM_DIR
-  platform_dir_path=$(shell $(READLINK) -f $(PLATFORM_DIR))
+  platform_dir_path:=$(shell $(READLINK) -f $(PLATFORM_DIR))
   ifdef PLATFORM
     platform_parent_dir=$(platform_dir_path)
   else
-    PLATFORM=$(shell basename $(platform_dir_path))
-    platform_parent_dir=$(shell realpath ${platform_dir_path}/..)
+    PLATFORM:=$(shell basename $(platform_dir_path))
+    platform_parent_dir:=$(shell realpath ${platform_dir_path}/..)
   endif
 else
  platform_parent_dir=$(src_dir)/platform
-- 
2.55.0




More information about the opensbi mailing list