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

Re: [UNIKRAFT PATCH 1/3] build: Configure the compiler from command line



On 21.11.20 17:34, Vlad-Andrei Badoiu wrote:
By default, the compiler is GCC. Use COMPILER=clang with make to configure the 
compiler as CLANG.

Signed-off-by: Alice Suiu <alicesuiu17@xxxxxxxxx>
Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxx>
---
  Makefile | 13 +++++++++++--
  1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 1f309b7d..b3ba38c4 100644
--- a/Makefile
+++ b/Makefile
@@ -544,11 +544,20 @@ 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
+
+

I think we should prefer a mechanism that works the same way as CROSS_COMPILE. This approach would be slightly more flexible (.config, environment variable, and command line) and would still cover your command line case:

ifneq ("$(origin COMPILER)","undefined")
CONFIG_COMPILER := $(COMPILER:"%"=%)
endif

We maybe need to add CONFIG_COMPILER to the `unexport` list (like we had to do for CONFIG_CROSS_COMPILE), but please double-check. It had to do with our nested sub-make call.

  $(eval $(call 
verbose_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


Btw, the AR and NM commands, are there clang variants available, too?

AR := $(CONFIG_CROSS_COMPILE)$(CONFIG_COMPILER)-ar
NM := $(CONFIG_CROSS_COMPILE)$(CONFIG_COMPILER)-nm

If I remember correctly, something like this was needed when enabling LTO with gcc.



 


Rackspace

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