Re: [PATCH v2 1/1] kbuild: deb-pkg: Build parallely with current dpkg-buildpackage

From: Masahiro Yamada
Date: Wed Mar 15 2023 - 12:52:53 EST


On Thu, Mar 16, 2023 at 1:29 AM Bastian Germann <bage@xxxxxxxxxxxxx> wrote:
>
> With dpkg-buildpackage v1.21.10 or later, the only way to build the


Please include the commit hash.

I guess

Commit 1d0ea9b2ba3f ("dpkg-buildpackage: Change -j, --jobs semantics
to non-force mode")

is the one.


> deb-pkg generated package parallely is adding -j<N> to the MAKEFLAGS
> environment variable or using the --jobs-force option. The package ignores
> the usual parallel build option that is described in Debian Policy §4.9.1.

If a new section is inserted before, the section number '4.9.1'
may not be true in the future.

I think you can drop the section number
if you add the Link: tag close to the relevant section.


>
> Derive make's -j parameter from the DEB_BUILD_OPTIONS environment variable
> that ends up being set by dpkg-buildpackage -j<N>.
>
> Link: https://www.debian.org/doc/debian-policy/ch-source.html



Link: https://www.debian.org/doc/debian-policy/ch-source.html#debian-rules-and-deb-build-options

might be better - it points to the relevant section.





>
> build-indep:
> build-arch:
> - \$(MAKE) -f \$(srctree)/Makefile ARCH=${ARCH} \
> + \$(MAKE) -f \$(srctree)/Makefile ARCH=${ARCH} \$(JOBS) \
> \$(shell \$(srctree)/scripts/package/deb-build-option) \
> olddefconfig all
>
> @@ -250,10 +254,10 @@ build: build-arch
>
> binary-indep:
> binary-arch: build-arch
> - \$(MAKE) -f \$(srctree)/Makefile ARCH=${ARCH} intdeb-pkg
> + \$(MAKE) -f \$(srctree)/Makefile ARCH=${ARCH} \$(JOBS) intdeb-pkg
> clean:
> rm -rf debian/files debian/linux-*
> - \$(MAKE) -f \$(srctree)/Makefile ARCH=${ARCH} clean
> + \$(MAKE) -f \$(srctree)/Makefile ARCH=${ARCH} \$(JOBS) clean
>
> binary: binary-arch
> EOF
> --
> 2.39.2
>

I prefer appending it to MAKEFLAGS instead of touching every target.
(or is there any reason why MAKEFLAGS does not work here?)

The reference code exists in the link you mentioned.

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
MAKEFLAGS += -j$(NUMJOBS)
endif



--
Best Regards
Masahiro Yamada