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

[Minios-devel] [UNIKRAFT PATCH] Add support for clang compilation



Remove some flags (-fno-tree-sra, -mno-fp-ret-in-387, -fno-reorder-blocks) to 
add support for clang compilation.
Add the CONFIG_COMPILER variable to define the compiler to be used (gcc or 
clang). By default the variable is set to gcc. 
Use 'make COMPILER=clang' to compile with clang.

Signed-off-by: Alice Suiu <alicesuiu17@xxxxxxxxx>
---
 Makefile                    | 12 ++++++++++--
 Makefile.uk                 |  6 +++---
 arch/x86/x86_64/Makefile.uk |  6 +++---
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile
index 84adb16..5828891 100644
--- a/Makefile
+++ b/Makefile
@@ -481,11 +481,19 @@ ifneq ("$(origin CROSS_COMPILE)","undefined")
 CONFIG_CROSS_COMPILE := $(CROSS_COMPILE:"%"=%)
 endif
 
+# Use 'make COMPILER=clang' to compile with clang
+ifeq ("$(origin COMPILER)", "command line")
+  CONFIG_COMPILER := $(COMPILER)
+endif
+ifndef CONFIG_COMPILER
+  CONFIG_COMPILER = gcc
+endif
+
 include $(CONFIG_UK_BASE)/arch/$(UK_FAMILY)/Compiler.uk
 
 # Make variables (CC, etc...)
-LD             := $(CONFIG_CROSS_COMPILE)gcc
-CC             := $(CONFIG_CROSS_COMPILE)gcc
+LD             := $(CONFIG_CROSS_COMPILE)$(CONFIG_COMPILER)
+CC             := $(CONFIG_CROSS_COMPILE)$(CONFIG_COMPILER)
 CPP            := $(CC)
 CXX            := $(CPP)
 GOC            := $(CONFIG_CROSS_COMPILE)gccgo-7
diff --git a/Makefile.uk b/Makefile.uk
index 3f01a25..3890d62 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -8,17 +8,17 @@ ASFLAGS     += -U __linux__ -U __FreeBSD__ -U __sun__ 
-D__ASSEMBLY__
 ASINCLUDES  += -nostdinc -nostdlib -I$(CONFIG_UK_BASE)/include
 
 CFLAGS      += -U __linux__ -U __FreeBSD__ -U __sun__
-CFLAGS      += -fno-stack-protector -fno-omit-frame-pointer -fno-tree-sra
+CFLAGS      += -fno-stack-protector -fno-omit-frame-pointer
 CFLAGS      += -Wall -Wextra
 CINCLUDES   += -nostdinc -nostdlib -I$(CONFIG_UK_BASE)/include
 
 CXXFLAGS    += -U __linux__ -U __FreeBSD__ -U __sun__
-CXXFLAGS    += -fno-stack-protector -fno-omit-frame-pointer -fno-tree-sra
+CXXFLAGS    += -fno-stack-protector -fno-omit-frame-pointer
 CXXFLAGS    += -Wall -Wextra
 CXXINCLUDES += -nostdinc -nostdlib -I$(CONFIG_UK_BASE)/include
 
 GOCFLAGS    += -U __linux__ -U __FreeBSD__ -U __sun__
-GOCFLAGS    += -fno-stack-protector -fno-omit-frame-pointer -fno-tree-sra
+GOCFLAGS    += -fno-stack-protector -fno-omit-frame-pointer
 GOCFLAGS    += -fno-split-stack -Wall -Wextra
 GOCINCLUDES += -nostdinc -nostdlib -I$(CONFIG_UK_BASE)/include
 
diff --git a/arch/x86/x86_64/Makefile.uk b/arch/x86/x86_64/Makefile.uk
index 8ec7d6b..285a4e9 100644
--- a/arch/x86/x86_64/Makefile.uk
+++ b/arch/x86/x86_64/Makefile.uk
@@ -1,9 +1,9 @@
 ASFLAGS  += -D__X86_64__
 ASFLAGS  += -m64
 CFLAGS   += -D__X86_64__
-CFLAGS   += -m64 -mno-red-zone -fno-reorder-blocks 
-fno-asynchronous-unwind-tables
+CFLAGS   += -m64 -mno-red-zone -fno-asynchronous-unwind-tables
 CXXFLAGS += -D__X86_64__
-CXXFLAGS += -m64 -mno-red-zone -fno-reorder-blocks 
-fno-asynchronous-unwind-tables
+CXXFLAGS += -m64 -mno-red-zone -fno-asynchronous-unwind-tables
 
 CINCLUDES   += -I$(CONFIG_UK_BASE)/arch/x86/x86_64/include
 ASINCLUDES  += -I$(CONFIG_UK_BASE)/arch/x86/x86_64/include
@@ -11,7 +11,7 @@ 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
-NO_X86_EXTREGS_FLAGS := -mno-80387 -mno-fp-ret-in-387 -mno-mmx -mno-sse 
-mno-avx
+NO_X86_EXTREGS_FLAGS := -mno-80387 -mno-mmx -mno-sse -mno-avx
 
 ASFLAGS-$(CONFIG_MARCH_X86_64_GENERIC)     += -mtune=generic
 CFLAGS-$(CONFIG_MARCH_X86_64_GENERIC)      += -mtune=generic
-- 
2.17.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

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