ericpruitt / static-glibc-vim

Makefile that creates a statically linked Vim binary
28 stars 12 forks source link

Any pointers to how to get Python & Lua plugin support in static build? #3

Open srinathh opened 8 years ago

srinathh commented 8 years ago

I went into the makefile and changed the command line to add the following lines to the ./configure command line but the build I get is still missing python & lua support when i run the static binary.

                --enable-pythoninterp \
                --with-python-config-dir=/usr/lib/python2.7/config \
                --enable-luainterp

I essentially want to use plugins like NeoComplete and similar which are written in those languages.

ericpruitt commented 8 years ago

I'm a minimalist when it comes to Vim plugins and have never attempted to compile Vim with Python or Lua support as I have no use for it. That being said, I don't think it's possible to use this repo to build Vim with Python support. Since that Python config folder typically contains a *.so files, that means Vim probably uses dlopen(3) to execute Python. A bit of grepping confirms this:

static-vim$ fgrep -IR dlopen . | fgrep python
./vim-src/src/if_python3.c:#   define load_dll(n) dlopen((n), RTLD_LAZY)
./vim-src/src/if_python3.c:#   define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL)
./vim-src/src/configure.in:      void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
./vim-src/src/configure.in:      void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
./vim-src/src/if_python.c:#   define load_dll(n) dlopen((n), RTLD_LAZY)
./vim-src/src/if_python.c:#   define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL)
./vim-src/src/auto/configure:      void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
./vim-src/src/auto/configure:      void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL);
./vim-src/src/Makefile:# dlopen(), dlsym(), dlclose(), i.e. pythonX.Y.so must be available

My build explicitly disables dlopen(3) because it's not possible to have dlopen(3) without a hard dependency on whatever glibc version is used to compile Vim. You can have Python support or 0-dependence on glibc, but not both.

What is your motivation for using my repo to compile Vim? My goal in creating this repo was to eliminate all external glibc dependencies. If you're only using my repo because you want the latest-and-greatest version of Vim, you're not using my repo for its intended purpose and would probably be better served compiling Vim without my tweaks.

srinathh commented 8 years ago

Thanks for the quick reply.

The reason I want to statically build vim with support for lua/python is because I want 7.4 version of vim along with smart auto-completion support in a server environment that has an outdated vim version but no possibility of installing build tools & dependencies required for vim. I do have a python 2 interpreter available in the environment and probably can get stand-alone lua interpreter in my $HOME but I don't have build tools on the server or updated shared libs on the server. So to get an updated vim - I need to build for amd64 target statically on my laptop & copy over the binary & runtime package.

On Sat, Apr 30, 2016 at 7:43 AM Eric Pruitt notifications@github.com wrote:

I'm a minimalist when it comes to Vim plugins and have never attempted to compile Vim with Python or Lua support as I have no use for it. That being said, I don't think it's possible to use this repo to build Vim with Python support. Since that Python config folder typically contains a *.so files, that means Vim probably uses dlopen(3) to execute Python. A bit of grepping confirms this:

static-vim$ fgrep -IR dlopen . | fgrep python ./vim-src/src/if_python3.c:# define load_dll(n) dlopen((n), RTLD_LAZY) ./vim-src/src/if_python3.c:# define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL) ./vim-src/src/configure.in: void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL); ./vim-src/src/configure.in: void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL); ./vim-src/src/if_python.c:# define load_dll(n) dlopen((n), RTLD_LAZY) ./vim-src/src/if_python.c:# define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL) ./vim-src/src/auto/configure: void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL); ./vim-src/src/auto/configure: void* pylib = dlopen(python_instsoname, RTLD_LAZY|RTLD_LOCAL); ./vim-src/src/Makefile:# dlopen(), dlsym(), dlclose(), i.e. pythonX.Y.so must be available

My build explicitly disables dlopen(3) because it's not possible to have dlopen(3) without a hard dependency on whatever glibc version is used to compile Vim. You can have Python support or 0-dependence on glibc, but not both.

What is your motivation for using my repo to compile Vim? My goal in creating this repo was to eliminate all external glibc dependencies. If you're only using my repo because you want the latest-and-greatest version of Vim, you're not using my repo for its intended purpose and would probably be better served compiling Vim without my tweaks.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/ericpruitt/static-vim/issues/3#issuecomment-215925483

ericpruitt commented 8 years ago

I see. I have an idea for an approach, but I'm not sure if it'll work.

First, run make clean then delete the rule that disables dlopen(3) in the Makefile; it's this block:

@if ! fgrep -q '#undef HAVE_DLOPEN' vim-src/src/auto/config.h; then \
    set -e; \
    echo '#undef HAVE_DLOPEN' >> vim-src/src/auto/config.h; \
    echo '- Disabled dlopen(3)'; \
    touch $@; \
fi

After that, add your flags, try recompiling and finally copy Vim to the remote host after confirming it works locally. Depending on how much the version of glibc differs on the host that you're compiling on versus the host that you're targeting this may not work. An alternative would be to install the same version of the OS you're targeting on a virtual machine, make the same changes to the Makefile and compile Vim inside the VM.

srinathh commented 8 years ago

Thanks! That sounds like it may work. I'll try it out over a couple of days and update you how it went,

On Saturday, April 30, 2016, Eric Pruitt notifications@github.com wrote:

I see. I have an idea for an approach, but I'm not sure if it'll work.

First, run make clean then delete the rule that disables dlopen(3) in the Makefile; it's this block:

@if ! fgrep -q '#undef HAVE_DLOPEN' vim-src/src/auto/config.h; then \ set -e; \ echo '#undef HAVE_DLOPEN' >> vim-src/src/auto/config.h; \ echo '- Disabled dlopen(3)'; \ touch $@; \ fi

After that, add your flags, try recompiling and finally copy Vim to the remote host after confirming it works locally. Depending on how much the version of glibc differs on the host that you're compiling on versus the host that you're targeting this may not work. An alternative would be to install the same version of the OS you're targeting on a virtual machine, make the same changes to the Makefile and compile Vim inside the VM.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/ericpruitt/static-vim/issues/3#issuecomment-215926555

Best Regards, Srinath Blog: Curiosity & the Geek http://srinathh.github.io/

ericpruitt commented 8 years ago

Have you had a chance to work on this?

srinathh commented 8 years ago

Sorry nope. Haven't had a chance to work on this

On Sat, May 7, 2016, 07:21 Eric Pruitt notifications@github.com wrote:

Have you had a chance to work on this?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/ericpruitt/static-vim/issues/3#issuecomment-217598203

srinathh commented 8 years ago

hmmm... I'm actually seem to be having trouble getting the build tools chain installed even on a VM of the distribution that's on the server (cdh based on CentOS). Will troubleshoot some more else will try my luck with building on my Ubuntu laptop that does compile vim and trying to run it on the server.