build: introduce mk/boards.mk board target table, T= selects board
Build / build-amd64-iso (push) Failing after 38s
Build / build-aarch64-iso (push) Failing after 34s
Build / build-riscv64-img (push) Failing after 28s

T= now names a specific board (qemu, pc, pi4, pi5, milkv) rather than
an arch alias. mk/boards.mk is the single table: sets ARCH, BOARD, and
BOARD_NAME. Each Makefile applies board-specific compiler flags after its
arch block — pi5 gets Cortex-A76 tuning, pi4 gets Cortex-A72, qemu uses
portable x86-64 baseline instead of -march=native. Zynq-7020 is stubbed
in comments for future 32-bit ARM support. ARCH= override still works
for raw arch selection without a named board.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-11-06 04:10:07 +00:00
co-authored by Claude Sonnet 4.6
parent 81caf71511
commit 0820ee7d32
3 changed files with 117 additions and 27 deletions
+44 -16
View File
@@ -4,9 +4,11 @@
#
# Quick Start:
# make - Build for host arch (fastest profile, always)
# make T=raspi - Build for Raspberry Pi 4 (T= is a shorthand for ARCH=)
# make T=amd64 - Build for x86_64
# make T=riscv64 - Build for RISC-V 64
# make T=qemu - Build portable x86-64 for QEMU
# make T=pc - Build for x86-64 PC (native tuning)
# make T=pi4 - Cross-compile for Raspberry Pi 4 (Cortex-A72)
# make T=pi5 - Cross-compile for Raspberry Pi 5 (Cortex-A76)
# make T=milkv - Cross-compile for Milk-V Pioneer (RISC-V 64)
# make help - Show all available targets
#
# ==============================================================================
@@ -23,10 +25,8 @@ CC = gcc
# See docs/DEVELOPER.md for installation instructions
ISABELLE ?= isabelle
# Architecture / target selection — T= is a shorthand for ARCH= (board/SBC)
ifdef T
ARCH ?= $(T)
endif
# Board / architecture selection — T= picks a board (see mk/boards.mk)
include mk/boards.mk
ARCH ?= $(shell uname -m)
ARCH := $(strip $(ARCH))
TARGET := fastest
@@ -105,6 +105,33 @@ else
ASM_SYNTAX =
endif
# Board-specific overrides — refine arch defaults for exact hardware
# QEMU: use portable baseline, not -march=native
ifeq ($(BOARD),qemu)
ARCH_FLAGS := -march=x86-64 -mtune=generic
ARCH_DEFINES += -DBOARD_QEMU=1
# PC: native tuning (already the amd64 default; explicit for clarity)
else ifeq ($(BOARD),pc)
ARCH_FLAGS := -march=native
ARCH_DEFINES += -DBOARD_PC=1
# Raspberry Pi 4 — Cortex-A72, ARMv8-A
else ifeq ($(BOARD),pi4)
ARCH_FLAGS := -march=armv8-a+crc+simd -mtune=cortex-a72
ARCH_DEFINES += -DBOARD_RPI4=1 -DRASPBERRY_PI_BUILD=1
# Raspberry Pi 5 — Cortex-A76, ARMv8.2-A
else ifeq ($(BOARD),pi5)
ARCH_FLAGS := -march=armv8.2-a+crypto+fp16+rcpc+dotprod -mtune=cortex-a76
ARCH_DEFINES += -DBOARD_RPI5=1 -DRASPBERRY_PI_BUILD=1
# Milk-V Pioneer — SG2042 RISC-V 64
else ifeq ($(BOARD),milkv)
ARCH_FLAGS := -march=rv64gc -mabi=lp64d -mcmodel=medany
ARCH_DEFINES += -DBOARD_MILKV=1
endif
# Use board name in ARCH_NAME when T= is set
ifdef BOARD_NAME
ARCH_NAME := $(BOARD_NAME)
endif
# Compiler flags
# Feature switches (default: enabled)
# Physics/SSM knob family: repointed through the Kconfig bridge (see
@@ -1251,18 +1278,19 @@ help:
@echo "════════════════════════════════════════════════════════════"
@echo ""
@echo "🛠️ Variables:"
@echo " ARCH=<arch> (default: $(ARCH); canonical directory: $(ARCH_DIR))"
@echo " TARGET=<profile> (standard | fast | fastest | turbo)"
@echo " T=<board> Board target (preferred). Supported:"
@echo " qemu — portable x86-64 for QEMU"
@echo " pc — x86-64 PC (native tuning)"
@echo " pi4 — Raspberry Pi 4 (Cortex-A72)"
@echo " pi5 — Raspberry Pi 5 (Cortex-A76)"
@echo " milkv — Milk-V Pioneer (SG2042 RISC-V 64)"
@echo " ARCH=<arch> Low-level arch override (amd64 | arm64 | riscv64)"
@echo " Active: $(ARCH) / board: $(or $(BOARD_NAME),$(ARCH_NAME))"
@echo ""
@echo "🏆 OPTIMIZATION BUILDS:"
@echo " fastest - Maximum performance (ASM + direct threading + LTO)"
@echo " fast - Fast without LTO (easier debugging)"
@echo " turbo - Assembly optimizations only"
@echo "🏆 BUILD PROFILE: fastest (always — ASM + direct threading + LTO)"
@echo ""
@echo "🥧 PLATFORM-SPECIFIC BUILDS:"
@echo " rpi4 - Native build on Raspberry Pi 4"
@echo " rpi4-cross - Cross-compile from x86_64"
@echo " rpi4-fastest - Maximum optimization for RPi4"
@echo " rpi4-cross - Cross-compile for Raspberry Pi 4 (legacy; use T=pi4)"
@echo " riscv64-clang - Cross-compile for RISC-V 64 via clang (GCC fails here)"
@echo " minimal - Minimal/embedded build"
@echo ""
+25 -11
View File
@@ -26,10 +26,8 @@ canon_arch = $(strip \
$(if $(filter riscv riscv64,$1),riscv64,$1))))))
UNAME_M := $(shell uname -m)
# T= is a shorthand for ARCH= (board/SBC selection)
ifdef T
ARCH ?= $(T)
endif
# T= selects the board target (see mk/boards.mk for the full table)
include mk/boards.mk
ARCH ?= $(call canon_arch,$(UNAME_M))
override ARCH := $(call canon_arch,$(ARCH))
@@ -245,6 +243,13 @@ endif
LOADER_CC ?= $(CC)
LOADER_LD ?= $(LD)
# Board-specific ARCH_CFLAGS overrides — refine CPU tuning beyond arch default
ifeq ($(BOARD),pi4)
ARCH_CFLAGS := -march=armv8-a -mcpu=cortex-a72 -DARCH_AARCH64 -mno-outline-atomics
else ifeq ($(BOARD),pi5)
ARCH_CFLAGS := -march=armv8.2-a -mcpu=cortex-a76 -DARCH_AARCH64 -mno-outline-atomics
endif
# ==============================================================================
# COMPILER FLAGS
# ==============================================================================
@@ -1246,6 +1251,7 @@ endif
info:
@echo "StarKernel Build Configuration"
@echo "==============================="
@echo "Board: $(or $(BOARD_NAME),$(ARCH) (no board selected))"
@echo "Architecture: $(ARCH)"
@echo "Target: $(TARGET)"
@echo "Compiler: $(CC)"
@@ -1263,10 +1269,17 @@ help:
@echo "StarKernel Build System"
@echo "======================="
@echo ""
@echo "Usage: make -f Makefile.starkernel [ARCH=<arch>] [TARGET=<target>] <goal>"
@echo "Usage: make -f Makefile.starkernel [T=<board>] [TARGET=<target>] <goal>"
@echo ""
@echo "Architectures (aliases accepted):"
@echo " ARCH=amd64 / x86_64 — x86-64 (default on x86 host)"
@echo "Board targets (T=):"
@echo " T=qemu — QEMU x86_64 (portable baseline)"
@echo " T=pc — x86_64 PC (native tuning)"
@echo " T=pi4 — Raspberry Pi 4 (Cortex-A72, aarch64)"
@echo " T=pi5 — Raspberry Pi 5 (Cortex-A76, aarch64)"
@echo " T=milkv — Milk-V Pioneer (SG2042, riscv64)"
@echo ""
@echo "Low-level arch override (bypasses board table):"
@echo " ARCH=amd64 / x86_64 — x86-64"
@echo " ARCH=aarch64 / arm64 — ARM64"
@echo " ARCH=riscv64 / riscv — RISC-V 64-bit"
@echo ""
@@ -1293,8 +1306,9 @@ help:
@echo " help — show this message"
@echo ""
@echo "Examples:"
@echo " make -f Makefile.starkernel ARCH=amd64 qemu"
@echo " make -f Makefile.starkernel ARCH=aarch64 clean qemu"
@echo " make -f Makefile.starkernel ARCH=riscv64 clean qemu"
@echo " make -f Makefile.starkernel ARCH=x86_64 qemu # alias works"
@echo " make -f Makefile.starkernel T=qemu qemu"
@echo " make -f Makefile.starkernel T=pi4 clean qemu"
@echo " make -f Makefile.starkernel T=pi5 clean qemu"
@echo " make -f Makefile.starkernel T=milkv clean all"
@echo " make -f Makefile.starkernel kernel-all"
@echo " make -f Makefile.starkernel ARCH=riscv64 clean qemu # arch override still works"
+48
View File
@@ -0,0 +1,48 @@
# Board target table — T= selects board, sets ARCH + BOARD + BOARD_NAME.
# Included early by both Makefile and Makefile.starkernel, before arch
# normalization runs. Each Makefile applies board-specific flag overrides
# after its own arch block.
#
# Adding a new board: add an ifeq block here, then add compiler-flag
# overrides in the board-override sections of Makefile and
# Makefile.starkernel if the board needs tuning beyond the arch default.
ifdef T
ifeq ($(T),qemu)
ARCH ?= amd64
BOARD := qemu
BOARD_NAME := QEMU x86_64
else ifeq ($(T),pc)
ARCH ?= amd64
BOARD := pc
BOARD_NAME := x86_64 PC (native)
else ifeq ($(T),pi4)
ARCH ?= aarch64
BOARD := pi4
BOARD_NAME := Raspberry Pi 4 (Cortex-A72)
else ifeq ($(T),pi5)
ARCH ?= aarch64
BOARD := pi5
BOARD_NAME := Raspberry Pi 5 (Cortex-A76)
else ifeq ($(T),milkv)
ARCH ?= riscv64
BOARD := milkv
BOARD_NAME := Milk-V Pioneer (SG2042 RISC-V 64)
# ── Future boards (uncomment + add flag overrides in Makefile / Makefile.starkernel) ──
# else ifeq ($(T),zynq7020)
# ARCH ?= arm
# BOARD := zynq7020
# BOARD_NAME := Xilinx Zynq-7020 (Cortex-A9, 32-bit)
# # NOTE: requires removing the 32-bit guardrail and adding armhf toolchain support
else
$(error Unknown board target T='$(T)'. Supported: qemu pc pi4 pi5 milkv)
endif
endif # ifdef T