Re: [PATCH kvmtool 0/1] Don't empty CFLAGS in Makefile for static building

Yao Yuan <[email protected]>
Newsgroups org.kernel.vger.kvm
Message-ID <l3jrmqj2jtkgygxrxhh4jolti4pggr7wwbvmdv775ibnbv3hpz@zcvq5pkphpni>
On Mon, Aug 17, 2026 at 10:43:37AM +0800, Alexandru Elisei wrote:
> Hi,
>
> On Mon, Aug 17, 2026 at 04:45:33PM +0800, Yao Yuan wrote:
> > Don't set the CFLAGS to empty in Makefile for passing more
> > CFLAGS options from environment variable, e.g -static for
> > native static building.
>
> I think the lkvm-static makefile target might be your friend in this case :)
>
> $ make -j$(getconf _NPROCESSORS_ONLN) ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- lkvm-static
>
> (have a look at the $(PROGRAM)-static target if you want to double check that it
> fits your needs)

Hi Alex,

Thanks for such nice suggestion!

Yes, it fits my requirement and it works in native building yet.

So I think this can be dropped unless it helps in other purposes.

>
> Thanks,
> Alex
>
> >
> > One use case of static buidling is using kvmtool for
> > pre-silicon validation on emulation system, such system has
> > limited or even no IO part and run w/ small solo ramdisk as
> > linux userspace instead of full Linux distribution, and run
> > in slow speed. Thus the self-contained kvmtool static
> > building is good choice in performance and size for testing
> > on such system.
> >
> > The static building is verified on arm64 host:
> >
> > CFLAGS=-static make -j32
> > ...
> > LINK     lkvm
> > LN       vm
> >
> > $ldd ./lkvm
> >         not a dynamic executable
> >
> > The funciton is verified w/ below command, boot arm64 guest
> > to serial successfully:
> >
> > cmdline=(
> > 	ignore_loglevel
> > 	earlycon=uart8250,mmio,0x1000000,115200n8
> > 	console=uart8250,mmio,0x1000000,115200n8
> > 	nokaslr
> > 	selinux=0
> > 	audit=0
> > 	root=/dev/vda3
> > )
> >
> > ./lkvm run \
> > 	   --name test_kvmtool \
> > 	   -c 4 -m 1G \
> > 	   --nodefaults \
> > 	   --irqchip gicv3-its \
> > 	   --console serial \
> > 	   --virtio-transport pci \
> > 	   --disk /path/to/the/disk/image
> > 	   --kernel /path/to/the/arm64/boot/image
> > 	   --param "${cmdline[*]}"
> >
> >
> > Yao Yuan (1):
> >   Makefile: Don't set -CFLAGS := in Makefile
> >
> >  Makefile | 1 -
> >  1 file changed, 1 deletion(-)
> >
> > --
> > 2.43.5
> >
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.