Skip to contentSkip to conversation

Don't empty CFLAGS in Makefile for static building

PATCH In review Yao Yuan 2 participants 4 messages Aug 17 – Aug 18

Subsystems (2)
lore
Share & tools
lore

Yao Yuan

author
#0 lore raw

cover Don't empty CFLAGS in Makefile for static building

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

author
#1 lore raw

PATCH 1/1 Makefile: Don't set -CFLAGS := in Makefile

Don't set CFLAGS to empty in the Makefile to allow set the addtional CFLAGS option from environment, support e.g native static compiling.

---
 Makefile | 1 -
 1 file changed, 1 deletion(-)
Makefile +0 -1
index 60e551f..6755910 100644
@@ -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
Signature · 1 line
2.43.5
#2 lore raw
In reply to Yao Yuan

Hi,

Quoted 3 lines · Yao Yuan

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

Quoted 53 lines

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

author
#3 lore raw
Quoted 7 lines · Alexandru Elisei

Hi,

Quoted 3 lines · Yao Yuan

Don't set the CFLAGS to empty in Makefile for passing more CFLAGS options from environment variable, e.g -static for native static building.

Quoted 6 lines

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.

Quoted 57 lines

Thanks,
Alex

Quoted 53 lines

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