llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.93k stars 11.53k forks source link

Cmake configuration fails on windows #40885

Open zero9178 opened 5 years ago

zero9178 commented 5 years ago
Bugzilla Link 41540
Version unspecified
OS Windows NT
Blocks llvm/llvm-project#48661
Attachments CMakeCache
CC @andrewrk,@DimitryAndric,@smithp35,@tstellar

Extended Description

Hello everyone, I am trying to build LLD without using the LLVM mono repo since I already have LLVM installed. I am using following cmake command and get the following error at configure time.

C:\Tools\cmake-3.13.1-win64-x64\bin\cmake.exe .. -G "CodeBlocks - MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=C:/MGPKG/LLVM-8.0.0 -DCMAKE_INSTALL_PREFIX=C:/MGPKG/LLD-8.0.0 -DBUILD_SHARED_LIBS=OFF -- The C compiler identification is GNU 8.1.0 -- The CXX compiler identification is GNU 8.1.0 -- Check for working C compiler: C:/mingw-w64/8.1/bin/gcc.exe -- Check for working C compiler: C:/mingw-w64/8.1/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:/mingw-w64/8.1/bin/g++.exe -- Check for working CXX compiler: C:/mingw-w64/8.1/bin/g++.exe -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Performing Test C_SUPPORTS_WERROR_DATE_TIME CMake Error at C:/Users/Markus/Documents/lld-8.0.0.src/build/CMakeFiles/CMakeTmp/CMakeLists.txt:2 (set): Syntax error in cmake code at

C:/Users/Markus/Documents/lld-8.0.0.src/build/CMakeFiles/CMakeTmp/CMakeLists.txt:2

when parsing string

C:\MGPKG\LLVM-8.0.0/lib/cmake/llvm

Invalid character escape '\M'.

CMake Error at C:/Tools/cmake-3.13.1-win64-x64/share/cmake-3.13/Modules/CheckCSourceCompiles.cmake:98 (try_compile): Failed to configure test project build system. Call Stack (most recent call first): C:/Tools/cmake-3.13.1-win64-x64/share/cmake-3.13/Modules/CheckCCompilerFlag.cmake:50 (CHECK_C_SOURCE_COMPILES) C:/MGPKG/LLVM-8.0.0/lib/cmake/llvm/HandleLLVMOptions.cmake:172 (check_c_compiler_flag) C:/MGPKG/LLVM-8.0.0/lib/cmake/llvm/HandleLLVMOptions.cmake:416 (add_flag_if_supported) CMakeLists.txt:56 (include)

-- Configuring incomplete, errors occurred! See also "C:/Users/Markus/Documents/lld-8.0.0.src/build/CMakeFiles/CMakeOutput.log".

I have also attached CMakeCache.txt file. If I am doing something wrong when building please tell me. Building Clang like that has worked for me so far.

tstellar commented 2 years ago

mentioned in issue llvm/llvm-project#48661

andrewrk commented 3 years ago

I just ran the same config and then msbuild install on LLVM and Clang prior to doing it for LLD. It's the same process that package maintainers use when creating system packages.

DimitryAndric commented 3 years ago

Where did you get the "already installed LLVM from"? My guess is that the CMake configuration is running llvm-config.exe, and this outputs a path with backslashes in it. These backslashes confuse CMake.

andrewrk commented 3 years ago

Confirming this bug exists with LLD 12. The same problem does not happen with LLVM or Clang, just LLD.

c:\msys64\home\andy\tmp\llvm-project-12\lld\build-release>"c:\Program Files\CMake\bin\cmake.exe" .. -Thost=x64 -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=c:/msys64/home/andy/local/llvm12-release -DCMAKE_PREFIX_PATH=c:/msys64/home/andy/local/llvm12-release -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_CRT_RELEASE=MT -- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041. -- Using Debug VC++ CRT: MDd -- Using Release VC++ CRT: MT -- Using MinSizeRel VC++ CRT: MD -- Using RelWithDebInfo VC++ CRT: MD -- Using Release VC++ CRT: MT -- Performing Test LLVM_HAS_ATOMICS CMake Error at C:/msys64/home/andy/tmp/llvm-project-12/lld/build-release/CMakeFiles/CMakeTmp/CMakeLists.txt:2 (set): Syntax error in cmake code at

C:/msys64/home/andy/tmp/llvm-project-12/lld/build-release/CMakeFiles/CMakeTmp/CMakeLists.txt:2

when parsing string

C:\msys64\home\andy\local\llvm12-release\lib\cmake\llvm

Invalid character escape '\m'.

CMake Error at C:/Program Files/CMake/share/cmake-3.15/Modules/CheckCXXSourceCompiles.cmake:110 (try_compile): Failed to configure test project build system. Call Stack (most recent call first): C:/msys64/home/andy/local/llvm12-release/lib/cmake/llvm/CheckAtomic.cmake:88 (CHECK_CXX_SOURCE_COMPILES) CMakeLists.txt:57 (include)

-- Configuring incomplete, errors occurred! See also "C:/msys64/home/andy/tmp/llvm-project-12/lld/build-release/CMakeFiles/CMakeOutput.log".