Bug 15451

Summary: llvm: objcopy error when using llvm to build kernel
Product: [Build System, Metadata & Runtime] OE-Core Reporter: lxy204899
Component: kernelAssignee: Unassigned <unassigned>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: Medium CC: hemanth.250302, lxy204899, randy.macleod, steve, sundeep.kokkonda
Version: 4.0.20   
Target Milestone: 4.0.32   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)
Attachments:
Description Flags
enhance objcopy command call for kernel compilation with llvm none

Description lxy204899 2024-03-21 08:52:18 UTC
When using the llvm to compile kernel by meta-clang, the strip tool from gcc is used always. It is advisable to use ${HOST_PREFIX}llvm-objcopy instead of ${HOST_PREFIX}objcopy in kernel-module-split.bbclass if llvm condition.


```
### kernel-module-split.bbclass line 65
    cmd = "%sobjcopy -j .modinfo -O binary %s %s" % (d.getVar("HOST_PREFIX") or "", tmpkofile, tmpfile)
        else:
            cmd = "%sobjcopy -j .modinfo -O binary %s %s" % (d.getVar("HOST_PREFIX") or "", file, tmpfile)
        subprocess.check_call(cmd, shell=True)
```
Comment 1 Randy MacLeod 2024-03-21 14:51:34 UTC
Can you send a patch to change the recipe to use the OBJCOPY variable defined in bitbake.conf.
Comment 2 lxy204899 2024-03-22 02:31:20 UTC
Created attachment 5034 [details]
enhance objcopy command call for  kernel compilation with llvm
Comment 3 lxy204899 2024-03-22 02:33:01 UTC
Okay, it's a good idea. I have submitted a patch.
Comment 4 lxy204899 2024-03-29 07:03:26 UTC
Recently I discovered many similar issues without using the 'llvm' prefix. I would like to ask, how has the community's support for llvm been recently?
Comment 5 lxy204899 2024-03-29 07:08:37 UTC
When searching for `${HOST_PREFIX}` and `${HOST_PREFIX}`, you will find a lot of similar calls.
Comment 6 Randy MacLeod 2024-10-31 15:06:25 UTC
move to unassigned. feel free to take back if you have time.
Comment 7 Randy MacLeod 2025-11-04 19:58:39 UTC
Sundeep,

Can we have someone test this on master ONLY?
With the changes that happened in moving clang to oe-core, perhaps the problem has been fixed.

We (YP) have no plan to backport a fix for 4.0.xx since we don't really even now support building the kernel with clang IIRC.
Comment 8 Hemanth Kumar 2025-11-14 06:30:35 UTC
Hi Randy,

This issue is no longer seen in poky-master, as the patch/fix for kernel-module-split.bbclass is already present. The kernel build now correctly uses ${KERNEL_OBJCOPY} / ${OBJCOPY}, which resolve to llvm-objcopy when building with Clang, instead of the hard-coded objcopy.
Comment 9 Randy MacLeod 2025-11-14 14:22:52 UTC
Resolved as per Hemanth's explanation. Thanks everyone.
Comment 10 Randy MacLeod 2025-11-14 14:24:39 UTC
This was reported against 4.0 but 
I think a backport is out of scope since so much has changed with the merge of clang to oe-core. Sorry.