All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ihor Solodrai <ihor.solodrai@linux.dev>
To: Nathan Chancellor <nathan@kernel.org>, kernel test robot <lkp@intel.com>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
	Andrii Nakryiko <andrii@kernel.org>, bpf <bpf@vger.kernel.org>
Subject: Re: [bpf-next:master 8/9] ld.lld: error: .tmp_vmlinux1.btf.o is incompatible with elf32lriscv
Date: Mon, 29 Dec 2025 09:56:22 -0800	[thread overview]
Message-ID: <72b12d0b-a513-41a6-91ac-076404a25713@linux.dev> (raw)
In-Reply-To: <20251228215613.GA2167770@ax162>

On 12/28/25 1:56 PM, Nathan Chancellor wrote:
> On Wed, Dec 24, 2025 at 06:02:31AM +0800, kernel test robot wrote:
>> 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/202512240559.2M06DSX7-lkp@intel.com/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/202512240559.2M06DSX7-lkp@intel.com/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 <lkp@intel.com>
>> | Closes: https://lore.kernel.org/oe-kbuild-all/202512240559.2M06DSX7-lkp@intel.com/
>>
>> All errors (new ones prefixed by >>):
>>
>>>> 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).

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:

diff --git a/scripts/gen-btf.sh b/scripts/gen-btf.sh
index 06c6d8becaa2..12244dbe097c 100755
--- a/scripts/gen-btf.sh
+++ b/scripts/gen-btf.sh
@@ -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.

> 
> Cheers,
> Nathan


      reply	other threads:[~2025-12-29 17:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-23 22:02 [bpf-next:master 8/9] ld.lld: error: .tmp_vmlinux1.btf.o is incompatible with elf32lriscv kernel test robot
2025-12-28 21:56 ` Nathan Chancellor
2025-12-29 17:56   ` Ihor Solodrai [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=72b12d0b-a513-41a6-91ac-076404a25713@linux.dev \
    --to=ihor.solodrai@linux.dev \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=oe-kbuild-all@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.