From 9b16da332bfad3a6e955f5874a1cc42348dec554 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Fri, 27 Mar 2009 16:32:57 +0000 Subject: [PATCH] Update "Getting Started" with more current information about 'clang-cc' and 'clang'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67850 91177308-0d34-0410-b5e6-96231b3b80d8 --- www/get_started.html | 136 +++++++++++++++++++++---------------------- 1 file changed, 67 insertions(+), 69 deletions(-) diff --git a/www/get_started.html b/www/get_started.html index 1809362a61..1393981c5b 100644 --- a/www/get_started.html +++ b/www/get_started.html @@ -15,14 +15,12 @@

Getting Started: Building and Running Clang

- -

This page gives you the shortest path to checking out clang and demos a few +

This page gives you the shortest path to checking out Clang and demos a few options. This should get you up and running with the minimum of muss and fuss. If you like what you see, please consider getting -involved with the clang community.

- +involved with the Clang community.

-

A word of warning

+

A Word of Warning

While this work aims to provide a fully functional C/C++/ObjC front-end, it is still early work and is under heavy development. In particular, @@ -43,10 +41,10 @@ href="http://llvm.org/bugs/">LLVM Bugzilla or bring up the issue on the Clang development mailing list.

-

Building clang / working with the code

+

Building Clang and Working with the Code

-

If you would like to check out and build the project, the current scheme -is:

+

If you would like to check out and build Clang, the current procedure is as +follows:

  1. Checkout @@ -57,7 +55,7 @@ is:

  2. cd llvm
  3. ./configure; make
  4. -
  5. Checkout clang:
  6. +
  7. Checkout Clang:
    • From within the llvm directory (where you built llvm):
    • @@ -65,8 +63,8 @@ is:

    • svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
    -
  8. If you intend to work on clang C++ support, you may need to tell it how - to find your C++ standard library headers. If clang can't find your +
  9. If you intend to work on Clang C++ support, you may need to tell it how + to find your C++ standard library headers. If Clang cannot find your system libstdc++ headers, please follow these instructions:
    • @@ -77,7 +75,7 @@ is:

      change the lines below to include that path.
    -
  10. Build clang:
  11. +
  12. Build Clang:
-

Note that the C front-end uses LLVM, but does not depend on - llvm-gcc. If you encounter problems with building clang, make - sure you have the latest SVN version of LLVM. LLVM contains - support libraries for clang that will be updated as well as - development on clang progresses.

+

Note that the C front-end uses LLVM, but does not depend on llvm-gcc. If you +encounter problems with building Clang, make sure you have the latest SVN +version of LLVM. LLVM contains support libraries for Clang that will be updated +as well as development on Clang progresses.

-

Building clang while building llvm:

-

Since you've checked out clang into the llvm source tree you can - build them all at once with a simple Makefile change. This moves - Step 1 above to Step 4.

-
    -
  • cd llvm/tools
  • -
  • then edit Makefile to have a clang target in PARALLEL_DIRS - just like llvm-config
  • -
  • then just build llvm normally as above and clang will build at - the same time
  • -
  • Note: you can update your toplevel project and all (possibly unrelated) - projects inside it with make update. This will run - svn update on all subdirectories related to subversion.
  • -
+

Simultaneously Building Clang and LLVM:

+ +

Once you have checked out Clang into the llvm source tree it will build along +with the rest of llvm. To build all of LLVM and Clang together all at +once simply run make from the root LLVM directory.

+ +

Note: Observe that Clang is technically part of a separate +Subversion repository. As mentioned above, the latest Clang sources are tied to +the latest sources in the LLVM tree. You can update your toplevel LLVM project +and all (possibly unrelated) projects inside it with make +update. This will run svn update on all subdirectories related +to subversion.

+ +

High-Level Compiler Driver (Drop-in Substitute for GCC)

+ +

While the clang-cc executable is a low-level frontend executable +that can perform code generation, program analysis, and other actions, it is not +designed to be a drop-in replacement for GCC's cc. For this purpose, +use the high-level driver, aptly named clang. Here are some +examples of how to use the high-level driver: +

+ +
+$ cat t.c
+#include <stdio.h>
+int main(int argc, char **argv) { printf("hello world\n"); }
+$ clang t.c
+$ ./a.out
+hello world
+
+ +

Examples of using Clang

-

Examples of using clang

+

The high-level driver clang is designed to understand most of GCC's +options, and the lower-level clang-cc executable also directly takes +many of GCC's options. You can see which options clang-cc accepts with +'clang-cc --help'. Here are a few examples of using clang and +clang-cc:

-

The clang driver takes a lot of GCC compatible options, which you can see -with 'clang --help'. Here are a few examples: