summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2023-02-28 21:30:05 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-03-01 21:29:31 +0000
commit43a4d45f5145a5b174f5bfa5f2eb9988559d785f (patch)
tree7a2842911a1aeda2bdeb0f1b1121a07a561c2ac5
parent6a025980f450004821e8b5a9e78dc20d8d8dd970 (diff)
downloadpoky-43a4d45f5145a5b174f5bfa5f2eb9988559d785f.tar.gz
kernel: Add kernel specific OBJDUMP
This helps in switching toolchains cleanly for kernel build between gcc and clang Currently, some kernels allow building with clang but not all the distro might use clang as default system compiler but kernel may demand gcc which is provided via KERNEL_* variables, however kernel does use OBJCOPY at places during build and it maybe set to use llvm objcopy when using clang. That should be a deliberate setting when clang is used for kernel as well, otherwise it should use binutils provided objcopy (From OE-Core rev: 17b409f2fd97894e0943d13c2cb0d52abde647e3) Signed-off-by: Khem Raj <raj.khem@gmail.com> Cc: Bruce Ashfield <bruce.ashfield@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes-recipe/kernel-arch.bbclass3
-rw-r--r--meta/classes-recipe/kernel-devicetree.bbclass2
-rw-r--r--meta/classes-recipe/kernel-uboot.bbclass2
-rw-r--r--meta/classes-recipe/kernel-yocto.bbclass4
-rw-r--r--meta/classes-recipe/kernel.bbclass2
-rw-r--r--meta/classes-recipe/module.bbclass5
-rw-r--r--meta/recipes-kernel/make-mod-scripts/make-mod-scripts_1.0.bb3
-rw-r--r--meta/recipes-kernel/systemtap/systemtap-uprobes_git.bb4
8 files changed, 16 insertions, 9 deletions
diff --git a/meta/classes-recipe/kernel-arch.bbclass b/meta/classes-recipe/kernel-arch.bbclass
index 777f900241..5877048916 100644
--- a/meta/classes-recipe/kernel-arch.bbclass
+++ b/meta/classes-recipe/kernel-arch.bbclass
@@ -68,9 +68,12 @@ TARGET_LD_KERNEL_ARCH ?= ""
68HOST_LD_KERNEL_ARCH ?= "${TARGET_LD_KERNEL_ARCH}" 68HOST_LD_KERNEL_ARCH ?= "${TARGET_LD_KERNEL_ARCH}"
69TARGET_AR_KERNEL_ARCH ?= "" 69TARGET_AR_KERNEL_ARCH ?= ""
70HOST_AR_KERNEL_ARCH ?= "${TARGET_AR_KERNEL_ARCH}" 70HOST_AR_KERNEL_ARCH ?= "${TARGET_AR_KERNEL_ARCH}"
71TARGET_OBJCOPY_KERNEL_ARCH ?= ""
72HOST_OBJCOPY_KERNEL_ARCH ?= "${TARGET_OBJCOPY_KERNEL_ARCH}"
71 73
72KERNEL_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}" 74KERNEL_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}"
73KERNEL_LD = "${CCACHE}${HOST_PREFIX}ld.bfd ${HOST_LD_KERNEL_ARCH}" 75KERNEL_LD = "${CCACHE}${HOST_PREFIX}ld.bfd ${HOST_LD_KERNEL_ARCH}"
74KERNEL_AR = "${CCACHE}${HOST_PREFIX}ar ${HOST_AR_KERNEL_ARCH}" 76KERNEL_AR = "${CCACHE}${HOST_PREFIX}ar ${HOST_AR_KERNEL_ARCH}"
77KERNEL_OBJCOPY = "${CCACHE}${HOST_PREFIX}objcopy ${HOST_OBJCOPY_KERNEL_ARCH}"
75TOOLCHAIN ?= "gcc" 78TOOLCHAIN ?= "gcc"
76 79
diff --git a/meta/classes-recipe/kernel-devicetree.bbclass b/meta/classes-recipe/kernel-devicetree.bbclass
index b2117de805..4d0ecb1032 100644
--- a/meta/classes-recipe/kernel-devicetree.bbclass
+++ b/meta/classes-recipe/kernel-devicetree.bbclass
@@ -68,7 +68,7 @@ do_compile:append() {
68 68
69 for dtbf in ${KERNEL_DEVICETREE}; do 69 for dtbf in ${KERNEL_DEVICETREE}; do
70 dtb=`normalize_dtb "$dtbf"` 70 dtb=`normalize_dtb "$dtbf"`
71 oe_runmake $dtb CC="${KERNEL_CC} $cc_extra " LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} 71 oe_runmake $dtb CC="${KERNEL_CC} $cc_extra " LD="${KERNEL_LD}" OBJCOPY="${KERNEL_OBJCOPY}" ${KERNEL_EXTRA_ARGS}
72 done 72 done
73} 73}
74 74
diff --git a/meta/classes-recipe/kernel-uboot.bbclass b/meta/classes-recipe/kernel-uboot.bbclass
index 4aab02671e..30a85ccc28 100644
--- a/meta/classes-recipe/kernel-uboot.bbclass
+++ b/meta/classes-recipe/kernel-uboot.bbclass
@@ -34,7 +34,7 @@ uboot_prep_kimage() {
34 linux_comp="${FIT_KERNEL_COMP_ALG}" 34 linux_comp="${FIT_KERNEL_COMP_ALG}"
35 fi 35 fi
36 36
37 [ -n "${vmlinux_path}" ] && ${OBJCOPY} -O binary -R .note -R .comment -S "${vmlinux_path}" linux.bin 37 [ -n "${vmlinux_path}" ] && ${KERNEL_OBJCOPY} -O binary -R .note -R .comment -S "${vmlinux_path}" linux.bin
38 38
39 if [ "${linux_comp}" != "none" ] ; then 39 if [ "${linux_comp}" != "none" ] ; then
40 if [ "${linux_comp}" = "gzip" ] ; then 40 if [ "${linux_comp}" = "gzip" ] ; then
diff --git a/meta/classes-recipe/kernel-yocto.bbclass b/meta/classes-recipe/kernel-yocto.bbclass
index 7de99cff56..108b7e6752 100644
--- a/meta/classes-recipe/kernel-yocto.bbclass
+++ b/meta/classes-recipe/kernel-yocto.bbclass
@@ -455,7 +455,7 @@ do_kernel_configme() {
455 bbfatal_log "Could not find configuration queue (${meta_dir}/config.queue)" 455 bbfatal_log "Could not find configuration queue (${meta_dir}/config.queue)"
456 fi 456 fi
457 457
458 CFLAGS="${CFLAGS} ${TOOLCHAIN_OPTIONS}" HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}" CC="${KERNEL_CC}" LD="${KERNEL_LD}" ARCH=${ARCH} merge_config.sh -O ${B} ${config_flags} ${configs} > ${meta_dir}/cfg/merge_config_build.log 2>&1 458 CFLAGS="${CFLAGS} ${TOOLCHAIN_OPTIONS}" HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}" CC="${KERNEL_CC}" LD="${KERNEL_LD}" OBJCOPY="${KERNEL_OBJCOPY}" ARCH=${ARCH} merge_config.sh -O ${B} ${config_flags} ${configs} > ${meta_dir}/cfg/merge_config_build.log 2>&1
459 if [ $? -ne 0 -o ! -f ${B}/.config ]; then 459 if [ $? -ne 0 -o ! -f ${B}/.config ]; then
460 bberror "Could not generate a .config for ${KMACHINE}-${LINUX_KERNEL_TYPE}" 460 bberror "Could not generate a .config for ${KMACHINE}-${LINUX_KERNEL_TYPE}"
461 if [ ${KCONF_AUDIT_LEVEL} -gt 1 ]; then 461 if [ ${KCONF_AUDIT_LEVEL} -gt 1 ]; then
@@ -489,6 +489,7 @@ python do_config_analysis() {
489 env['PATH'] = "%s:%s%s" % (d.getVar('PATH'), s, "/scripts/util/") 489 env['PATH'] = "%s:%s%s" % (d.getVar('PATH'), s, "/scripts/util/")
490 env['LD'] = d.getVar('KERNEL_LD') 490 env['LD'] = d.getVar('KERNEL_LD')
491 env['CC'] = d.getVar('KERNEL_CC') 491 env['CC'] = d.getVar('KERNEL_CC')
492 env['OBJCOPY'] = d.getVar('KERNEL_OBJCOPY')
492 env['ARCH'] = d.getVar('ARCH') 493 env['ARCH'] = d.getVar('ARCH')
493 env['srctree'] = s 494 env['srctree'] = s
494 495
@@ -550,6 +551,7 @@ python do_kernel_configcheck() {
550 env['PATH'] = "%s:%s%s" % (d.getVar('PATH'), s, "/scripts/util/") 551 env['PATH'] = "%s:%s%s" % (d.getVar('PATH'), s, "/scripts/util/")
551 env['LD'] = d.getVar('KERNEL_LD') 552 env['LD'] = d.getVar('KERNEL_LD')
552 env['CC'] = d.getVar('KERNEL_CC') 553 env['CC'] = d.getVar('KERNEL_CC')
554 env['OBJCOPY'] = d.getVar('KERNEL_OBJCOPY')
553 env['ARCH'] = d.getVar('ARCH') 555 env['ARCH'] = d.getVar('ARCH')
554 env['srctree'] = s 556 env['srctree'] = s
555 557
diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass
index 4fbe84c4e4..3f9c6c00e6 100644
--- a/meta/classes-recipe/kernel.bbclass
+++ b/meta/classes-recipe/kernel.bbclass
@@ -234,7 +234,7 @@ UBOOT_LOADADDRESS ?= "${UBOOT_ENTRYPOINT}"
234# Some Linux kernel configurations need additional parameters on the command line 234# Some Linux kernel configurations need additional parameters on the command line
235KERNEL_EXTRA_ARGS ?= "" 235KERNEL_EXTRA_ARGS ?= ""
236 236
237EXTRA_OEMAKE += ' CC="${KERNEL_CC}" LD="${KERNEL_LD}"' 237EXTRA_OEMAKE += ' CC="${KERNEL_CC}" LD="${KERNEL_LD}" OBJCOPY="${KERNEL_OBJCOPY}"'
238EXTRA_OEMAKE += ' HOSTCC="${BUILD_CC}" HOSTCFLAGS="${BUILD_CFLAGS}" HOSTLDFLAGS="${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}"' 238EXTRA_OEMAKE += ' HOSTCC="${BUILD_CC}" HOSTCFLAGS="${BUILD_CFLAGS}" HOSTLDFLAGS="${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}"'
239EXTRA_OEMAKE += ' HOSTCXX="${BUILD_CXX}" HOSTCXXFLAGS="${BUILD_CXXFLAGS}" PAHOLE=false' 239EXTRA_OEMAKE += ' HOSTCXX="${BUILD_CXX}" HOSTCXXFLAGS="${BUILD_CXXFLAGS}" PAHOLE=false'
240 240
diff --git a/meta/classes-recipe/module.bbclass b/meta/classes-recipe/module.bbclass
index d52d5e3098..b3b852be5f 100644
--- a/meta/classes-recipe/module.bbclass
+++ b/meta/classes-recipe/module.bbclass
@@ -32,6 +32,7 @@ python do_devshell:prepend () {
32 os.environ['CC'] = d.getVar('KERNEL_CC') 32 os.environ['CC'] = d.getVar('KERNEL_CC')
33 os.environ['LD'] = d.getVar('KERNEL_LD') 33 os.environ['LD'] = d.getVar('KERNEL_LD')
34 os.environ['AR'] = d.getVar('KERNEL_AR') 34 os.environ['AR'] = d.getVar('KERNEL_AR')
35 os.environ['OBJCOPY'] = d.getVar('KERNEL_OBJCOPY')
35 os.environ['O'] = d.getVar('STAGING_KERNEL_BUILDDIR') 36 os.environ['O'] = d.getVar('STAGING_KERNEL_BUILDDIR')
36 kbuild_extra_symbols = d.getVar('KBUILD_EXTRA_SYMBOLS') 37 kbuild_extra_symbols = d.getVar('KBUILD_EXTRA_SYMBOLS')
37 if kbuild_extra_symbols: 38 if kbuild_extra_symbols:
@@ -45,7 +46,7 @@ module_do_compile() {
45 oe_runmake KERNEL_PATH=${STAGING_KERNEL_DIR} \ 46 oe_runmake KERNEL_PATH=${STAGING_KERNEL_DIR} \
46 KERNEL_VERSION=${KERNEL_VERSION} \ 47 KERNEL_VERSION=${KERNEL_VERSION} \
47 CC="${KERNEL_CC}" LD="${KERNEL_LD}" \ 48 CC="${KERNEL_CC}" LD="${KERNEL_LD}" \
48 AR="${KERNEL_AR}" \ 49 AR="${KERNEL_AR}" OBJCOPY="${KERNEL_OBJCOPY}" \
49 O=${STAGING_KERNEL_BUILDDIR} \ 50 O=${STAGING_KERNEL_BUILDDIR} \
50 KBUILD_EXTRA_SYMBOLS="${KBUILD_EXTRA_SYMBOLS}" \ 51 KBUILD_EXTRA_SYMBOLS="${KBUILD_EXTRA_SYMBOLS}" \
51 ${MAKE_TARGETS} 52 ${MAKE_TARGETS}
@@ -55,7 +56,7 @@ module_do_install() {
55 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS 56 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
56 oe_runmake DEPMOD=echo MODLIB="${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}" \ 57 oe_runmake DEPMOD=echo MODLIB="${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}" \
57 INSTALL_FW_PATH="${D}${nonarch_base_libdir}/firmware" \ 58 INSTALL_FW_PATH="${D}${nonarch_base_libdir}/firmware" \
58 CC="${KERNEL_CC}" LD="${KERNEL_LD}" \ 59 CC="${KERNEL_CC}" LD="${KERNEL_LD}" OBJCOPY="${KERNEL_OBJCOPY}" \
59 O=${STAGING_KERNEL_BUILDDIR} \ 60 O=${STAGING_KERNEL_BUILDDIR} \
60 ${MODULES_INSTALL_TARGET} 61 ${MODULES_INSTALL_TARGET}
61 62
diff --git a/meta/recipes-kernel/make-mod-scripts/make-mod-scripts_1.0.bb b/meta/recipes-kernel/make-mod-scripts/make-mod-scripts_1.0.bb
index 38282e58f1..28e0807d1d 100644
--- a/meta/recipes-kernel/make-mod-scripts/make-mod-scripts_1.0.bb
+++ b/meta/recipes-kernel/make-mod-scripts/make-mod-scripts_1.0.bb
@@ -27,7 +27,8 @@ EXTRA_OEMAKE += " HOSTCXX="${BUILD_CXX} ${BUILD_CXXFLAGS} ${BUILD_LDFLAGS}" CROS
27do_configure() { 27do_configure() {
28 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS 28 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
29 for t in prepare scripts_basic scripts; do 29 for t in prepare scripts_basic scripts; do
30 oe_runmake CC="${KERNEL_CC}" LD="${KERNEL_LD}" AR="${KERNEL_AR}" \ 30 oe_runmake CC="${KERNEL_CC}" LD="${KERNEL_LD}" \
31 AR="${KERNEL_AR}" OBJCOPY="${KERNEL_OBJCOPY}" \
31 -C ${STAGING_KERNEL_DIR} O=${STAGING_KERNEL_BUILDDIR} $t 32 -C ${STAGING_KERNEL_DIR} O=${STAGING_KERNEL_BUILDDIR} $t
32 done 33 done
33} 34}
diff --git a/meta/recipes-kernel/systemtap/systemtap-uprobes_git.bb b/meta/recipes-kernel/systemtap/systemtap-uprobes_git.bb
index 2181e45a8d..efe359ec32 100644
--- a/meta/recipes-kernel/systemtap/systemtap-uprobes_git.bb
+++ b/meta/recipes-kernel/systemtap/systemtap-uprobes_git.bb
@@ -21,12 +21,12 @@ do_compile() {
21 then 21 then
22 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS CC LD CPP 22 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS CC LD CPP
23 oe_runmake CC="${KERNEL_CC}" LD="${KERNEL_LD}" \ 23 oe_runmake CC="${KERNEL_CC}" LD="${KERNEL_LD}" \
24 AR="${KERNEL_AR}" \ 24 AR="${KERNEL_AR}" OBJCOPY="${KERNEL_OBJCOPY}" \
25 -C ${STAGING_KERNEL_DIR} scripts 25 -C ${STAGING_KERNEL_DIR} scripts
26 oe_runmake KDIR=${STAGING_KERNEL_DIR} \ 26 oe_runmake KDIR=${STAGING_KERNEL_DIR} \
27 M="${S}/runtime/uprobes/" \ 27 M="${S}/runtime/uprobes/" \
28 CC="${KERNEL_CC}" LD="${KERNEL_LD}" \ 28 CC="${KERNEL_CC}" LD="${KERNEL_LD}" \
29 AR="${KERNEL_AR}" \ 29 AR="${KERNEL_AR}" OBJCOPY="${KERNEL_OBJCOPY}" \
30 -C "${S}/runtime/uprobes/" 30 -C "${S}/runtime/uprobes/"
31 fi 31 fi
32} 32}