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

Move /opt before /usr to search for M1 native libs first - solve the conflicts when both x64 and arm64 libs installed #936

Closed

Conversation

southwolf
Copy link

This is trying to solve
#880 (comment)

In apple silicon machines, when both versions are installed, the native arm64 libs ('/opt/local/lib/') should be the first option, and x64 ('/usr/local/lib/') as a failsafe fallback only when arm64 version is not available.

In my case: I've installed both x64 & arm64 version of glib, but ffi found x64 and then stopped, giving up to try /opt ones
image

While placing /opt before /usr/local

image

@notjulian
Copy link

Hi @southwolf,
with this, or #941, it is possible to use this lib without rosetta, natively?

thanks

PS: I use it with react native

@southwolf
Copy link
Author

Hi @notjulian yes that is the purpose of this PR. If you have installed native ARM64 libraries, it will use native libs first

@ronaldtse
Copy link

Thank you @southwolf for this!

Can a project maintainer look at this? (ping @larskanis) It is a necessary step for using the ffi gem on Apple M1 natively -- which applies to nearly the full Mac line up today. Thanks!

@chinyakao
Copy link

chinyakao commented Apr 30, 2022

Thank you @southwolf !

Could project maintainer (@larskanis) updated this? :)
It is very necessary for MacOs M1 user.
Thank you so much!

@southwolf
Copy link
Author

@larskanis @Kerilk Hi ffi maintainers could you please take some time to review and merge this PR as a temporary solution if no better one available?

More and more people are asking about the Apple Silicon compatibility issue. Thanks!

@rainyjonne
Copy link

@larskanis @Kerilk Hi we really need this solution to work... my thesis is burning on fire QQ
Please take time to look at this!

@Kerilk
Copy link
Contributor

Kerilk commented May 9, 2022

@rainyjonne, @southwolf I am not a maintainer and shared libraries are not my subject of predilection, but I'll just throw my two cents here:

The change you propose is impacting most platforms and can break the existing workflow of many. If those are indeed required for this specific platform, I would add a conditional for it, using this directory order only on those specific M1 Macs. You may need to add additional detection mechanisms to: https://github.com/ffi/ffi/blob/master/lib/ffi/platform.rb

@southwolf
Copy link
Author

@Kerilk Thanks for pointing out! Agree with your point, but I didn't do that because in most cases people just use /usr/local as default installation path, /opt is only seen in MacOS + Apple Silicon scenarios AFAIK. Another reason I made a quick fix instead of a thorough solution is that maintainers of the library just ignored this PR (and all other related PRs/issues) without responses, so maybe I'll just leave it there as a temporary workaround or FYI.

@eregon
Copy link
Collaborator

eregon commented Jun 6, 2022

Another reason I made a quick fix instead of a thorough solution is that maintainers of the library just ignored this PR (and all other related PRs/issues) without responses, so maybe I'll just leave it there as a temporary workaround or FYI.

A proper solution would have a good chance to be merged. A hack/incompatibility like this will be ignored.
So far we see many macOS M1 users just wanting a hack after another, and not owning the additional complexity that Apple adds with 2-arch machines (which TBH I wish would not exist, it just invites developers to break their dev env too easily).
This is annoying, e.g., because it's spamming me.
It looks like M1 owners just expect maintainers have infinite time to try to fix their problems, but don't spend themselves the time for a proper solution.

So, a proper solution here is to add the Homebrew aarch64 path earlier, but only if the current process is aarch64. If it's amd64 or non-macOS, nothing should change.

Copy link
Collaborator

@eregon eregon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's reject this because it breaks other platforms needlessly.
#965 avoids the problem to affect other platforms.
#880 (comment) is about finding a correct and generic solution so the order hardly matters anymore.

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

Successfully merging this pull request may close these issues.

None yet

7 participants