kernel-arch: use file-prefix-map in KERNEL_CC
PATCH 1/1 kernel-arch: use file-prefix-map in KERNEL_CC
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]
---
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(-)
meta/classes-recipe/kernel-arch.bbclass +5 -1
@@ -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}"
---
base-commit: fec201518be3c35a9359ec8c37675a33e458b92d
change-id: 20250305-fix_tmpdir-501249b96b16
Best regards,
Signature · 1 line
Stefan Müller-Klieser <[email protected]>
Quoted 34 lines · Stefan Mueller-Klieser via lists.openembedded.org
When building external modules, macros can include absolute names of kernel headers. The macro-prefix-map for the
STAGING_KERNEL_DIRis 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-r0do_package_qa: QA Issue: File <..> cryptodev.ko <..> contains reference to TMPDIR [buildpaths]Signed-off-by Stefan Müller-Klieser <[email protected]>---
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 whereKERNEL_CCgets 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(-)meta/classes-recipe/kernel-arch.bbclass +0
-0@@ -71,7 +71,11 @@ HOST_AR_KERNEL_ARCH ?= "${TARGET_AR_KERNEL_ARCH}"TARGET_OBJCOPY_KERNEL_ARCH ?= ""
HOST_OBJCOPY_KERNEL_ARCH?= "${TARGET_OBJCOPY_KERNEL_ARCH}"meta/classes-recipe/kernel-arch.bbclass +5
-1-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} \ +"
Quoted 3 lines
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