如何针对自定义glibc编译LLVM?

时间:2015-05-20 14:13:23

标签: vim cmake clang llvm glibc

我使用YouCompleteMe Vim插件完成文本(通过Vundle安装)。 YouCompleteMe使用Clang进行C系列语言的文本完成(C,C ++,Objective-C,Objective-C ++)。但是,在YouCompleteMe更新后(通过Vim中的:VundleUpdate)YouCompleteMe停止工作。

简而言之,问题是:如何针对自定义glibc版本编译Clang? Debian Wheezy附带glibc 2.13,似乎最新的Clang版本至少需要glibc 2.15(在更多细节见下文)。以防万一,我使用的是Debian Wheezy,x86-64和自定义Linux内核版本4.0.0-rc6。

所以我根据LLVM website

上的说明从git镜像下载了LLVM
$ mkdir ~/code
$ cd ~/code/llvm_source_tree
$ git clone http://llvm.org/git/llvm.git
$ cd ~/code/llvm_source_tree/llvm/tools
$ git clone http://llvm.org/git/clang.git
$ cd ~/code/llvm_source_tree/llvm/projects
$ git clone http://llvm.org/git/compiler-rt.git
$ git clone http://llvm.org/git/test-suite.git
$ cd ~/code/llvm_source_tree/llvm
$ git config branch.master.rebase true

然后,我按照LLVM website上的说明编译了LLVM:

$ cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE='Release' ~/code/llvm_source_tree/llvm/
$ make -j 5
$ su
# make install

到目前为止一切都很好,所以我通过在YouCompleteMe install instructions之后编译YouCompleteMe支持库来继续安装YouCompleteMe:

$ mkdir ~/ycm_build
$ cd ~/ycm_build
$ cmake -G "Unix Makefiles" -DEXTERNAL_LIBCLANG_PATH=/usr/local/lib/libclang.so . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
$ make ycm_support_libs

然后我跑了Vim,我注意到YouCompleteMe似乎仍然不起作用。当我在某个C ++文件中进入Vim中的编辑模式时(例如),YouCompleteMe打印错误:The ycmd server SHUT DOWN (restart with :YcmRestartServer). Stderr (last 30 lines):,之后:YcmRestartServer打印Restarting ycmd server...,然后('Connection aborted.', error(111, 'Connection refused')))。< / p>

:YcmDebugInfo打印以下内容:

Printing YouCompleteMe debug information...
-- Server crashed, no debug info from server
-- Server running at: http://127.0.0.1:37730
-- Server process ID: 22358
-- Server logfiles:
--   /tmp/ycm_temp/server_37730_stdout.log
--   /tmp/ycm_temp/server_37730_stderr.log

/tmp/ycm_temp/server_37730_stdout.log为空,但/tmp/ycm_temp/server_37730_stderr.log包含以下行:

2015-05-20 17:06:46,126 - DEBUG - No global extra conf, not calling method YcmCorePreload
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/user/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/__main__.py", line 164, in 
    Main()
  File "/home/user/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/__main__.py", line 150, in Main
    from ycmd import handlers
  File "/home/user/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/handlers.py", line 30, in 
    str( e ) ) )
RuntimeError: Error importing ycm_core. Are you sure you have placed a version 3.2+ libclang.[so|dll|dylib] in folder "/home/user/.vim/bundle/YouCompleteMe/third_party/ycmd"? See the Installation Guide in the docs. Full error: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.14' not found (required by /home/user/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../libclang.so)

所以我运行了YouCompleteMe的测试,并在运行./vim/bundle/YouCompleteMe/third_party/ycmd/run_tests.sh时遇到了这个错误:

[ 98%] Building CXX object ycm/tests/CMakeFiles/ycm_core_tests.dir/main.cpp.o
[100%] Building CXX object ycm/tests/CMakeFiles/ycm_core_tests.dir/TestUtils.cpp.o
Linking CXX executable ycm_core_tests
../../clang+llvm-3.6.0-x86_64-linux-gnu/lib/libclang.so: undefined reference to `posix_spawn@GLIBC_2.15'
../../clang+llvm-3.6.0-x86_64-linux-gnu/lib/libclang.so: undefined reference to `memcpy@GLIBC_2.14'
collect2: error: ld returned 1 exit status
make[3]: *** [ycm/tests/ycm_core_tests] Error 1
make[2]: *** [ycm/tests/CMakeFiles/ycm_core_tests.dir/all] Error 2
make[1]: *** [ycm/tests/CMakeFiles/ycm_core_tests.dir/rule] Error 2
make: *** [ycm_core_tests] Error 2
Traceback (most recent call last):
  File "/home/user/.vim/bundle/YouCompleteMe/third_party/ycmd/build.py", line 196, in 
    Main()
  File "/home/user/.vim/bundle/YouCompleteMe/third_party/ycmd/build.py", line 189, in Main
    BuildYcmdLibs( GetCmakeArgs( args ) )
  File "/home/user/.vim/bundle/YouCompleteMe/third_party/ycmd/build.py", line 152, in BuildYcmdLibs
    _err = sys.stderr )
  File "/home/user/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/sh/sh.py", line 1021, in __call__
    return RunningCommand(cmd, call_args, stdin, stdout, stderr)
  File "/home/user/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/sh/sh.py", line 486, in __init__
    self.wait()
  File "/home/user/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/sh/sh.py", line 500, in wait
    self.handle_command_exit_code(exit_code)
  File "/home/user/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/sh/sh.py", line 516, in handle_command_exit_code
    raise exc(self.ran, self.process.stdout, self.process.stderr)
sh.ErrorReturnCode_2: 

  RAN: '/usr/bin/make -j 8 ycm_core_tests'

  STDOUT:


  STDERR:

所以看来Clang 3.6.0可能需要glibc 2.15或更新版本。 Debian Wheezy附带glibc 2.13。因此决定安装最新稳定版的glibc(目前为2.21)。我之前已经编译了binutils并将其安装到/usr/local/bin/,所以我现在不需要这样做。

所以我下载了http://ftp.gnu.org/gnu/glibc/glibc-2.21.tar.bz2,然后解压缩并编译了源代码并安装了它:

$ cd ~/code
$ mkdir ~/code/glibc
$ cd ~/code/glibc
$ mv -iv ~/downloads/glibc-2.21.tar.bz2 .
$ tar xjvf glibc-2.21.tar.bz2
$ cd glibc-2.21
$ mkdir build
$ cd build
$ ../configure --with-binutils=/usr/local/bin --prefix=/usr/local/glibc/glibc-2.21
$ make -j 5
$ su
# make install

然后我重新编译了LLVM。我将CMAKE_CXX_FLAGS环境变量的g ++链接器标记传递给cmake,这是在使用俄语对SO问题Multiple glibc libraries on a single host的回答之后:

$ export CMAKE_CXX_FLAGS='-Wl,--rpath=/usr/local/glibc/glibc-2.21 -Wl,--dynamic-linker=/usr/local/glibc/glibc-2.21/ld-linux.so.2'
$ cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE='Release' ~/code/llvm_source_tree/llvm/
$ make -j 5

然后我重新编译了YouCompleteMe支持库,再次将g ++链接器标志传递给cmake中的CMAKE_CXX_FLAGS

$ export CMAKE_CXX_FLAGS='-Wl,--rpath=/usr/local/glibc/glibc-2.21 -Wl,--dynamic-linker=/usr/local/glibc/glibc-2.21/ld-linux.so.2'
$ cmake -G "Unix Makefiles" -DEXTERNAL_LIBCLANG_PATH=/usr/local/lib/libclang.so . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp

但YouCompleteMe的问题仍然存在,测试仍然以同样的方式失败。也许CMAKE_CXX_FLAGS不是将g ++链接器标志传递给cmake的充分方法吗?在针对glibc 2.21编译LLVM时,我也尝试使用LD_LIBRARY_PATH

$ cd ~/code/llvm_source_tree
$ mkdir build2
$ cd build2
$ export LD_LIBRARY_PATH="/usr/local/glibc/glibc-2.21/lib:$LD_LIBRARY_PATH"
$ cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE='Release' ~/code/llvm_source_tree/llvm/

得到了这个错误:

cmake: error while loading shared libraries: __vdso_time: invalid mode for dlopen(): Invalid argument

然后我也尝试了LD_PRELOAD

$ export LD_PRELOAD='/usr/local/glibc/glibc-2.21/lib/ld-linux-x86-64.so.2 /usr/local/glibc/glibc-2.21/lib/libc.so.6'
$ export LD_LIBRARY_PATH="/usr/local/glibc/glibc-2.21/lib:$LD_LIBRARY_PATH"
$ cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE='Release' ~/code/llvm_source_tree/llvm/

并且遇到了这些错误:

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
Inconsistency detected by ld.so: dl-minimal.c: 136: realloc: Assertion `ptr == alloc_last_block' failed!

然后我也尝试将/usr/local/glibc/glibc-2.21/lib/ld-2.21.so添加到export LD_PRELOAD,但它没有以任何方式更改错误消息。

我很确定Clang不需要glibc 2.15(精确),即使其他缺失符号(posix_spawn@GLIBC_2.15)最初来自glibc 2.15,因为glibc根据其文档试图保持向后兼容性无论如何,另一个缺失的符号(memcpy@GLIBC_2.14)来自glibc 2.14。所以我没有用glibc 2.15来尝试这一切。但是现在我没有想法,任何建议都会受到赞赏。

编辑1

我跟着Employed Russian's answer (below),但我的问题没有任何改变。所以我得出结论,export CMAKE_CXX_FLAGS不是将g ++链接器标志传递给cmake的正确方法。 CMAKE_CXX_FLAGS是变量内部cmake的名称,但cmake根本不关心环境变量同名(CMAKE_CXX_FLAGS)。可以在CMAKE_CXX_FLAGS中直接定义CMakeLists.txt,但在LLVM compiling instructions中没有使用主CMakeLists.txt,如果有&#我不想从头开始重新创建LLVM编译脚本39;一些更实用的选择。但我仍然可以找到其他3种选择:

  1. cmake从名为CMAKE_CXX_FLAGS的环境变量初始化CXXFLAGS。请参阅sakra对问题Adding include directories to cmake when calling it from command line的回答。
  2. $ export CXXFLAGS='-Wl,--rpath=/usr/local/glibc/glibc-2.21 -Wl,--dynamic-linker=/usr/local/glibc/glibc-2.21/ld-linux-x86-64.so.2'
    $ cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE='Release' ~/code/llvm_source_tree/llvm/
    $ make
    
    1. CMAKE_CXX_FLAGS也可以使用-DCMAKE_CXX_FLAGS
    2. 从命令行初始化
      $ cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE='Release' -DCMAKE_CXX_FLAGS='-Wl,--rpath=/usr/local/glibc/glibc-2.21 -Wl,--dynamic-linker=/usr/local/glibc/glibc-2.21/ld-linux-x86-64.so.2' ~/code/llvm_source_tree/llvm/
      $ make
      
      1. CMAKE_CXX_FLAGS也可以使用-DCMAKE_CXX_FLAGS:STRING从命令行初始化(参见Building mpllibs):
      2. $ cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE='Release' -DCMAKE_CXX_FLAGS:STRING='-Wl,--rpath=/usr/local/glibc/glibc-2.21 -Wl,--dynamic-linker=/usr/local/glibc/glibc-2.21/ld-linux-x86-64.so.2' ~/code/llvm_source_tree/llvm/
        $ make
        

        所有这三个选项都会产生完全相同的结果:编译LLVM结束时会产生与目标llvm-tblgenintrinsics_gen相同的错误(3 Makefile&上面由cmake命令生成的#s目录名是由每个构建在不同目录中完成的事实引起的。似乎目标llvm-tblgen被适当地编译和链接,但在此之后,目标llvm-tblgen似乎是目标intrinsics_gen的依赖关系,并且无法找到llvm-tblgen 。这些是make输出的最后一行(对于上面3个构建中的每个构建都是相同的):

        Linking CXX executable ../../bin/llvm-tblgen
        [  4%] Built target llvm-tblgen
        Scanning dependencies of target intrinsics_gen
        [  4%] Building Intrinsics.gen...
        /bin/sh: 1: ../../../bin/llvm-tblgen: not found
        make[2]: *** [include/llvm/IR/Intrinsics.gen.tmp] Error 127
        make[1]: *** [include/llvm/IR/CMakeFiles/intrinsics_gen.dir/all] Error 2
        make: *** [all] Error 2
        

        我想知道这是否是LLVM中的错误或者设置cmake变量CMAKE_CXX_FLAGS的方式(在上面的3个版本中)足够或者是由其他原因导致的。任何想法如何继续将不胜感激。

        编辑2

        正如雇佣俄语在他的评论(below his answer)中所建议的那样:

        $ export CXXFLAGS='-Wl,--rpath=/usr/local/glibc/glibc-2.21 -Wl,--dynamic-linker=/usr/local/glibc/glibc-2.21/lib/ld-linux-x86-64.so.2'
        $ cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE='Release' ~/code/llvm_source_tree/llvm/
        $ make
        

        这也导致了与目标llvm-tblgenintrinsics_gen相关的编译错误,但错误与之前的错误相比有所不同。这些是make输出的最后一行:

        Linking CXX executable ../../bin/llvm-tblgen
        [  4%] Built target llvm-tblgen
        Scanning dependencies of target intrinsics_gen
        [  4%] Building Intrinsics.gen...
        ../../../bin/llvm-tblgen: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
        make[2]: *** [include/llvm/IR/Intrinsics.gen.tmp] Error 127
        make[1]: *** [include/llvm/IR/CMakeFiles/intrinsics_gen.dir/all] Error 2
        make: *** [all] Error 2
        

        现在似乎找到llvm-tblgen,但加载共享库libtinfo.so.5时出错。所以我将--rpath=/usr/local/glibc/glibc-2.21更改为--rpath=/usr/local/glibc/glibc-2.21/lib并再次尝试:

        $ export CXXFLAGS='-Wl,--rpath=/usr/local/glibc/glibc-2.21/lib -Wl,--dynamic-linker=/usr/local/glibc/glibc-2.21/lib/ld-linux-x86-64.so.2'
        $ cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE='Release' ~/code/llvm_source_tree/llvm/
        $ make
        

        但是,--rpath的此更改并未更改make生成的错误消息。我想知道这个共享库libtinfo.so.5应该位于何处。

        然后我遇到Building the Clang + LLVM compilers website并尝试将-std=c++11添加到CXXFLAGS

        $ export CXXFLAGS='-std=c++11 -Wl,--rpath=/usr/local/glibc/glibc-2.21 -Wl,--dynamic-linker=/usr/local/glibc/glibc-2.21/lib/ld-linux-x86-64.so.2'
        $ cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE='Release' ~/code/llvm_source_tree/llvm/
        $ make
        

        但它没有帮助,错误信息是相同的,也就是说,共享库libtinfo.so.5仍然无法找到。也许我的g++版本太旧了,它与Debian Wheezy一起提供g++ 4.7.2(g++ --version打印g++ (Debian 4.7.2-5) 4.7.2)。 Building the Clang + LLVM compilers website的作者写道,他仅使用g++ 4.7.1在Fedora 15上构建LLVM的尝试失败了,而使用不同g++版本的多次重启编译它(4.8,4.8.0) ,4.7.1)终于成功了(在网站上有描述)。有什么想法吗?

        编辑3

        根据Employed Russian的建议,我用-Wl,--rpath=/usr/local/glibc/glibc-2.21/lib:/lib:/usr/lib:/lib/x86_64-linux-gnu重新编译了glibc 2.21:

        $ cd ~/code/glibc/glibc-2.21
        $ mv -iv build old_build
        $ mkdir build
        $ cd build
        $ export LD_FLAGS='-Wl,--rpath=/usr/local/glibc/glibc-2.21/lib:/lib:/usr/lib:/lib/x86_64-linux-gnu'
        $ ../configure --with-binutils=/usr/local/bin --prefix=/usr/local/glibc/glibc-2.21
        $ make -j 5
        

        make check产生了一些错误:

        Summary of test results:
            112 FAIL
           2073 PASS
            199 XFAIL
              3 XPASS
        make[1]: *** [tests] Error 1
        make[1]: Leaving directory `/home/user/code/glibc/glibc-2.21'
        make: *** [check] Error 2
        

        无论如何,我安装了新编译的glibc 2.21:

        $ su
        # make install
        

        make install发出了此警告:

        /home/user/code/glibc/glibc-2.21/build/elf/ldconfig: Warning: ignoring configuration file that cannot be opened: /usr/local/glibc/glibc-2.21/etc/ld.so.conf: No such file or directory
        make[1]: Leaving directory `/home/user/code/glibc/glibc-2.21'
        

        然后我再次使用:-Wl,--rpath=/usr/local/glibc/glibc-2.21/lib:/lib:/usr/lib:/lib/x86_64-linux-gnu重新编译LLVM:

        $ export CXXFLAGS='-std=c++11 -Wl,--rpath=/usr/local/glibc/glibc-2.21/lib:/lib:/usr/lib:/lib/x86_64-linux-gnu -Wl,--dynamic-linker=/usr/local/glibc/glibc-2.21/lib/ld-linux-x86-64.so.2'
        $ cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE='Release' ~/code/llvm_source_tree/llvm/
        $ make
        

        libstdc++.so.6遗失了:

        Linking CXX executable ../../bin/llvm-tblgen
        [  4%] Built target llvm-tblgen
        Scanning dependencies of target intrinsics_gen
        [  4%] Building Intrinsics.gen...
        ../../../bin/llvm-tblgen: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
        make[2]: *** [include/llvm/IR/Intrinsics.gen.tmp] Error 127
        make[1]: *** [include/llvm/IR/CMakeFiles/intrinsics_gen.dir/all] Error 2
        make: *** [all] Error 2
        

        所以我得出结论,--rpath还需要一些其他库目录。

        $ cd /usr
        $ sudo find . -name 'libstdc++.so.6'
        ./lib32/debug/libstdc++.so.6
        ./lib32/libstdc++.so.6
        ./lib/x86_64-linux-gnu/debug/libstdc++.so.6
        ./lib/x86_64-linux-gnu/libstdc++.so.6
        ./lib/git-annex.linux/usr/lib/x86_64-linux-gnu/libstdc++.so.6
        ./lib/i386-linux-gnu/libstdc++.so.6
        

        其中,./lib/x86_64-linux-gnu/libstdc++.so.6看起来最适合我。所以我将/usr/lib/x86_64-linux-gnu添加到了--rpath,并再次重新编译了glibc 2.21:

        $ cd ~/code/glibc/glibc-2.21
        $ mv -iv build old_build2
        $ mkdir build
        $ cd build
        $ export LD_FLAGS='-Wl,--rpath=/usr/local/glibc/glibc-2.21/lib:/lib:/usr/lib:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu'
        $ ../configure --with-binutils=/usr/local/bin --prefix=/usr/local/glibc/glibc-2.21
        $ make -j 5
        

        这次我没有费心去make check,而是继续直接安装:

        $ su
        # make install
        

        得到了同样看似无害的警告:

        /home/user/code/glibc/glibc-2.21/build/elf/ldconfig: Warning: ignoring configuration file that cannot be opened: /usr/local/glibc/glibc-2.21/etc/ld.so.conf: No such file or directory
        make[1]: Leaving directory `/home/user/code/glibc/glibc-2.21'
        

        所以我为/usr/lib/x86_64-linux-gnu添加了--rpath用于LLVM,并重新编译了LLVM:

        $ export CXXFLAGS='-std=c++11 -Wl,--rpath=/usr/local/glibc/glibc-2.21/lib:/lib:/usr/lib:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu -Wl,--dynamic-linker=/usr/local/glibc/glibc-2.21/lib/ld-linux-x86-64.so.2'
        $ cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE='Release' ~/code/llvm_source_tree/llvm/
        $ make
        

        构建成功,所以我安装了LLVM:

        $ su
        # make install
        

        然后我用与编译LLVM相同的CXXFLAGS重新编译了YouCompleteMe支持库:

        $ export CXXFLAGS='-std=c++11 -Wl,--rpath=/usr/local/glibc/glibc-2.21/lib:/lib:/usr/lib:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu -Wl,--dynamic-linker=/usr/local/glibc/glibc-2.21/lib/ld-linux-x86-64.so.2'
        $ cmake -G "Unix Makefiles" -DEXTERNAL_LIBCLANG_PATH=/usr/local/lib/libclang.so . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
        $ make ycm_support_libs
        

        这个版本也很成功。然后我重新安装了YouCompleteMe:

        $ cd
        $ .vim/bundle/YouCompleteMe/install.sh
        

        完成似乎有效。然后我运行了YouCompleteMe的测试:

        $ .vim/bundle/YouCompleteMe/run_tests.sh
        

        好的,完成仍然有效。

        $ .vim/bundle/YouCompleteMe/third_party/ycmd/run_tests.sh
        

        这引起了一个问题。似乎这个.vim/bundle/YouCompleteMe/third_party/ycmd/run_tests.sh重新编译支持库 - 不使用我的Makefile - 因此打破了支持库。 解决方案无法运行.vim/bundle/YouCompleteMe/third_party/ycmd/run_tests.sh

        [100%] Building CXX object ycm/tests/CMakeFiles/ycm_core_tests.dir/TestUtils.cpp.o
        Linking CXX executable ycm_core_tests
        ../../clang+llvm-3.6.0-x86_64-linux-gnu/lib/libclang.so: undefined reference to `posix_spawn@GLIBC_2.15'
        ../../clang+llvm-3.6.0-x86_64-linux-gnu/lib/libclang.so: undefined reference to `memcpy@GLIBC_2.14'
        collect2: error: ld returned 1 exit status
        make[3]: *** [ycm/tests/ycm_core_tests] Error 1
        make[2]: *** [ycm/tests/CMakeFiles/ycm_core_tests.dir/all] Error 2
        make[1]: *** [ycm/tests/CMakeFiles/ycm_core_tests.dir/rule] Error 2
        make: *** [ycm_core_tests] Error 2
        

        所以我以最近的方式重新编译了支持库,之后又重新安装了YouCompleteMe:

        $ export CXXFLAGS='-std=c++11 -Wl,--rpath=/usr/local/glibc/glibc-2.21/lib:/lib:/usr/lib:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu -Wl,--dynamic-linker=/usr/local/glibc/glibc-2.21/lib/ld-linux-x86-64.so.2'
        $ cmake -G "Unix Makefiles" -DEXTERNAL_LIBCLANG_PATH=/usr/local/lib/libclang.so . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
        $ make ycm_support_libs
        
        $ cd
        $ .vim/bundle/YouCompleteMe/install.sh
        

        最后,YouCompleteMe再次运作!

1 个答案:

答案 0 :(得分:3)

  

然后我也尝试了LD_PRELOAD

正如here所述,为了使用自定义glibc,您需要设置正确的--dynamic-linker

我发现您使用的是--dynamic-linker=/usr/local/glibc/glibc-2.21/ld-linux.so.2,但看起来并不正确:您需要ld-linux-x86-64.so.2

  

export LD_PRELOAD='/usr/local/glibc/glibc-2.21/lib/ld-linux-x86-64.so.2 ...

那个(ld-linux的预加载)永远不会工作:它是ld-linux首先解释LD_PRELOAD