From 1d158d21d162f306cef4c6439f2fff555d048125 Mon Sep 17 00:00:00 2001 From: d00f <8052722+DrDoof@users.noreply.github.com> Date: Sun, 25 Oct 2026 16:04:49 +0100 Subject: [PATCH] build: show the compiler and the toolchain in the version banner The boot banner and the version command print the SDCC release and revision from the compiler's own macros, and the name of the in-tree toolchain the Makefile built, which is the checksum of sdcc/ and so changes with every patch in it. A build with CC given on the command line says "system" instead, since that compiler need not carry the patches. A plain release and the same release with the patches report the same revision, so the toolchain line is what tells them apart. Costs 66 bytes of BANK2. --- Makefile | 6 +++++- cmd_parser.c | 2 ++ rtl837x_common.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e0e2aaa8..98d9cd0e 100644 --- a/Makefile +++ b/Makefile @@ -4,11 +4,14 @@ DEFAULT_CONFIG_LOCATION = 454656 CONFIG_LOCATION = 458752 HTML_LOCATION = 262144 -SDCC_PREFIX = toolchain/sdcc-$(shell cat sdcc/* | cksum | cut -d' ' -f1) +SDCC_TOOLCHAIN = sdcc-$(shell cat sdcc/* | cksum | cut -d' ' -f1) +SDCC_PREFIX = toolchain/$(SDCC_TOOLCHAIN) ifeq ($(origin CC),default) SDCC = $(SDCC_PREFIX)/bin/sdcc CC = $(SDCC) ASM = $(SDCC_PREFIX)/bin/sdas8051 +else +SDCC_TOOLCHAIN = system endif CC_FLAGS = -mmcs51 -I. -Imachine -Ihttpd -Iuip ASM ?= sdas8051 @@ -172,6 +175,7 @@ $(VERSION_HEADER): FORCE @printf '%s\n' "#ifndef VERSION_H" "#define VERSION_H" \ "#define VERSION_SW \"$(VERSION_EXTENSION)\"" \ "#define BUILD_DATE \"$(BUILD_DATE)\"" \ + "#define SDCC_TOOLCHAIN \"$(SDCC_TOOLCHAIN)\"" \ "#endif" > $(VERSION_HEADER).tmp @cmp -s $(VERSION_HEADER).tmp $(VERSION_HEADER) \ && rm -f $(VERSION_HEADER).tmp \ diff --git a/cmd_parser.c b/cmd_parser.c index 0da626e4..dec53aaa 100644 --- a/cmd_parser.c +++ b/cmd_parser.c @@ -1840,6 +1840,8 @@ void print_gpio_status(void) { void print_sw_version(void) __banked { print_string("Software version: " VERSION_SW); print_string("\nBuild date: " BUILD_DATE); + print_string("\nCompiler: SDCC " STR(__SDCC_VERSION_MAJOR) "." STR(__SDCC_VERSION_MINOR) "." STR(__SDCC_VERSION_PATCH) " #" STR(__SDCC_REVISION)); + print_string("\nToolchain: " SDCC_TOOLCHAIN); print_string("\nHardware: "); print_string(machine.machine_name); write_char('\n'); diff --git a/rtl837x_common.h b/rtl837x_common.h index ae7a1b29..e4f5cc3d 100644 --- a/rtl837x_common.h +++ b/rtl837x_common.h @@ -19,6 +19,8 @@ #define MAC_ADDR_LEN 6 #define PORT_BIT(p) ((uint16_t)1 << (p)) #define NUL '\0' +#define STR_(x) #x +#define STR(x) STR_(x) // Define Port-masks for 9-port devices and 6-port devices #define PMASK_9 0x1ff