Skip to content

Commit 48041b0

Browse files
committed
build: check compiler version and enforce >= 13
1 parent 4d9d6fe commit 48041b0

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

Configuration.mk

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ CONFIGURATION_MAKEFILE = 1
1818
MAKEFLAGS += -r
1919
MAKEFLAGS += -R
2020

21+
# Enforce a minimum complier version
22+
MINIMUM_GCC_MAJOR := 13
23+
2124
# Toolchain programs.
2225
AR := -ar
2326
AS := -as
@@ -260,6 +263,12 @@ ifneq ($(findstring rv32i,$(TOCK_ARCH_FAMILIES)),)
260263
CC_rv32_version_major := $(shell echo $(CC_rv32_version) | cut -f1 -d.)
261264
endif
262265

266+
# Validate the the toolchain is new enough
267+
ifneq (1,$(shell [ $(CC_rv32_version_major) -ge $(MINIMUM_GCC_MAJOR) ] && echo "1"))
268+
$(info $(TOOLCHAIN_rv32)$(CC_rv32) -dumpfullversion: $(CC_rv32_version))
269+
$(error Your compiler is too old. Need gcc version >= $(MINIMUM_GCC_MAJOR))
270+
endif
271+
263272
# Match compiler version to support libtock-newlib versions.
264273
ifeq ($(CC_rv32_version_major),10)
265274
NEWLIB_VERSION_rv32 := 4.2.0.20211231
@@ -406,6 +415,12 @@ ifneq ($(findstring cortex-m,$(TOCK_ARCH_FAMILIES)),)
406415
CC_cortex-m_version_major := $(shell echo $(CC_cortex-m_version) | cut -f1 -d.)
407416
endif
408417

418+
# Validate the the toolchain is new enough
419+
ifneq (1,$(shell [ $(CC_cortex-m_version_major) -ge $(MINIMUM_GCC_MAJOR) ] && echo "1"))
420+
$(info $(TOOLCHAIN_cortex-m)$(CC_cortex-m) -dumpfullversion: $(CC_cortex-m_version))
421+
$(error Your compiler is too old. Need gcc version >= $(MINIMUM_GCC_MAJOR))
422+
endif
423+
409424
# Match compiler version to support libtock-newlib versions.
410425
ifeq ($(CC_cortex-m_version_major),10)
411426
NEWLIB_VERSION_cortex-m := 4.2.0.20211231

Helpers.mk

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,6 @@ ifdef TOCK_USERLAND_BASE_DIR
4040
endif
4141
endif
4242

43-
# # Validate the the toolchain is new enough (known not to work for gcc <= 5.1)
44-
# CC_VERSION_MAJOR := $(shell $(CC) -dumpversion | cut -d '.' -f1)
45-
# ifeq (1,$(shell expr $(CC_VERSION_MAJOR) \>= 6))
46-
# # Opportunistically turn on gcc 6.0+ warnings since we're already version checking:
47-
# override CPPFLAGS += -Wduplicated-cond # if (p->q != NULL) { ... } else if (p->q != NULL) { ... }
48-
# override CPPFLAGS += -Wnull-dereference # deref of NULL (thought default if -fdelete-null-pointer-checks, in -Os, but no?)
49-
# else
50-
# ifneq (5,$(CC_VERSION_MAJOR))
51-
# $(info CC=$(CC))
52-
# $(info $$(CC) -dumpversion: $(shell $(CC) -dumpversion))
53-
# $(error Your compiler is too old. Need gcc version > 5.1)
54-
# endif
55-
# CC_VERSION_MINOR := $(shell $(CC) -dumpversion | cut -d '.' -f2)
56-
# ifneq (1,$(shell expr $(CC_VERSION_MINOR) \> 1))
57-
# $(info CC=$(CC))
58-
# $(info $$(CC) -dumpversion: $(shell $(CC) -dumpversion))
59-
# $(error Your compiler is too old. Need gcc version > 5.1)
60-
# endif
61-
# endif
62-
6343

6444
# Format check rule
6545
.PHONY: _format_check_unstaged

0 commit comments

Comments
 (0)