Closed haubna closed 2 years ago
Shouldn't be hard (at least for x86, M1 might be a different story), but I don't have a Mac so I can't compile the native libraries for that.
I have no Mac either :/
I have a Mac, but it uses the M1 chip, if that's OK, what exactly do I compile?
Unfortunately, it's not only running the compiler but also writing the CMake scripts for the JNI MacOS target. In case you wanna trry that you need to create a new compiler preset XML in PhysX/physx/buildtools/presets/public
and then the actual CMake scripts in PhysX/physx/source/compiler/cmake/jni_mac
.
That said, I'm not going to accept PRs with native libraries I can't compile myself (because I wouldn't be able to keep them up-to-date with any future updates)
Is there a way I can be notified if someone forks this for ARM64 macOS?
I guess if anyone is willing to do that he/she will comment on this issue (or I will). You should get a notification then.
I can do it for M1 (maybe)
Why not have the stuff there so people can compile it for macos themselves? Sure, it's a bit of an inconvenience for people with macOS, but at least they can do it. Also, curious, why does it need to be compiled specifically for a given operating system? I thought java runs in it's own VM.
Why not have the stuff there so people can compile it for macos themselves?
That's the problem: "The stuff" (JNI-wrapper specific CMake build scripts) does not yet exist for Mac.
Also, curious, why does it need to be compiled specifically for a given operating system? I thought java runs in it's own VM.
That is true for pure Java programs. This library, however, provides Java bindings for nvidia PhysX, which is a C++ library. This means the PhysX code itself needs to be compiled for the target operating system, so that it can be loaded by the Java VM.
Unfortunately, it's not only running the compiler but also writing the CMake scripts for the JNI MacOS target. In case you wanna trry that you need to create a new compiler preset XML in
PhysX/physx/buildtools/presets/public
and then the actual CMake scripts inPhysX/physx/source/compiler/cmake/jni_mac
.
I might be able to help with this. The existing CMake scripts between Linux and Mac are rather similar, so I assume the CMake scripts for JNI targets should be similar too.
The problem though, is that I'm really not good with CMake, and haven't used Java and C for a long time. But at least I think I can start a PR to try to incubate it.
That said, I'm not going to accept PRs with native libraries I can't compile myself (because I wouldn't be able to keep them up-to-date with any future updates)
Would a workflow for GitHub actions or a virtual machine help with this problem?
I might be able to help with this. The existing CMake scripts between Linux and Mac are rather similar, so I assume the CMake scripts for JNI targets should be similar too.
Yes, I think so. For the existing jni build scripts for Windows and Linux I simply took the regular ones and only modified them to include the JNI specific stuff.
That said, I'm not going to accept PRs with native libraries I can't compile myself (because I wouldn't be able to keep them up-to-date with any future updates)
Would a workflow for GitHub actions or a virtual machine help with this problem?
Ah, I assumed there are no github runners for macos, but apparently I was wrong, so that might work. A virtual machine should also work, but at least the macos instances available via AWS are quite expensive.
Yes, I think so. For the existing jni build scripts for Windows and Linux I simply took the regular ones and only modified them to include the JNI specific stuff.
Ah, I assumed there are no github runners for macos, but apparently I was wrong, so that might work.
If it's ok with you, I think I can start a PR with CMake scripts along with a new workflow.
A virtual machine should also work, but at least the macos instances available via AWS are quite expensive.
The Passthrough Post has a good tutorial for setting up a macOS VM on Linux. I think this might be helpful, since a local VM should be a lot cheaper than a cloud-hosted one (mostly just electricity cost). Although, one potential problem is that unless your computer uses any of those GPUs that support Metal (mostly AMD GPUs and a few old (pre-2013) Nvidia GPUs), the graphics in the VM will be glitchy.
If it's ok with you, I think I can start a PR with CMake scripts along with a new workflow.
Yes sure, go for it!
I also might try the local VM approach
Alright, the VM works surprisingly well (although it's painfully slow) and I managed to compile the native libs for macOS. For now the libs are targeting x86-64 and not Apple Silicon / M1, but as far as I know x86 code works on Apple Silicon as well.
Native M1 support is probably not feasible until Nvidia adds that to PhysX and I don't know when / if that will happen.
Anyway, I just published version 0.4.13 containing the macOS libs.
Much appreciated! Thanks :)
Apologies for continuing on a closed issue.
Alright, the VM works surprisingly well (although it's painfully slow) and I managed to compile the native libs for macOS. For now the libs are targeting x86-64 and not Apple Silicon / M1, but as far as I know x86 code works on Apple Silicon as well.
Anyway, I just published version 0.4.13 containing the macOS libs.
I saw that you added CMake scripts for macOS JNI target, so I just wanted to confirm that I don't need to submit a PR for it anymore, right?
Native M1 support is probably not feasible until Nvidia adds that to PhysX and I don't know when / if that will happen.
I think native M1 support should be possible without anything from Nvidia. Since PhysX can be built using Clang for Linux aarch64, it should already be buildable for M1. Maybe passing -target aarch64-apple-darwin20.0.0
("20.0.0" points to macOS 11, and probably can be omitted) to Clang can enable cross-compilation to M1.
I saw that you added CMake scripts for macOS JNI target, so I just wanted to confirm that I don't need to submit a PR for it anymore, right?
Yes, sorry in case you already invested work into it...
I think native M1 support should be possible without anything from Nvidia. Since PhysX can be built using Clang for Linux aarch64, it should already be buildable for M1. Maybe passing
-target aarch64-apple-darwin20.0.0
("20.0.0" points to macOS 11, and probably can be omitted) to Clang can enable cross-compilation to M1.
Could be worth a try. However, the code uses a lot of SIMD / SSE instructions which probably won't work on M1. It's possible to disable SIMD (by defining PX_SIMD_DISABLED
) but that costs performance. On the other hand x86 emulation on M1 also costs performance.
Any plans on macOS support in the future?