Clang get started

来源:互联网 发布:2015西安行知中学官网 编辑:程序博客网 时间:2024/06/09 22:16

Clang get started 地址:

http://clang.llvm.org/get_started.html


windows下方法:

Using Visual Studio

The following details setting up for and building Clang on Windows using Visual Studio:

  1. Get the required tools:
    • Subversion. Source code control program. Get it from: http://subversion.apache.org/packages.html
    • CMake. This is used for generating Visual Studio solution and project files. Get it from: http://www.cmake.org/cmake/resources/software.html
    • Visual Studio 2013 or later
    • Python. This is needed only if you will be running the tests (which is essential, if you will be developing for clang). Get it from: http://www.python.org/download/
    • GnuWin32 tools These are also necessary for running the tests. (Note that the grep from MSYS or Cygwin doesn't work with the tests because of embedded double-quotes in the search strings. The GNU grep does work in this case.) Get them fromhttp://getgnuwin32.sourceforge.net/.
  2. Check out LLVM:
    • svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
  3. Check out Clang:
    • cd llvm\tools
    • svn co http://llvm.org/svn/llvm-project/cfe/trunk clang

    Note: Some Clang tests are sensitive to the line endings. Ensure that checking out the files does not convert LF line endings to CR+LF. If you use git-svn, make sure your core.autocrlf setting is false.

  4. Run CMake to generate the Visual Studio solution and project files:
    • cd ..\.. (back to where you started)
    • mkdir build (for building without polluting the source dir)
    • cd build
    • If you are using Visual Studio 2013: cmake -G "Visual Studio 12" ..\llvm
    • By default, the Visual Studio project files generated by CMake use the 32-bit toolset. If you are developing on a 64-bit version of Windows and want to use the 64-bit toolset, pass the ``-Thost=x64`` flag when generating the Visual Studio solution. This requires CMake 3.8.0 or later.
    • See the LLVM CMake guide for more information on other configuration options for CMake.
    • The above, if successful, will have created an LLVM.sln file in the build directory.
  5. Build Clang:
    • Open LLVM.sln in Visual Studio.
    • Build the "clang" project for just the compiler driver and front end, or the "ALL_BUILD" project to build everything, including tools.
  6. Try it out (assuming you added llvm/debug/bin to your path). (See the running examples from above.)
  7. See Hacking on clang - Testing using Visual Studio on Windows for information on running regression tests on Windows.

Note that once you have checked out both llvm and clang, to synchronize to the latest code base, use the svn update command in both the llvm and llvm\tools\clang directories, as they are separate repositories.