diff mbox series

kernel-arch: use file-prefix-map in KERNEL_CC

Message ID 20250306-fix_tmpdir-v1-1-3575a7ec43af@phytec.de
State New
Headers show
Series kernel-arch: use file-prefix-map in KERNEL_CC | expand

Commit Message

Stefan Müller-Klieser March 6, 2025, 4:46 p.m. UTC
When building external modules, macros can include absolute names of
kernel headers. The macro-prefix-map for the STAGING_KERNEL_DIR is
currently missing. Add it by switching to the file-prefix-map which
includes both.

This fixes reproducible builds and following build error:
ERROR: cryptodev-module-1.14-r0 do_package_qa: QA Issue: File <..>
cryptodev.ko <..> contains reference to TMPDIR [buildpaths]

Signed-off-by: Stefan Müller-Klieser <s.mueller-klieser@phytec.de>
---
I don't know if this is the preferred solution. The macro-prefix-map
could also go into the modules-base.bbclass. But then we have yet
another place where KERNEL_CC gets modified and ordering matters. With
this patch it is done similiarly to the default cc settings in
bitbake.conf except by switching to the file-prefix-map.
---
 meta/classes-recipe/kernel-arch.bbclass | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)


---
base-commit: fec201518be3c35a9359ec8c37675a33e458b92d
change-id: 20250305-fix_tmpdir-501249b96b16

Best regards,

Comments

Richard Purdie March 6, 2025, 10:02 p.m. UTC | #1
On Thu, 2025-03-06 at 17:46 +0100, Stefan Mueller-Klieser via lists.openembedded.org wrote:
> When building external modules, macros can include absolute names of
> kernel headers. The macro-prefix-map for the STAGING_KERNEL_DIR is
> currently missing. Add it by switching to the file-prefix-map which
> includes both.
> 
> This fixes reproducible builds and following build error:
> ERROR: cryptodev-module-1.14-r0 do_package_qa: QA Issue: File <..>
> cryptodev.ko <..> contains reference to TMPDIR [buildpaths]
> 
> Signed-off-by: Stefan Müller-Klieser <s.mueller-klieser@phytec.de>
> ---
> I don't know if this is the preferred solution. The macro-prefix-map
> could also go into the modules-base.bbclass. But then we have yet
> another place where KERNEL_CC gets modified and ordering matters. With
> this patch it is done similiarly to the default cc settings in
> bitbake.conf except by switching to the file-prefix-map.
> ---
>  meta/classes-recipe/kernel-arch.bbclass | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/classes-recipe/kernel-arch.bbclass b/meta/classes-recipe/kernel-arch.bbclass
> index b32f6137a2fe02f7a56a746cc3f4e76f1528e5a0..145ce24a48f52eb44be08c03f1110a228e899747 100644
> --- a/meta/classes-recipe/kernel-arch.bbclass
> +++ b/meta/classes-recipe/kernel-arch.bbclass
> @@ -71,7 +71,11 @@ HOST_AR_KERNEL_ARCH ?= "${TARGET_AR_KERNEL_ARCH}"
>  TARGET_OBJCOPY_KERNEL_ARCH ?= ""
>  HOST_OBJCOPY_KERNEL_ARCH ?= "${TARGET_OBJCOPY_KERNEL_ARCH}"
>  
> -KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_KERNEL_ARCH} -fuse-ld=bfd ${DEBUG_PREFIX_MAP} -fdebug-prefix-map=${STAGING_KERNEL_DIR}=${KERNEL_SRC_PATH} -fdebug-prefix-map=${STAGING_KERNEL_BUILDDIR}=${KERNEL_SRC_PATH}"
> +KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_KERNEL_ARCH} \
> + -fuse-ld=bfd ${DEBUG_PREFIX_MAP} \
> + -ffile-prefix-map=${STAGING_KERNEL_DIR}=${KERNEL_SRC_PATH} \
> + -fdebug-prefix-map=${STAGING_KERNEL_BUILDDIR}=${KERNEL_SRC_PATH} \
> +"
>  KERNEL_LD = "${HOST_PREFIX}ld.bfd ${HOST_LD_KERNEL_ARCH}"
>  KERNEL_AR = "${HOST_PREFIX}ar ${HOST_AR_KERNEL_ARCH}"
>  KERNEL_OBJCOPY = "${HOST_PREFIX}objcopy ${HOST_OBJCOPY_KERNEL_ARCH}"

At first glance, file-prefix-map sounds great. The challenge, at least
last time I checked, is that some tools don't process it and only
process macro-prefix-map (perhaps the C preprocessor?). This meant we
had build failures last time I tried to simply the entry in
bitbake.conf.

I'm ok with changing it in this file but we may want to copy what
bitbake.conf is doing and set both?

Cheers,

Richard
diff mbox series

Patch

diff --git a/meta/classes-recipe/kernel-arch.bbclass b/meta/classes-recipe/kernel-arch.bbclass
index b32f6137a2fe02f7a56a746cc3f4e76f1528e5a0..145ce24a48f52eb44be08c03f1110a228e899747 100644
--- a/meta/classes-recipe/kernel-arch.bbclass
+++ b/meta/classes-recipe/kernel-arch.bbclass
@@ -71,7 +71,11 @@  HOST_AR_KERNEL_ARCH ?= "${TARGET_AR_KERNEL_ARCH}"
 TARGET_OBJCOPY_KERNEL_ARCH ?= ""
 HOST_OBJCOPY_KERNEL_ARCH ?= "${TARGET_OBJCOPY_KERNEL_ARCH}"
 
-KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_KERNEL_ARCH} -fuse-ld=bfd ${DEBUG_PREFIX_MAP} -fdebug-prefix-map=${STAGING_KERNEL_DIR}=${KERNEL_SRC_PATH} -fdebug-prefix-map=${STAGING_KERNEL_BUILDDIR}=${KERNEL_SRC_PATH}"
+KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_KERNEL_ARCH} \
+ -fuse-ld=bfd ${DEBUG_PREFIX_MAP} \
+ -ffile-prefix-map=${STAGING_KERNEL_DIR}=${KERNEL_SRC_PATH} \
+ -fdebug-prefix-map=${STAGING_KERNEL_BUILDDIR}=${KERNEL_SRC_PATH} \
+"
 KERNEL_LD = "${HOST_PREFIX}ld.bfd ${HOST_LD_KERNEL_ARCH}"
 KERNEL_AR = "${HOST_PREFIX}ar ${HOST_AR_KERNEL_ARCH}"
 KERNEL_OBJCOPY = "${HOST_PREFIX}objcopy ${HOST_OBJCOPY_KERNEL_ARCH}"