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

YCM build on Cygwin 64: errors in pyport.h, LONG_BIT wrong #684

Closed
whitedwarfsun opened this issue Nov 22, 2013 · 24 comments
Closed

YCM build on Cygwin 64: errors in pyport.h, LONG_BIT wrong #684

whitedwarfsun opened this issue Nov 22, 2013 · 24 comments

Comments

@whitedwarfsun
Copy link

I have still no luck in building YCM on cygwin64. Please see me comment in issue #66 (comment)

I've tried some other flags (-DCMAKE_CXX_FLAGS=-m64) and compilers (mingw32/64, cygwin32/64) but was not successful.

@Valloric
Copy link
Member

There's no official support for Windows. Pull requests welcome.

@Aneurin
Copy link

Aneurin commented Feb 4, 2014

Boost.Python makes the incorrect assumption that Cygwin is always 32-bit. The Cygwin version of wrap_python.hpp include the following modification that allows compilation to proceed:

--- .vim/bundle/YouCompleteMe/cpp/BoostParts/boost/python/detail/wrap_python.hpp        2014-02-04 20:36:49.154074800 +0000
+++ ../Desktop/wrap_python.hpp  2013-05-29 23:40:03.000000000 +0100
@@ -82,8 +82,8 @@
 // Some things we need in order to get Python.h to work with compilers other
 // than MSVC on Win32
 //
-#if defined(_WIN32) || defined(__CYGWIN__)
-# if defined(__GNUC__) && defined(__CYGWIN__)
+#if defined(_WIN32)
+# if defined(__GNUC__)

 #  define SIZEOF_LONG 4

@ofan
Copy link

ofan commented Feb 5, 2014

Confirmed that @Aneurin 's patch is working on Windows 7 with Cygwin 64bit.

@Aneurin
Copy link

Aneurin commented Feb 5, 2014

@ofan, I wonder: does that mean you've had success at actually using it, or just building? For me, compilation appears successful but I'm currently stuck on Vim immediately segfaulting on startup.
Investigation still ongoing...

(PS: what's the protocol for discussion of tangential topics in bug threads, given that Github doesn't appear to provide the facility to send PMs?)

@whitedwarfsun
Copy link
Author

Same here: build completes succefully, but after copying ycm_core and ycm_support_libs into python dir (and renaming to .dll), vim (and the entire cygwin terminal) crashes (i.e., does not respond any more).

P.S.: I did not try to include Clang.

@ofan
Copy link

ofan commented Feb 8, 2014

It compiles successfully but I got link error for some reason. Clang completer also seems broken in Cygwin(link error too).

@abhinav31415
Copy link
Contributor

I know this thread is closed but for people looking for a one-stop fix.
Win 7+ Cygwin 64 bit: Compiled successfully (w/o clang) with the changes suggested by @Aneurin on this thread @Valloric on #66 (about using -DPYTHON_INCLUDE_DIR and -DPYTHON_LIBRARY)
This is what the final cmake command looks like
cmake -G "Unix Makefiles" -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/libpython2.7.dll.a . ../cpp.

@whitedwarfsun
Copy link
Author

well, you're right the build compiles successfully (w/o clang) when I use your cmake command on my Win7_64 in cygwin64.
However, vim (and the complete cygwin terminal) still crashes when it is started.

@abhinav31415
Copy link
Contributor

Weird, its working fine for me. I had an issue with it hanging on the "." operator in python, but that went away when I removed my python-mode plugin. You could check if you have other plugins which might be interacting in some crazy way with YCM. Or you could remove YCM from your .vimrc and add it back with vundle and re-do the :BundleInstall, should be much faster now that you've already compiled and built it.

@whitedwarfsun
Copy link
Author

Thanks for the hint: Now I, at least, get an error message, but it's still not working.

I removed .vim and .vimrc completely and started over again using two variants:

  1. I cloned Pathogen into .vim/autoload, set .vimrc right for Pathogen, cloned YCM into .vim/bundle, adjusted wrap_python.hpp, built ycm, copied core and support into ycm/python and renamed both files to .dll, started vim.
    This way I get errors reported in lines 13-19 in youcompleteme#Enable.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/user/.vim/bundle/YouCompleteMe/autoload/../python/ycm/base.py", line 23, in <module>
    from ycm import user_options_store
  File "/home/user/.vim/bundle/YouCompleteMe/autoload/../python/ycm/user_options_store.py", line 22, in <module>
    from frozendict import frozendict
ImportError: No module named frozendict
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'base' is not defined
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/user/.vim/bundle/YouCompleteMe/autoload/../python/ycm/user_options_store.py", line 22, in <module>
    from frozendict import frozendict
ImportError: No module named frozendict
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'user_options_store' is not defined
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'base' is not defined
E858: Eval did not return a valid python object
YouCompleteMe unavailable: YCM support libs too old, PLEASE RECOMPILE
  1. I cloned gmarik/vundle into .vim/bundle, set .vimrc right, cloned ycm into bundle, adjusted wrap_python.hpp, built, copied and renamed everything. Then started vim, used BundleInstall which marks YouCompleteMe as happily installed. But: same errors occur.

I'm happy to see an error message, but it still does not work.

@abhinav31415
Copy link
Contributor

The frozendict issue should be related to missing submodules. An earlier issue #582 talks about it. Follow the steps there see if it helps. You should run "git submodule update --init --recursive" inside your YCM directory.
To avoid this I think you should install it via Vundle like the readme mentions (add to Vimrc and :BubdleInstall) that takes care of this getting the submodules.

@whitedwarfsun
Copy link
Author

Tried that: fresh Vundle, .vimrc and YCM, including git submodule update, mods to wrap_python.hpp and so on.
Error message now:

Vim: Caught deadly signal SEGV
Vim: Finished.
Segmentation fault

@abhinav31415
Copy link
Contributor

I have no idea, but I would try 1 or both of the following.

  1. Run vim with gdb see what its complaining about.
  2. Re-install vim (On Cygwin that means re-install cygwin, unless you know a better way, select "All Packages" while installing if disk space is not an issue. It will take a while, but that way you know everything is fresh and should work. Preferably in a different directory)

@whitedwarfsun
Copy link
Author

1.: gdb (and/or a stack/core dump) shows only some addresses; nothing of use.
2.: Working on it ...

@whitedwarfsun
Copy link
Author

It works! Thank you all for your contributions!

For the sake of completeness, here is a (poorly-commented) step-by-step instruction:
0. System: Win7-64; start with a fresh install of Cygwin-64.
1a. Pathogen:

mkdir -p ~/.vim/{bundle,autoload}
cd ~/.vim/autoload
wget https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
echo '
execute pathogen#infect()
syntax on
filetype plugin indent on
' > ~/.vimrc

1b. Vundle:

git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
echo '
set nocompatible               " be iMproved
filetype off                   " required!

set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

Bundle 'gmarik/vundle'
Bundle 'Valloric/YouCompleteMe'

filetype plugin indent on     " required!
' > .vimrc

2 . Clone YCM, update submodules, adjust BoostParts, build, copy and rename core and client_support_libs:

git clone https://github.com/Valloric/YouCompleteMe ~/.vim/bundle/YouCompleteMe
cd ~/.vim/bundle/YouCompleteMe
git submodule update --init --recursive
cd ~/.vim/bundle/YouCompleteMe
sed -i '/__CYGWIN__/ s/).*/)/' cpp/BoostParts/boost/python/detail/wrap_python.hpp
mkdir build
cd build
cmake -G "Unix Makefiles" -DPYTHON_INCLUDE_DIR=/usr/include/python2.7/ -DPYTHON_LIBRARY=/usr/lib/libpython2.7.dll.a . ../cpp
make ycm_support_libs -j4
cp ycm/ycm_client_support.pyd ../python/ycm_client_support.dll
cp ycm/ycm_core.pyd ../python/ycm_core.dll

@whitedwarfsun
Copy link
Author

Btw: I've tried to build YCM with Clang 3.4 but did not succeed.

Following my configure command

cmake -G "Unix Makefiles" -DPYTHON_INCLUDE_DIR=/usr/include/python2.7/ -DPYTHON_LIBRARY=/usr/lib/libpython2.7.dll.a -DPATH_TO_LLVM_ROOT=/home/user/tools/inst/ -DTEMP=/home/user/tools/inst/bin/cygclang.dll . ../cpp

the build produced the error message

Linking CXX executable ycm_core_tests.exe
CMakeFiles/ycm_core_tests.dir/CandidateRepository_test.cpp.o:CandidateRepository_test.cpp:(.text+0x117): undefined reference to `YouCompleteMe::CandidateRepository::Instance()'
CMakeFiles/ycm_core_tests.dir/CandidateRepository_test.cpp.o:CandidateRepository_test.cpp:(.text+0x117): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `YouCompleteMe::CandidateRepository::Instance()'
CMakeFiles/ycm_core_tests.dir/CandidateRepository_test.cpp.o:CandidateRepository_test.cpp:(.text+0x12a): undefined reference to `YouCompleteMe::CandidateRepository::GetCandidatesForStrings(std::vector<std::string, std::allocator<std::string> > const&)'
CMakeFiles/ycm_core_tests.dir/CandidateRepository_test.cpp.o:CandidateRepository_test.cpp:(.text+0x12a): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `YouCompleteMe::CandidateRepository::GetCandidatesForStrings(std::vector<std::string, std::allocator<std::string> > const&)'
CMakeFiles/ycm_core_tests.dir/CandidateRepository_test.cpp.o:CandidateRepository_test.cpp:(.text+0x9d5): undefined reference to `YouCompleteMe::CandidateRepository::Instance()'
CMakeFiles/ycm_core_tests.dir/CandidateRepository_test.cpp.o:CandidateRepository_test.cpp:(.text+0x9d5): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `YouCompleteMe::CandidateRepository::Instance()'
CMakeFiles/ycm_core_tests.dir/CandidateRepository_test.cpp.o:CandidateRepository_test.cpp:(.text+0x9e8): undefined reference to `YouCompleteMe::CandidateRepository::GetCandidatesForStrings(std::vector<std::string, std::allocator<std::string> > const&)'
CMakeFiles/ycm_core_tests.dir/CandidateRepository_test.cpp.o:CandidateRepository_test.cpp:(.text+0x9e8): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `YouCompleteMe::CandidateRepository::GetCandidatesForStrings(std::vector<std::string, std::allocator<std::string> > const&)'
/usr/lib/gcc/x86_64-pc-cygwin/4.8.2/../../../../x86_64-pc-cygwin/bin/ld: CMakeFiles/ycm_core_tests.dir/CandidateRepository_test.cpp.o: bad reloc address 0x3 in section `.text$_ZN7testing8internal15TestFactoryBaseD1Ev[_ZN7testing8internal15TestFactoryBaseD1Ev]'
collect2: error: ld returned 1 exit status
ycm/tests/CMakeFiles/ycm_core_tests.dir/build.make:344: recipe for target 'ycm/tests/ycm_core_tests.exe' failed
make[2]: *** [ycm/tests/ycm_core_tests.exe] Error 1
CMakeFiles/Makefile2:288: recipe for target 'ycm/tests/CMakeFiles/ycm_core_tests.dir/all' failed
make[1]: *** [ycm/tests/CMakeFiles/ycm_core_tests.dir/all] Error 2
Makefile:75: recipe for target 'all' failed
make: *** [all] Error 2

Just the test executable failed; both shared libs were built successfully. So I renamed and copied them but Vim now reports a ycmd shutdown on start.

(Configure command for llvm/clang was

CC=gcc CXX=g++ cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=~/tools/inst -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_SHARED_LIBS=true -DLLVM_TARGETS_TO_BUILD:STRING="X86" ../../sources/llvm-3.4/

in ~/tools/builds/llvm-3.4)

@wlnirvana
Copy link

@Aneurin Your analysis is correct, but your patch seems problematic. YCM works for me on Win7 (64bit) + Cygwin after I change
# define SIZEOF_LONG 4
to
# define SIZEOF_LONG 8

This link might be helpful.

@vesanieminen
Copy link

@wlnirvana thanks for the tip, that solved the problem for me o/

@adibsaad
Copy link

@Aneurin thanks! Your patch worked for me on cygwin/windows 8.1 64 bit though the file's path was /YouCompleteMe/third_party/ycmd/cpp/BoostParts/boost/python/detail/wrap_python.hpp

@nfarrar
Copy link

nfarrar commented May 25, 2015

@Aneurin's patch worked for me as well on windows 8.1 with cygwin x64. It runs really slow though. Anyone else experienced this issue (and hopefully have a fix)? I'm using vim, llvm & clang from official repos:

CYGINW: CYGWIN_NT-6.3 desktop 2.0.2(0.287/5/3) 2015-05-08 17:00 x86_64
VIM:    vim-7.4.726-1.x86_64 (May 7 2015 03:25:59)
LLVM:   x86_64/release/llvm/llvm-3.5.1-2.tar.xz
CLANG:  x86_64/release/llvm/clang/clang-3.5.1-2.tar.xz

@gitaarik
Copy link

gitaarik commented Jun 4, 2015

Well, in the wrap_python.hpp header file is:

#if defined(_WIN32) || defined(__CYGWIN__)
# if defined(__GNUC__) && defined(__CYGWIN__)

#  define SIZEOF_LONG 4

So yeah, It assumes Cygwin is always 32 bit. Maybe we could detect if Cygwin is 32 or 64 bit? Then we could decide to defineSIZEOF_LONG as 4 or 8.

@fatso83
Copy link

fatso83 commented Dec 9, 2015

For anyone following this, it might make sense to vote/comment on the associated Boost issue. The patch has remained untouched for a year. Issue link

I submitted Chris Nixon's patch to the Boost repo. That will hopefully make manually patching the YCM build a thing of the past :-)

@fatso83
Copy link

fatso83 commented Mar 6, 2016

This is now fixed in Boost!

boostorg/python#49

@Valloric
Copy link
Member

Valloric commented Mar 6, 2016

@fatso83 Thanks for pushing the patch upstream! :)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests