nvim-telescope / telescope-fzf-native.nvim

FZF sorter for telescope written in c
1.4k stars 46 forks source link

Fails to load on Apple silicon CPUs because libfzf.so is built only for Intel CPUs #119

Closed proofer closed 9 months ago

proofer commented 9 months ago

Workaround: run nvim under Rosetta (on the fly Intel to Apple silicon binary code translator). E.g., use the arch -x86_64 nvim ... command to start nvim.

Fix: in Makefile, add CFLAGS to build libfzf.so for the CPU architecture on which make is running; as in my fork's Makefile.

Conni2461 commented 9 months ago

see https://github.com/nvim-telescope/telescope-fzf-native.nvim/issues/79

currently the way the makefile is setup it should be enough to just do CFLAGS=-arch arm64 make or maybe even this works CFLAGS=-march=native make

i dont have mac, so i cant test any of this and provide a fix. Like back over a year ago i am happy to merge one :) i am just the wrong person to create one, as i have not the reasources to even test a single solution (m1 or intel based) ...

so yeah please open a PR if you have a working solution

proofer commented 9 months ago

I don't think CFLAGS=-arch arm64 make and similar would be a general solution -- it wouldn't work for Intel CPU Macs. CFLAGS += -march=native may work, but it bothers me that I can't find doc on native; do you have a pointer?

In my fork I inserted... ifeq ($(UNAME_S),Darwin) UNAME_P := $(shell uname -p) ifeq ($(UNAME_P),x86_64) CFLAGS += -arch x86-64 endif ifeq ($(UNAME_P)),arm) CFLAGS += -arch arm64 endif endif

I'm not sure it's the most elegant solution, especially if =natiive would work, but I don't yet know why it wouldn't work on any Mac. It works on my M2 Mac. I should be able to test it on an Intel Mac. Would a test on just those two systems be enough for a PR? Maybe I should note that any PR I open would be my first ever.

rywng commented 9 months ago

I don't think CFLAGS=-arch arm64 make and similar would be a general solution -- it wouldn't work for Intel CPU Macs. CFLAGS += -march=native may work, but it bothers me that I can't find doc on native; do you have a pointer?

https://wiki.gentoo.org/wiki/GCC_optimization#-march

or

https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gcc/AArch64-Options.html#index-march

The wiki says march=native works in GCC, but I'm not sure if apple's clang supports it, you can try it out.

I don't have a arm device to test, but the following works for me on a AMD64 CPU:

-- lazy.nvim config
    {
        'nvim-telescope/telescope-fzf-native.nvim',
        build = 'CFLAGS=-march=native make',
        lazy = true
    },
proofer commented 9 months ago

build = 'CFLAGS=-march=native make'

works on my Apple silicon Mac!