noib3 / nvim-oxi

:link: Rust bindings to all things Neovim
https://crates.io/crates/nvim-oxi
MIT License
902 stars 45 forks source link

Build issue on aarch64 Macos #175

Closed zdcthomas closed 4 months ago

zdcthomas commented 4 months ago

Hi! I'm not sure if this is at all related to this crate, but I wanted to see if you had any thoughts about it either way. I'm seeing a new error, even though I don't think I've changed anything, here's the error

error: linking with `/nix/store/xzhppl1kydagd12hpymdr077in85015c-clang-wrapper-16.0.6/bin/cc` failed: exit status: 1
  |
  = note: env -u IPHONEOS_DEPLOYMENT_TARGET -u TVOS_DEPLOYMENT_TARGET LC_ALL="C" PATH="/nix/store/v1d55z24gf9lm1rawy2g8nfbg558y7r2-rust-nightly-com>
  = note: Undefined symbols for architecture arm64:
            "_nvim_buf_del_keymap", referenced from:
                nvim_oxi_api::buffer::Buffer::del_keymap::hd9f8542644d643b4 in libnvim_oxi_api-1810259784ad2574.rlib(nvim_oxi_api-1810259784ad2574.>
            "_nvim_set_keymap", referenced from:
                nvim_oxi_api::vim::set_keymap::h8728ff711adbca21 in libnvim_oxi_api-1810259784ad2574.rlib(nvim_oxi_api-1810259784ad2574.nvim_oxi_ap>
            "_luv_loop", referenced from:
                nvim_oxi_libuv::loop::init::h1cf99579f43be02f in libnvim_oxi_libuv-53f5f9439c8e56aa.rlib(nvim_oxi_libuv-53f5f9439c8e56aa.nvim_oxi_l>
            "_nvim_buf_set_keymap", referenced from:
                nvim_oxi_api::buffer::Buffer::set_keymap::h59fbaafc7f1c8fdf in libnvim_oxi_api-1810259784ad2574.rlib(nvim_oxi_api-1810259784ad2574.>
            "_nvim_notify", referenced from:
                nvim_oxi_api::vim::notify::hf21af98bdd3e6a47 in libnvim_oxi_api-1810259784ad2574.rlib(nvim_oxi_api-1810259784ad2574.nvim_oxi_api.f2>
            "_nvim_get_keymap", referenced from:
                nvim_oxi_api::vim::get_keymap::h55874fd420b01b62 in libnvim_oxi_api-1810259784ad2574.rlib(nvim_oxi_api-1810259784ad2574.nvim_oxi_ap>
            "_nvim_get_current_buf", referenced from:
                nvim_oxi_api::vim::get_current_buf::hfd7904501a7c055c in libnvim_oxi_api-1810259784ad2574.rlib(nvim_oxi_api-1810259784ad2574.nvim_o>
            "_nvim_eval", referenced from:
                ned::lines::hda2f6019118f7760 in ned.ned.61793e39bdfed096-cgu.01.rcgu.o
            "_nvim_create_user_command", referenced from:
                nvim_oxi_api::command::create_user_command::hefe9569b023769ec in ned.ned.61793e39bdfed096-cgu.05.rcgu.o
            "_nvim_buf_get_lines", referenced from:
                ned::lines::hda2f6019118f7760 in ned.ned.61793e39bdfed096-cgu.01.rcgu.o
          ld: symbol(s) not found for architecture arm64
          clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

and I'm using a flake for local dev https://github.com/zdcthomas/ned/blob/cd4c9605b1b256c22aa63aff7d24119f0cbb6ca4/flake.nix#L1

I might be doing something super dumb, and I can definitely close if this is totally unrelated, but I thought I'd ask anyway.

Thanks!

zdcthomas commented 4 months ago

Ok, I figure it out! For some reason cargo wasn't picking up the build flags to tell the compiler to use dynamic lookup for the nvim_* calls. In nix, I put the env var in the build step with

          RUSTFLAGS = [
            "-C link-arg=-undefined"
            "-C link-arg=dynamic_lookup"
          ];
noib3 commented 4 months ago

Can you reproduce it on an x86 Mac? If not, it sounds like this could be a Cargo bug since those exact flags are already defined in the .cargo/config.toml file.