Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac M1 support #15

Closed
riccardobl opened this issue Jan 18, 2022 · 12 comments
Closed

Mac M1 support #15

riccardobl opened this issue Jan 18, 2022 · 12 comments
Labels
enhancement New feature or request

Comments

@riccardobl
Copy link

M1 support should be available in gradle since version 7.
Bullet should compile and work, since it is already compatible with linux arm64, my understanding is that the build script needs to be modified to include a target for

 architecture 'aarch64'
 operatingSystem 'osx'

I don't know how to do it, but if someone does i can test.

@stephengold
Copy link
Owner

Indeed, I was planning to investigate this after JME 3.5.0 is done.

A solution to this issue should ideally include continuous integration to build and test the native libraries, but none of my current CI providers (GitHub Actions, TravisCI, Appveyor) offers Mac-on-ARM hosts. Do you know one that does? (Preferably one that's free for open-source projects.)

Upgrading the project to Gradle 7 will be tricky. I tried once before and gave up, so I hope it's not necessary.

@stephengold stephengold added the enhancement New feature or request label Jan 18, 2022
@riccardobl
Copy link
Author

Do you know one that does?

I don't, but x86_64 mac can crosscompile to arm64 (aarch64) if the target platform is provided, so i guess it will just work if configured in gradle.

@stephengold
Copy link
Owner

That's fine for building natives, but I also want to test them.

@stephengold
Copy link
Owner

I started my investigation in the new "gradle7" branch. Gradle 7 builds work fine (aside from some Gradle warnings) for all platforms except MacOSX_ARM64, which was skipped when I expected it to be built. I suspect that's because this project still uses the "cpp" plugin (incubated in Gradle 4) instead of the "cpp-library" plugin (from Gradle 5+). Probably the "cpp" plugin hasn't been updated to cross-compile using XCode.

Perhaps I can work around this without switching plugins...

@stephengold
Copy link
Owner

Got stuck on a Gradle crash:

A problem occurred configuring root project 'Libbulletjme'.
> Exception thrown while executing model rule: NativeBinaryRules#assignTools(NativeBinarySpec, NativeToolChainRegistryInternal, ProjectLayout)
   > A problem occurred starting process 'command 'xcrun''

Will try migrating to the "cpp-library" plugin...

@stephengold
Copy link
Owner

Apparently Gradle v7.3.3 only knows 2 values for class MachineArchitecture: X86 and X86_64!

@riccardobl
Copy link
Author

It seems cpp-library doesn't have support for cross compilation to arm: gradle/gradle-native#989

Is it possible to inject "-arch arm64" for clang using the old cpp plugin ? Maybe that could work?

Also i guess you are testing this on the CI, is it using the last xcode version ?

@stephengold
Copy link
Owner

Thanks for the link to issue 989.

I'm still pursuing multiple approaches. I've been using Xcode 13.2.1.

@stephengold
Copy link
Owner

I've found a mechanism in the "cpp" plugin to inject command-line args into Gcc and Clang toolchains, like so:

        clangArm64(Clang) {
            target('MacOS_ARM64') {
                cppCompiler.arguments('-arch arm64')
                linker.arguments('-arch arm64')
            }
        }

The catch is that the "cpp" plugin doesn't allow the macOS hosts I'm using to build for target platforms with "arm64" or "aarch64" architecture, though it allows them to build for both "x86" and "x86_64". "cpp" doesn't place such restrictions on Linux hosts.

@stephengold
Copy link
Owner

I've found a mechanism

Actually that doesn't work. Cross-compiling in Gradle is hard, especially for me with my ignorance of the Groovy language.

I'll add a target to "build.gradle" so you can try building your own natives on a Mac M1. However, I can't guess when pre-built native libraries will be available.

@stephengold
Copy link
Owner

I discovered a 3rd-party plugin that might help: https://docs.nokee.dev

@stephengold
Copy link
Owner

stephengold commented Mar 29, 2022

Native libraries for MacOSX_ARM64 became available on 2 March 2022, with the release of Libbulletjme 14.0.0 .
They were added to Minie at 04178cf5cd15e8200088e4cd4390d90723567c01 .
Support for Minie on MacOSX_ARM64 platforms became generally available on 20 March 2022, with the release of Minie v4.8.0 .
Note that, for native physics to work on JME, v3.5.1-stable (or later) is required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants