[cfe-dev] Clang build on windows

Petr Penzin via cfe-dev cfe-dev at lists.llvm.org
Thu Oct 31 12:11:29 PDT 2019


The CMake line in your first attempt does not build the project it just 
generates build files. The command you shared:

cmake -DLLVM_ENABLE_PROJECTS=clang -G "Visual Studio 15 2017" -A x64 
-Thost=x64 ../llvm

should set up your build directory (before building anything), to run 
the build try "cmake --build ." (MSVC build can be invoked from the 
command line, but the command is much more complicated).

For the second attempt, I haven't had luck with Makefiles on Windows 
(but maybe it is just me), but Ninja with LLVM works really well. To 
configure the build with ninja use Ninja generator in CMake (-GNinja on 
command line). Note that ninja is parallel by default and you might need 
to limit the number of concurrent link jobs, so that you don't run out 
of memory. The configuration that has worked the best for me is Ninja 
with LLVM toolchain (clang+lld). So in the Visual Studio shell with LLVM 
release on the PATH it would look something like this:

> cmake  -GNinja -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl 
-DCMAKE_LINKER=lld-link -DLLVM_PARALLEL_LINK_JOBS=<N> <any other 
options> <src dir>

Parallel link parameter is best set by trial and error, but I was able 
to get away with four lobs of LLVM 8 on 16 GB of ram. To build with 
ninja simply invoke 'ninja'.

Hope that helps, let me know if you have any questions.


Best,

Petr

On 10/30/19 10:16 PM, ghalib exaleap via cfe-dev wrote:
> Hi,
>      To build clang on windows i have gone through the following step's,
> Try-1 on a windows machine
> ------------------------------------
> Followed step's from http://clang.llvm.org/get_started.html ----->
>
>
>       Using Visual Studio
>
> 1. Downloaded Git https://git-scm.com/download
> 2. *CMake *https://cmake.org/download/
> 3. *Visual Studio 2017 *
> 4. *Python *https://www.python.org/download/
> 5. *GnuWin32 tools *http://sourceforge.net/projects/getgnuwin32/files/
> 6. Cloned git clone https://github.com/llvm/llvm-project.git
> 7. mkdir build && cd build
> 8. cmake -DLLVM_ENABLE_PROJECTS=clang -G "Visual Studio 15 2017" -A 
> x64 -Thost=x64 ../llvm
> *** Build was successful but, Am not getting what happen I searched 
> each and ervery folder their i haven't found clang executables.
>
> *** You can find the build log & folder structure in the attachment.
>
> -----------------------------------------------------------------------------------
> Try-2 on a windows machine
> ------------------------------------
> steps:
> 1. Download MSYS2
> 2. pacman -S cmake
> 3. Run
> $ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Release" 
> -DBUILD_SHARED_LIBS=True -DLLVM_USE_SPLIT_DWARF=True 
> -DCMAKE_INSTALL_PREFIX="\Users\Dell\llvm-project\khan\install" 
> -DLLVM_OPTIMIZED_TABLEGEN=True -DLLVM_BUILD_TESTS=False 
> -DDEFAULT_SYSROOT="\Users\Dell\llvm-project\khan\install\sysroot" 
> -DLLVM_DEFAULT_TARGET_TRIPLE="x86_64-w64-mingw32" 
> -DLLVM_TARGETS_TO_BUILD="" 
> -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="RISCV" ../llvm
>
> (Or)
>   DLLVM_DEFAULT_TARGET_TRIPLE="riscv64-unknown-linux-gnu"
>
> Getting an Error:
> -----------------------
> CMake Error at CMakeLists.txt:53 (project):
>   Generator
>
>     Unix Makefiles
>
>   does not support platform specification, but platform
>
>     64
>
>   was specified.
>
>
> -- Configuring incomplete, errors occurred!
> See also "/home/Dell/llvm-project/build/CMakeFiles/CMakeOutput.log".
> ------------------------------------------------------------------------------------------------------------------------------
>
>   *** Can anyone please help me to get clang Windows Executable.
>
>  Thanks
> Ghalib khan.
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20191031/ad3da498/attachment.html>


More information about the cfe-dev mailing list