New testing workflow for Windows (was Re: [PATCH] [DOCS] How to Setup a Windows Builder)

Rick Foos rfoos at
Wed Nov 13 10:55:28 PST 2013

*** the attachment is only to clarify this discussion, and not a 
proposed change. Mikael is working on the next change***

1) I agree with a some of this discussion, but I am concerned that we 
are getting away from a one page guide to provision a general purpose 
Windows Builder.

Completing all the steps results in a builder suitable for integration 
with Zorg.

The order of the sections is important for installation, and the 
original didn't have enough of that.

I made a revision that only Mikael has to correct the flow, and allow 
optional components as Reid suggested. I'll attach it here for 
discussion. (Mikael is making the final changes and clarifications).

2) The build machine should have the ability to build in multiple 
environments that you would encounter on Windows. Msys, Cygwin, DOS.

When all packages are installed, it can be done by setting paths prior 
to invoking one of the Bourne shells. I envision Buildbot/Zorg making 
this build environment selection.

The new section layout allows the user to skip some subsections, and 
come up with a more specific build machine.

3) In regards to the modified Bash, we are running the test suite for 
llvm, clang, and polly. I think a specialized bash is fine, but to me it 
is one more option that the build machine can do. It doesn't take away 
from the packages that are in place.

I'm a little concerned with a patched bash that the user cannot build, 
or needs to set up another build environment to recreate, but that can 
be addressed.

4) In the attached document, MSVC has a small section to avoid some 
pitfalls to avoid when using it to build LLVM. I agree that it is NOT 
important to say anything about installing a commercial product.

5) What is simple, and what is complicated depends on what you are doing...

As a developer, a windows build machine should build llvm one way.

This setup is a bit complicated in that regard.

As someone using a buildbot infrastructure, a windows build machine 
needs a complete set of standard packages that build and test LLVM all 
ways possible. Then I can replicate a number of buildslaves, and it is 
simple to select a host and spread out the workload.

This setup is simple in that regard.

Best Regards,
Rick Foos

On 11/13/2013 12:04 PM, Reid Kleckner wrote:
> This sounds awesome!  It would be really great for developers that 
> just want to use VS as well.  No need to go and choose one of the 
> various sets of Unix tools for Windows that are all slightly 
> incompatible in different obscure ways.
> On Wed, Nov 13, 2013 at 1:07 AM, Alp Toker <alp at 
> <mailto:alp at>> wrote:
>     On 13/11/2013 01:06, Sean Silva wrote:
>>     +**Notice:** If you do not plan to run the test suite, or sshd
>>     server, you don't
>>     +need Cygwin. You can build LLVM + Clang with only Subversion,
>>     MingwNN, and CMake.
>>     I feel like the way you are handling these notices is backwards.
>     This is all very complicated and difficult to document!
>     I'd like to share an alternative..
>     At Nuanti we have a setup that can run the full test suite
>     natively on Windows using only the native Microsoft toolchain and
>     a special BusyBox binary, so we don't even install MingW or Cygwin
>     on Windows development systems.
>     This has a number of benefits:
>       * Full test coverage. Our BusyBox is patched to be compatible
>         with Unix so we get to run tests that would usually fail due
>         to REQURES/XFAIL mingw/shell/shell-preserves-root.
>       * No need for Administrator access. There is nothing to install,
>         no GNU this or that, just a fresh SVN/git checkout from
> <>.
>       * Easy to set up. Just drop the single binary in your PATH or
>         lit folder.
>       * Escaping and /dev/null hacks for Windows in lit are no longer
>         needed.
>       * Full in-process execution. Forking is slow on Windows, but
>         with our approach a full test suite run is reduced close to
>         native timings comparable to other platforms.
>     I was planning to upstream this work later in the 3.5 cycle but
>     looking at how painful the process is at present, and more so the
>     effort to document it, I feel now like it might be worth pushing
>     ahead earlier.
>     The patch to lit itself is very small / low-impact and most of the
>     work is in BusyBox itself.
>     I can get this work Open Sourced along with a build of the drop-in
>     llvm-busybox.exe later today if it sounds desirable.
>     Certainly it'd reduce much of this document to just "Copy
>     llvm-busybox.exe into your PATH"
>     How does this sound?
>     If you like the idea, let me know soon as today's the best time
>     for me to pull this all together and post the lit side of the work
>     for review.
>     Regards,
>     Alp.
>     -- 
>     the browser experts
>     _______________________________________________
>     llvm-commits mailing list
>     llvm-commits at <mailto:llvm-commits at>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at

Rick Foos
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>
-------------- next part --------------
How to Setup Windows for the LLVM Buildbot Infrastructure

.. contents::
   :depth: 2

Building LLVM on Windows using the MinGW32, MinGW64, and Visual Studio toolchains
is complicated. This document aims to make it easy for you to configure
Windows to build LLVM with the major windows toolchains, bourne shells, and
natively with Microsoft's ``cmd.exe``. Additional instructions are provided to
add this build machine to the LLVM Buildbot Infrastructure.

In the text that follows, your LLVM working directory will be referred to as

MinGW, MSYS, and Cygwin for Beginners
MinGW stands for *Minimalistic Gnu for Windows*.  The intent of the MinGW
project is to deliver a set of ready-to-use ports of GNU software on Windows.

MinGW currently exists in two versions: MinGW32 (32-bit tools) and MinGW64
(64-bit tools).  The 32-bit tools are readily available from the `main MinGW
website <>`_.  The 64-bit tools are available from the
`MinGW W64 website <>`_.

MinGW tools are distributed as standalone packages, or packaged with Cygwin.
The Cygwin setup tool is a GUI package manager with the MinGW package names
prefixed with mingw32- or mingw64-.
Cygwin provides a POSIX runtime environment for POSIX applications ported to
Windows. In this example, Cygwin will be used to supply missing utilities.

We will primarily use the standalone MinGW tools for the GCC builds of LLVM.

The standalone MinGW tools come with an alternative to Microsoft's ``cmd.exe``
called MSYS. MSYS stands for "Minimal SYStem", a Bourne Shell command line
interpreter and utilities that are suited for porting Open Source applications
to MS-Windows.

   **Notice:** You don't need Microsoft Visual Studio to build LLVM and Clang on
   Windows.  If your application needs to link in special Microsoft libraries,
   that are not part of the MinGW distribution, you can get access to those by
   downloading the *Microsoft Windows SDK for Windows 7 and .NET 4.0* from the
   `Microsoft Download Center <>`_.

System Requirements
If you are going to debug LLVM or Clang, you need at least 6 gigabytes of
memory.  This is because the GNU linker (``ld``) eats a lot of memory when
linking in libraries that contain debug information.  If you are not going
to debug LLVM and/or Clang, you can do with 4 gigabytes.

You'll need about 5 gigabytes of free disk space for the tools and the build.

Software Setup
In this chapter, you'll be walked through downloading and installing all of
the software packages that are needed to do a full debug or release build
and test of LLVM.

The primary purpose of this is a one page list of instructions to set up a
general purpose Windows Build Machine.
For those who want subsets of this, subsections were added so that some
components can be skipped for different configurations. The end result in
all cases is a Windows Build Machine for LLVM.

Required for All
These package installs are required for all configurations.

Installing Python v2.x
Download and install the latest release of v2.x of Python from the
`Python website <>`_.

Installing Python v2.x SetupTools
Download and install the latest version of SetupTools for Python from the PyPi
page for the SetupTools.  Be sure to pick the version that matches your Python

Installing the Python Win32 Bindings
Download and install the most recent Python v2.7 version of PyWin32 from the
PyWin32 website.  Pick the newest build (with the highest number) and then
download the appropriate version for your version of Python.

PyWin32 is a module/library inside python that is used to provide OS related
functionality. It is required for Buildbot, and LLVM testing otherwise it is
optional. PyWin32 is automatically used by CMake and other python packages
and so it is recommended for all configurations.

.. _cygwin64install:

Installing Cygwin64
Download and install the most recent Cygwin64 setup program from the
`Cygwin website <>`_.  Now for the most painful part of this guide:
Picking what Cygwin components you want to install. Unfortunately, the
install all feature in the Cygwin installation program results in a long download
of more packages than you will ever need. Cygwin provides a default installation with
a minimal set of packages, and the GUI setup program is used to manually pick
the additional items we need:

   | Devel/DejaGnu.
   | Interpreter/tcl.
   | Tcl/expect.
   | -- git required ``Workaround for test-suite Bug 13121``
   | Devel/git
   | Devel/git-completion
   | Devel/git-svn
   | Utils/gnupg
   | -- optional subversion (replaces command line TortoiseSVN)
   | Devel/subversion
   | Devel/subversion-tools
   | -- optional sshd server (ssh-host-config)
   | Net/openssh.
   | Admin/cygrunsrv.

Installing Subversion
Download and install Subversion from the `Subversion download page
<>`_.  Pick the appropriate
version for your OS. Install it using the ``Typical`` choice.

   **Notice:** You will not need Subversion if you are building from an official
   release.  However, the recommended path is to build from the Subversion trunk
   as that gives you the most recent code and because you can that way much
   easier integrate new features and code changes into your own project.

The MinGW compiler and MSYS bourne shell for 32 bit GCC builds.

   **Notice:** If you only want to build 64-bit programs, you do **not** need to
   install MinGW32.

Installing GnuWin32
Install GnuWin32 by following the *Looking for the latest version?* link at
`GnuWin32 on <>`_.  Download and run
the executable.  Once it has run to completion, you need to run both the
download and install scripts that are in the download directory
(please notice that you should specify an installation directory, say,
C:\\GnuWin32, to the install script).  The download directory is by default
identical to C:\Users\Build\Downloads\GetGnuWin32.

The primary purpose of GnuWin32 is to supply utilities missing in MinGW-32
MSYS. GnuWin32 will be after MSYS in the path and handle utilities that are not
available in MSYS.

   **Notice:** If you do not plan to run the test suite, or debug the code,
   you don't need GnuWin32. You can build LLVM + Clang with only Subversion,
   MingwNN, and CMake.

Installing MinGW 32-bit
Download and install MinGW32 using the MinGW installer found at the `MinGW
project at SourceForge <>`_. Download
the file marked as the default download (``mingw-get-inst-YYYYMMDD.exe``).
Run it then select ``Download latest repository catalogues``. Install
to ``C:\Mingw32`` as you'll perhaps also be installing MinGW64 later on.
Select and check the ``C Compiler`` and the ``C++ Compiler``.


   **Notice:** If you only want to build 32-bit programs, you do **not** need to
   install MinGW64.

Installing MinGW 64-bit MSYS
Install MinGW64 by downloading the latest version from the
`Download MinGW-w64 <>`_.
``mingw-w64-<version>.tar.bz2``.  Untar it, using 7-Zip from
` <>`_, to ``C:\MinGW64``,
or Cygwin with the bzip2 package installed.

Installing MinGW 64-bit Cygwin
Cygwin is another established source for MinGW compilers. This compiler
install does not replace the Windows install above, but provides an
alternative build environment.

The following packages should be added to build with the Cygwin version of MinGW-64.
You can start Cygwin setup from a Microsoft ``cmd.exe`` window as follows:

   | C:\Users>start C:\cygwin64\setup-x86_64.exe

Next, add the following packages to your existing Cygwin64 installation:

    | gcc4
    | make
    | automake
    | autoconf
    | bison
    | flex
    | libiconv
    | gperf
    | mingw64-x86_64-binutils
    | mingw64-x86_64-bzip2
    | mingw64-x86_64-gcc-core
    | mingw64-x86_64-gcc-g++
    | mingw64-x86_64-headers
    | mingw64-x86_64-pthreads
    | mingw64-i686-pthreads
    | mingw64-x86_64-headers
    | mingw64-x86_64-runtime
    | mingw64-x86_64-winpthreads
    | mingw64-x86_64-zlib

.. _WinTelCompiler:

Microsoft/Intel Compilers

Installing Microsoft Visual Studio
Microsoft Visual Studio Professional versions are purchased products. Express
versions are free and available at 
`Visual Studio Express Products <>`_.
Installation is supported by the vendor, and not documented further here.

LLVM Builds support MSVC and Intel compilers using CMake. After compiler installation
make sure that the ``Microsoft Visual C++ Redistributable`` packages are present. The CMake install
uses redistributable packages to add support needed for builds. These packages are
availble for free at the 
`Microsoft Download Center <>`_.

Programs that use ``windows.h`` are common in large applications. This file
is provided by the SDK, and while it may not be necessary immediately, installing the SDK
is a good idea on a build machine.
The Visual Studio SDK is a separate install, and may be downloaded for free at 
`Products and Extensions for Visual Studio <[0].Type=RootCategory&f[0].Value=tools&f[1].Type=Tag&f[1].Value=Visual%20Studio%20SDK>`_.

Installing Intel C++ Studio
`Intel Compilers <>`_ consist of the compiler
itself, and several performance tools. An existing Microsoft Visual Studio installation is required.

After Installation, only the performance tools used in conjunction with Visual Studio are active.
The compiler (icl) requires an additional setup script to be run that selects the architecture
used to generate code.

   **Notice:** The Intel Compiler has not been extensively tested for LLVM builds, but it
   is used for some of our other packages.

.. _CMakeInstall:

CMake Build System
CMake is a family of tools designed to build, test and package software. LLVM supports
both CMake and GNU Autotools. 

   **Notice:** CMake is **REQUIRED** if any :ref:`WinTelCompiler` are installed.

Installing CMake
Navigate to the `CMake download page
<>`_ and download
the latest Win32 installer.  Run it and install CMake to its default location
while making sure you select the ``Add CMake to the system PATH for current
user (or All users)`` option during setup.

CMake searches for all known compilers and make systems during install. To verify
that all tools were found, type ``cmake`` and check the list of Generators available.

Installing Ninja
Ninja is a *very* fast build tool that is one of the builders in CMake.
You can download a binary from
`CMakeScript <>`_.  You
can save it to your standard tools directory or to ``%LLVMDIR%`` and invoke it
from there.

   **Notice:** This version of Ninja requires you to have the Microsoft Visual
   C++ Redistributable installed.  You can get it from `Microsoft's Download
   Center <>`_.

LLVM Buildbot Infrastructure
This section describes installs needed to add a Windows Buildslave(s) to the 
LLVM Buildbot Infrastructure.

System Administration
For use with Buildbot, create a new user account named ``buildbot``.  Give it
any password you like, but be sure to not use a password that you already use
on your network so as to make sure that hackers and hostile build masters
cannot access all of your computers on your local network.

Mark the user ``buildbot`` for automatic login.  On Windows 7, you do this by
running the command ``netplwiz`` and then uncheck the *Users must enter a user
name and password to use this computer* field. Then click the Apply button and
enter the user name ``buildbot`` and the password that you gave this account.

Installing Windows Buildbot
If you want to setup your Windows build machine as Buildslave in the LLVM 
Buildbot Infrastructure (Zorg project), complete the Buildslave instructions at 
`Running Buildbot On Windows <>`_.
Several of the required install steps have been done, and it should not
take long to complete.

The remaining steps to add your Buildslave to the infrastructure project are in the
:doc:`HowToAddABuilder` document.

   **Notice:** Before connecting your Windows Buildslave to a master, complete the
   post-installation steps to ensure that your Windows Builder configuration successfully
   builds the compiler, and any other builds you intend to use with the infrastructure.

Installing Cygwin Buildbot (optional)
Cygwin now contains enough packages to run as a self contained Buildslave. Multiple
Buildslaves can be supported by a single build machine as long as care is taken not
to overload the machine with jobs.

The default Cygwin64 has been installed in an earlier step (:ref:`cygwin64install`). 
The following packages should be added prior to using the following guide to complete
the process. You can start Cygwin setup from a Microsoft ``cmd.exe`` window as follows:

   | C:\Users>start C:\cygwin64\setup-x86_64.exe

Select the following packages:

   | python
   | python-setuptools
   | python-twisted
   | -- optional packages to run a buildbot master.
   | python-zope

Install the packages in the document below, skipping the python easy_install's for packages
already installed.

The document 
`Setup a Cygwin Buildbot Slave <>_`
is a little out of date in terms packages now available in Cygwin, but remains a good guide
to set up a buildslave.

You can combine this with the above steps to install MinGW64 and as the document states have
a mingw64 buildbot slave.

   **Notice:** Some of the tools are duplicates of what has already been installed.
   This is intended as the Cygwin Buildslave needs Cygwin versions of all tools.

Post-Installation Setup

After you've installed all of the above, you need a small batch file to set up
your environment variables.  For unix style builds, you only need to set
up the ``PATH`` environment variable. MSVC and Intel compilers require setup
scripts that are invoked from existing environment variables. An example for MSVC10
is included. So, go ahead and create a file named ``setenv.bat`` in the outermost 
directory of your LLVM build tree (``%LLVMDIR%``), and copy and paste the 
``CMD.EXE`` code snippet below into it:

.. code-block:: bat

    @echo off
    rem This script sets up the paths BEFORE the Windows system tools
    rem so as to avoid accidentally invoking Windows tools (i.e. sort).

    rem Set up Cygwin as the fifth item in the search path
    rem path c:\Cygwin\usr\local\bin;c:\Cygwin\usr\bin;c:\Cygwin\bin;%path%
    if exist c:\cygwin64 path c:\cygwin64\usr\local\bin;c:\cygwin64\usr\bin;c:\cygwin64\bin;%path%
    if exist c:\cygwin path c:\cygwin\usr\local\bin;c:\cygwin\usr\bin;c:\cygwin\bin;%path%

    rem Set up TortoiseSVN as fifth in search path for SVN.
    if exist "c:\Program Files\TortoiseSVN\bin" path c:\Program Files\TortoiseSVN\bin;%path%

    rem Set up Mingw32 as the third item in the search path
    rem Comment out the next line if you're doing 64-bit builds.
    if exist c:\Mingw32 path c:\Mingw32\bin;c:\Mingw32\msys\1.0\bin;%path%

    rem Set up GnuWin32 as the second item in the search path
    rem GnuWin32 must come before MingW32 to get the right Make.
    if exist c:\GnuWin32 path c:\GnuWin32\bin;%path%

    rem Set up Mingw64 as the first item in the search path
    rem Comment out the next line if you're doing 32-bit builds.
    if exist c:\Mingw64 path c:\Mingw64\bin;c:\Mingw64\msys\1.0\bin;%path%

    rem Set up MSVC 10 first in the search path to avoid accidentally
    rem invoking Unix tools during the build (i.e. link).
    if exist "%VS100COMNTOOLS%\vsvars32.bat" "%VS100COMNTOOLS%\vsvars32.bat"

Building the Project
Now the time has come to actually get the sources and then build them.

Getting the LLVM and Clang Sources
Open a console window, and change to the directory ``%LLVMDIR%`` where you
will be building LLVM:

.. code-block:: bat

   cd /d %LLVMDIR%

Now you can get the sources by using this ``CMD.EXE`` batch file - copy and
paste it to a batch file with the name ``llvmcheckout.bat`` in the
``%LLVMDIR%`` directory:

.. code-block:: bat

    @echo off
    rem Pulls (checks out) all LLVM and Clang sources from

    rem Checkout/Update LLVM
    if exist llvm-trunk goto updateLLVM
    pushd .
    svn co llvm-trunk
    if errorlevel 1 goto Error
    goto endLLVM
    pushd llvm-trunk
    svn update -q
    if errorlevel 1 goto Error

    rem Checkout/Update Clang
    if exist llvm-trunk\tools\clang goto updateCLANG
    pushd llvm-trunk\tools
    svn co clang
    if errorlevel 1 goto Error
    goto endCLANG
    pushd llvm-trunk\tools\clang
    svn update -q
    if errorlevel 1 goto Error

    rem Checkout/Update Compiler-RT
    if exist llvm-trunk\projects\compiler-rt goto updateCOMPRT
    pushd llvm-trunk\projects
    svn co compiler-rt
    if errorlevel 1 goto Error
    goto endCOMPRT
    pushd llvm-trunk\projects\compiler-rt
    svn update -q
    if errorlevel 1 goto Error

    rem Checkout/Update test-suite
    rem Bug 13121 - ClamAV test case contains a virus that blocks SVN retrieve (WONTFIX)
    rem WORKAROUND: Use LLVM GIT mirror instead of SVN.
    if exist llvm-trunk\projects\test-suite goto updateSUITE
    pushd llvm-trunk\projects
    git clone test-suite
    if errorlevel 1 goto Error
    goto endSUITE
    pushd llvm-trunk\projects\test-suite
    git pull
    if errorlevel 1 goto Error

    goto End
    echo Error at:
    echo Error: LLVM pull failed
    goto End


Now run the ``llvmcheckout.bat`` command:

.. code-block:: bat


The whole thing takes about five minutes so you can safely go get a cup of
coffee or what you normally do when you have to wait for your machine.

If everything went okay and there were no error messages, you've succesfully
got all of the relevant sources from the LLVM Subversion repository.

You'll find the newly retrieved source files in ``%LLVMDIR%\llvm-trunk``.

Making the Makefiles
Now you just need to configure the build system so that you can start the
actual build of LLVM and Clang.  You can optionally specify one or more
CMake configuration parameters:

.. code-block:: bash

   CMAKE_BUILD_TYPE=Release   (enables release build mode without debug info)
   CMAKE_BUILD_TYPE=Debug     (enables debug mode with lots of debug info)
   CMAKE_INSTALL_PREFIX=path  (selects where to install LLVM and Clang)

You specify these on the command-line when you invoke ``cmake.exe``:

.. code-block:: bat

   cd /d %LLVMDIR%
   md llvm-build
   cd llvm-build
   cmake CMAKE_BUILD_TYPE=Release CMAKE_INSTALL_PREFIX=..\install -G Ninja ..\llvm-trunk

There's a complete list of CMake variables in the `Building LLVM with CMake
<>`_ document.

After you've run CMake the first time, you can use ``cmake-gui`` to configure
your build.  Alternatively, you can simply fire up ``cmake-gui`` instead of
``cmake`` as the fourth command in the code snippet shown above.

   **Notice:** ``cmake-gui`` is not part of the special Ninja version of CMake.

Building the Sources
You are now ready to build LLVM and Clang using Ninja:

.. code-block:: bat


This step takes about 15 minutes on a 1st generation Intel Core i7 with four

Using the Built Product
Once you have succesfully built LLVM and Clang, you can find the binaries in
the ``bin`` directory.  Preferredly, you can do a ``ninja install`` to make
the binaries, libraries, and headers, and have them installed in the location
you specified as part of the ``CMAKE_INSTALL_PREFIX`` variable above.

Updating the Source Tree
Occasionally (read: as often as possible), you want to synchronize with the
main trunk version of LLVM and Clang so that you discover incompatibilities
and errors as early as possible.  To do that, you can use this script (copy
and paste it to ``%LLVMDIR%\llvmupdate.bat``):

.. code-block:: bat

   @echo off
   rem Updates all LLVM and Clang sources from

   pushd llvm-trunk
   svn update
   if errorlevel 1 goto Error

   cd tools\clang
   if errorlevel 1 goto Error
   svn update
   if errorlevel 1 goto Error

   cd ..\..\projects\compiler-rt
   if errorlevel 1 goto Error
   svn update
   if errorlevel 1 goto Error

   cd ..\test-suite
   git pull
   if errorlevel 1 goto Error

   if errorlevel 1 goto Error

   goto End

   echo Error: LLVM update failed
   goto End


You should run that script as often as your work permits you to.  Please keep
in mind that running the script will require you to issue a new ``ninja``
command to update the build tree.

   **Notice:** ``ninja update`` does not work, and you need the above script.

Appendix A: Building LLVM and Clang using Clang
Let's assume that you want to build LLVM and Clang using Clang itself.  How do
you do that?  The process is very simple, but takes a while to discover.

   **Notice:** Depending on where you installed CMake, you may need Administrator
   rights.  The easiest is to use ``Windows Explorer`` to create the files with
   as it automatically elevates your rights when needed.

Here goes:

1. Locate your installation of CMake: ``which cmake.exe``
2. Change to the directory where CMake is installed:
   ``cd /d <directory-part-of-output-of-which-command>``
3. Change to the Platform directory: ``cd ..\share\cmake-2.8\Modules\Platform``
4. Create the file ``Windows-Clang-C.cmake`` and copy and paste this into it:

.. code-block:: cmake

      # Chain to generic Windows configuration

5. Create the file ``Windows-Clang-CXX.cmake`` and copy/paste this into it:

.. code-block:: cmake

      # Chain to generic Windows configuration

6. Now type each of these commands in succession:

.. code-block:: bat

   set PATH=%LLVMDIR%\install;%PATH%
   set CC=clang
   set CXX=clang++
   cd /d %LLVMDIR%
   md llvm-clang
   cd llvm-clang
   CMake -G Ninja ..\llvm-trunk

7. Launch the Ninja utility to build using Clang++:

.. code-block:: bat


The modifications to CMake fixes the problem that CMake currently does not
support Clang on Windows that well.  It is expected to be fixed in the next
version of CMake.

You should now be building LLVM and Clang using Clang itself.

Appendix B: Debugging MinGW Programs on Windows
You basically have four choices for debugging MinGW programs on Windows:

1. GDB - The GNU Debugger.  This is mostly intended for emergencies.
2. DDD - The Data Display Debugger.  A GUI debugger that requires you to
   install Cygwin.
3. ADG - `The Affinic Debugger GUI <>`_.
   This needs Cygwin64 ``gdb``, which supports 64-bit debugging.
4. ``printf()`` or ``cout``.  This method is guaranteed to work in most
   environments but requires efficient debugging techniques by the user.

Once you've built all of LLVM and Clang using debug symbols, the default
for Subversion sources, you should be able to fire up the debugger you've
chosen and simply pass the path of the program you want to debug, and any
arguments to it, as the arguments following the program name:

.. code-block:: bat

   gdb d:\bld\llvm-build\llvm\bin\clang.exe -c test.c


.. code-block:: bat

   ddd d:\bld\llvm-build\llvm\bin\clang.exe -c test.c


.. code-block:: bat

   adg d:\bld\llvm-build\llvm\bin\clang.exe -c test.c

Both of the GUI frontends run on top of ``gdb`` for which reason they
cannot support executable formats not supported by ``gdb``.

Appendix C: ``CMakeLists.txt`` Snippet Illustrating Link Order
Below you'll find a CMake snippet by Nathan Jeffords that
illustrates the link order of the LLVM libraries:

.. code-block:: cmake










This is important because the GNU linker (``ld``) takes the order of input
files very seriously and therefore can fail even though all symbols are
present in the list of libraries given to ``ld``.

You only need to use this list if you run into the problem that a link
against the LLVM libraries turn up unresolved symbols in the LLVM

More information about the llvm-commits mailing list