[PATCH 1/1] Makefile: Speed up parallel build
Anup Patel
anup at brainfault.org
Tue Oct 27 08:29:00 PDT 2026
On Thu, Sep 24, 2026 at 11:32 AM Maxim Kochetkov <fido_max at inbox.ru> wrote:
>
> 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>
LGMT.
Reviewed-by: Anup Patel <anup at brainfault.org>
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
> ---
> 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
>
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
More information about the opensbi
mailing list