commit c13664a12083de13e646f1d51ceae9788c89e71a
parent 05eaf7efa381c1f78ba45605fe6a5731d756fe5b
Author: Ryan Sepassi <rsepassi@gmail.com>
Date: Tue, 9 Jun 2026 15:30:03 -0700
driver: accept short arch aliases (x64, aa64, rv64, rv32) in the canonical arch-name table
All four aliases are now recognized in arch_from_tok (driver/lib/target.c),
the single authority for arch-name spellings used by driver_arch_from_name
and driver_target_from_triple. Removes the one-off rv64→riscv64 workaround
that had been hand-coded in emu.c.
Diffstat:
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/driver/cmd/emu.c b/driver/cmd/emu.c
@@ -110,14 +110,10 @@ static int emu_alloc_arrays(EmuOptions* o, int argc) {
static int emu_record_arch(EmuOptions* o, const char* val) {
KitArchKind arch;
- /* `rv64` is an emu-layer alias not carried by the shared arch-name table
- * (parallel to the cc-only -x aliases); fold it onto `riscv64` first. */
- const char* name = driver_streq(val, "rv64") ? "riscv64" : val;
- /* The emulator only supports the aarch64 / riscv64 guests today. Recognize
- * arch names through the shared driver_arch_from_name table, then restrict
- * to those two so an unsupported (but otherwise valid) arch still reports
- * the same "unsupported -arch value" error. */
- if (driver_arch_from_name(name, &arch, NULL) == 0 &&
+ /* Recognize arch names through the shared driver_arch_from_name table, then
+ * restrict to the supported guest set so an unsupported (but otherwise
+ * valid) arch still reports the same "unsupported -arch value" error. */
+ if (driver_arch_from_name(val, &arch, NULL) == 0 &&
(arch == KIT_ARCH_ARM_64 || arch == KIT_ARCH_RV64)) {
o->guest_arch = arch;
o->guest_arch_set = 1;
diff --git a/driver/lib/target.c b/driver/lib/target.c
@@ -29,23 +29,25 @@ static int arch_from_tok(const char* s, size_t n, KitArchKind* arch_out,
uint8_t* ptr_size_out) {
KitArchKind arch;
uint8_t ptr_size;
- if (triple_tok_eq(s, n, "x86_64") || triple_tok_eq(s, n, "amd64")) {
+ if (triple_tok_eq(s, n, "x86_64") || triple_tok_eq(s, n, "amd64") ||
+ triple_tok_eq(s, n, "x64")) {
arch = KIT_ARCH_X86_64;
ptr_size = 8;
} else if (triple_tok_eq(s, n, "i386") || triple_tok_eq(s, n, "i486") ||
triple_tok_eq(s, n, "i586") || triple_tok_eq(s, n, "i686")) {
arch = KIT_ARCH_X86_32;
ptr_size = 4;
- } else if (triple_tok_eq(s, n, "aarch64") || triple_tok_eq(s, n, "arm64")) {
+ } else if (triple_tok_eq(s, n, "aarch64") || triple_tok_eq(s, n, "arm64") ||
+ triple_tok_eq(s, n, "aa64")) {
arch = KIT_ARCH_ARM_64;
ptr_size = 8;
} else if (triple_tok_eq(s, n, "arm") || triple_tok_eq(s, n, "armv7")) {
arch = KIT_ARCH_ARM_32;
ptr_size = 4;
- } else if (triple_tok_eq(s, n, "riscv64")) {
+ } else if (triple_tok_eq(s, n, "riscv64") || triple_tok_eq(s, n, "rv64")) {
arch = KIT_ARCH_RV64;
ptr_size = 8;
- } else if (triple_tok_eq(s, n, "riscv32")) {
+ } else if (triple_tok_eq(s, n, "riscv32") || triple_tok_eq(s, n, "rv32")) {
arch = KIT_ARCH_RV32;
ptr_size = 4;
} else if (triple_tok_eq(s, n, "wasm32")) {