cmake/modules/AddLLVM.cmake 处的 CMake 错误

Posted

技术标签:

【中文标题】cmake/modules/AddLLVM.cmake 处的 CMake 错误【英文标题】:CMake Error at cmake/modules/AddLLVM.cmake 【发布时间】:2019-04-22 15:44:05 【问题描述】:

我尝试在 win10x64 上为 mingw_32 生成 llvm makefile,但发现了一些错误。

cmake -S "D:\Program Files\llvm-8.0.0.src"  -B "C:\CppLibs\libclang" -DLLVM_TARGETS_TO_BUILD:STRING="X86" -DCMAKE_BUILD_TYPE:STRING='Release' -DCMAKE_CONFIGURATION_TYPES:STRING="Release" -DDLLVM_INCLUDE_TESTS=OFF  -G "MinGW Makefiles"

-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/Qt/Tools/mingw730_64/bin/gcc.exe
-- Check for working C compiler: C:/Qt/Tools/mingw730_64/bin/gcc.exe
-- Check for working C compiler: C:/Qt/Tools/mingw730_64/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Qt/Tools/mingw730_64/bin/g++.exe
-- Check for working CXX compiler: C:/Qt/Tools/mingw730_64/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for dlfcn.h
-- Looking for dlfcn.h - not found
-- Looking for errno.h
-- Looking for errno.h - found
-- Looking for fcntl.h
-- Looking for fcntl.h - found
-- Looking for link.h
-- Looking for link.h - not found
-- Looking for malloc.h
-- Looking for malloc.h - found
-- Looking for malloc/malloc.h
-- Looking for malloc/malloc.h - not found
-- Looking for signal.h
-- Looking for signal.h - found
-- Looking for sys/ioctl.h
-- Looking for sys/ioctl.h - not found
-- Looking for sys/mman.h
-- Looking for sys/mman.h - not found
-- Looking for sys/param.h
-- Looking for sys/param.h - found
-- Looking for sys/resource.h
-- Looking for sys/resource.h - not found
-- Looking for sys/stat.h
-- Looking for sys/stat.h - found
-- Looking for sys/time.h
-- Looking for sys/time.h - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for termios.h
-- Looking for termios.h - not found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for valgrind/valgrind.h
-- Looking for valgrind/valgrind.h - not found
-- Looking for zlib.h
-- Looking for zlib.h - found
-- Looking for fenv.h
-- Looking for fenv.h - found
-- Looking for FE_ALL_EXCEPT
-- Looking for FE_ALL_EXCEPT - found
-- Looking for FE_INEXACT
-- Looking for FE_INEXACT - found
-- Looking for mach/mach.h
-- Looking for mach/mach.h - not found
-- Looking for histedit.h
-- Looking for histedit.h - not found
-- Looking for CrashReporterClient.h
-- Looking for CrashReporterClient.h - not found
-- Looking for pfm_initialize in pfm
-- Looking for pfm_initialize in pfm - not found
-- Looking for compress2 in z
-- Looking for compress2 in z - found
-- Looking for xar_open in xar
-- Looking for xar_open in xar - not found
-- Looking for arc4random
-- Looking for arc4random - not found
-- Looking for backtrace
-- Looking for backtrace - not found
-- Could NOT find Backtrace (missing: Backtrace_LIBRARY Backtrace_INCLUDE_DIR)
-- Performing Test C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW
-- Performing Test C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW - Failed
-- Looking for _Unwind_Backtrace
-- Looking for _Unwind_Backtrace - found
-- Looking for getpagesize
-- Looking for getpagesize - not found
-- Looking for sysconf
-- Looking for sysconf - not found
-- Looking for getrusage
-- Looking for getrusage - not found
-- Looking for setrlimit
-- Looking for setrlimit - not found
-- Looking for isatty
-- Looking for isatty - found
-- Looking for futimens
-- Looking for futimens - not found
-- Looking for futimes
-- Looking for futimes - not found
-- Looking for posix_fallocate
-- Looking for posix_fallocate - not found
-- Looking for sigaltstack
-- Looking for sigaltstack - not found
-- Looking for lseek64
-- Looking for lseek64 - found
-- Looking for mallctl
-- Looking for mallctl - not found
-- Looking for mallinfo
-- Looking for mallinfo - not found
-- Looking for malloc_zone_statistics
-- Looking for malloc_zone_statistics - not found
-- Looking for getrlimit
-- Looking for getrlimit - not found
-- Looking for posix_spawn
-- Looking for posix_spawn - not found
-- Looking for pread
-- Looking for pread - not found
-- Looking for realpath
-- Looking for realpath - not found
-- Looking for sbrk
-- Looking for sbrk - not found
-- Looking for strerror
-- Looking for strerror - found
-- Looking for strerror_r
-- Looking for strerror_r - not found
-- Looking for strerror_s
-- Looking for strerror_s - found
-- Looking for setenv
-- Looking for setenv - not found
-- Looking for _chsize_s
-- Looking for _chsize_s - found
-- Looking for _alloca
-- Looking for _alloca - not found
-- Looking for __alloca
-- Looking for __alloca - found
-- Looking for __chkstk
-- Looking for __chkstk - not found
-- Looking for __chkstk_ms
-- Looking for __chkstk_ms - not found
-- Looking for ___chkstk
-- Looking for ___chkstk - found
-- Looking for ___chkstk_ms
-- Looking for ___chkstk_ms - found
-- Looking for __ashldi3
-- Looking for __ashldi3 - not found
-- Looking for __ashrdi3
-- Looking for __ashrdi3 - not found
-- Looking for __divdi3
-- Looking for __divdi3 - not found
-- Looking for __fixdfdi
-- Looking for __fixdfdi - not found
-- Looking for __fixsfdi
-- Looking for __fixsfdi - not found
-- Looking for __floatdidf
-- Looking for __floatdidf - not found
-- Looking for __lshrdi3
-- Looking for __lshrdi3 - not found
-- Looking for __moddi3
-- Looking for __moddi3 - not found
-- Looking for __udivdi3
-- Looking for __udivdi3 - not found
-- Looking for __umoddi3
-- Looking for __umoddi3 - not found
-- Looking for __main
-- Looking for __main - found
-- Looking for __cmpdi2
-- Looking for __cmpdi2 - not found
-- Performing Test HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
-- Performing Test HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC - Failed
-- Performing Test HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
-- Performing Test HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC - Failed
-- Looking for __GLIBC__
-- Looking for __GLIBC__ - not found
-- Looking for sched_getaffinity
-- Looking for sched_getaffinity - not found
-- Looking for CPU_COUNT
-- Looking for CPU_COUNT - not found
-- Performing Test HAVE_CXX_ATOMICS_WITHOUT_LIB
-- Performing Test HAVE_CXX_ATOMICS_WITHOUT_LIB - Success
-- Performing Test HAVE_CXX_ATOMICS64_WITHOUT_LIB
-- Performing Test HAVE_CXX_ATOMICS64_WITHOUT_LIB - Success
-- Performing Test LLVM_HAS_ATOMICS
-- Performing Test LLVM_HAS_ATOMICS - Success
-- Performing Test SUPPORTS_VARIADIC_MACROS_FLAG
-- Performing Test SUPPORTS_VARIADIC_MACROS_FLAG - Success
-- Performing Test SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG
-- Performing Test SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG - Failed
-- Performing Test HAS_MAYBE_UNINITIALIZED
-- Performing Test HAS_MAYBE_UNINITIALIZED - Success
-- Native target architecture is X86
-- Threads enabled.
-- Doxygen disabled.
-- Go bindings disabled.
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH)
-- OCaml bindings disabled.
-- Could NOT find Python module pygments
-- Could NOT find Python module pygments.lexers.c_cpp
-- Could NOT find Python module yaml
-- LLVM host triple: x86_64-w64-windows-gnu
-- LLVM default target triple: x86_64-w64-windows-gnu
-- Performing Test C_SUPPORTS_WERROR_DATE_TIME
-- Performing Test C_SUPPORTS_WERROR_DATE_TIME - Success
-- Performing Test CXX_SUPPORTS_WERROR_DATE_TIME
-- Performing Test CXX_SUPPORTS_WERROR_DATE_TIME - Success
-- Performing Test CXX_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW
-- Performing Test CXX_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW - Failed
-- Performing Test CXX_SUPPORTS_CXX11
-- Performing Test CXX_SUPPORTS_CXX11 - Success
-- Performing Test CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG
-- Performing Test CXX_SUPPORTS_MISSING_FIELD_INITIALIZERS_FLAG - Success
-- Performing Test C_SUPPORTS_IMPLICIT_FALLTHROUGH_FLAG
-- Performing Test C_SUPPORTS_IMPLICIT_FALLTHROUGH_FLAG - Success
-- Performing Test CXX_SUPPORTS_IMPLICIT_FALLTHROUGH_FLAG
-- Performing Test CXX_SUPPORTS_IMPLICIT_FALLTHROUGH_FLAG - Success
-- Performing Test C_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG
-- Performing Test C_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG - Failed
-- Performing Test CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG
-- Performing Test CXX_SUPPORTS_COVERED_SWITCH_DEFAULT_FLAG - Failed
-- Performing Test CXX_SUPPORTS_CLASS_MEMACCESS_FLAG
-- Performing Test CXX_SUPPORTS_CLASS_MEMACCESS_FLAG - Failed
-- Performing Test CXX_SUPPORTS_NOEXCEPT_TYPE_FLAG
-- Performing Test CXX_SUPPORTS_NOEXCEPT_TYPE_FLAG - Success
-- Performing Test C_SUPPORTS_DELETE_NON_VIRTUAL_DTOR_FLAG
-- Performing Test C_SUPPORTS_DELETE_NON_VIRTUAL_DTOR_FLAG - Failed
-- Performing Test CXX_SUPPORTS_DELETE_NON_VIRTUAL_DTOR_FLAG
-- Performing Test CXX_SUPPORTS_DELETE_NON_VIRTUAL_DTOR_FLAG - Success
-- Performing Test C_WCOMMENT_ALLOWS_LINE_WRAP
-- Performing Test C_WCOMMENT_ALLOWS_LINE_WRAP - Failed
-- Performing Test C_SUPPORTS_STRING_CONVERSION_FLAG
-- Performing Test C_SUPPORTS_STRING_CONVERSION_FLAG - Failed
-- Performing Test CXX_SUPPORTS_STRING_CONVERSION_FLAG
-- Performing Test CXX_SUPPORTS_STRING_CONVERSION_FLAG - Failed
-- Found PythonInterp: C:/Python27/python.exe (found version "2.7.16")
-- Constructing LLVMBuild project information
-- LLVMHello ignored -- Loadable modules not supported on this platform.
-- Targeting X86
CMake Error at cmake/modules/AddLLVM.cmake:1526 (string):
  string begin index: -1 is out of range 0 - 23
Call Stack (most recent call first):
  tools/llvm-ar/CMakeLists.txt:18 (add_llvm_tool_symlink)


CMake Error at cmake/modules/AddLLVM.cmake:1527 (string):
  string sub-command REPLACE requires at least four arguments.
Call Stack (most recent call first):
  tools/llvm-ar/CMakeLists.txt:18 (add_llvm_tool_symlink)


CMake Error at cmake/modules/AddLLVM.cmake:1526 (string):
  string begin index: -1 is out of range 0 - 23
Call Stack (most recent call first):
  tools/llvm-ar/CMakeLists.txt:19 (add_llvm_tool_symlink)


CMake Error at cmake/modules/AddLLVM.cmake:1527 (string):
  string sub-command REPLACE requires at least four arguments.
Call Stack (most recent call first):
  tools/llvm-ar/CMakeLists.txt:19 (add_llvm_tool_symlink)


CMake Error at cmake/modules/AddLLVM.cmake:1526 (string):
  string begin index: -1 is out of range 0 - 23
Call Stack (most recent call first):
  tools/llvm-ar/CMakeLists.txt:20 (add_llvm_tool_symlink)


CMake Error at cmake/modules/AddLLVM.cmake:1527 (string):
  string sub-command REPLACE requires at least four arguments.
Call Stack (most recent call first):
  tools/llvm-ar/CMakeLists.txt:20 (add_llvm_tool_symlink)


-- BugpointPasses ignored -- Loadable modules not supported on this platform.
CMake Error at cmake/modules/AddLLVM.cmake:1526 (string):
  string begin index: -1 is out of range 0 - 23
Call Stack (most recent call first):
  tools/llvm-objcopy/CMakeLists.txt:31 (add_llvm_tool_symlink)


CMake Error at cmake/modules/AddLLVM.cmake:1527 (string):
  string sub-command REPLACE requires at least four arguments.
Call Stack (most recent call first):
  tools/llvm-objcopy/CMakeLists.txt:31 (add_llvm_tool_symlink)


CMake Error at cmake/modules/AddLLVM.cmake:1526 (string):
  string begin index: -1 is out of range 0 - 23
Call Stack (most recent call first):
  tools/llvm-readobj/CMakeLists.txt:26 (add_llvm_tool_symlink)


CMake Error at cmake/modules/AddLLVM.cmake:1527 (string):
  string sub-command REPLACE requires at least four arguments.
Call Stack (most recent call first):
  tools/llvm-readobj/CMakeLists.txt:26 (add_llvm_tool_symlink)


-- TestPlugin ignored -- Loadable modules not supported on this platform.
-- Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.17.1.windows.2")
-- git Version: v0.0.0
-- Version: 0.0.0
-- Performing Test HAVE_CXX_FLAG_STD_CXX11
-- Performing Test HAVE_CXX_FLAG_STD_CXX11 - Success
-- Performing Test HAVE_CXX_FLAG_WALL
-- Performing Test HAVE_CXX_FLAG_WALL - Success
-- Performing Test HAVE_CXX_FLAG_WEXTRA
-- Performing Test HAVE_CXX_FLAG_WEXTRA - Success
-- Performing Test HAVE_CXX_FLAG_WSHADOW
-- Performing Test HAVE_CXX_FLAG_WSHADOW - Success
-- Performing Test HAVE_CXX_FLAG_PEDANTIC
-- Performing Test HAVE_CXX_FLAG_PEDANTIC - Success
-- Performing Test HAVE_CXX_FLAG_PEDANTIC_ERRORS
-- Performing Test HAVE_CXX_FLAG_PEDANTIC_ERRORS - Success
-- Performing Test HAVE_CXX_FLAG_WSHORTEN_64_TO_32
-- Performing Test HAVE_CXX_FLAG_WSHORTEN_64_TO_32 - Failed
-- Performing Test HAVE_CXX_FLAG_WFLOAT_EQUAL
-- Performing Test HAVE_CXX_FLAG_WFLOAT_EQUAL - Success
-- Performing Test HAVE_CXX_FLAG_FSTRICT_ALIASING
-- Performing Test HAVE_CXX_FLAG_FSTRICT_ALIASING - Success
-- Performing Test HAVE_CXX_FLAG_FNO_EXCEPTIONS
-- Performing Test HAVE_CXX_FLAG_FNO_EXCEPTIONS - Success
-- Performing Test HAVE_CXX_FLAG_WSTRICT_ALIASING
-- Performing Test HAVE_CXX_FLAG_WSTRICT_ALIASING - Success
-- Performing Test HAVE_CXX_FLAG_WD654
-- Performing Test HAVE_CXX_FLAG_WD654 - Failed
-- Performing Test HAVE_CXX_FLAG_WTHREAD_SAFETY
-- Performing Test HAVE_CXX_FLAG_WTHREAD_SAFETY - Failed
-- Performing Test HAVE_CXX_FLAG_COVERAGE
-- Performing Test HAVE_CXX_FLAG_COVERAGE - Success
-- Performing Test HAVE_GNU_POSIX_REGEX
-- Performing Test HAVE_GNU_POSIX_REGEX
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Performing Test HAVE_POSIX_REGEX
-- Performing Test HAVE_POSIX_REGEX
-- Performing Test HAVE_POSIX_REGEX -- failed to compile
CMake Warning at utils/benchmark/CMakeLists.txt:241 (message):
  Using std::regex with exceptions disabled is not fully supported


-- Performing Test HAVE_STEADY_CLOCK
-- Performing Test HAVE_STEADY_CLOCK
-- Performing Test HAVE_STEADY_CLOCK -- success
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Configuring incomplete, errors occurred!
See also "C:/CppLibs/libclang/CMakeFiles/CMakeOutput.log".
See also "C:/CppLibs/libclang/CMakeFiles/CMakeError.log".

如果我为 msvc15 生成文件,一切都会正常工作。

CMakeError.log https://pastebin.com/krKDc7sR

CMakeOutput.log https://pastebin.com/ubWVtAk8

日志说我在 tools/llvm-ar/CMakeLists.txt 中调用了问题

add_llvm_tool_symlink(llvm-ranlib llvm-ar)
add_llvm_tool_symlink(llvm-lib llvm-ar)
add_llvm_tool_symlink(llvm-dlltool llvm-ar)

在 tools/llvm-objcopy/CMakeLists.txt 中

add_llvm_tool_symlink(llvm-strip llvm-objcopy)

在 tools/llvm-readobj/CMakeLists.txt 中

add_llvm_tool_symlink(llvm-readelf llvm-readobj)

都指向cmake/modules/AddLLVM.cmake

  string(SUBSTRING "$ARG_OUTPUT_DIR" $type_start -1 path_suffix)
  string(REPLACE "/$first_type/" "/$CMAKE_CFG_INTDIR/"

所以问题是如何解决这个问题并生成 makefile?谢谢

【问题讨论】:

您忘记提供错误消息所在的配置日志本身。请将此日志作为文本(而不是像CMakeError.logCMakeOutput.log 那样作为链接)添加到问题帖子中。可以使用Ctrl+K 按钮将粘贴的配置日志格式化为代码 我添加了日志,我想你是认真的 【参考方案1】:

生成器“MinGW Makefiles”不是多配置生成器。所以变量CMAKE_CONFIGURATION_TYPES 应该为其设置。

通过在命令行中设置变量,您会混淆项目的CMakeLists.txt 以假设您的生成器是多配置的,从而导致奇怪的错误。

【讨论】:

以上是关于cmake/modules/AddLLVM.cmake 处的 CMake 错误的主要内容,如果未能解决你的问题,请参考以下文章