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 1/3] 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 From 1b29fb687f12e195a4e3ce921746ed3e33153f1a Mon Sep 17 00:00:00 2001 From: d00f <8052722+DrDoof@users.noreply.github.com> Date: Sun, 25 Oct 2026 21:23:32 +0100 Subject: [PATCH 2/3] build: count the sdcc patches in the toolchain line The checksum changes with every patch but does not say how many there are. Print the number of patches in sdcc/ next to it. --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 98d9cd0e..ec4de1a2 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,9 @@ ifeq ($(origin CC),default) SDCC = $(SDCC_PREFIX)/bin/sdcc CC = $(SDCC) ASM = $(SDCC_PREFIX)/bin/sdas8051 +SDCC_BANNER = $(SDCC_TOOLCHAIN) ($(words $(wildcard sdcc/*.patch)) patches) else -SDCC_TOOLCHAIN = system +SDCC_BANNER = system endif CC_FLAGS = -mmcs51 -I. -Imachine -Ihttpd -Iuip ASM ?= sdas8051 @@ -175,7 +176,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)\"" \ + "#define SDCC_TOOLCHAIN \"$(SDCC_BANNER)\"" \ "#endif" > $(VERSION_HEADER).tmp @cmp -s $(VERSION_HEADER).tmp $(VERSION_HEADER) \ && rm -f $(VERSION_HEADER).tmp \ From c5f62bff95eea5969f3fe0afda55e5be966a4dd2 Mon Sep 17 00:00:00 2001 From: d00f <8052722+DrDoof@users.noreply.github.com> Date: Sun, 25 Oct 2026 22:49:37 +0100 Subject: [PATCH 3/3] build: name the sdcc/ revision in the toolchain line A commit hash can be looked up directly, a checksum cannot. Print the last commit that touched sdcc/, with -dirty for local changes, and fall back to the checksum when git is not available. The toolchain directory keeps the checksum. --- Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ec4de1a2..a9f72194 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,13 @@ ifeq ($(origin CC),default) SDCC = $(SDCC_PREFIX)/bin/sdcc CC = $(SDCC) ASM = $(SDCC_PREFIX)/bin/sdas8051 -SDCC_BANNER = $(SDCC_TOOLCHAIN) ($(words $(wildcard sdcc/*.patch)) patches) +SDCC_REV := $(shell git log -1 --format=%h -- sdcc 2>/dev/null) +ifneq ($(SDCC_REV),) +ifneq ($(shell git status --porcelain --untracked-files=no -- sdcc 2>/dev/null),) +SDCC_REV := $(SDCC_REV)-dirty +endif +endif +SDCC_BANNER = $(if $(SDCC_REV),sdcc/ at $(SDCC_REV),$(SDCC_TOOLCHAIN)) ($(words $(wildcard sdcc/*.patch)) patches) else SDCC_BANNER = system endif