From 85ed361198994fa34a8c3635d3e77130135d35a8 Mon Sep 17 00:00:00 2001
From: John Criswell The next section of this guide is meant to get
+ you up and running with LLVM and to give you some basic information about
+ the LLVM environment. The first subsection gives
+ a short summary for those who are already familiar with the system and
+ want to get started as quickly as possible.
+
+ The later sections of this guide describe the general layout of the the LLVM source-tree, a simple example using the LLVM tool chain, and links to find more information about LLVM or to get
+ help via e-mail.
+
+
+ The next section of this guide is meant to
-get you up and running with LLVM, and to give you some basic information
-about the LLVM environment. The first subsection
-gives a short summary for those who are already familiar with the system
-and want to get started as quickly as possible. The later sections of this guide describe the general
-layout of the LLVM source-tree, a simple example
-using the LLVM tool chain, and links to find more information
-about LLVM or to get help via e-mail.
- See Setting up your environment on tips to
- simplify working with the LLVM front-end and compiled tools. See the
- other sub-sections below for other useful details in working with LLVM,
- or go straight to Program Layout to learn about
-the layout of the source code tree.
- Through this manual, the following names are used to denote paths
-specific to the local system and working environment. These are not
- environment variables you need to set, but just strings used in the rest
- of this document below. In any of the examples below, simply replace
- each of these names with the appropriate pathname on your local system.
+
+ See Setting up your environment on tips to
+ simplify working with the LLVM front-end and compiled tools. See the
+ other sub-sections below for other useful details in working with LLVM,
+ or go straight to Program Layout to learn about the
+ layout of the source code tree.
+
+
+ Throughout this manual, the following names are used to denote paths
+ specific to the local system and working environment. These are not
+ environment variables you need to set, but just strings used in the rest
+ of this document below.. In any of the examples below, simply replace
+ each of these names with the appropriate pathname on your local system.
All these paths are absolute: Before checking out the source code, you will need to know the path to
- the CVS repository containing LLVM source code (we'll call this CVSROOTDIR
-below). Ask the person responsible for your local LLVM installation
-to give you this path. To get a fresh copy of the entire source code, all you need to do
-is check it out from CVS as follows: This will create an 'llvm' directory in the current directory
-and fully populate it with the LLVM source code, Makefiles, test directories,
-and local copies of documentation files. The file llvm/Makefile.config defines the following path
-variables which are specific to a particular installation of LLVM.
- These should need to be modified only once after checking out a copy
- of LLVM (if the default values do not already match your system):
-
- The LLVM make system sends most output files generated during the build
- into the directory defined by the variable OBJ_ROOT in llvm/Makefile.config.
- This can be either just your normal LLVM source tree or some other directory
-writable by you. You may wish to put object files on a different filesystem
-either to keep them from being backed up or to speed up local builds.
- If you do not wish to use a different location for object files (i.e.
-building into the source tree directly), just set this variable to ".".
- Add the following lines to your .cshrc (or the corresponding
- lines to your .profile if you use a bourne shell derivative).
- Before checking out the source code, you will need to know the path to
+ the CVS repository containing LLVM source code (we'll call this
+ CVSROOTDIR below). Ask the person responsible for your local LLVM
+ installation to give you this path.
+
+ To get a fresh copy of the entire source code, all you
+ need to do is check it out from CVS as follows:
+ Getting Started with the LLVM System
-
-By: Guochun Shi, Chris Lattner and Vikram Adve Contents
-
-
-
-
-
-
-Getting Started with the LLVM System
By: Guochun Shi,
+ Chris Lattner and
+ Vikram Adve
+ Contents
+
+
+
+
+
+
+
+ Overview
+ Getting Started
+ Getting Started Quickly (A Summary)
+
+
+ Here's the short story for getting up and running quickly with LLVM:
-
- Overview
- Getting Started
- Getting Started Quickly (A Summary)
-
- Here's the short story for getting up and running quickly with LLVM:
-
-
-
-
-Terminology and Notation
-
-
-Terminology and Notation
+
+
+
-
-
-
-
-Checkout LLVM from CVS
-
-
-
-
-
-Local Configuration Options
-
-
-
-
-
-
- In addition to settings in this file, you must set a LLVM_LIB_SEARCH_PATH
-environment variable in your startup scripts. This environment variable
-is used to locate "system" libraries like "-lc" and "-lm"
-when linking. This variable should be set to the absolute path for the
-bytecode-libs subdirectory of the C front-end install. For example,
- /home/vadve/lattner/local/x86/llvm-gcc/bytecode-libs is used
-for the X86 version of the C front-end on our research machines.
-The location for LLVM object files
-
-
-Setting up your environment
-
- NOTE: This step is optional but will set up your environment so you
- can use the compiled LLVM tools with as little hassle as possible.)
-
- # Make the C front end easy to use...
alias llvmgcc LLVMGCCDIR/bin/llvm-gcc
+
+
+
+
+ Checkout LLVM from CVS
+
+
+
+
This will create an 'llvm' directory in the current + directory and fully populate it with the LLVM source code, Makefiles, + test directories, and local copies of documentation files.
+ + +The file llvm/Makefile.config + defines the following path variables + which are specific to a particular installation of LLVM. + These need to be modified only once after checking out a copy + of LLVM (if the default values do not already match your system): + +
+ + +
The LLVM make system sends most output files generated during the build + into the directory defined by the variable OBJ_ROOT in + llvm/Makefile.config. This can be either just your normal LLVM + source tree or some other directory writable by you. You may wish to put + object files on a different filesystem either to keep them from being backed + up or to speed up local builds. + +
If you do not wish to use a different location for object files (i.e. + you are building into the source tree directly), just set this variable to + ".".
+ + +
Add the following lines to your .cshrc (or the corresponding + lines to your .profile if you use a bourne shell derivative). + +
+ # Make the C front end easy to use... + alias llvmgcc LLVMGCCDIR/bin/llvm-gcc # Make the LLVM tools easy to use... - setenv PATH OBJ_ROOT/llvm/tools/Debug:${PATH}- The llvmgcc alias is useful because the C compiler is not - included in the CVS tree you just checked out. -
The other LLVM tools are part of the LLVM source -base and are built when compiling LLVM. They will be built into the -OBJ_ROOT/tools/Debug directory.
- - -Every directory in the LLVM source tree includes a Makefile to - build it and any subdirectories that it contains. These makefiles require - GNU Make (gmake) instead of make to build them, but -can otherwise be used freely. To build the entire LLVM system, just -enter the top level llvm directory and type gmake. - A few minutes later you will hopefully have a freshly compiled toolchain -waiting for you in OBJ_ROOT/llvm/tools/Debug. - If you want to look at the libraries that were compiled, look in OBJ_ROOT/llvm/lib/Debug.
- If you get an error about the /localhome directory, chances -are good that something has been misconfigured. Follow the instructions -in the section about Setting Up Your Environment. - + setenv PATH OBJ_ROOT/llvm/tools/Debug:${PATH} + + The llvmgcc alias is useful because the C compiler is not + included in the CVS tree you just checked out. -One useful source of infomation about the LLVM sourcebase is the LLVM -doxygen documentation, available at -http://llvm.cs.uiuc.edu/doxygen/. -The following is a brief introduction to code layout:
- - -The other LLVM tools are part of the LLVM + source base and built when compiling LLVM. They will be built into the + OBJ_ROOT/tools/Debug directory.
+ + +Every directory in the LLVM source tree includes a Makefile to + build it and any subdirectories that it contains. These makefiles require + that you use GNU Make (aka gmake) instead of make to + build them, but can + otherwise be used freely. To build the entire LLVM system, just enter the + top level llvm directory and type gmake. A few minutes + later you will hopefully have a freshly compiled toolchain waiting for you + in OBJ_ROOT/llvm/tools/Debug. If you want to look at the + libraries that were compiled, look in + OBJ_ROOT/llvm/lib/Debug.
+ + If you get an error about a /localhome directory, follow the + instructions in the section about Setting Up Your + Environment. + + + + +One useful source of infomation about the LLVM sourcebase is the LLVM doxygen documentation, available at http://llvm.cs.uiuc.edu/doxygen/. The + following is a brief introduction to code layout:
+ + + +-
--
-
This directory contains regression tests and source code that is used -to test the LLVM infrastructure...
- - -The tools directory contains the executables built out of the - libraries above, which form the main part of the user interface. You -can always get help for a tool by typing tool_name --help. -The following is a brief introduction to the most important tools.
- --
-
-
-
+ + + If you are building with the "OBJ_ROOT=." option enabled in the + Makefile.config file, most source directories will contain two + directories, Depend and Debug. The Depend + directory contains automatically generated dependance files which are used + during compilation to make sure that source files get rebuilt if a header + file they use is modified. The Debug directory holds the object + files, library files, and executables that are used for building a debug + enabled build. The Release directory is created to hold the same + files when the ENABLE_OPTIMIZED=1 flag is passed to gmake, + causing an optimized built to be performed.
+ + + +
+
-
-
-
-
#include <stdio.h>-
int main() {
printf("hello world\n");
return 0;
}
% llvmgcc hello.c -o hello
-This will create two result files: hello and - hello.bc. The hello.bc is the LLVM bytecode that - corresponds the the compiled program and the library facilities that it - required. hello is a simple shell script that runs the bytecode - file with lli, making the result directly executable.
--
% ./hello
-or
-% lli hello.bc
--
% dis < hello.bc | less
--
% llc hello.bc -o hello.s
--
% /opt/SUNWspro/bin/cc -xarch=v9 hello.s -o hello.sparc
--
% ./hello.sparc
--
This document is just an introduction to how to use LLVM to do - some simple things... there are many more interesting and complicated -things that you can do that aren't documented here (but we'll gladly -accept a patch if you want to write something up!). For more information -about LLVM, check out:
- -+ +
This directory contains regression tests and source code that is used to + test the LLVM infrastructure...
+ + +The tools directory contains the executables built out of the + libraries above, which form the main part of the user interface. You can + always get help for a tool by typing tool_name --help. The + following is a brief introduction to the most important tools.
+ ++ +
+ +
+ +
+ +
+ +
+ +
+
+ + +
+ +
+ #include <stdio.h> + int main() { + printf("hello world\n"); + return 0; + } ++ +
+ + % llvmgcc hello.c -o hello
+ + This will create two result files: hello and + hello.bc. The hello.bc is the LLVM bytecode that + corresponds the the compiled program and the library facilities that it + required. hello is a simple shell script that runs the bytecode + file with lli, making the result directly executable.
+ +
-
+ + or
+ + % lli hello.bc
+ +
+ + % dis < hello.bc | less
+ +
+ + % llc hello.bc -o hello.s
+ +
+ + % /opt/SUNWspro/bin/cc -xarch=v9 hello.s -o hello.sparc
+ +
+ + % ./hello.sparc
+ +
This document is just an introduction to how to use LLVM to do + some simple things... there are many more interesting and complicated things + that you can do that aren't documented here (but we'll gladly accept a patch + if you want to write something up!). For more information about LLVM, check + out:
+ + + +