Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

fix(build): make fails on macos #55

Merged
merged 2 commits into from
Jun 15, 2022
Merged

Conversation

hjdivad
Copy link
Contributor

@hjdivad hjdivad commented Jun 12, 2022

Fix building on osx and add install instructions for non-linux platforms.

Trying to build & install on linux leads to three errors:

  1. Lua doesn't build
  2. libmpack doesn't build
  3. neovim/lua-client doesn't build

With this PR and libmpack/libmpack-lua#31 I'm able to build the lua client on osx.

uname -a
# Darwin hostname 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2 022; root:xnu-8020.121.3~4/RELEASE_X86_64 x86_64

On master

make
# ...

# gcc -o lua  lua.o liblua.a -lm -Wl,-E -ldl -lreadline -lhistory -lncurses
# ld: unknown option: -E
# clang: error: linker command failed with exit code 1 (use -v to see invocation)

This error installing lua is fixed by specifying a LUA_TARGET of macosx instead of linux. In general, several LUA_TARGETs can be specified. I've added them to README.md. The source of truth is make from lua itself, e.g.

cd .deps/5.1.5/src/lua && make
# Please do
#    make PLATFORM
# where PLATFORM is one of these:
#    aix ansi bsd freebsd generic linux macosx mingw posix solaris
# See INSTALL for complete instructions.

The next issue is that libmpack doesn't build. See libpack-lua#131. Apply the fix locally and install via:

cd ~/src/libmpack/libmpack-lua/
~/src/neovim/lua-client/.deps/usr/bin/luarocks make

With libmpack and lua installed make now errors with:

cc -g -fPIC -Wall -Wextra -Werror -Wconversion -Wextra -Wstrict-prototypes -ped
antic -o nvim/native.o -c nvim/native.c -I/Users/hjdivad/src/neovim/lua-client/
.deps/usr/include
cc -shared -fPIC nvim/native.o -o nvim/native.so
Undefined symbols for architecture x86_64:
  "_luaL_checkinteger", referenced from:
      _pid_wait in native.o
  "_luaL_register", referenced from:
      _luaopen_nvim_native in native.o
  "_lua_createtable", referenced from:
      _luaopen_nvim_native in native.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This is fixed by adding -undefined dynamic_lookup to LDFLAGS and not relying on it being the default behaviour.

hjdivad added 2 commits June 15, 2022 07:58
Specify `-undefined dynamic_lookup` explicitly, which is not the default
on osx.
Explain how to build for non-linux platforms.
@justinmk justinmk changed the title Fix Build on OSX fix(build): make fails on macos Jun 15, 2022
@justinmk justinmk merged commit c912fff into neovim:master Jun 15, 2022
@hjdivad hjdivad deleted the hjdivad/osx branch June 15, 2022 16:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants