summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2022-04-14 22:18:19 +0200
committerFlorin Coras <florin.coras@gmail.com>2022-04-15 17:52:43 +0000
commit8cb5d36c7e7492d3cc314e6b78dea571bbcc4889 (patch)
tree95ee00c56e4fa51829106056cf6642dca2b046c1
parent105cb1e4cfed2f7a92946fe7e9efc442e0183714 (diff)
build: c compiler version warnings
Type: make Change-Id: I9455da47f03383df822436d1adc4c4b5e58c7cf9 Signed-off-by: Damjan Marion <damarion@cisco.com>
-rw-r--r--Makefile6
-rw-r--r--src/CMakeLists.txt45
2 files changed, 37 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index 8eb1d54189d..fef563bb534 100644
--- a/Makefile
+++ b/Makefile
@@ -85,17 +85,17 @@ ifeq ($(OS_VERSION_ID),20.04)
DEB_DEPENDS += python3-virtualenv
DEB_DEPENDS += libssl-dev
DEB_DEPENDS += libelf-dev # for libbpf (af_xdp)
- DEB_DEPENDS += clang-11 clang-format-11
+ DEB_DEPENDS += clang clang-format-11
LIBFFI=libffi7
DEB_DEPENDS += enchant-2 # for docs
else ifeq ($(OS_VERSION_ID),20.10)
- DEB_DEPENDS += clang-11 clang-format-11
+ DEB_DEPENDS += clang clang-format-11
LIBFFI=libffi8ubuntu1
else ifeq ($(OS_ID)-$(OS_VERSION_ID),debian-10)
DEB_DEPENDS += virtualenv
else ifeq ($(OS_ID)-$(OS_VERSION_ID),debian-11)
DEB_DEPENDS += virtualenv
- DEB_DEPENDS += clang-11 clang-format-11
+ DEB_DEPENDS += clang clang-format-11
LIBFFI=libffi7
else
DEB_DEPENDS += clang-11 clang-format-11
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a1c18ff0951..de0c24135d7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -13,17 +13,7 @@
cmake_minimum_required(VERSION 3.13)
-set(CMAKE_C_COMPILER_NAMES
- clang-14
- clang-13
- clang-12
- clang-11
- clang-10
- clang-9
- gcc-10
- gcc-9
- cc
-)
+set(CMAKE_C_COMPILER_NAMES clang gcc cc)
project(vpp C)
@@ -51,6 +41,39 @@ string(REPLACE "-" ";" VPP_LIB_VERSION ${VPP_VERSION})
list(GET VPP_LIB_VERSION 0 VPP_LIB_VERSION)
##############################################################################
+# compiler specifics
+##############################################################################
+
+set(MIN_SUPPORTED_CLANG_C_COMPILER_VERSION 9.0.0)
+set(MIN_SUPPORTED_GNU_C_COMPILER_VERSION 9.0.0)
+
+if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ if (CMAKE_C_COMPILER_VERSION VERSION_LESS MIN_SUPPORTED_CLANG_C_COMPILER_VERSION)
+ set(COMPILER_TOO_OLD TRUE)
+ endif()
+elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ if (CMAKE_C_COMPILER_VERSION VERSION_LESS MIN_SUPPORTED_GNU_C_COMPILER_VERSION)
+ set(COMPILER_TOO_OLD TRUE)
+ endif()
+else()
+ message(WARNING "WARNING: Unsupported C compiler `${CMAKE_C_COMPILER_ID}` is used")
+ set (PRINT_MIN_C_COMPILER_VER TRUE)
+endif()
+if (COMPILER_TOO_OLD)
+ message(WARNING "WARNING: C compiler version is too old and it's usage may result")
+ message(WARNING " in sub-optimal binaries or lack of support for specific CPU types.")
+ set (PRINT_MIN_C_COMPILER_VER TRUE)
+endif()
+
+if (PRINT_MIN_C_COMPILER_VER)
+ string (APPEND _t "Supported C compilers are ")
+ string (APPEND _t "Clang ${MIN_SUPPORTED_CLANG_C_COMPILER_VERSION} or higher ")
+ string (APPEND _t "and GNU ${MIN_SUPPORTED_GNU_C_COMPILER_VERSION} or higher.")
+ message(WARNING " ${_t}")
+ unset (_t)
+endif()
+
+##############################################################################
# cross compiling
##############################################################################
if(CMAKE_CROSSCOMPILING)