Clang build on windows

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Clang build on windows

Kristof Beyls via cfe-dev
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
3. Visual Studio 2017 
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
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

build.log (18K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Clang build on windows

Kristof Beyls via cfe-dev
The problem is that CMake caches some build configuration options for you, against your will.

Remove your whole build directory and try the `cmake` invocation from your second try again, and it should work (It’s picking up the cached value of the `-A` argument from your first invocation, which isn’t valid for Makefiles).

Looking at your other options that you provide to the build system, if you want your default target triple to be x86-based, you should specify `-DLLVM_TARGETS_TO_BUILD=“X86;RISCV”` (RISC-V is no longer experimental, so it can go in either `LLVM_TARGETS_TO_BUILD` or `LLVM_EXPERIMENTAL_TARGETS_TO_BUILD` now).

Hope this helps!

Sam

> On 31 Oct 2019, at 5:16 am, ghalib exaleap via cfe-dev <[hidden email]> 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.
> <build.log>_______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

--
Sam Elliott
Software Developer - LLVM
lowRISC CIC
--

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang build on windows

Kristof Beyls via cfe-dev
In reply to this post by Kristof Beyls via cfe-dev

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
3. Visual Studio 2017 
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
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev