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

[UNIKRAFT PATCH v5 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>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@xxxxxxxxx>
---
 Makefile                    |  2 ++
 Makefile.uk                 | 15 +++++++++++----
 arch/x86/x86_64/Makefile.uk |  9 ++++++---
 3 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 699f12e..b396b0b 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 e505c04..9f0da22 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
@@ -19,12 +21,14 @@ CINCLUDES    += -I$(CONFIG_UK_BASE)/include
 CXXINCLUDES  += -I$(CONFIG_UK_BASE)/include
 GOCINCLUDES  += -I$(CONFIG_UK_BASE)/include
 
-LIBLDFLAGS  += -nostdinc -nostdlib -Wl,-r -Wl,-d -Wl,--build-id=none -no-pie
+LIBLDFLAGS  += -nostdlib -Wl,-r -Wl,-d -Wl,--build-id=none -no-pie
+LIBLDFLAGS-$(call have_gcc)    += -nostdinc
 
 # 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.
-LDFLAGS     += -nostdinc -nostdlib -Wl,--omagic -Wl,--build-id=none
+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
 COMPFLAGS-$(CONFIG_OPTIMIZE_SIZE)         += -Os
@@ -56,3 +60,6 @@ M4FLAGS      += -DUK_VERSION=$(UK_VERSION).$(UK_SUBVERSION)
 # "--enable-default-pie" by default.
 COMPFLAGS-$(call gcc_version_ge,6,1)   += -fno-PIC
 LDFLAGS-$(call gcc_version_ge,6,1)     += -no-pie
+
+COMPFLAGS-$(call have_clang)   += -fno-builtin -fno-PIC
+LDFLAGS-$(call have_clang)     += -no-pie
diff --git a/arch/x86/x86_64/Makefile.uk b/arch/x86/x86_64/Makefile.uk
index 24919fb..c4d5109 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®.