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

Catalyst should use the .dylib file extension where appropriate for macOS builds #1347

Open
joeycarter opened this issue Nov 29, 2024 · 2 comments

Comments

@joeycarter
Copy link
Contributor

Catalyst uses the .so file extension for dynamic libraries on macOS in a few places (see below). We should rename these libraries so that they use the standard .dylib extension.

A few examples where we use the .so file extension (this is not necessarily an exhaustive list):

catalyst/setup.py

Lines 241 to 254 in 57bc011

class CustomBuildExtMacos(UnifiedBuildExt):
"""Custom build extension class for macOS platforms
In addition to the work performed by the base class UnifiedBuildExt, this
class also changes the LC_ID_DYLIB that is otherwise constant and equal to
where the shared library was created.
"""
def run(self):
# Run the original build_ext command
super().run()
# Construct library name based on ext suffix (contains python version, architecture and .so)
library_name = "libcustom_calls.so"

set_target_properties(catalyst_callback_registry PROPERTIES SUFFIX ".so")

set_target_properties(wrapper PROPERTIES SUFFIX ".so")

Be sure to update the relevant Makefile commands and build scripts as well, for example:

catalyst/Makefile

Lines 215 to 216 in 57bc011

clean-frontend:
find frontend/catalyst -name "*.so" -exec rm -v {} +

@dime10
Copy link
Contributor

dime10 commented Nov 29, 2024

What about renaming the .dylibs to .so instead? 😅 Would make the handling of our libraries very uniform

@joeycarter
Copy link
Contributor Author

@mlxd recommended this, since .dylib is the conventional file extension for dynamic libraries on macOS. I gather that on macOS there is a subtle difference between shared objects (which get the .so extension by convention) and dynamic libraries (which get the .dylib extension). If I understand correctly, we're creating dynamic libraries in our macOS builds, but giving some of them the .so file extension, so it's a slight misnomer. I think the argument for uniformity is a valid one, especially since there don't appear to be any issues with our macOS wheels shipped with .so files, so happy to discuss more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants