* [PATCH kvmtool 0/1] Don't empty CFLAGS in Makefile for static building
@ 2026-08-17 8:45 Yao Yuan
2026-08-17 8:45 ` [PATCH kvmtool 1/1] Makefile: Don't set -CFLAGS := in Makefile Yao Yuan
2026-08-17 9:43 ` [PATCH kvmtool 0/1] Don't empty CFLAGS in Makefile for static building Alexandru Elisei
0 siblings, 2 replies; 4+ messages in thread
From: Yao Yuan @ 2026-08-17 8:45 UTC (permalink / raw)
To: kvm, julien.thierry.kdev, will; +Cc: yaoyuan0329os, yaoyuan
Don't set the CFLAGS to empty in Makefile for passing more
CFLAGS options from environment variable, e.g -static for
native static building.
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
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH kvmtool 1/1] Makefile: Don't set -CFLAGS := in Makefile
2026-08-17 8:45 [PATCH kvmtool 0/1] Don't empty CFLAGS in Makefile for static building Yao Yuan
@ 2026-08-17 8:45 ` Yao Yuan
2026-08-17 9:43 ` [PATCH kvmtool 0/1] Don't empty CFLAGS in Makefile for static building Alexandru Elisei
1 sibling, 0 replies; 4+ messages in thread
From: Yao Yuan @ 2026-08-17 8:45 UTC (permalink / raw)
To: kvm, julien.thierry.kdev, will; +Cc: yaoyuan0329os, yaoyuan
Don't set CFLAGS to empty in the Makefile to allow
set the addtional CFLAGS option from environment,
support e.g native static compiling.
Signed-off-by: Yao Yuan <yaoyuan@linux.alibaba.com>
---
Makefile | 1 -
1 file changed, 1 deletion(-)
diff --git a/Makefile b/Makefile
index 60e551f..6755910 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,6 @@ include config/feature-tests.mak
-include $(OUTPUT)KVMTOOLS-VERSION-FILE
CC := $(CROSS_COMPILE)gcc
-CFLAGS :=
LD := $(CROSS_COMPILE)ld
LDFLAGS :=
OBJCOPY := $(CROSS_COMPILE)objcopy
--
2.43.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH kvmtool 0/1] Don't empty CFLAGS in Makefile for static building
2026-08-17 8:45 [PATCH kvmtool 0/1] Don't empty CFLAGS in Makefile for static building Yao Yuan
2026-08-17 8:45 ` [PATCH kvmtool 1/1] Makefile: Don't set -CFLAGS := in Makefile Yao Yuan
@ 2026-08-17 9:43 ` Alexandru Elisei
2026-08-18 0:35 ` Yao Yuan
1 sibling, 1 reply; 4+ messages in thread
From: Alexandru Elisei @ 2026-08-17 9:43 UTC (permalink / raw)
To: Yao Yuan; +Cc: kvm, julien.thierry.kdev, will, yaoyuan0329os
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)
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
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH kvmtool 0/1] Don't empty CFLAGS in Makefile for static building
2026-08-17 9:43 ` [PATCH kvmtool 0/1] Don't empty CFLAGS in Makefile for static building Alexandru Elisei
@ 2026-08-18 0:35 ` Yao Yuan
0 siblings, 0 replies; 4+ messages in thread
From: Yao Yuan @ 2026-08-18 0:35 UTC (permalink / raw)
To: Alexandru Elisei; +Cc: kvm, julien.thierry.kdev, will, yaoyuan0329os
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
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-18 0:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-17 8:45 [PATCH kvmtool 0/1] Don't empty CFLAGS in Makefile for static building Yao Yuan
2026-08-17 8:45 ` [PATCH kvmtool 1/1] Makefile: Don't set -CFLAGS := in Makefile Yao Yuan
2026-08-17 9:43 ` [PATCH kvmtool 0/1] Don't empty CFLAGS in Makefile for static building Alexandru Elisei
2026-08-18 0:35 ` Yao Yuan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox