From ee0e800b1e4cff01ff8db647c68447ec93e821cf Mon Sep 17 00:00:00 2001 From: Random-Scientist Date: Sat, 18 Apr 2026 16:56:52 -0700 Subject: [PATCH] ship darwin x86_64 natives --- common/build.gradle | 13 +++++++++++-- common/src/main/rust/Dockerfile | 1 + common/src/main/rust/rapier/.cargo/config.toml | 4 ++++ common/src/main/rust/rapier/Cargo.toml | 6 +++++- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/common/build.gradle b/common/build.gradle index 2bc1987..7068b49 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -57,7 +57,7 @@ tasks.register('compileRust', Exec) { finalizedBy copyRustNativesDev } -tasks.register('compileRustMac', Exec) { +tasks.register('compileRustMacAArch64', Exec) { group = 'rust' workingDir rustProjectDir commandLine dockerCommand @@ -65,6 +65,14 @@ tasks.register('compileRustMac', Exec) { dependsOn createContainersDirectory } +tasks.register('compileRustMacX86', Exec) { + group = 'rust' + workingDir rustProjectDir + commandLine dockerCommand + args 'cargo', 'zigbuild', '--release', '--target', 'x86_64-apple-darwin' + dependsOn createContainersDirectory +} + tasks.register('compileRustLinuxAArch64', Exec) { group = 'rust' workingDir rustProjectDir @@ -93,7 +101,7 @@ tasks.register('buildRustNatives') { group = 'build' description = 'Compiles all Rust natives and moves them to resources.' - dependsOn compileRustMac, compileRustLinux, compileRustLinuxAArch64, compileRustWindows + dependsOn compileRustMacAArch64, compileRustMacX86, compileRustLinux, compileRustLinuxAArch64, compileRustWindows finalizedBy copyRustNatives } @@ -105,6 +113,7 @@ tasks.register('copyRustNatives', Copy) { def moves = [ [src: "target/aarch64-apple-darwin/release/libsable_rapier.dylib", dest: "sable_rapier_aarch64_macos.dylib"], + [src: "target/x86_64-apple-darwin/release/libsable_rapier.dylib", dest: "sable_rapier_x86_64_macos.dylib"], [src: "target/x86_64-unknown-linux-gnu/release/libsable_rapier.so", dest: "sable_rapier_x86_64_linux.so"], [src: "target/aarch64-unknown-linux-gnu/release/libsable_rapier.so", dest: "sable_rapier_aarch64_linux.so"], [src: "target/x86_64-pc-windows-gnu/release/sable_rapier.dll", dest: "sable_rapier_x86_64_windows.dll"] diff --git a/common/src/main/rust/Dockerfile b/common/src/main/rust/Dockerfile index 0489ade..5c50f72 100644 --- a/common/src/main/rust/Dockerfile +++ b/common/src/main/rust/Dockerfile @@ -8,5 +8,6 @@ RUN rustup target add x86_64-pc-windows-gnu RUN rustup target add aarch64-apple-darwin RUN rustup target add x86_64-unknown-linux-gnu RUN rustup target add aarch64-unknown-linux-gnu +RUN rustup target add x86_64-apple-darwin WORKDIR / diff --git a/common/src/main/rust/rapier/.cargo/config.toml b/common/src/main/rust/rapier/.cargo/config.toml index f722478..d9d6d37 100644 --- a/common/src/main/rust/rapier/.cargo/config.toml +++ b/common/src/main/rust/rapier/.cargo/config.toml @@ -1,2 +1,6 @@ [target.x86_64-pc-windows-gnu] rustflags = ["-C", "link-arg=-Wl,-Brepro"] + +[target.x86_64-apple-darwin] +# Required to avoid a rustc hang when building for this target. +rustflags = ["-C", "codegen-units=2"] diff --git a/common/src/main/rust/rapier/Cargo.toml b/common/src/main/rust/rapier/Cargo.toml index 14f4f69..5ccfebb 100644 --- a/common/src/main/rust/rapier/Cargo.toml +++ b/common/src/main/rust/rapier/Cargo.toml @@ -5,7 +5,10 @@ edition = "2021" [dependencies] jni = "0.21.1" -rapier3d = { git = "https://github.com/ryanhcode/rapier", rev = "a728067629d4f85cef99f388e12c9b0ee8cd1164", features = ["simd-nightly", "parallel"] } +rapier3d = { git = "https://github.com/ryanhcode/rapier", rev = "a728067629d4f85cef99f388e12c9b0ee8cd1164", features = [ + "simd-nightly", + "parallel", +] } #rapier3d = { version = "0.26.1", features = [ "simd-stable" ] } log = "0.4.22" fern = { version = "0.6.2", features = ["colored"] } @@ -31,4 +34,5 @@ harness = false criterion = "0.8.2" [profile.release] +lto = "thin" codegen-units = 1