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

Release universal binaries for MacOS #4654

Open
jeroen opened this issue Jan 21, 2024 · 1 comment
Open

Release universal binaries for MacOS #4654

jeroen opened this issue Jan 21, 2024 · 1 comment

Comments

@jeroen
Copy link
Contributor

jeroen commented Jan 21, 2024

Currently you are releasing separate binaries for macos x86_64 and arm64, for example:

It is very easy on macos to merge two libraries into "univeral binaries", for example:

lipo -create x86_64/lib/libtiledb.dylib  arm64/lib/libtiledb.dylib -output universal/libtiledb.dylib

The resulting libtiledb.dylib contains both libs and can be linked on either architecture:

file universal/libtiledb.dylib
## universal/libtiledb.dylib: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [arm64]
## universal/libtiledb.dylib (for architecture x86_64):	Mach-O 64-bit dynamically linked shared library x86_64
## universal/libtiledb.dylib (for architecture arm64):	Mach-O 64-bit dynamically linked shared library arm64

Currently, the client application has to guess what platform it is targeting, which is tricky when we may be cross compiling, such that the host is different than target. For example tiledbsoma has this:

          if (CMAKE_OSX_ARCHITECTURES STREQUAL x86_64)
            SET(DOWNLOAD_URL "https://github.com/TileDB-Inc/TileDB/releases/download/2.19.0/tiledb-macos-x86_64-2.19.0-fa30a88a.tar.gz")
            SET(DOWNLOAD_SHA1 "089b3aa8a92df0bd5a8f7515ed8e5b6bacb5ab47")
          elseif (CMAKE_OSX_ARCHITECTURES STREQUAL arm64)
            SET(DOWNLOAD_URL "https://github.com/TileDB-Inc/TileDB/releases/download/2.19.0/tiledb-macos-arm64-2.19.0-fa30a88a.tar.gz")
            SET(DOWNLOAD_SHA1 "83acdc7529d50dcf293dbd6bbc81263856c7c74c")
          elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(AMD64|amd64)|(^i.86$)")
            SET(DOWNLOAD_URL "https://github.com/TileDB-Inc/TileDB/releases/download/2.19.0/tiledb-macos-x86_64-2.19.0-fa30a88a.tar.gz")
            SET(DOWNLOAD_SHA1 "089b3aa8a92df0bd5a8f7515ed8e5b6bacb5ab47")
          elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
            SET(DOWNLOAD_URL "https://github.com/TileDB-Inc/TileDB/releases/download/2.19.0/tiledb-macos-arm64-2.19.0-fa30a88a.tar.gz")
            SET(DOWNLOAD_SHA1 "83acdc7529d50dcf293dbd6bbc81263856c7c74c")
          endif()

Where we are supposed to set CMAKE_OSX_ARCHITECTURES manually when cross compiling. And then some more heuristics when building the R package. This is painful and error prone. If you just ship libtiledb as universal binaries you can get rid of all that, one library that will just work any macos hardware, even with cross compiling.

@eddelbuettel
Copy link
Member

Thanks for submitting the PR @jeroen and helping us with your build expertise. For TileDB as a whole there may be other issues at hand beyond the use by CRAN (which is the primary use case here) so the build team will take a look but as a first reaction a simplification and robustifcation seems welcome.

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