5
5
Introduction
6
6
============
7
7
8
- This is a small python-based wrapper around a GCC-compatible compiler
9
- to make it easy to build whole-program (or whole-library) LLVM bitcode
10
- files. The idea is that it first invokes the compiler as normal to
11
- build a real object file. It then invokes a bitcode compiler to
12
- generate the corresponding bitcode, recording the location of the
13
- bitcode file in an ELF section of the actual object file.
14
-
15
- When object files are linked together, the contents of non-special ELF
16
- sections are just concatenated (so we don't lose the locations of any
17
- of the constituent bitcode files).
18
-
19
- This package contains an extra utility, extract-bc, to read the
20
- contents of this ELF section and link all of the bitcode into a single
21
- whole-program bitcode file. This utility can also be used on built
22
- native static libraries to generate LLVM bitcode archives.
8
+ This project, WLLVM, provides tools for building whole-program (or
9
+ whole-library) LLVM bitcode files from an unmodified ` C ` or ` C++ `
10
+ source package. It currently runs on ` *nix ` platforms such as Linux,
11
+ FreeBSD, and Mac OS X.
12
+
13
+ WLLVM provides python-based compiler wrappers that first
14
+ invoke the compiler as normal to build a real object file. The wrapper then
15
+ invokes a bitcode compiler to generate the corresponding bitcode, and
16
+ records the location of the bitcode file in a dedicated section of the actual
17
+ object file.
18
+ When object files are linked together, the contents of the dedicated
19
+ sections are concatenated (so we don't lose the locations of any
20
+ of the constituent bitcode files). After the build process is finished,
21
+ an WLLVM utility reads the
22
+ contents of the dedicated section and links all of the bitcode into a single
23
+ whole-program bitcode file. This utility can also be used when building
24
+ native libraries to generate corresponding LLVM bitcode archives.
25
+
26
+ Currently, WLLVM works with either ` clang ` or the ` gcc ` dragonegg plugin.
27
+
28
+
29
+
30
+
23
31
24
32
This two-phase build process is slower and more elaborate than normal,
25
33
but in practice is necessary to be a drop-in replacement for gcc in
@@ -29,14 +37,15 @@ static libraries in builds. This approach has the distinct advantage
29
37
of generating working binaries, in case some part of a build process
30
38
actually requires that.
31
39
32
- Currently, this package only works using clang or the dragonegg plugin
33
- with gcc 4.5 (with the required patch for dragonegg).
34
40
35
41
Usage
36
42
=====
37
43
38
- There are three environment variables that must be set to use this
39
- wrapper script:
44
+ The project provides a two wrappers, ` wllvm ` , for ` CC ` and ` wllvm++ ` , for ` CXX `
45
+ and an auxillary tool ` extract-bc ` .
46
+
47
+
48
+ Three environment variables must be set to use these wrappers:
40
49
41
50
* ` LLVM_COMPILER ` should be set to 'dragonegg' or 'clang'.
42
51
* ` LLVM_GCC_PREFIX ` should be set to the prefix for the version of gcc that should
@@ -45,7 +54,7 @@ wrapper script:
45
54
* ` LLVM_DRAGONEGG_PLUGIN ` should be the full path to the dragonegg plugin. This
46
55
variable is not used if ` $LLVM_COMPILER == clang ` .
47
56
48
- Once the environment is set up, just use wllvm and wllvm++ as your C
57
+ Once the environment is set up, just use ` wllvm ` and ` wllvm++ ` as your C
49
58
and C++ compilers, respectively.
50
59
51
60
In addition to the above environment variables the following can be optionally used:
@@ -63,7 +72,20 @@ In addition to the above environment variables the following can be optionally u
63
72
This may prevent configuration errors being cause by the unexpected production
64
73
of the hidden bitcode files.
65
74
66
- Example building bitcode module
75
+ Example building bitcode module with clang
76
+ ===============================
77
+
78
+ export LLVM_COMPILER=clang
79
+
80
+ tar xf pkg-config-0.26.tar.gz
81
+ cd pkg-config-0.26
82
+ CC=wllvm ./configure
83
+ make
84
+
85
+ # Produces pkg-config.bc
86
+ extract-bc pkg-config
87
+
88
+ Example building bitcode module with dragonegg
67
89
===============================
68
90
69
91
export LLVM_COMPILER=dragonegg
@@ -78,6 +100,7 @@ Example building bitcode module
78
100
# Produces pkg-config.bc
79
101
extract-bc pkg-config
80
102
103
+
81
104
Example building bitcode archive
82
105
================================
83
106
0 commit comments