[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [UNIKRAFT PATCH v2 3/3] build: Add support for clang
We condition the gcc specific flags via have_gcc and the clang specific flags with have_clang. Signed-off-by: Alice Suiu <alicesuiu17@xxxxxxxxx> Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx> --- Makefile | 2 ++ Makefile.uk | 19 +++++++++++++++---- arch/x86/x86_64/Makefile.uk | 9 ++++++--- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index b3ba38c4..4925a2bb 100644 --- a/Makefile +++ b/Makefile @@ -643,10 +643,12 @@ $(error You did not select a library that handles bootstrapping! (e.g., ukboot)) endif ifeq ($(CONFIG_OPTIMIZE_LTO), y) +ifeq ($(call have_gcc),y) ifneq ($(call gcc_version_ge,6,1),y) $(error Your gcc version does not support incremental link time optimisation) endif endif +endif # Generate build rules $(eval $(call verbose_include,$(CONFIG_UK_BASE)/support/build/Makefile.build)) diff --git a/Makefile.uk b/Makefile.uk index 4f1c7642..7e2a1028 100644 --- a/Makefile.uk +++ b/Makefile.uk @@ -4,9 +4,11 @@ # ################################################################################ -COMPFLAGS += -nostdinc -nostdlib +COMPFLAGS += -nostdlib COMPFLAGS += -U __linux__ -U __FreeBSD__ -U __sun__ -COMPFLAGS += -fno-omit-frame-pointer -fno-tree-sra -fno-split-stack +COMPFLAGS += -fno-omit-frame-pointer +COMPFLAGS-$(call have_gcc) += -fno-tree-sra -fno-split-stack -nostdinc + ifneq ($(HAVE_STACKPROTECTOR),y) COMPFLAGS += -fno-stack-protector endif @@ -22,10 +24,17 @@ GOCINCLUDES += -I$(CONFIG_UK_BASE)/include # Set the text and data sections to be readable and writable. Also, # do not page-align the data segment. If the output format supports # Unix style magic numbers, mark the output as OMAGIC. -LIBLDFLAGS += -nostdinc -nostdlib -Wl,--omagic -Wl,-r -Wl,-d -Wl,--build-id=none -LDFLAGS += -nostdinc -nostdlib -Wl,--omagic -Wl,--build-id=none +LIBLDFLAGS += -nostdlib -Wl,--omagic -Wl,-r -Wl,-d -Wl,--build-id=none +LIBLDFLAGS-$(call have_gcc) += -nostdinc +LDFLAGS += -nostdlib -Wl,--omagic -Wl,--build-id=none +LDFLAGS-$(call have_gcc) += -nostdinc COMPFLAGS-$(CONFIG_OPTIMIZE_NONE) += -O0 -fno-optimize-sibling-calls -fno-tree-vectorize + +ifeq ($(CONFIG_COMPILER), clang) +COMPFLAGS-$(CONFIG_OPTIMIZE_NONE):=$(filter-out -fno-tree-sra,$(COMPFLAGS-$(CONFIG_OPTIMIZE_NONE))) +endif + COMPFLAGS-$(CONFIG_OPTIMIZE_SIZE) += -Os COMPFLAGS-$(CONFIG_OPTIMIZE_PERF) += -O2 @@ -56,3 +65,5 @@ M4FLAGS += -DUK_VERSION=$(UK_VERSION).$(UK_SUBVERSION) COMPFLAGS-$(call gcc_version_ge,6,1) += -no-pie LIBLDFLAGS-$(call gcc_version_ge,6,1) += -no-pie LDFLAGS-$(call gcc_version_ge,6,1) += -no-pie + +COMPFLAGS-$(call have_clang) +=-fno-builtin -fno-PIC diff --git a/arch/x86/x86_64/Makefile.uk b/arch/x86/x86_64/Makefile.uk index 24919fb8..7af494d0 100644 --- a/arch/x86/x86_64/Makefile.uk +++ b/arch/x86/x86_64/Makefile.uk @@ -1,7 +1,9 @@ ARCHFLAGS += -D__X86_64__ -ARCHFLAGS += -m64 -mno-red-zone -fno-reorder-blocks -fno-asynchronous-unwind-tables +ARCHFLAGS += -m64 -mno-red-zone -fno-asynchronous-unwind-tables +ARCHFLAGS-$(call have_gcc) += -fno-reorder-blocks ISR_ARCHFLAGS += -D__X86_64__ -ISR_ARCHFLAGS += -m64 -mno-red-zone -fno-reorder-blocks -fno-asynchronous-unwind-tables +ISR_ARCHFLAGS += -m64 -mno-red-zone -fno-asynchronous-unwind-tables +ISR_ARCHFLAGS-$(call have_gcc) += -fno-reorder-blocks CINCLUDES += -I$(CONFIG_UK_BASE)/arch/x86/x86_64/include ASINCLUDES += -I$(CONFIG_UK_BASE)/arch/x86/x86_64/include @@ -9,7 +11,8 @@ CXXINCLUDES += -I$(CONFIG_UK_BASE)/arch/x86/x86_64/include # compiler flags to prevent use of extended (FP, SSE, AVX) registers. # This is for files that contain trap/exception/interrupt handlers -ISR_ARCHFLAGS += -mno-80387 -mno-fp-ret-in-387 -mno-mmx -mno-sse -mno-avx +ISR_ARCHFLAGS += -mno-80387 -mno-mmx -mno-sse -mno-avx +ISR_ARCHFLAGS-$(call have_gcc) += -mno-fp-ret-in-387 ISR_ARCHFLAGS-$(call gcc_version_ge,7,1) += -mgeneral-regs-only ARCHFLAGS-$(CONFIG_MARCH_X86_64_GENERIC) += -mtune=generic -- 2.27.0
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |