From e1630da3e94d071c419b3ff862c03b41abc4eb99 Mon Sep 17 00:00:00 2001 From: "Michael J. Spencer" Date: Fri, 17 Sep 2010 06:33:20 +0000 Subject: [PATCH] docs: Update GettingStartedVS to reflect current state. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114167 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/GettingStartedVS.html | 150 ++++++++++++++++++++----------------- 1 file changed, 83 insertions(+), 67 deletions(-) diff --git a/docs/GettingStartedVS.html b/docs/GettingStartedVS.html index 40b187737d1..e007ecaea78 100644 --- a/docs/GettingStartedVS.html +++ b/docs/GettingStartedVS.html @@ -26,7 +26,7 @@
-

Written by: +

Written by: Jeff Cohen

@@ -40,23 +40,30 @@
-

The Visual Studio port has some limitations. It is suitable for - use if you are writing your own compiler front end or otherwise have a - need to dynamically generate machine code. The JIT and interpreter are - functional, but it is currently not possible to generate assembly code which - is then assembled into an executable. You can output object files - in COFF format, though. You can also indirectly create executables - by using the C backend.

+

Welcome to LLVM on Windows! This document only covers native Windows, not + mingw or cygwin. In order to get started, you first need to know some basic + information.

-

llvm-gcc is based on GCC, which cannot be bootstrapped - using VC++. There are llvm-gcc binaries based on MinGW - available on the - LLVM download - page. Eventually, Clang - will be able to produce executables on Windows.

+

There are many different projects that compose LLVM. The first is the LLVM + suite. This contains all of the tools, libraries, and header files needed to + use the low level virtual machine. It contains an assembler, disassembler, + bitcode analyzer and bitcode optimizer. It also contains a test suite that can + be used to test the LLVM tools.

-

bugpoint does build, but does not work. The other tools - 'should' work, but have not been fully tested.

+

Another useful project on Windows is + clang. Clang is a C family + ([Objective]C/C++) compiler. Clang fully works on Windows, but does not + currently understand all of the Microsoft extensions to C and C++. Because of + this, clang cannot parse the C++ standard library included with Visual Studio, + nor parts of the Windows Platform SDK. However, most standard C programs do + compile. Clang can be used to emit bitcode, directly emit object files or + even linked executables using Visual Studio's link.exe

+ +

The LLVM test suite cannot be run on the Visual Studio port at this + time.

+ +

Most of the tools build and work. bugpoint does build, but does + not work.

Additional information about the LLVM directory structure and tool chain can be found on the main Getting Started @@ -85,7 +92,7 @@

-

Any system that can adequately run Visual Studio .NET 2005 SP1 is fine. +

Any system that can adequately run Visual Studio .NET 2005 SP1 is fine. The LLVM source tree and object files, libraries and executables will consume approximately 3GB.

@@ -97,16 +104,17 @@

You will need Visual Studio .NET 2005 SP1 or higher. The VS2005 SP1 beta and the normal VS2005 still have bugs that are not completely - compatible. VS2003 would work except (at last check) it has a bug with - friend classes that you can work-around with some minor code rewriting - (and please submit a patch if you do). Earlier versions of Visual Studio - do not support the C++ standard well enough and will not work.

- + compatible. Earlier versions of Visual Studio do not support the C++ standard + well enough and will not work.

+

You will also need the CMake build system since it generates the project files you will use to build with.

-

- Do not install the LLVM directory tree into a path containing spaces (e.g. +

If you would like to run the LLVM tests you will need + Python. Versions 2.4-2.7 are known to + work.

+ +

Do not install the LLVM directory tree into a path containing spaces (e.g. C:\Documents and Settings\...) as the configure step will fail.

@@ -139,27 +147,22 @@
  • With anonymous Subversion access:
    1. cd where-you-want-llvm-to-live
    2. -
    3. svn co http://llvm.org/svn/llvm-project/llvm-top/trunk llvm-top -
    4. -
    5. make checkout MODULE=llvm +
    6. svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
    7. cd llvm
  • - +
  • Use CMake to generate up-to-date project files:
      -
    • Once CMake is installed then the most simple way is to just - start the CMake GUI, select the directory where you have LLVM - extracted to, and the default options should all be fine. One - option you may really want to change, regardless of anything - else, might be the CMAKE_INSTALL_PREFIX setting to select a - directory to INSTALL to once compiling is complete, although - installation is not mandatory for using LLVM. Another - important option is LLVM_TARGETS_TO_BUILD, which controls the - LLVM target architectures that are included on the build. If - you want to run the example described - below you must set that variable to "X86;CBackend".
    • +
    • Once CMake is installed then the simplest way is to just start the + CMake GUI, select the directory where you have LLVM extracted to, and the + default options should all be fine. One option you may really want to + change, regardless of anything else, might be the CMAKE_INSTALL_PREFIX + setting to select a directory to INSTALL to once compiling is complete, + although installation is not mandatory for using LLVM. Another important + option is LLVM_TARGETS_TO_BUILD, which controls the LLVM target + architectures that are included on the build.
    • See the LLVM CMake guide for detailed information about how to configure the LLVM build.
    • @@ -188,6 +191,28 @@ program will print the corresponding fibonacci value.
  • +
  • Test LLVM: +
      +
    • The LLVM tests can be run by cding to the llvm source directory + and running: + +
      +
      +% llvm-lit test
      +
      +
      + +

      Note that quite a few of these test will fail.

      +
    • + +
    • A specific test or test directory can be run with:
    • + +
      +
      +% llvm-lit test/path/to/test
      +
      +
      +
  • @@ -216,7 +241,7 @@ int main() {
    -% llvm-gcc -c hello.c -emit-llvm -o hello.bc
    +% clang -c hello.c -emit-llvm -o hello.bc
     
    @@ -225,23 +250,27 @@ int main() { facilities that it required. You can execute this file directly using lli tool, compile it to native assembly with the llc, optimize or analyze it further with the opt tool, etc.

    - -

    Note: you will need the llvm-gcc binaries from the - LLVM - download page

    + +

    Alternatively you can directly output an executable with clang with: +

    + +
    +
    +% clang hello.c -o hello.exe
    +
    +
    + +

    The -o hello.exe is required because clang currently outputs + a.out when neither -o nor -c are given.

  • Run the program using the just-in-time compiler:

    - +
     % lli hello.bc
     
    -

    Note: this will only work for trivial C programs. Non-trivial programs - (and any C++ program) will have dependencies on the GCC runtime that - won't be satisfied by the Microsoft runtime libraries.

  • -
  • Use the llvm-dis utility to take a look at the LLVM assembly code:

    @@ -251,40 +280,27 @@ int main() {
  • -
  • Compile the program to C using the LLC code generator:

    +
  • Compile the program to object code using the LLC code generator:

    -% llc -march=c hello.bc
    +% llc -filetype=obj hello.bc
     
    - -

    Note: you need to add the C backend to the LLVM build, - which amounts to setting the CMake - variable LLVM_TARGETS_TO_BUILD to "X86;CBackend" when - you generate the VS solution files. See - the LLVM CMake guide for more - information about how to configure the LLVM - build.

  • - -
  • Compile to binary using Microsoft C:

    +
  • Link to binary using Microsoft link:

    -% cl hello.cbe.c
    +% link hello.obj -defaultlib:libcmt
     
    -

    Note: this will only work for trivial C programs. Non-trivial programs - (and any C++ program) will have dependencies on the GCC runtime that won't - be satisfied by the Microsoft runtime libraries.

  • -
  • Execute the native code program:

    -% hello.cbe.exe
    +% hello.exe