Skip to contentSkip to conversation

linux/linux.mk: forcibly (re)enable Make jobserver

PATCH Applied Laszlo Ersek 2 participants 7 messages Jul 30 – Sep 25

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux/linux.mk: forcibly (re)enable Make jobserver

Commit 0b9efc991f8a («linux: use BR2_MAKE», 2023-04-10) replaced $(MAKE) with $(BR2_MAKE) in a number of recipes. As a consequence, the child make is unable to discover the job server, and we get a warning such as

Quoted 1 line

warning: jobserver unavailable: using -j1. Add `+' to parent make rule.

https://www.gnu.org/software/make/manual/html_node/Error-Messages.html
https://www.gnu.org/software/make/manual/html_node/MAKE-Variable.html

Inform the parent Make, by prefixing the recipe with "+", that $(BR2_MAKE) can deal with the job server.

Cc Arnout Vandecappelle <[email protected]>
Cc Oleg Lyovin <[email protected]>

---

Notes:

    Commit 0b9efc991f8a replaces multiple instances of $(MAKE) with
    $(BR2_MAKE); I'm only prefixing the one recipe with "+" that seems to
    cause the most noticeable slowdown for me (by missing out on a parallel
    kernel build).
 linux/linux.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux/linux.mk +1 -1
index e790daff6608..80581081a7eb 100644
@@ -696,7 +696,7 @@ linux-rebuild-with-initramfs: rootfs-cpio
 linux-rebuild-with-initramfs:
 	@$(call MESSAGE,"Rebuilding kernel with initramfs")
 	# Build the kernel.
-	$(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) $(LINUX_TARGET_NAME)
+	+$(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) $(LINUX_TARGET_NAME)
 	$(LINUX_APPEND_DTB)
 	# Copy the kernel image(s) to its(their) final destination
 	$(call LINUX_INSTALL_IMAGE,$(BINARIES_DIR))

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#1 lore raw
Quoted 16 lines · Laszlo Ersek

Commit 0b9efc991f8a («linux: use BR2_MAKE», 2023-04-10) replaced $(MAKE) with $(BR2_MAKE) in a number of recipes. As a consequence, the child make is unable to discover the job server, and we get a warning such as

Quoted 1 line

warning: jobserver unavailable: using -j1. Add `+' to parent make rule.

https://www.gnu.org/software/make/manual/html_node/Error-Messages.html
https://www.gnu.org/software/make/manual/html_node/MAKE-Variable.html

Inform the parent Make, by prefixing the recipe with "+", that $(BR2_MAKE) can deal with the job server.

Cc Arnout Vandecappelle <[email protected]>
Cc Oleg Lyovin <[email protected]>
Quoted 7 lines

---

Notes:

     Commit 0b9efc991f8a replaces multiple instances of $(MAKE) with
     $(BR2_MAKE); I'm only prefixing the one recipe with "+" that seems to
     cause the most noticeable slowdown for me (by missing out on a parallel
     kernel build).

Are you really sure this speeds things up? The core of the work should be in
the make all invocation on line 546. All the other invocations should be pretty much serial. In particular the rebuild-with-initramfs should do nothing more than re-linking and re-compressing the kernel because the exact same command was already done in the build step.

Regards,
Arnout

Quoted 16 lines
  linux/linux.mk | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
linux/linux.mk +1 -1
index e790daff6608..80581081a7eb 100644
@@ -696,7 +696,7 @@ linux-rebuild-with-initramfs: rootfs-cpio
  linux-rebuild-with-initramfs:
  	@$(call MESSAGE,"Rebuilding kernel with initramfs")
  	# Build the kernel.
-	$(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) $(LINUX_TARGET_NAME)
+	+$(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) $(LINUX_TARGET_NAME)
  	$(LINUX_APPEND_DTB)
  	# Copy the kernel image(s) to its(their) final destination
  	$(call LINUX_INSTALL_IMAGE,$(BINARIES_DIR))
Quoted 4 lines

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#2 lore raw
Quoted 22 lines · Arnout Vandecappelle
Quoted 19 lines · Laszlo Ersek

Commit 0b9efc991f8a («linux: use BR2_MAKE», 2023-04-10) replaced $(MAKE) with $(BR2_MAKE) in a number of recipes. As a consequence, the child make is unable to discover the job server, and we get a warning such as

Quoted 1 line

warning: jobserver unavailable: using -j1. Add `+' to parent make rule.

https://www.gnu.org/software/make/manual/html_node/Error-Messages.html
https://www.gnu.org/software/make/manual/html_node/MAKE-Variable.html

Inform the parent Make, by prefixing the recipe with "+", that $(BR2_MAKE) can deal with the job server.

Cc Arnout Vandecappelle <[email protected]>
Cc Oleg Lyovin <[email protected]>

---

Quoted 7 lines
Quoted 5 lines

Notes:
Commit 0b9efc991f8a replaces multiple instances of $(MAKE) with $(BR2_MAKE); I'm only prefixing the one recipe with "+" that seems to cause the most noticeable slowdown for me (by missing out on a parallel kernel build).

Are you really sure this speeds things up?

Yes.

Quoted 5 lines

The core of the work should be in the make all invocation on line
546. All the other invocations should be pretty much serial. In particular the rebuild-with-initramfs should do nothing more than re-linking and re-compressing the kernel because the exact same command was already done in the build step.

In my case,

- both "LINUX_BUILD_CMDS" -- the "all" target --,

- and "linux-rebuild-with-initramfs" -- the $(LINUX_TARGET_NAME), aka "Image" target --

seem to perform a similarly large [1] kernel build. The first one builds object files concurrently already, the second one (without this patch) doesn't.

[1] The "Image" build (from "linux-rebuild-with-initramfs") seems not to execute the following types of recipes from the "all" target (from "LINUX_BUILD_CMDS"):

- CC [M]
- LD [M]
- CHKSHA1 on various headers
- COPY on various headers
- DTC on various device tree files
- GZIP on Image.gz
- UPD and WRAP on various generated header files

I think these differences are expected. However, while "linux-rebuild-with-initramfs" performs fewer build steps, according to the above, it does build all the built-in object files anew, and that happens way more slowly than in "LINUX_BUILD_CMDS", because "linux-rebuild-with-initramfs" doesn't do it concurrently.

(FWIW, I'm based off of release 2025.05.)

Laszlo
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw
Quoted 29 lines · Laszlo Ersek
Quoted 28 lines · Arnout Vandecappelle
Quoted 24 lines · Laszlo Ersek

Commit 0b9efc991f8a («linux: use BR2_MAKE», 2023-04-10) replaced $(MAKE) with $(BR2_MAKE) in a number of recipes. As a consequence, the child make is unable to discover the job server, and we get a warning such as

Quoted 1 line

warning: jobserver unavailable: using -j1. Add `+' to parent make rule.

https://www.gnu.org/software/make/manual/html_node/Error-Messages.html
https://www.gnu.org/software/make/manual/html_node/MAKE-Variable.html

Inform the parent Make, by prefixing the recipe with "+", that $(BR2_MAKE) can deal with the job server.

Cc Arnout Vandecappelle <[email protected]>
Cc Oleg Lyovin <[email protected]>

---

Notes:
     Commit 0b9efc991f8a replaces multiple instances of $(MAKE) with $(BR2_MAKE); I'm only prefixing the one recipe with "+" that seems to cause the most noticeable slowdown for me (by missing out on a parallel kernel build).

Quoted 3 lines
Quoted 1 line

  Are you really sure this speeds things up?

Yes.

Ah, I just saw now that _BUILD_CMDS already has a + in pkg-generic.mk.

Quoted 29 lines
Quoted 5 lines

The core of the work should be in the make all invocation on line
546. All the other invocations should be pretty much serial. In particular the rebuild-with-initramfs should do nothing more than re-linking and re-compressing the kernel because the exact same command was already done in the build step.

In my case,

- both "LINUX_BUILD_CMDS" -- the "all" target --,

- and "linux-rebuild-with-initramfs" -- the $(LINUX_TARGET_NAME), aka "Image" target --

seem to perform a similarly large [1] kernel build. The first one builds object files concurrently already, the second one (without this patch) doesn't.

[1] The "Image" build (from "linux-rebuild-with-initramfs") seems not to execute the following types of recipes from the "all" target (from "LINUX_BUILD_CMDS"):

- CC [M]
- LD [M]
- CHKSHA1 on various headers
- COPY on various headers
- DTC on various device tree files
- GZIP on Image.gz
- UPD and WRAP on various generated header files

Quoted 3 lines

I think these differences are expected. However, while "linux-rebuild-with-initramfs" performs fewer build steps, according to the above, it does build all the built-in object files anew, and that

That's weird though. Well, it's not weird that it doesn't re-do the modules
because the LINUX_TARGET_NAME goal doesn't build the modules. But it's weird that it rebuilds the builtin object files, nothing should have changed compared to the earlier run except for the single object file that contains the initramfs cpio image.

It would be nice to fix that, but regardless, it's not a bad idea to add the +
to the rebuild-with-initramfs goal so I'll apply this patch.

Regards,
Arnout

Quoted 6 lines

happens way more slowly than in "LINUX_BUILD_CMDS", because "linux-rebuild-with-initramfs" doesn't do it concurrently.

(FWIW, I'm based off of release 2025.05.)

Laszlo

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#4 lore raw
Quoted 32 lines · Arnout Vandecappelle
Quoted 29 lines · Laszlo Ersek
Quoted 28 lines · Arnout Vandecappelle
Quoted 24 lines · Laszlo Ersek

Commit 0b9efc991f8a («linux: use BR2_MAKE», 2023-04-10) replaced $(MAKE) with $(BR2_MAKE) in a number of recipes. As a consequence, the child make is unable to discover the job server, and we get a warning such as

Quoted 1 line

warning: jobserver unavailable: using -j1. Add `+' to parent make rule.

https://www.gnu.org/software/make/manual/html_node/Error-Messages.html
https://www.gnu.org/software/make/manual/html_node/MAKE-Variable.html

Inform the parent Make, by prefixing the recipe with "+", that $(BR2_MAKE) can deal with the job server.

Cc Arnout Vandecappelle <[email protected]>
Cc Oleg Lyovin <[email protected]>

---

Notes:
     Commit 0b9efc991f8a replaces multiple instances of $(MAKE) with $(BR2_MAKE); I'm only prefixing the one recipe with "+" that seems to cause the most noticeable slowdown for me (by missing out on a parallel kernel build).

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

  Are you really sure this speeds things up?

Yes.

 Ah, I just saw now that _BUILD_CMDS already has a + in pkg-generic.mk.

Ah indeed, from commit 069b33a30e6d («package: enable jobserver for recursive make», 2014-02-14). :)

(... I couldn't really figure out the macro trickery with *_BUILD_CMDS -- I think I did grep for just _BUILD_CMDS, but must have surely missed this instance.)

Quoted 33 lines
Quoted 29 lines
Quoted 5 lines

The core of the work should be in the make all invocation on line
546. All the other invocations should be pretty much serial. In particular the rebuild-with-initramfs should do nothing more than re-linking and re-compressing the kernel because the exact same command was already done in the build step.

In my case,

- both "LINUX_BUILD_CMDS" -- the "all" target --,

- and "linux-rebuild-with-initramfs" -- the $(LINUX_TARGET_NAME), aka "Image" target --

seem to perform a similarly large [1] kernel build. The first one builds object files concurrently already, the second one (without this patch) doesn't.

[1] The "Image" build (from "linux-rebuild-with-initramfs") seems not to execute the following types of recipes from the "all" target (from "LINUX_BUILD_CMDS"):

- CC [M]
- LD [M]
- CHKSHA1 on various headers
- COPY on various headers
- DTC on various device tree files
- GZIP on Image.gz
- UPD and WRAP on various generated header files

Quoted 3 lines

I think these differences are expected. However, while "linux-rebuild-with-initramfs" performs fewer build steps, according to the above, it does build all the built-in object files anew, and that

Quoted 5 lines

 That's weird though. Well, it's not weird that it doesn't re-do the
modules because the LINUX_TARGET_NAME goal doesn't build the modules. But it's weird that it rebuilds the builtin object files, nothing should have changed compared to the earlier run except for the single object file that contains the initramfs cpio image.

 It would be nice to fix that, but regardless, it's not a bad idea to
add the + to the rebuild-with-initramfs goal so I'll apply this patch.

Thank you!
Laszlo

Quoted 12 lines

 Regards,
 Arnout

Quoted 6 lines

happens way more slowly than in "LINUX_BUILD_CMDS", because "linux-rebuild-with-initramfs" doesn't do it concurrently.

(FWIW, I'm based off of release 2025.05.)

Laszlo

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#5 lore raw
In reply to Laszlo Ersek

Hi Laszlo,

Quoted 9 lines · Laszlo Ersek

Commit 0b9efc991f8a («linux: use BR2_MAKE», 2023-04-10) replaced $(MAKE) with $(BR2_MAKE) in a number of recipes. As a consequence, the child make is unable to discover the job server, and we get a warning such as

Quoted 1 line

warning: jobserver unavailable: using -j1. Add `+' to parent make rule.

https://www.gnu.org/software/make/manual/html_node/Error-Messages.html
https://www.gnu.org/software/make/manual/html_node/MAKE-Variable.html

Quoted 7 lines

Inform the parent Make, by prefixing the recipe with "+", that $(BR2_MAKE) can deal with the job server.

Cc Arnout Vandecappelle <[email protected]>
Cc Oleg Lyovin <[email protected]>

Applied to master, thanks.

I initially had the same interrogations as Arnout.
So I dug a bit more in this issue, to have minimal configuration to reproduce it. I ended up logging all this info by extending the commit log. See:
https://gitlab.com/buildroot.org/buildroot/-/commit/86a56dcc17cc540c08cc4760af9481636016550d

While this commit alone is useful, I believe there is another
issue: basically, when building an initramfs embedded in the kernel and per-package directories is used, the iniramfs integration might rebuild the kernel. This can be investigated separately.

Best regards,

Julien.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#6 lore raw
In reply to Laszlo Ersek

In reply of:

Quoted 9 lines

Commit 0b9efc991f8a («linux: use BR2_MAKE», 2023-04-10) replaced $(MAKE) with $(BR2_MAKE) in a number of recipes. As a consequence, the child make is unable to discover the job server, and we get a warning such as

Quoted 1 line

warning: jobserver unavailable: using -j1. Add `+' to parent make rule.

https://www.gnu.org/software/make/manual/html_node/Error-Messages.html
https://www.gnu.org/software/make/manual/html_node/MAKE-Variable.html

Quoted 7 lines

Inform the parent Make, by prefixing the recipe with "+", that $(BR2_MAKE) can deal with the job server.

Cc Arnout Vandecappelle <[email protected]>
Cc Oleg Lyovin <[email protected]>

Applied to 2025.02.x, 2026.08.x. Thanks

Quoted 16 lines

---

Notes:

    Commit 0b9efc991f8a replaces multiple instances of $(MAKE) with
    $(BR2_MAKE); I'm only prefixing the one recipe with "+" that seems to
    cause the most noticeable slowdown for me (by missing out on a parallel
    kernel build).
 linux/linux.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux/linux.mk +0 -0
index e790daff6608..80581081a7eb 100644

linux/linux.mk linux-rebuild-with-initramfs: rootfs-cpio · line 702

Quoted 8 lines
linux/linux.mk +1 -1
@@ -696,7 +696,7 @@ linux-rebuild-with-initramfs: rootfs-cpio
 linux-rebuild-with-initramfs:
 	@$(call MESSAGE,"Rebuilding kernel with initramfs")
 	# Build the kernel.
-	$(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) $(LINUX_TARGET_NAME)
+	+$(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) $(LINUX_TARGET_NAME)
 	$(LINUX_APPEND_DTB)
 	# Copy the kernel image(s) to its(their) final destination
 	$(call LINUX_INSTALL_IMAGE,$(BINARIES_DIR))

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot