sonos / dinghy

Easier cross-compilation for phones and single boards computers
Other
365 stars 44 forks source link

Add macOS M1 binary to release CI #200

Closed simlay closed 9 months ago

simlay commented 1 year ago

Was using cargo-binstall on CI with an M1 runner and it failed because the released CLI is built for intel macs. I'm not sure how binstall does it but they have a universal binary.

It'd be nice if aarch64-apple-darwin was there as well.

I might get around to doing this myself.

briansmith commented 9 months ago

I'm not sure how binstall does it but they have a universal binary.

cargo build --release --target=aarch64-apple-darwin && cargo build --release --target=x86_64-apple-darwin, then use lipo to merge them together into the universal binary. See their PR: https://github.com/cargo-bins/cargo-binstall/pull/551, which makes it look straightforward.

From the users' point of view, a universal binary would be preferrable to separate ARM and x86-64 binaries, since it would allow users to avoid some conditional logic in their build scripts / CI configuration.

briansmith commented 9 months ago

My experience in GitHub Actions is that the prebuilt cargo-dignhy binary version 0.6.2 (presumably x86_64-only) works fine for macos-12 (x86_64) runners, and it runs on macos-14 (arm64) runners. However, it fails with error thread 'main' panicked at 'Failed to get the exit status line from lldb: "(lldb) command source -s 0.

So basically, the prebuilt release cannot be used from a macos-14 runner in GitHub Actions. To work around this, I used cargo install --version 0.6.2; the cargo installed version worked fine. See https://github.com/rust-random/getrandom/pull/398.

``` Run cargo dinghy -p auto-ios-aarch64-sim -d 9F4E44B4-1F31-4AD1-ADFC-F6F9E196B07D test Targeting platform auto-ios-aarch64-sim and device 9F4E44B4-1F31-4AD1-ADFC-F6F9E196B07D Compiling libc v0.2.153 Compiling cfg-if v1.0.0 Compiling getrandom v0.2.[12](https://github.com/rust-random/getrandom/actions/runs/7979193242/job/21786032976#step:7:13) (/Users/runner/work/getrandom/getrandom) Finished test [unoptimized + debuginfo] target(s) in 19.47s Running unittests src/lib.rs (target/aarch64-apple-ios-sim/debug/deps/getrandom-98dae7d7b808a7aa) Installing getrandom-98dae7d7b808a7aa to 9F4E44B4-1F31-4AD1-ADFC-F6F9E196B07D Running getrandom-98dae7d7b808a7aa on 9F4E44B4-1F31-4AD1-ADFC-F6F9E196B07D thread 'main' panicked at 'Failed to get the exit status line from lldb: "(lldb) command source -s 0 '/var/folders/1k/qq3pcbf12vb6vyblh8[17](https://github.com/rust-random/getrandom/actions/runs/7979193242/job/21786032976#step:7:18)36p40000gn/T/mobiledevice-rs-lldb.3TdjnShyoMZI/lldb-script'\nExecuting commands in '/var/folders/1k/qq3pcbf12vb6vyblh81736p40000gn/T/mobiledevice-rs-lldb.3TdjnShyoMZI/lldb-script'.\n(lldb) attach 9993\n"', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/dinghy-lib-0.6.2/src/ios/device.rs:461:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ```