[1/5] linux-module: Use debug-prefix-map to build modules deterministically

Message ID 20231207154114.20400-2-venkata.pyla@toshiba-tsip.com
State New
Headers show
Series Make ext4 images reproducible | expand

Commit Message

venkata.pyla@toshiba-tsip.com Dec. 7, 2023, 3:41 p.m. UTC
From: venkata pyla <venkata.pyla@toshiba-tsip.com>

The custom linux modules are built non-determinstically due to the
reason that the kernel build includes absolute paths in the debug
information which is not necessary and can be trimmed using
`debug-prefix-map` option.

Signed-off-by: venkata pyla <venkata.pyla@toshiba-tsip.com>
---
 meta/recipes-kernel/linux-module/files/debian/rules.tmpl | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

MOESSBAUER, Felix Dec. 8, 2023, 10:27 a.m. UTC | #1
On Thu, 2023-12-07 at 21:11 +0530, venkata.pyla@toshiba-tsip.com wrote:
> From: venkata pyla <venkata.pyla@toshiba-tsip.com>
> 
> The custom linux modules are built non-determinstically due to the
> reason that the kernel build includes absolute paths in the debug
> information which is not necessary and can be trimmed using
> `debug-prefix-map` option.
> 
> Signed-off-by: venkata pyla <venkata.pyla@toshiba-tsip.com>

Hi, 

thanks for this. It is basically the same patch I send a year ago for
the kernel recipe.

@Maintainers: This patch needs to be serialized with this one:
"add support for non-default modules dir in linux-module".

Acked-by: Felix Moessbauer <felix.moessbauer@siemens.com>

Best regards,
Felix

> ---
>  meta/recipes-kernel/linux-module/files/debian/rules.tmpl | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/recipes-kernel/linux-module/files/debian/rules.tmpl
> b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl
> index 7d950e38..20d5f670 100755
> --- a/meta/recipes-kernel/linux-module/files/debian/rules.tmpl
> +++ b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl
> @@ -45,11 +45,14 @@ KERNEL_DEP := $(shell dpkg-query -W -f
> '$${Depends}' ${KERNEL_HEADERS_PKG} | sed
>  KDIR := $(shell dpkg -L $(KERNEL_DEP) | grep
> "/lib/modules/.*/build")
>  endif
>  
> +KCFLAGS := "-fdebug-prefix-map=$(PWD)=."
> +KAFLAGS := "-fdebug-prefix-map=$(PWD)=."
> +
>  override_dh_auto_clean:
>         $(MAKE) -C $(KDIR) M=$(PWD) clean
>  
>  override_dh_auto_build:
> -       $(MAKE) -C $(KDIR) M=$(PWD) $(PARALLEL_MAKE) modules
> +       $(MAKE) -C $(KDIR) M=$(PWD) $(PARALLEL_MAKE)
> KCFLAGS="$(KCFLAGS)" KAFLAGS="$(KAFLAGS)" modules
>  ifneq ($(filter pkg.sign,$(DEB_BUILD_PROFILES)),)
>         find . -name "*.ko" -print -exec $(KDIR)/scripts/sign-file
> ${SIGNATURE_HASHFN} ${SIGNATURE_KEYFILE} ${SIGNATURE_CERTFILE} {} \;
>  endif

Patch

diff --git a/meta/recipes-kernel/linux-module/files/debian/rules.tmpl b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl
index 7d950e38..20d5f670 100755
--- a/meta/recipes-kernel/linux-module/files/debian/rules.tmpl
+++ b/meta/recipes-kernel/linux-module/files/debian/rules.tmpl
@@ -45,11 +45,14 @@  KERNEL_DEP := $(shell dpkg-query -W -f '$${Depends}' ${KERNEL_HEADERS_PKG} | sed
 KDIR := $(shell dpkg -L $(KERNEL_DEP) | grep "/lib/modules/.*/build")
 endif
 
+KCFLAGS := "-fdebug-prefix-map=$(PWD)=."
+KAFLAGS := "-fdebug-prefix-map=$(PWD)=."
+
 override_dh_auto_clean:
 	$(MAKE) -C $(KDIR) M=$(PWD) clean
 
 override_dh_auto_build:
-	$(MAKE) -C $(KDIR) M=$(PWD) $(PARALLEL_MAKE) modules
+	$(MAKE) -C $(KDIR) M=$(PWD) $(PARALLEL_MAKE) KCFLAGS="$(KCFLAGS)" KAFLAGS="$(KAFLAGS)" modules
 ifneq ($(filter pkg.sign,$(DEB_BUILD_PROFILES)),)
 	find . -name "*.ko" -print -exec $(KDIR)/scripts/sign-file ${SIGNATURE_HASHFN} ${SIGNATURE_KEYFILE} ${SIGNATURE_CERTFILE} {} \;
 endif