Build Instructions - lock3/cppx GitHub Wiki

This page outlines build instructions for the Clang/Cppx llvm frontend. It is a fork of the lock3/meta project. See the meta repo and wiki for more information.

On Unix-Like Systems

Get the required tools.

See Getting Started with the LLVM System - Requirements.
Note also that Python is needed for running the test suite. Get it at: https://www.python.org/downloads/
Standard build process uses CMake. Get it at: https://cmake.org/download/

Check out the CPPX project:

  • Change directory to where you want the cppx directory placed.
  • git clone https://github.com/lock3/cppx.git

Build LLVM and Clang/Cppx:

  • cd cppx
  • mkdir build (in-tree build is not supported)
  • cd build
  • cmake -DLLVM_ENABLE_PROJECTS=clang -G "Unix Makefiles" ../llvm
  • make This builds both LLVM and Clang/Cppx for debug mode.
    Note: For subsequent Clang/Cppx development, you can just run make clang.

If building requires too many system resources, we recommend building clang with the Ninja build system and building in release mode. To do this, replace step 4 with cmake -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_BUILD_TYPE=Release -G "Ninja" ../llvm, then replace step 5 with ninja

CMake allows you to generate project files for several IDEs: Xcode, Eclipse CDT4, CodeBlocks, Qt-Creator (use the CodeBlocks generator), KDevelop3.
If you intend to use Clang's C++ support, you may need to tell it how to find your C++ standard library headers. In general, Clang will detect the best version of libstdc++ headers available and use them - it will look both for system installations of libstdc++ as well as installations adjacent to Clang itself. If your configuration fits neither of these scenarios, you can use the -DGCC_INSTALL_PREFIX cmake option to tell Clang where the gcc containing the desired libstdc++ is installed.

Try it out (assuming you add build/bin to your path):

  • clang-gold --help
  • clang-gold file.usyntax (compile a Usyntax file)
  • clang-gold file.cpp (compile a C++ file)

Run the testsuite:

  • make GoldTests
  • tools/clang/unittests/GoldTests

On Visual Studio

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

Get the required tools:

  • Git. Source code control program. Get it from: https://git-scm.com/download
  • CMake. This is used for generating Visual Studio solution and project files. Get it from: https://cmake.org/download/
  • Visual Studio 2017 or later
  • Python. It is used to run the clang test suite. Get it from: https://www.python.org/download/
  • GnuWin32 tools The Clang and LLVM test suite use various GNU core utilities, such as grep, sed, and find. The gnuwin32 packages are the oldest and most well-tested way to get these tools. However, the MSys utilities provided by git for Windows have been known to work. Cygwin has worked in the past, but is not well tested. If you don't already have the core utilies from some other source, get gnuwin32 from http://getgnuwin32.sourceforge.net/.

Check out CPPX:
git clone https://github.com/lock3/cppx.git

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're using git on Windows, make sure your core.autocrlf setting is false.

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 2017: cmake -DLLVM_ENABLE_PROJECTS=clang -G "Visual Studio 15 2017" -A x64 -Thost=x64 ..\llvm -Thost=x64 is required, since the 32-bit linker will run out of memory.
  • To generate x86 binaries instead of x64, pass -A Win32.
  • 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.

Build Clang/Cppx:

  • 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.
  • Try it out (assuming you added debug/bin to your path). (See the running examples from above.)

See Also

⚠️ **GitHub.com Fallback** ⚠️