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

Re: [Minios-devel] [UNIKRAFT PATCHv4 05/43] build: Add a makefile function to check GCC version



I just noticed that this check is not working if you compare 4.9 (older) with 4.10 (newer) because 4.10 is considered as the floating point number 4.1 by `bc`. As fix we probably should do two individual checks: (1) major and then (2) minor. Btw, do you think you could provide a version that does not need `bc`? I rather prefer something that requires the least possible tools installed on the system. My concern is that we can't assume `bc` is installed as a standard tool. But maybe I am wrong with this concern. What do you think?

On 06.07.2018 11:03, Wei Chen wrote:
In this patch, we add a test_gcc_version function to test GCC
version and return a result. In this case, this function can
be used not only for processor flags check, but also can be
used in other places of Unikraft.

Signed-off-by: Wei Chen <Wei.Chen@xxxxxxx>
---
  Makefile                     | 4 ++++
  support/build/Makefile.rules | 5 +++++
  2 files changed, 9 insertions(+)

diff --git a/Makefile b/Makefile
index d10f53b..e133039 100644
--- a/Makefile
+++ b/Makefile
@@ -428,6 +428,10 @@ LIFTOFF            := liftoff -e -s
  override ARFLAGS:= rcs
  CC_VERSION    := $(shell $(CC) --version | \
                   sed -n -r 's/^.* ([0-9]*)\.([0-9]*)\.([0-9]*)[ ]*.*/\1.\2/p')
+# Retrieve GCC major and minor number from CC_VERSION. They would be used
+# to select correct optimization parameters for target CPUs.
+CC_VER_MAJOR   := $(word 1,$(subst ., ,$(CC_VERSION)))
+CC_VER_MINOR   := $(word 2,$(subst ., ,$(CC_VERSION)))
ASFLAGS += -DCC_VERSION=$(CC_VERSION)
  CFLAGS                += -DCC_VERSION=$(CC_VERSION)
diff --git a/support/build/Makefile.rules b/support/build/Makefile.rules
index e317e3d..d5372cd 100644
--- a/support/build/Makefile.rules
+++ b/support/build/Makefile.rules
@@ -29,6 +29,11 @@ lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst 
E,e,$(subst F,f,$(s
  # upper case
  uc = $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst 
f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst 
l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst 
r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst 
x,X,$(subst y,Y,$(subst z,Z,$(1)))))))))))))))))))))))))))
+# test whether GCC version meets the minimum requirement
+# test_gcc_version $gcc_major,$gcc_minor
+define test_gcc_version =
+$(shell echo 'if($(CC_VER_MAJOR).$(CC_VER_MINOR)>=$(1).$(2)) print "y"'| bc)
+endef
################################################################################
  #


_______________________________________________
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®.