From 233f147691339389f046c516d4b67ea5a9eac881 Mon Sep 17 00:00:00 2001
From: Chad Rosier
The second piece is the GCC front end. This component provides a version of -GCC that compiles C and C++ code into LLVM bitcode. Currently, the GCC front -end uses the GCC parser to convert code to LLVM. Once -compiled into LLVM bitcode, a program can be manipulated with the LLVM tools -from the LLVM suite.
+The second piece is the Clang front end. This component compiles C, C++, +Objective C, and Objective C++ code into LLVM bitcode. Once compiled into LLVM +bitcode, a program can be manipulated with the LLVM tools from the LLVM suite. +
There is a third, optional piece called Test Suite. It is a suite of programs @@ -1721,20 +1720,11 @@ are code generators for parts of LLVM infrastructure.
This section gives an example of using LLVM. llvm-gcc3 is now obsolete, -so we only include instructions for llvm-gcc4. -
- -Note: The gcc4 frontend's invocation is considerably different -from the previous gcc3 frontend. In particular, the gcc4 frontend does not -create bitcode by default: gcc4 produces native code. As the example below illustrates, -the '--emit-llvm' flag is needed to produce LLVM bitcode output. For makefiles and -configure scripts, the CFLAGS variable needs '--emit-llvm' to produce bitcode -output.
+This section gives an example of using LLVM with the Clang front end.
Next, compile the C file into a native executable:
-% llvm-gcc hello.c -o hello
% clang hello.c -o hello
Note that llvm-gcc works just like GCC by default. The standard -S and +
Note that clang works just like GCC by default. The standard -S and -c arguments work as usual (producing a native .s or .o file, respectively).
Next, compile the C file into a LLVM bitcode file:
% llvm-gcc -O3 -emit-llvm hello.c -c -o hello.bc
% clang -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 bitcode file.
- -Unlike llvm-gcc3, llvm-gcc4 correctly responds to -O[0123] arguments. -
+ the bitcode file.Run the program in both forms. To run the program, use:
@@ -1810,7 +1797,7 @@ int main() {% ./hello.native
Note that using llvm-gcc to compile directly to native code (i.e. when +
Note that using clang to compile directly to native code (i.e. when the -emit-llvm option is not present) does steps 6/7/8 for you.