Re: [PATCH v11 3/3] kbuild: distributed build support for Clang ThinLTO
From: Rong Xu
Date: Thu May 28 2026 - 19:11:54 EST
On Thu, May 28, 2026 at 3:07 PM Nathan Chancellor <nathan@xxxxxxxxxx> wrote:
>
> On Thu, 28 May 2026 13:39:05 -0700, xur@xxxxxxxxxx <xur@xxxxxxxxxx> wrote:
> > diff --git a/scripts/Makefile.thinlto b/scripts/Makefile.thinlto
> > new file mode 100644
> > index 000000000000..408b63786a08
> > --- /dev/null
> > +++ b/scripts/Makefile.thinlto
> > @@ -0,0 +1,41 @@
> > +PHONY := __default
> > +__default:
> > +
> > +include include/config/auto.conf
> > +include $(srctree)/scripts/Kbuild.include
> > +include $(srctree)/scripts/Makefile.lib
> > +
> > +native-objs := $(patsubst %.o,%.thinlto-native.o,$(call read-file, vmlinux.thinlto-index))
> > +
> > +__default: $(native-objs)
> > +
> > +# Generate .thinlto-native.o (obj) from .o (bitcode) and .thinlto.bc (summary) files
> > +# ---------------------------------------------------------------------------
> > +quiet_cmd_cc_o_bc = CC $(quiet_modtag) $@
> > + be_flags = $(saved_c_flags_$(<))
>
> This change...
>
> > [ ... skip 20 lines ... ]
> > +prereq-ir-objs := $(targets:%.thinlto-native.o=%.o)
> > +existing-ir-objs := $(wildcard $(sort $(prereq-ir-objs)))
> > +
> > +-include $(foreach f, $(existing-targets) $(existing-ir-objs), $(dir $(f)).$(notdir $(f)).cmd)
> > +
> > +.PHONY: $(PHONY)
>
> ... and this change appear to break the build in certain circumstances.
>
> | $ printf 'CONFIG_%s\n' LTO_NONE=n LTO_CLANG_THIN_DIST=y >kernel/configs/repro.config
> |
> | $ make -skj"$(nproc)" ARCH=arm64 LLVM=1 mrproper defconfig repro.config vmlinux
> | ...
> | warning: linking module 'virt/kvm/coalesced_mmio.o': Linking two modules of different target triples: 'mm/slab_common.o' is 'aarch64-unknown-linux-gnu' whereas 'virt/kvm/coalesced_mmio.o' is 'x86_64-unknown-linux-gnu' [-Wlinker-warnings]
> | '+v8a' is not a recognized feature for this target (ignoring feature)
> | '-fmv' is not a recognized feature for this target (ignoring feature)
> | '-fp-armv8' is not a recognized feature for this target (ignoring feature)
> | '-neon' is not a recognized feature for this target (ignoring feature)
> | '+v8a' is not a recognized feature for this target (ignoring feature)
> | '-fmv' is not a recognized feature for this target (ignoring feature)
> | '-fp-armv8' is not a recognized feature for this target (ignoring feature)
> | '-neon' is not a recognized feature for this target (ignoring feature)
> | <inline asm>:1:2: error: invalid instruction mnemonic 'dmb'
> | dmb ishst
> | ^~~
> | 2 warnings and 3 errors generated.
> | make[5]: *** [scripts/Makefile.thinlto:22: virt/kvm/dirty_ring.thinlto-native.o] Error 1
> | ...
>
> Looking at V=1 output, the backend flags are missing from this object
> and the other ones that errored. If I revert back to how you had it in
> v10, the build is successful and the flags appear to be included
> properly.
I think this error from the relative path issue: I have the _c_flags as:
"saved_c_flags_arch/arm64/kvm/../../../virt/kvm/coalesced_mmio.o"
But in the backend compilation, I tried to load
"saved_c_flags_virt/kvm/coalesced_mmio.o".
I think I will revert to my v10 implementation here.
>
> Sashiko has another comment as well.
>
> https://sashiko.dev/#/patchset/26003?part=3
Are you referring to KBUILD_VMLINUX_OBJS and KBUILD_VMLINUX_LIBS part?
I'm not sure if that's true: in my build, KBUILD_VMLINUX_OBJS includes
lib/lib.a etc.
In line 1296 of Makefile:
KBUILD_VMLINUX_OBJS := built-in.a $(patsubst %/, %/lib.a, $(filter %/,
$(libs-y)))
We can see native objects in lib/*.
% find lib -name '*.thinlto-native.o' |wc
204 204 7104
>
> --
> Cheers,
> Nathan
>