diff --git a/docs/GettingStarted.html b/docs/GettingStarted.html index f75fbe2c927..ca0256d9e05 100644 --- a/docs/GettingStarted.html +++ b/docs/GettingStarted.html @@ -305,17 +305,18 @@ up
  • No native code generation
  • Build is not complete: one or more tools don't link
  • The GCC-based C/C++ frontend does not build
  • -
  • The port is done using the MSYS shell. +
  • The port is done using the MSYS shell. Download and install bison (excl. M4.exe) and flex in that order. Build binutils-2.15 from source, -if necessary. Bison & flex can be also grabbed from GNUWin32 sf.net project
  • +if necessary. Bison & flex can be also grabbed from GNUWin32 sf.net +project.
  • Native code generation exists but is not complete.
  • -
  • Binutils up to post-2.17 has bug in bfd/cofflink.c +
  • Binutils up to post-2.17 has bug in bfd/cofflink.c preventing LLVM from building correctly. Several workarounds have been introduced into LLVM build system, but the bug can occur anytime in the - future. It's highly recommended to rebuild your current binutils with the + future. We highly recommend that you rebuild your current binutils with the patch from - Binutils bugzilla, if it's wasn't already applied.
  • + Binutils bugzilla, if it wasn't already applied. @@ -1488,6 +1489,86 @@ are code generators for parts of LLVM infrastructure.

    +
    +

    This section gives an example of using LLVM. Since we are currently +transitioning from llvm-gcc3 to llvm-gcc4, we include examples for both. +

    +
    + + +
    Example with llvm-gcc4
    + +
    + +
      +
    1. First, create a simple C file, name it 'hello.c': +
      +   #include <stdio.h>
      +   int main() {
      +     printf("hello world\n");
      +     return 0;
      +   }
      +       
    2. + +
    3. Next, compile the C file into a native executable:

      + +

      % llvm-gcc hello.c -o hello

      + +

      Note that llvm-gcc works just like GCC by default. The standard -S and + -c arguments work as usual (producing a native .s or .o file, + respectively).

      + +
    4. Next, compile the C file into a LLVM bytecode file:

      +

      % llvm-gcc -O3 -emit-llvm hello.c -c -o hello.bc

      + +

      The -emit-llvm option can be used with the -S or -c options to emit an + LLVM ".ll" or ".bc" file (respectively) for the code. This allows you + to use the standard LLVM tools on + the bytecode file.

      + +

      Unlike llvm-gcc3, llvm-gcc4 correctly responds to -O[0123] arguments. +

    5. + +
    6. Run the program in both forms. To run the program, use:

      + +

      % ./hello

      + +

      and

      + +

      % lli hello.bc

    7. + +

      The second examples shows how to invoke the LLVM JIT, lli.

      + +
    8. Use the llvm-dis utility to take a look at the LLVM assembly + code:

      + +

      % llvm-dis < hello.bc | less

    9. + +
    10. Compile the program to native assembly using the LLC code + generator:

      + +

      % llc hello.bc -o hello.s

      + +
    11. Assemble the native assembly language file into a program:

      + +

      Solaris:% /opt/SUNWspro/bin/cc -xarch=v9 hello.s -o hello.native

      +

      Others:% gcc hello.s -o hello.native

      + +
    12. Execute the native code program:

      + +

      % ./hello.native

    13. + +

      Note that using llvm-gcc to compile directly to native code (i.e. when + the -emit-llvm option is not present) does steps 6/7/8 for you.

      + +
    + +
    + + +
    Example with llvm-gcc3
    +