twlz0ne / homebrew-ccls

Homebrew formula to install [ccls](https://github.com/MaskRay/ccls)
17 stars 7 forks source link

Undefined symbol when installing #2

Closed gvol closed 6 years ago

gvol commented 6 years ago

I tried installing today, and got this error. I'm happy to try and debug it, but if you think it would be helpful.

$ brew install --HEAD ccls
==> Installing ccls from twlz0ne/ccls
==> Cloning https://github.com/MaskRay/ccls.git
Updating /Users/iandrus/Library/Caches/Homebrew/ccls--git
==> Checking out branch master
Synchronizing submodule url for 'thirdparty/gtest'
==> mkdir -p release
==> cmake -DCMAKE_C_FLAGS_RELEASE=-DNDEBUG -DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar
==> cmake --build release --target install
Last 15 lines from /Users/iandrus/Library/Logs/Homebrew/ccls/03.cmake:
/usr/local/opt/llvm/bin/clang++  -DNDEBUG -Wl,-search_paths_first -Wl,-headerpad_max_install_names  CMakeFiles/ccls.dir/third_party/siphash.cc.o CMakeFiles/ccls.dir/src/cache_manager.cc.o CMakeFiles/ccls.dir/src/clang_complete.cc.o CMakeFiles/ccls.dir/src/clang_cursor.cc.o CMakeFiles/ccls.dir/src/clang_indexer.cc.o CMakeFiles/ccls.dir/src/clang_translation_unit.cc.o CMakeFiles/ccls.dir/src/clang_utils.cc.o CMakeFiles/ccls.dir/src/config.cc.o CMakeFiles/ccls.dir/src/diagnostics_engine.cc.o CMakeFiles/ccls.dir/src/file_consumer.cc.o CMakeFiles/ccls.dir/src/filesystem.cc.o CMakeFiles/ccls.dir/src/fuzzy_match.cc.o CMakeFiles/ccls.dir/src/main.cc.o CMakeFiles/ccls.dir/src/import_pipeline.cc.o CMakeFiles/ccls.dir/src/include_complete.cc.o CMakeFiles/ccls.dir/src/method.cc.o CMakeFiles/ccls.dir/src/language.cc.o CMakeFiles/ccls.dir/src/lex_utils.cc.o CMakeFiles/ccls.dir/src/lsp.cc.o CMakeFiles/ccls.dir/src/match.cc.o CMakeFiles/ccls.dir/src/message_handler.cc.o CMakeFiles/ccls.dir/src/platform_posix.cc.o CMakeFiles/ccls.dir/src/platform_win.cc.o CMakeFiles/ccls.dir/src/port.cc.o CMakeFiles/ccls.dir/src/position.cc.o CMakeFiles/ccls.dir/src/project.cc.o CMakeFiles/ccls.dir/src/query_utils.cc.o CMakeFiles/ccls.dir/src/query.cc.o CMakeFiles/ccls.dir/src/queue_manager.cc.o CMakeFiles/ccls.dir/src/serializer.cc.o CMakeFiles/ccls.dir/src/test.cc.o CMakeFiles/ccls.dir/src/third_party_impl.cc.o CMakeFiles/ccls.dir/src/timer.cc.o CMakeFiles/ccls.dir/src/type_printer.cc.o CMakeFiles/ccls.dir/src/utils.cc.o CMakeFiles/ccls.dir/src/working_files.cc.o CMakeFiles/ccls.dir/src/messages/ccls_base.cc.o CMakeFiles/ccls.dir/src/messages/ccls_call_hierarchy.cc.o CMakeFiles/ccls.dir/src/messages/ccls_callers.cc.o CMakeFiles/ccls.dir/src/messages/ccls_file_info.cc.o CMakeFiles/ccls.dir/src/messages/ccls_freshen_index.cc.o CMakeFiles/ccls.dir/src/messages/ccls_inheritance_hierarchy.cc.o CMakeFiles/ccls.dir/src/messages/ccls_member_hierarchy.cc.o CMakeFiles/ccls.dir/src/messages/ccls_random.cc.o CMakeFiles/ccls.dir/src/messages/ccls_vars.cc.o CMakeFiles/ccls.dir/src/messages/exit.cc.o CMakeFiles/ccls.dir/src/messages/initialize.cc.o CMakeFiles/ccls.dir/src/messages/shutdown.cc.o CMakeFiles/ccls.dir/src/messages/text_document_code_lens.cc.o CMakeFiles/ccls.dir/src/messages/text_document_completion.cc.o CMakeFiles/ccls.dir/src/messages/text_document_definition.cc.o CMakeFiles/ccls.dir/src/messages/text_document_did_change.cc.o CMakeFiles/ccls.dir/src/messages/text_document_did_close.cc.o CMakeFiles/ccls.dir/src/messages/text_document_did_open.cc.o CMakeFiles/ccls.dir/src/messages/text_document_did_save.cc.o CMakeFiles/ccls.dir/src/messages/text_document_document_highlight.cc.o CMakeFiles/ccls.dir/src/messages/text_document_document_symbol.cc.o CMakeFiles/ccls.dir/src/messages/text_document_hover.cc.o CMakeFiles/ccls.dir/src/messages/text_document_implementation.cc.o CMakeFiles/ccls.dir/src/messages/text_document_references.cc.o CMakeFiles/ccls.dir/src/messages/text_document_rename.cc.o CMakeFiles/ccls.dir/src/messages/text_document_signature_help.cc.o CMakeFiles/ccls.dir/src/messages/text_document_type_definition.cc.o CMakeFiles/ccls.dir/src/messages/workspace_did_change_configuration.cc.o CMakeFiles/ccls.dir/src/messages/workspace_did_change_watched_files.cc.o CMakeFiles/ccls.dir/src/messages/workspace_symbol.cc.o  -o ccls /usr/local/opt/llvm/lib/libclang.dylib -lc++experimental /usr/local/opt/llvm/lib/libclangDriver.a /usr/local/opt/llvm/lib/libclangBasic.a /usr/local/opt/llvm/lib/libLLVMOption.a /usr/local/opt/llvm/lib/libLLVMSupport.a /usr/local/opt/llvm/lib/libLLVMDemangle.a /usr/lib/libcurses.dylib /usr/lib/libform.dylib
Undefined symbols for architecture x86_64:
  "_compress2", referenced from:
      llvm::zlib::compress(llvm::StringRef, llvm::SmallVectorImpl<char>&, llvm::zlib::CompressionLevel) in libLLVMSupport.a(Compression.cpp.o)
  "_compressBound", referenced from:
      llvm::zlib::compress(llvm::StringRef, llvm::SmallVectorImpl<char>&, llvm::zlib::CompressionLevel) in libLLVMSupport.a(Compression.cpp.o)
  "_crc32", referenced from:
      llvm::zlib::crc32(llvm::StringRef) in libLLVMSupport.a(Compression.cpp.o)
  "_uncompress", referenced from:
      llvm::zlib::uncompress(llvm::StringRef, char*, unsigned long&) in libLLVMSupport.a(Compression.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [ccls] Error 1
make[1]: *** [CMakeFiles/ccls.dir/all] Error 2
make: *** [all] Error 2
twlz0ne commented 6 years ago

It's an issue of ccls,the temp temporary solution:

git clone https://github.com/twlz0ne/homebrew-ccls
cd homebrew-ccls
$EDITOR Formula/ccls.rb

Add following, then save changes and exit editing:

  # head "https://github.com/MaskRay/ccls.git"
  head "https://github.com/twlz0ne/ccls.git", :branch => "add-clangbasic-to-cmake"

Back to shell, install like this:

brew install Formula/ccls.rb --HEAD
MaskRay commented 6 years ago

On Linux,

% nm -D /usr/lib/libz.so.1 | grep compressB    
000000000000cd20 T compressBound
% bundled/clang+llvm-6.0.0-x86_64-linux-gnu-ubuntu-16.04/lib/cmake/llvm/LLVMConfig.cmake
...
set(LLVM_ENABLE_ZLIB 0)

set(LLVM_LIBXML2_ENABLED 0)

set(LLVM_ENABLE_DIA_SDK 0)

I suspect on your system, the llvm libraries were compiled with LLVM_ENABLE_ZLIB=1. Can you try -DUSE_SHARED_LLVM=on (linking against the dynamic LLVM shared object)? I have also pushed a commit to link against zlib.

gvol commented 6 years ago

Thanks! I just reinstalled with no changes, and it worked. I also tried @twlz0ne's suggestion and that worked too.