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

macOS Univeral binary for Intel & Apple Silicon #129

Open
jelmervdl opened this issue Jan 30, 2023 · 6 comments
Open

macOS Univeral binary for Intel & Apple Silicon #129

jelmervdl opened this issue Jan 30, 2023 · 6 comments

Comments

@jelmervdl
Copy link
Collaborator

I've been trying to make a universal binary for x86 and M1/2 hardware so we can distribute just one app for all of macOS. This issue is here for tracking findings.

Getting rid of CMAKE_BUILD_ARCH is necessary. Right now I'm stuck on cpuinfo not supporting it, because it does assume it is being built for a single architecture.

Command (and many changes to the CMake files so not entirely useful on its own):

cmake .. \
  -DGIT_SUBMODULE=Off \
  -DCMAKE_SYSTEM_NAME=Darwin \
  -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" \
  -DSPM_ENABLE_TCMALLOC=Off \
  -DSSPLIT_USE_INTERNAL_PCRE2=On \
  -DBUILD_EXTERNAL_LIBARCHIVE=On \
  -DICU_ROOT_DIR=(brew --prefix icu4c) \
  -DCMAKE_PREFIX_PATH=/Users/jelmer/Qt/6.2.2/macos \
&& ../cmake/fix_ruy_build.sh ../ ./ \
&& make -j8 translateLocally.dmg

Issues:
https://github.com/loongson/cpuinfo/blob/5d5348e000f91baa9849d7b30b22fce8a77ae3da/CMakeLists.txt#L167-L169

https://github.com/loongson/cpuinfo/blob/5d5348e000f91baa9849d7b30b22fce8a77ae3da/CMakeLists.txt#L55-L57

@XapaJIaMnu
Copy link
Owner

What if we have a separate binary? Would that be too bad? How is usually Apple software distributed?

@jelmervdl
Copy link
Collaborator Author

Usually universal binary. You never really have to choose which chipset you have when downloading stuff. Only open source stuff makes you choose. OBS would be a popular example. So it is not unheard of.

Apple itself is moving towards shipping stripped & pre-optimised binaries through their App Store but that's all automated and not really relevant for us right now.

@XapaJIaMnu
Copy link
Owner

So, should we open an issue on cpuinfo? What do we use cpuinfo for anyways? Setting the right cmake flags? Our usecase is to compile for generic architecture...

@jelmervdl
Copy link
Collaborator Author

ruy and fbgemm embed cpuinfo. I am able to compile an intel-only or arm-only version now.

My intuition now is that cpuinfo will probably need quite a bit of refactoring to support mutlicpu compilation (because they rely on cmake for defining cpu features…)

@XapaJIaMnu
Copy link
Owner

We can get rid of fbgemm since their models aren't compatible with multiple architecture... But not ruy... Maybe with onednn later..?

@jelmervdl
Copy link
Collaborator Author

Maybe indeed. My suggestion right now is to just deal with it at a later stage, and distribute an Apple Silicon build separately right now.

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

No branches or pull requests

2 participants