]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
build: Implement a more robust compiler detection
authorMarco Schlumpp <marco@unikraft.io>
Mon, 27 Feb 2023 14:33:10 +0000 (15:33 +0100)
committerUnikraft <monkey@unikraft.io>
Thu, 4 May 2023 14:08:45 +0000 (14:08 +0000)
Instead of checking the compiler executable name, inspect the compiler's
version output. This also works when there are symlinks involved or the
executable name has additional text such as version numbers.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #774

Makefile
support/build/Makefile.rules

index bcaa2b90d48453b61d43e3028639dc7246620fe8..e727d3f464be1c4b8951f02ad3a2f42fa00ca26b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -636,6 +636,8 @@ CFLAGS              += -DCC_VERSION=$(CC_VERSION)
 CXXFLAGS       += -DCC_VERSION=$(CC_VERSION)
 GOCFLAGS       += -DCC_VERSION=$(CC_VERSION)
 
+CC_NAME                := $(shell $(CC) -v 2>&1 | grep -E "\\w+ version" | sed 's/\s.*$$//')
+
 # ensure $(BUILD_DIR)/kconfig, $(BUILD_DIR)/include and $(BUILD_DIR)/include/uk exists
 $(call mk_sub_build_dir,kconfig)
 $(call mk_sub_build_dir,include)
index 4c4f0306198711ca91e45b05b82df00a057aa971..6a7a0c7b12f7ff787ebbdee01674fe12ccd128be 100644 (file)
@@ -31,12 +31,12 @@ uc = $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(s
 
 # test if GCC is set as a compiler
 define have_gcc =
-$(if $(filter %gcc,$(CC)),y,n)
+$(if $(filter gcc,$(CC_NAME)),y,n)
 endef
 
 # test if CLANG is set as a compiler
 define have_clang =
-$(if $(filter %clang,$(CC)),y,n)
+$(if $(filter clang,$(CC_NAME)),y,n)
 endef
 
 # test whether GCC version is greater than or equal to the minimum requirement