Build linux and kvmunittests with toolchain in repo
Use the clang/llvm toolchain in repo, as rather than what's in the
user's path, for building linux and the kvm-unit-tests.
Signed-off-by: Fuad Tabba <tabba@google.com>
diff --git a/Makefile b/Makefile
index 2115f98..732f0b2 100644
--- a/Makefile
+++ b/Makefile
@@ -13,6 +13,10 @@
CROSS_PREFIX ?= "aarch64-linux-gnu-"
CCACHE ?= ""
+# Find toolchain for current OS
+UNNAME_S := $(shell uname -s | tr '[:upper:]' '[:lower:]')
+TOOLCHAIN := $(ROOT_DIR)/toolchains/clang/$(UNNAME_S)-x86/clang-r383902
+export PATH := $(TOOLCHAIN)/bin:$(PATH)
##
## Common targets
@@ -76,13 +80,19 @@
KUT_ARCH := "arm64"
KUT_SRC := $(ROOT_DIR)/kvm-unit-tests
KUT_OUT := $(OUT_DIR)/kvm-unit-tests
+KUT_CC := $(TOOLCHAIN)/bin/clang
+KUT_LD := $(TOOLCHAIN)/bin/ld.lld
+KUT_OBJCOPY := $(TOOLCHAIN)/bin/llvm-objcopy
+KUT_OBJDUMP := $(TOOLCHAIN)/bin/llvm-objdump
+KUT_COMMON_CFLAGS := "-Qunused-arguments -target aarch64-linux-gnueabi -fno-integrated-as -Wno-asm-operand-widths -fpic"
.PHONY: kvmunittests
kvmunittests:
cd $(KUT_SRC) && \
./configure --prefix=$(KUT_OUT) --arch=$(KUT_ARCH) \
- --cross-prefix=$(KUT_CROSS_PREFIX)
- + cd $(KUT_SRC) && $(MAKE) install
+ --cc=$(KUT_CC) --ld=$(KUT_LD) \
+ --objcopy=$(KUT_OBJCOPY) --objdump=$(KUT_OBJDUMP)
+ + cd $(KUT_SRC) && COMMON_CFLAGS=$(KUT_COMMON_CFLAGS) $(MAKE) install
.PHONY: kvmunittests_clean
kvmunittests_clean:
@@ -100,11 +110,12 @@
LINUX_SRC := $(ROOT_DIR)/linux
LINUX_OUT := $(OUT_DIR)/linux
LINUX_MAKE := $(MAKE) ARCH=$(LINUX_ARCH) CROSS_COMPILE=$(LINUX_CROSS_PREFIX) \
- -C $(LINUX_SRC) V=$(LINUX_VERBOSE) O=$(LINUX_OUT)
+ LLVM=1 -C $(LINUX_SRC) V=$(LINUX_VERBOSE) O=$(LINUX_OUT)
.PHONY: linux
linux:
- + $(LINUX_MAKE) defconfig && $(LINUX_MAKE)
+ + $(LINUX_MAKE) defconfig
+ + $(LINUX_MAKE)
.PHONY: linux_clean
@@ -130,5 +141,3 @@
.PHONY: unittests
unittests: buildroot kvmunittests linux
@ VERBOSE=$(VERBOSE) $(TEST_SCRIPTS_DIR)/run_tests.sh -j $(JOBS) -t $(KUT_OUT)/share/kvm-unit-tests/ -x $(KUT_EXCLUDE) -l $(LINUX_OUT)/arch/arm64/boot/Image -r $(BR_OUT)/images/rootfs.ext4 -e $(BR_OUT)/host/bin/qemu-system-aarch64
-
-