Skip to content

Add PowerPC Tiger port (Mac OS X 10.4) - #13

Merged
danifunker merged 1 commit into
danifunker:mainfrom
Scottcjn:ppc-tiger-port
Mar 11, 2026
Merged

danifunker merged 1 commit into
danifunker:mainfrom
Scottcjn:ppc-tiger-port

Conversation

@Scottcjn

Copy link
Copy Markdown

Summary

Native C port of rusty-backup for PowerPC Macs running Mac OS X Tiger (10.4.x). All source lives in ppc-tiger/ — no changes to existing Rust code.

  • 58KB Mach-O binary runs on G3/G4/G5 Macs
  • Full feature parity: MBR, APM, EBR chain, gzip, CRC32, SHA-1, FAT compaction
  • Carbon GUI frontend with native Aqua widgets
  • Build script for gcc-4.0 (Xcode 2.x)
  • Compatible metadata.json format — backups are interchangeable

What's included

File Purpose
rust_cli_real.c (2,251 lines) Complete CLI — backup, restore, inspect, list-devices, rip
rusty_backup_gui.c (853 lines) Carbon GUI with progress bars and file pickers
rust_runtime_v2.c (182 lines) Runtime symbol stubs
build.sh One-command build script
Info.plist .app bundle metadata
README.md Build and usage instructions

FAT compaction example

Backing up partition 0 (FAT16, 4.0 MiB)...
  [compact] 7/2020 clusters allocated (99.7% savings)
  [compact] Output: 32256 bytes (was 4162048, saved 4129792)

Tested on

  • Dual G4 Power Mac, Mac OS X Tiger 10.4.11
  • All 4 internal disks detected with correct sizes
  • Backup/restore round-trip verified (MD5 match)
  • APM partition table correctly parsed
  • Gzip compression + decompression verified

Related: #10

Test plan

  • list-devices shows all disks with sizes
  • backup with MBR image — partitions detected, data copied
  • backup --compression gzip — gzip output verified
  • backup --checksum crc32 — CRC32 sidecar written
  • backup --checksum sha1 — SHA-1 sidecar written
  • FAT compaction — 99.7% savings on sparse FAT16 image
  • --sector-by-sector — bypasses compaction correctly
  • restore from gzip backup — decompresses automatically
  • inspect — displays metadata with human-readable sizes
  • Real device backup (APM/HFS+ disk) — streaming works
  • --version shows 0.3.0-ppc with feature list

🤖 Generated with Claude Code

Native C reimplementation of rusty-backup for PowerPC Macs running
Mac OS X Tiger. Produces a 58KB Mach-O binary with full feature parity:

- MBR/APM/EBR partition table support
- Gzip compression via zlib
- CRC32 and SHA-1 checksums
- FAT12/16/32 compaction (only backs up allocated clusters)
- Carbon GUI frontend with progress bars
- Gzip-aware restore (decompresses .gz files automatically)

Tested on Dual G4 Power Mac with Tiger 10.4.11.
Built with gcc-4.0 from Xcode 2.x.

Created with rust-ppc-tiger transpiler.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@danifunker
danifunker merged commit b3617c3 into danifunker:main Mar 11, 2026
@danifunker

Copy link
Copy Markdown
Owner

Merged, I'd like to see ext2/3/4 and btrfs working on here as well, along with exfat and ntfs. All of the filesystem access should be managed within the application itself.

danifunker added a commit that referenced this pull request May 19, 2026
  * Adds `rb-cli inspect IMG` (verb #13): whole-disk aggregate view
    using `PartitionTable::detect` + `PartitionInfo::type_name`,
    with optional CHD info appended. Supports --format text/json/yaml
    via the shared Envelope schema. Phase B/C extend to per-partition
    volume info via open_filesystem.

  * Reshapes `put` to keep cp-like positional ordering working when
    --zero / --boot aren't in play, and adds an explicit `--dst FLAG`
    for the --zero case. Two positional slots couldn't disambiguate
    "host_file vs dst" when --zero pulled host_file out of scope.

  * tests/cli_flat.rs (7 e2e tests against the flat grammar): new /
    put / mkdir / get / ls / rm / fsck --checkonly round-trip,
    put --boot byte-exactness, --format json envelope shape,
    IMG@0 rejection, rm on nonexistent path, completions emit a
    non-empty script for every supported shell, inspect runs on a
    raw HFS image.

  * tests/cli_help_snapshot.rs (6 grammar-drift tripwires): asserts
    the documented verb names + global flags + show subcommands +
    put modes + fsck modes + new --fs values are present in
    --help. Any rename fires the corresponding assert.

  * example/generate_manpage.rs: clap_mangen-based manpage generator
    for packagers. Emits OUT_DIR/rb-cli.1. Wired as a Cargo
    [[example]] so packaging recipes can `cargo run --example
    generate_manpage -- $DESTDIR/usr/share/man/man1`.

Phase A complete. All 959 lib + 118 integration tests green.
danifunker added a commit that referenced this pull request Jul 31, 2026
`scripts/build-ppc.sh ppclibs` has never set MINICARGO_NO_DEBUG_ASSERTIONS,
so every stdlib it produced aborted before main:

    thread panicked while processing panic. aborting.
    Abort trap (exit 134)

`debug_assertions` switches on libcore's `assert_unsafe_precondition!`, which
asserts a Rust-level invariant this target's C ABI cannot satisfy. Under the
Darwin/PowerPC "power" alignment rule a member that is not first is capped to
4, so `std::thread::Inner` lays out as

    Option<CString> @0 | Parker @8 (76 bytes) | ThreadId @84

with ALIGNOF(Inner) == 4 while ThreadId's own alignment is 8. `ArcInner` puts
Inner at +8, so `id` lands at +92 and `ptr::write`'s precondition fails inside
`Thread::new`. `std::rt::init` calls it, and the panic hook then reads the
current thread's name - reaching `Thread::new` a second time - so the first
panic becomes a double panic and aborts. gdb on the G5:

    #21 std::rt::init
    #20 std::thread::Thread::new       <- panic_nounwind
    #13 std::panicking::default_hook
    #8  std::thread::Thread::new       <- again, during the hook
    #1  abort

The emitted C is correct - gcc agrees with mrustc's layout and every
sizeof/alignof assertion compiles - only the Rust-level assertion disagrees.
docs/build-ppc-mrustc.md has documented the flag and the reason since the
stdlib first came up; the script simply never carried it over, and the one
binary that worked was a stale artifact built by the hand-run command in
those docs.

Verified end-to-end: wipe output-1.74.0-powerpc-apple-darwin, rebuild through
the script with no environment override, then a hello-world compiled *with*
`--cfg debug_assertions` (matching the engine) runs on the G5:

    hello from powerpc
    vec [0, 1, 2, 3, 4] sum 10
    exit=0

Also carries the sync_rustc_src_patch guard: a branch switch refreshes
rustc-<ver>-src.patch's mtime without changing its content, which made
minicargo.mk re-apply it to an already-patched tree and fail the build.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants