commit 017aba99c7025892aa12a320937438d387161da8
parent 2c1127782f786415c1334e10e399b1ac33f33b54
Author: Ryan Sepassi <rsepassi@gmail.com>
Date: Tue, 16 Jun 2026 17:07:58 -0700
arm32 Phase 2: runtime variant + kit-ld auto-rt resolution
Diffstat:
1 file changed, 46 insertions(+), 0 deletions(-)
diff --git a/driver/lib/runtime.c b/driver/lib/runtime.c
@@ -174,6 +174,37 @@ static const char* const kRtSrcRv32Elf[] = {
"stack/print_backtrace.c",
};
+/* arm32 (ARMv7-M Thumb-2) freestanding runtime: the same ilp32 integer layout
+ * (int32/int32.c for the 64-bit-on-32-bit helpers, int/int.c for i64 div/mod)
+ * and soft double (fp/fp.c) as rv32, plus the ARM EABI helper layer — the
+ * __aeabi_* div/mod/shift trampolines (arm/aeabi_thumb2.S over the generic
+ * compiler-rt bodies, arm/aeabi.c). coro/arm32.c replaces rv32's coro asm. This
+ * is the exact effective source set of `make rt-arm-eabi-thumb2`
+ * (RT_SRCS_arm-eabi-thumb2 in mk/rt.mk), so the on-demand archive carries the
+ * same symbols as the Makefile-built one. */
+static const char* const kRtSrcArm32[] = {
+ "assert/assert.c",
+ "int/int.c",
+ "int/si_div.c",
+ "fp/fp.c",
+ "mem/mem.c",
+ "string/string.c",
+ "ctype/ctype.c",
+ "stdlib/stdlib.c",
+ "stdlib/qsort.c",
+ "stdio/printf.c",
+ "atomic/atomic_freestanding.c",
+ "cache/clear_cache.c",
+ "kit/ifunc_init.c",
+ "int32/int32.c",
+ "coro/arm32.c",
+ "coro/coro.c",
+ "arm/aeabi_thumb2.S",
+ "arm/aeabi.c",
+ "stack/backtrace.c",
+ "stack/print_backtrace.c",
+};
+
static const RuntimeVariant kRtVariants[] = {
{"x86_64-linux", KIT_ARCH_X86_64, KIT_OS_LINUX, KIT_OBJ_ELF, 8, 8,
"lib/include/lp64_le", 1, 0, kRtSrcX64,
@@ -243,6 +274,21 @@ static const RuntimeVariant kRtVariants[] = {
4, 4, "lib/include/ilp32_le", 0, 0, kRtSrcRv32Elf,
(uint32_t)(sizeof(kRtSrcRv32Elf) / sizeof(kRtSrcRv32Elf[0])),
KIT_FLOAT_ABI_SINGLE, "rv32imafc", "ilp32f"},
+ /* arm32 freestanding (ARMv7-M Thumb-2, soft float). Key matches the
+ * `make rt` variant dir `arm-eabi-thumb2` (RT_arm-eabi-thumb2 in mk/rt.mk)
+ * so a checkout shares build/rt with the Makefile and the on-demand build
+ * target is `make rt-arm-eabi-thumb2`. Soft-float arm objects do NOT stamp a
+ * float-ABI e_flag (ARM toolchain convention: only hard-float sets a bit, so
+ * elf_arm_float_abi_from_e_flags returns DEFAULT for kit's soft objects).
+ * There is no hard-float arm runtime to disambiguate against, so this
+ * variant is float-ABI-agnostic (DEFAULT wildcard) and resolves for any
+ * detected arm float_abi — unlike rv32, whose objects do carry the ABI bits
+ * and so pin SOFT vs SINGLE. The default `-target arm-none-eabi` profile is
+ * correct (the make recipe sets no -march/-mabi), so isa/abi stay NULL. */
+ {"arm-eabi-thumb2", KIT_ARCH_ARM_32, KIT_OS_FREESTANDING, KIT_OBJ_ELF, 4, 4,
+ "lib/include/ilp32_le", 0, 0, kRtSrcArm32,
+ (uint32_t)(sizeof(kRtSrcArm32) / sizeof(kRtSrcArm32[0])),
+ KIT_FLOAT_ABI_DEFAULT, NULL, NULL},
};
static char* rt_dup(DriverEnv* env, const char* s, size_t* out_size) {