ld.lld: error: .tmp_vmlinux1.btf.o is incompatible with elf32lriscv
kernel test robot
build bottree: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master head: f14cdb1367b947d373215e36cfe9c69768dbafc9 commit: 522397d05e7d4a7c30b91841492360336b24f833 [8/9] resolve_btfids: Change in-place update with raw binary output config: riscv-randconfig-002-20251224 (https://download.01.org/0day-ci/archive/20251224/[email protected]/config) compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 4ef602d446057dabf5f61fb221669ecbeda49279) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251224/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> ld.lld: error: .tmp_vmlinux1.btf.o is incompatible with elf32lriscv
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Quoted 7 lines · kernel test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master head: f14cdb1367b947d373215e36cfe9c69768dbafc9 commit: 522397d05e7d4a7c30b91841492360336b24f833 [8/9] resolve_btfids: Change in-place update with raw binary output config: riscv-randconfig-002-20251224 (https://download.01.org/0day-ci/archive/20251224/[email protected]/config) compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 4ef602d446057dabf5f61fb221669ecbeda49279) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251224/[email protected]/reproduce)
Quoted 8 lines
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/All errors (new ones prefixed by >>):
Quoted 1 line
Quoted 1 line
ld.lld: error: .tmp_vmlinux1.btf.o is incompatible with elf32lriscv
While I have not verified this, I suspect this error occurs because the ${CC} command in gen_btf_o() in scripts/gen-btf.sh only includes CLANG_FLAGS for the target selection but not '-m32' or '-m64' from KBUILD_CFLAGS to control the word size (as documented in scripts/Makefile.clang).
Cheers,
Nathan
Ihor Solodrai
reviewerQuoted 15 lines · Nathan Chancellor
Quoted 14 lines · kernel test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master head: f14cdb1367b947d373215e36cfe9c69768dbafc9 commit: 522397d05e7d4a7c30b91841492360336b24f833 [8/9] resolve_btfids: Change in-place update with raw binary output config: riscv-randconfig-002-20251224 (https://download.01.org/0day-ci/archive/20251224/[email protected]/config) compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 4ef602d446057dabf5f61fb221669ecbeda49279) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251224/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/All errors (new ones prefixed by >>):
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
ld.lld: error: .tmp_vmlinux1.btf.o is incompatible with elf32lriscv
While I have not verified this, I suspect this error occurs because the ${CC} command in
gen_btf_o()inscripts/gen-btf.shonly includesCLANG_FLAGSfor the target selection but not '-m32' or '-m64' fromKBUILD_CFLAGSto control the word size (as documented inscripts/Makefile.clang).
Hi Nathan, thanks for the pointer.
I was able to reproduce this. Your suspicion is correct.
The .o file generated by:
echo "" | ${CC} ${CLANG_FLAGS} -c -x c -o ${btf_data} -when cross-compiling to riscv is 64-bit, while vmlinux.o is 32-bit, hence the error.
This helps:
scripts/gen-btf.sh +1 -1
@@ -96,7 +96,7 @@ gen_btf_o() # deletes all symbols including __start_BTF and __stop_BTF, which will # be redefined in the linker script. info OBJCOPY "${btf_data}" - echo "" | ${CC} ${CLANG_FLAGS} -c -x c -o ${btf_data} - + echo "" | ${CC} ${CLANG_FLAGS} ${KBUILD_CFLAGS} -c -x c -o ${btf_data} - ${OBJCOPY} --add-section .BTF=${ELF_FILE}.BTF \ --set-section-flags .BTF=alloc,readonly ${btf_data} ${OBJCOPY} --only-section=.BTF --strip-all ${btf_data}
I'll send a proper patch later today. Have another bug report to check.
Quoted 3 lines
Cheers,
Nathan