]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
scripts/gen-btf.sh: Fix .btf.o generation when compiling for RISCV
authorIhor Solodrai <ihor.solodrai@linux.dev>
Mon, 29 Dec 2025 20:28:23 +0000 (12:28 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 30 Dec 2025 18:35:16 +0000 (10:35 -0800)
gen-btf.sh emits a .btf.o file with BTF sections to be linked into
vmlinux in link-vmlinux.sh

This .btf.o file is created by compiling an emptystring with ${CC},
and then adding BTF sections into it with ${OBJCOPY}.

To ensure the .btf.o is linkable when cross-compiling with LLVM, we
have to also pass ${KBUILD_FLAGS}, which in particular control the
target word size.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202512240559.2M06DSX7-lkp@intel.com/
Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
Link: https://lore.kernel.org/r/20251229202823.569619-1-ihor.solodrai@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
scripts/gen-btf.sh

index 06c6d8becaa264e70bc433526fba8eb8927932c4..12244dbe097c02643212927b60f65eedd2b0d099 100755 (executable)
@@ -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}