llvm.org GIT mirror llvm / 46079d2
Add C/C++ build instructions, first draft. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9355 91177308-0d34-0410-b5e6-96231b3b80d8 Brian Gaeke 15 years ago
1 changed file(s) with 140 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0
1 Bootstrapping the C/C++ Front-End
2
3
4

Bootstrapping the C/C++ Front-End

5
6

7
8
9
10
11 Instructions
12
13
14
15

This document is intended to explain the process of building the LLVM

16 C/C++ front-end, based on GCC 3.4, from source.

17
18

NOTE: This is currently a somewhat fragile, error-prone

19 process, and you should only try to do it if (A) you really, really,
20 really can't use the binaries we distribute, and (B) you are a wicked
21 good GCC hacker.

22
23

We welcome patches to help make this process simpler.

24
25
26
  • Configure and build the LLVM libraries and tools using:

  • 27
    
                      
                    
    28 % cd llvm
    29 % ./configure [options...]
    30 % gmake tools-only
    31
    32

    The use of the non-default target "tools-only" means that the

    33 LLVM tools and libraries will build, and the binaries will be
    34 deposited in llvm/tools/Debug, but the runtime (bytecode)
    35 libraries will not build.

    36
    37
  • Add the directory containing the tools to your PATH.

  • 38
    
                      
                    
    39 % set path = ( `cd llvm/tools/Debug && pwd` $path )
    40
    41
    42
  • Unpack the C/C++ front-end source into cfrontend/src.

  • 43
    44
  • Edit src/configure. Change the first line (starting w/ #!) to

  • 45 contain the correct full pathname of sh.

    46
    47
  • Make "build" and "install" directories as siblings of the "src"

  • 48 tree.

    49
    
                      
                    
    50 % pwd
    51 /usr/local/example/cfrontend/src
    52 % cd ..
    53 % mkdir build install
    54 % set CFEINSTALL = `pwd`/install
    55
    56
    57
  • Configure, build and install the C front-end:

  • 58
    
                      
                    
    59 % cd build
    60 % ../src/configure --prefix=$CFEINSTALL --disable-nls --disable-shared \
    61 --enable-languages=c,c++
    62 % gmake all-gcc
    63 % setenv LLVM_LIB_SEARCH_PATH `pwd`/gcc
    64 % gmake all; gmake install
    65
    66
    67

    Common Problem 1: You may get error messages regarding the fact

    68 that LLVM does not support inline assembly. Here are two common
    69 fixes:

    70
    71
    72
  • Fix 1: If you have system header files that include

  • 73 inline assembly, you may have to modify them to remove the inline
    74 assembly, and install the modified versions in
    75 $CFEINSTALL/target-triplet/sys-include.

    76
    77
  • Fix 2: If you are building the C++ front-end on a CPU we
  • 78 haven't tried yet, you will probably have to edit the appropriate
    79 version of atomicity.h under
    80 src/libstdc++-v3/config/cpu/name-of-cpu/atomicity.h
    81 and apply a patch so that it does not use inline assembly.

    82
    83
    84

    Common Problem 2: FIXME: Chris should add a section about

    85 common problems porting to a new architecture, including changes you
    86 might have to make to the gcc/gcc/config/name-of-cpu
    87 directory. For example (expand these):

    88
    89
    90
  • Munge linker flags so they are compatible with gccld.
  • 91
  • Change the target so it doesn't have long double; just use double
  • 92 instead.
    93
  • No inline assembly for position independent code.
  • 94
  • We handle init and fini differently.
  • 95
  • Do not include inline assembly map things for SPARC, or profile things.
  • 96
    97
    98
  • Go back into the LLVM source tree proper. Edit Makefile.config

  • 99 to redefine LLVMGCCDIR to the full pathname of the
    100 $CFEINSTALL directory, which is the directory you just
    101 installed the C front-end into. (The ./configure script is likely to
    102 have set this to a directory which does not exist on your system.)

    103
    104
  • If you edited header files during the C/C++ front-end build as

  • 105 described in "Fix 1" above, you must now copy those header files from
    106 $CFEINSTALL/target-triplet/sys-include to
    107 $CFEINSTALL/lib/gcc/target-triplet/3.4-llvm/include.
    108 (This should be the "include" directory in the same directory as the
    109 libgcc.a library, which you can find by running
    110 $CFEINSTALL/bin/gcc --print-libgcc-file-name.)

    111
    112
  • Build and install the runtime (bytecode) libraries by running:

  • 113
    
                      
                    
    114 % gmake -C runtime
    115 % mkdir $CFEINSTALL/bytecode-libs
    116 % gmake -C runtime install
    117 % setenv LLVM_LIB_SEARCH_PATH $CFEINSTALL/bytecode-libs
    118
    119
    120
  • Test the newly-installed C frontend by one or more of the

  • 121 following means:

    122
    123
  • compiling and running a "hello, world" program in C or C++.
  • 124
  • running the tests under test/Programs using gmake -C
  • 125 test/Programs;
    126
    127
    128

    129
    130
    131
    132
    133
    134
    135
    136
    Brian Gaeke
    137 Last modified: $Date$
    138
    139