Suggestions for getting crc32c library working with CMAKE_OSX_ARCHITECTURES

Google’s crc32c library is pretty small and gives good performing crc32c implementations for arm and intel

It currently builds for Intel (everywhere) and arm on linux. My PR here gets it working for ARM on macOS

However it doesn’t work when using CMAKE_OSX_ARCHITECTURES=“arm64;x86_64” for a few reasons:

  • try_compile of the intel or arm intrinsics fails when compiling the other platform so they return false
  • if forced to true the arm compiler complains at being sent -msse4.2 for the intel file and the intel compile complains about the equivalent arm thing.

Does anyone have any good ideas of how to make a library like this work well?

Hmm. I’m not sure how to send arch-specific flags to a macOS fat binary compilation.

Cc: @brad.king @gjasny

You could use -Xarch_xyz like: -Xarch_i386 -fomit-frame-pointer. The best documentation I could find is here: DriverInternals.

Hope this helps!

1 Like

Ah. Note that in actual usage, you’ll likely need to let CMake know that these are compound options like "SHELL:-Xarch_i386 -fomit-frame-pointer".