[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[UNIKRAFT PATCH 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.uk                 | 17 ++++++++++++++---
 arch/x86/x86_64/Makefile.uk |  9 ++++++---
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/Makefile.uk b/Makefile.uk
index 4f1c7642..54914b26 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -6,7 +6,9 @@
 
 COMPFLAGS    += -nostdinc -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
+
 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




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.