rdnetto / YCM-Generator

Generates config files for YouCompleteMe (https://github.com/Valloric/YouCompleteMe)
GNU General Public License v3.0
917 stars 128 forks source link

Support for Swift open source project (CMake) #84

Open danielmartin opened 8 years ago

danielmartin commented 8 years ago

I've tried YCM-Generator with the Swift open source project at https://github.com/apple/swift (based on CMake), but the following error occurs:

CMake Error at cmake/modules/SwiftUtils.cmake:94 (message):
  Unknown build type:
Call Stack (most recent call first):
  CMakeLists.txt:89 (is_build_type_optimized)

-- Configuring incomplete, errors occurred!

Running make...
$ make -i -j4
make: *** No targets specified and no makefile found.  Stop.

Cleaning up...

Build completed in 0.02 sec

Collected 0 relevant entries for C compilation (0 discarded).
Collected 0 relevant entries for C++ compilation (0 discarded).

ERROR: No commands were logged to the build logs (C: /var/folders/00/nsb8_t2n5wq23whfdzmhys9c0000gp/T/tmp3kulSv, C++: /var/folders/00/nsb8_t2n5wq23whfdzmhys9c0000gp/T/tmpogeFBw).
Your build system may not be compatible.

How can we investigate this problem further? Thank you.

rdnetto commented 8 years ago

It's failing because Swift doesn't use Cmake as the top-level build system - you'll get the same error if you run cmake . in the directory. The README for Swift says that it should be built using ./utils/build-script. The best way of handling this is to figure out what flags cmake is called with and pass them to it.

Running ./utils/build-script -R -n produces the following (once you've checked out the other sources as indicated in the README):

./swift/utils/build-script -R -n                                                                      15:50:36 
+ mkdir -p /tmp/mnt/build/Ninja-ReleaseAssert
+ env HOST_VARIABLE_linux_x86_64__SWIFT_BENCHMARK_TARGETS= HOST_VARIABLE_linux_x86_64__SWIFT_RUN_BENCHMARK_TARGETS= HOST_VARIABLE_linux_x86_64__SWIFT_SDKS=LINUX HOST_VARIABLE_linux_x86_64__SWIFT_STDLIB_TARGETS=swift-test-stdlib-linux-x86_64 HOST_VARIABLE_linux_x86_64__SWIFT_TEST_TARGETS= /tmp/mnt/swift/utils/build-script-impl --workspace /tmp/mnt --build-dir /tmp/mnt/build/Ninja-ReleaseAssert --install-prefix /usr --host-target linux-x86_64 --stdlib-deployment-targets linux-x86_64 --host-cc /usr/bin/clang --host-cxx /usr/bin/clang++ --darwin-xcrun-toolchain default --darwin-deployment-version-osx=10.9 --darwin-deployment-version-ios=7.0 --darwin-deployment-version-tvos=9.0 --darwin-deployment-version-watchos=2.0 --cmake /usr/bin/cmake --cmark-build-type Release --llvm-build-type Release --swift-build-type Release --swift-stdlib-build-type Release --lldb-build-type Release --foundation-build-type Release --libdispatch-build-type Release --xctest-build-type Release --swift-enable-assertions true --swift-stdlib-enable-assertions true --swift-analyze-code-coverage false --cmake-generator Ninja --build-jobs 6 '--common-cmake-options=-G Ninja -DCMAKE_C_COMPILER:PATH=/usr/bin/clang -DCMAKE_CXX_COMPILER:PATH=/usr/bin/clang++' --build-args=-j6 --cmark-cmake-options= '--llvm-cmake-options=-DLLVM_ENABLE_ASSERTIONS=TRUE -DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64;PowerPC;SystemZ' --swift-cmake-options= --build-stdlib-deployment-targets all --ninja-bin=/usr/bin/ninja --skip-build-foundation --skip-build-xctest --skip-build-lldb --skip-build-llbuild --skip-build-libdispatch --skip-build-swiftpm --skip-build-playgroundlogger --skip-build-playgroundsupport --build-swift-dynamic-stdlib --build-swift-dynamic-sdk-overlay --skip-build-ios-device --skip-build-ios-simulator --skip-build-tvos-device --skip-build-tvos-simulator --skip-build-watchos-device --skip-build-watchos-simulator --skip-build-android --skip-test-swift --skip-test-cmark --skip-test-lldb --skip-test-llbuild --skip-test-swiftpm --skip-test-xctest --skip-test-foundation --skip-test-libdispatch --skip-test-playgroundlogger --skip-test-playgroundsupport --skip-test-linux --skip-test-freebsd --skip-test-cygwin --skip-test-osx --skip-test-ios-host --skip-test-ios-simulator --skip-test-tvos-host --skip-test-tvos-simulator --skip-test-watchos-host --skip-test-watchos-simulator --skip-test-android-host --skip-test-benchmarks --skip-test-optimized --android-deploy-device-path /data/local/tmp --dry-run --llvm-lit-args=-sv
+ ln -sf ../../clang /tmp/mnt/llvm/tools/clang
+ ln -sf ../../compiler-rt /tmp/mnt/llvm/projects/compiler-rt
Building the standard library for: swift-test-stdlib-linux-x86_64
cmark: using gold linker
+ rm -rf /tmp/mnt/build/Ninja-ReleaseAssert/cmark-linux-x86_64/module-cache
+ mkdir -p /tmp/mnt/build/Ninja-ReleaseAssert/cmark-linux-x86_64/module-cache
+ mkdir -p /tmp/mnt/build/Ninja-ReleaseAssert/cmark-linux-x86_64
+ pushd /tmp/mnt/build/Ninja-ReleaseAssert/cmark-linux-x86_64
+ env /usr/bin/cmake -G Ninja -DCMAKE_C_COMPILER:PATH=/usr/bin/clang -DCMAKE_CXX_COMPILER:PATH=/usr/bin/clang++ -DCMAKE_EXE_LINKER_FLAGS:STRING=-fuse-ld=gold -DCMAKE_SHARED_LINKER_FLAGS:STRING=-fuse-ld=gold -DCMAKE_BUILD_TYPE:STRING=Release /tmp/mnt/cmark
+ popd
+ /usr/bin/cmake --build /tmp/mnt/build/Ninja-ReleaseAssert/cmark-linux-x86_64 -- -j6 all
llvm: using gold linker
+ rm -rf /tmp/mnt/build/Ninja-ReleaseAssert/llvm-linux-x86_64/module-cache
+ mkdir -p /tmp/mnt/build/Ninja-ReleaseAssert/llvm-linux-x86_64/module-cache
+ mkdir -p /tmp/mnt/build/Ninja-ReleaseAssert/llvm-linux-x86_64
+ pushd /tmp/mnt/build/Ninja-ReleaseAssert/llvm-linux-x86_64
+ env /usr/bin/cmake -G Ninja -DCMAKE_C_COMPILER:PATH=/usr/bin/clang -DCMAKE_CXX_COMPILER:PATH=/usr/bin/clang++ -DCMAKE_EXE_LINKER_FLAGS:STRING=-fuse-ld=gold -DCMAKE_SHARED_LINKER_FLAGS:STRING=-fuse-ld=gold -DLLVM_ENABLE_ASSERTIONS=TRUE '-DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64;PowerPC;SystemZ' '-DCMAKE_C_FLAGS= -fno-stack-protector' '-DCMAKE_CXX_FLAGS= -fno-stack-protector' '-DCMAKE_C_FLAGS_RELWITHDEBINFO=-O2 -DNDEBUG' '-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=-O2 -DNDEBUG' -DCMAKE_BUILD_TYPE:STRING=Release -DLLVM_TOOL_SWIFT_BUILD:BOOL=NO -DLLVM_INCLUDE_DOCS:BOOL=TRUE -DLLVM_ENABLE_LTO:STRING= -DLLVM_TOOL_COMPILER_RT_BUILD:BOOL=TRUE -DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL=TRUE -DLLVM_LIT_ARGS=-sv -DCMAKE_INSTALL_PREFIX:PATH=/usr/ -DINTERNAL_INSTALL_PREFIX=local /tmp/mnt/llvm
+ popd
symlinking the system headers (/usr/include/c++) into the local clang build directory (/tmp/mnt/build/Ninja-ReleaseAssert/llvm-linux-x86_64/include).
+ ln -s -f /usr/include/c++ /tmp/mnt/build/Ninja-ReleaseAssert/llvm-linux-x86_64/include
+ /usr/bin/cmake --build /tmp/mnt/build/Ninja-ReleaseAssert/llvm-linux-x86_64 -- -j6 all
swift: using gold linker
+ rm -rf /tmp/mnt/build/Ninja-ReleaseAssert/swift-linux-x86_64/module-cache
+ mkdir -p /tmp/mnt/build/Ninja-ReleaseAssert/swift-linux-x86_64/module-cache
+ mkdir -p /tmp/mnt/build/Ninja-ReleaseAssert/swift-linux-x86_64
+ pushd /tmp/mnt/build/Ninja-ReleaseAssert/swift-linux-x86_64
+ env /usr/bin/cmake -G Ninja -DCMAKE_C_COMPILER:PATH=/usr/bin/clang -DCMAKE_CXX_COMPILER:PATH=/usr/bin/clang++ -DSWIFT_ENABLE_GOLD_LINKER=TRUE '-DCMAKE_C_FLAGS= -fno-stack-protector' '-DCMAKE_CXX_FLAGS= -fno-stack-protector' '-DCMAKE_C_FLAGS_RELWITHDEBINFO=-O2 -DNDEBUG' '-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=-O2 -DNDEBUG' -DCMAKE_BUILD_TYPE:STRING=Release -DLLVM_ENABLE_ASSERTIONS:BOOL=TRUE -DSWIFT_ANALYZE_CODE_COVERAGE:STRING=FALSE -DSWIFT_STDLIB_BUILD_TYPE:STRING=Release -DSWIFT_STDLIB_ASSERTIONS:BOOL=TRUE -DSWIFT_STDLIB_ENABLE_RESILIENCE:BOOL=FALSE -DSWIFT_STDLIB_SIL_SERIALIZE_ALL:BOOL=TRUE -DSWIFT_NATIVE_LLVM_TOOLS_PATH:STRING= -DSWIFT_NATIVE_CLANG_TOOLS_PATH:STRING= -DSWIFT_NATIVE_SWIFT_TOOLS_PATH:STRING= -DSWIFT_INCLUDE_TOOLS:BOOL=TRUE -DSWIFT_BUILD_REMOTE_MIRROR:BOOL=TRUE -DSWIFT_SERIALIZE_STDLIB_UNITTEST:BOOL=FALSE -DSWIFT_STDLIB_SIL_DEBUGGING:BOOL=FALSE -DSWIFT_CHECK_INCREMENTAL_COMPILATION:BOOL=FALSE -DSWIFT_BUILD_DYNAMIC_STDLIB:BOOL=TRUE -DSWIFT_BUILD_STATIC_STDLIB:BOOL=FALSE -DSWIFT_BUILD_DYNAMIC_SDK_OVERLAY:BOOL=TRUE -DSWIFT_BUILD_STATIC_SDK_OVERLAY:BOOL=FALSE -DSWIFT_BUILD_PERF_TESTSUITE:BOOL=TRUE -DSWIFT_BUILD_EXAMPLES:BOOL=TRUE -DSWIFT_INCLUDE_TESTS:BOOL=TRUE -DSWIFT_INSTALL_COMPONENTS:STRING= -DSWIFT_EMBED_BITCODE_SECTION:BOOL=FALSE -DSWIFT_TOOLS_ENABLE_LTO:STRING= -DSWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER:BOOL=TRUE -DSWIFT_HOST_VARIANT=linux -DSWIFT_HOST_VARIANT_SDK=LINUX -DSWIFT_HOST_VARIANT_ARCH=x86_64 -DLLVM_LIT_ARGS=-sv -DCOVERAGE_DB= -DSWIFT_SOURCEKIT_USE_INPROC_LIBRARY:BOOL=TRUE -DSWIFT_DARWIN_XCRUN_TOOLCHAIN:STRING=default -DSWIFT_AST_VERIFIER:BOOL=TRUE -DSWIFT_SIL_VERIFY_ALL:BOOL=FALSE -DSWIFT_RUNTIME_ENABLE_LEAK_CHECKER:BOOL=FALSE -DCMAKE_INSTALL_PREFIX:PATH=/usr/ -DSWIFT_PATH_TO_CLANG_SOURCE:PATH=/tmp/mnt/llvm/tools/clang -DSWIFT_PATH_TO_CLANG_BUILD:PATH=/tmp/mnt/build/Ninja-ReleaseAssert/llvm-linux-x86_64 -DSWIFT_PATH_TO_LLVM_SOURCE:PATH=/tmp/mnt/llvm -DSWIFT_PATH_TO_LLVM_BUILD:PATH=/tmp/mnt/build/Ninja-ReleaseAssert/llvm-linux-x86_64 -DSWIFT_PATH_TO_CMARK_SOURCE:PATH=/tmp/mnt/cmark -DSWIFT_PATH_TO_CMARK_BUILD:PATH=/tmp/mnt/build/Ninja-ReleaseAssert/cmark-linux-x86_64 -DSWIFT_PATH_TO_LIBDISPATCH_SOURCE:PATH=/tmp/mnt/swift-corelibs-libdispatch -DSWIFT_PATH_TO_LIBDISPATCH_BUILD:PATH=/tmp/mnt/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64 -DSWIFT_CMARK_LIBRARY_DIR:PATH=/tmp/mnt/build/Ninja-ReleaseAssert/cmark-linux-x86_64/src -DSWIFT_SDKS:STRING=LINUX -DSWIFT_EXEC:STRING=/tmp/mnt/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swiftc /tmp/mnt/swift
+ popd
+ /usr/bin/cmake --build /tmp/mnt/build/Ninja-ReleaseAssert/swift-linux-x86_64 -- -j6 all swift-test-stdlib-linux-x86_64

Judging by that, you'll need to use -e to preserve the environment variables, and use -C to pass in the cmake options. I suggest you figure out how to run cmake directly first, before you try to make YCM-Gen work. I have no idea how much effort it'll take though.