feat(verify): ABI checks on arm64, riscv64 and loong64

Assisted-by: GLM 5.3 Flash
This commit is contained in:
2026-08-30 11:27:54 +02:00
parent 6d7f10f13e
commit 8f84dac10b
19 changed files with 710 additions and 138 deletions
+36 -15
View File
@@ -185,6 +185,22 @@ func newCommand(name, usageLine, long string) *flag.FlagSet {
}
// readSource returns the contents of path, or stdin when path is "-".
// hostArch maps the running GOARCH onto the arch package's identifiers.
// It returns arch.Unknown on hosts the toolkit cannot JIT for.
func hostArch() arch.Arch {
switch runtime.GOARCH {
case "amd64":
return arch.AMD64
case "arm64":
return arch.ARM64
case "riscv64":
return arch.RISCV
case "loong64":
return arch.LOONG64
}
return arch.Unknown
}
func readSource(path string) (string, error) {
if path == "-" {
b, err := io.ReadAll(os.Stdin)
@@ -1065,21 +1081,26 @@ decoders) that crash on random input but should succeed on valid data.
}
path := set.Arg(0)
targetArch := arch.FromFilename(path)
switch targetArch {
case arch.AMD64:
// JIT-based verification below.
case arch.RISCV:
// RISC-V: ground-truth only (no JIT on non-RISC-V hosts).
return cmdVerifyRISCV(path, *groundTruth, *profile)
case arch.LOONG64:
// LoongArch: ground-truth only (no JIT on non-LoongArch hosts).
return cmdVerifyLOONG64(path, *groundTruth, *profile)
case arch.ARM64:
// AArch64: ground-truth only (no JIT on non-ARM64 hosts).
return cmdVerifyARM64(path, *groundTruth, *profile)
default:
fmt.Fprintln(os.Stderr, "gasm verify: unsupported architecture")
return 1
// JIT execution requires the host CPU to match the kernel's
// architecture; on any other host only the toolchain comparisons run.
if targetArch != hostArch() {
switch targetArch {
case arch.RISCV:
// RISC-V: ground-truth only (no JIT on non-RISC-V hosts).
return cmdVerifyRISCV(path, *groundTruth, *profile)
case arch.LOONG64:
// LoongArch: ground-truth only (no JIT on non-LoongArch hosts).
return cmdVerifyLOONG64(path, *groundTruth, *profile)
case arch.ARM64:
// AArch64: ground-truth only (no JIT on non-ARM64 hosts).
return cmdVerifyARM64(path, *groundTruth, *profile)
case arch.AMD64:
fmt.Fprintln(os.Stderr, "gasm verify: JIT-based checks need an amd64 host; use --ground-truth here")
return 1
default:
fmt.Fprintln(os.Stderr, "gasm verify: unsupported architecture")
return 1
}
}
k, err := verify.Load(path)