Skip to content

Commit 6aff4f5

Browse files
authored
Add powerpc64 and mips32 architecture support (#170)
* Add powerpc64 and mips32 architecture support Add startup code for powerpc64le (ELFv2 ABI) and mipsel (O32 ABI) targets, enabling no_std programs to run on these architectures. PowerPC64 (powerpc64.rs): - _start sets up r2 (TOC pointer) using r12 before calling entry - trap() uses the `trap` instruction - Full thread support scaffolding (clone, thread pointer, TLS) - Relocation support for PIC binaries MIPS32 (mips32.rs): - __start entry point (MIPS convention, not _start) - 8-byte stack alignment with 16-byte O32 save area - trap() uses the `break` instruction - Thread support using rdhwr for thread pointer - Syscall convention: $v0=syscall#, $a0-$a3=args, $a3=error flag Both architectures: - Implement origin-start feature for program startup - Support optimize_for_size feature - Follow existing origin patterns from other architectures Tested with QEMU user-mode emulation (qemu-ppc64le-static, qemu-mipsel-static). Note: QEMU ppc64le has a bug with argv setup for non-glibc binaries, but the startup code itself is correct and works on real hardware. * Fix rustfmt: remove extra blank line in mips32.rs That blank line was apparently living rent-free between __start and trap. * Fix misleading comment about MIPS entry points We only define __start, not both. The comment was aspirational fiction. * Simplify mprotect syscall: remove unused r0 output The syscall return value was just sitting there looking decortaive. We only need the error flag from $a3. Note: MIPS cross-compilation is not available on this dev machine, letting CI handle the actual build verification. * Use symbolic constant for __NR_set_thread_area Magic numbers... Now using the proper constant from linux_raw_sys like civilized folk. * Fail explicitly for unsupported clone flags on MIPS O32 ABI requires child_tid (5th arg) on stack, which we don't do. Check for CLONE_CHILD_CLEARTID/SETTID upfront and return EOPNOTSUPP. * Trim verbose clone() comment in powerpc64.rs MIPS got the concise treatment, PPC64 was feeling left out. * Document which architectures aren't tested in CI Added a note about arm, powerpc64, and mips32 not being in CI, along with the reasons why (missing rust-std, crate support gaps, and a branch that got lost in the shuffle).
1 parent 17031bc commit 6aff4f5

4 files changed

Lines changed: 796 additions & 0 deletions

File tree

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@ using nightly Rust, enable the feature "nightly" to let origin use nightly-only
3333
features, which include proper support for unwinding, better safety checks, and
3434
better optimizations.
3535

36+
Origin supports multiple architectures: x86-64, x86, aarch64, arm (32-bit),
37+
riscv64, powerpc64, and mips32. The arm, powerpc64, and mips32 ports are not
38+
tested in CI, for reasons that range from "Rust doesn't ship binaries for that"
39+
to "that one crate doesn't support this arch yet":
40+
41+
- **mips32**: rust-std isn't available for download. CI would need `-Zbuild-std`
42+
to build the standard library from source, which is nightly-only.
43+
44+
- **powerpc64**: On stable, rustix uses the libc backend which is missing the
45+
runtime module for signal handling. On nightly, the `unwinding` crate hasn't
46+
caught up with ppc64 yet.
47+
48+
- **arm (32-bit)**: CI setup exists on a branch somewhere, waiting to be merged.
49+
3650
## Example crates
3751

3852
Origin can also be used on its own, in several different configurations:

0 commit comments

Comments
 (0)