5
5
Introduction
6
6
============
7
7
8
- This project, WLLVM, provides tools for building whole-program (or
8
+ This project, WLLVM, provides tools for building whole-program (or
9
9
whole-library) LLVM bitcode files from an unmodified ` C ` or ` C++ `
10
10
source package. It currently runs on ` *nix ` platforms such as Linux,
11
11
FreeBSD, and Mac OS X.
12
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.
13
+ WLLVM provides python-based compiler wrappers that work in two
14
+ steps. The wrappers first invoke the compiler as normal. Then, for
15
+ each object file, they call a bitcode compiler to produce LLVM
16
+ bitcode. The wrappers also store the location of the generated bitcode
17
+ file in a dedicated section of the object file. When object files are
18
+ linked together, the contents of the dedicated sections are
19
+ concatenated (so we don't lose the locations of any of the constituent
20
+ bitcode files). After the build completes, one can use an WLLVM
21
+ utility to read the contents of the dedicated section and link all of
22
+ the bitcode into a single whole-program bitcode file. This utility
23
+ works for both executable and native libraries.
25
24
26
25
Currently, WLLVM works with either ` clang ` or the ` gcc ` dragonegg plugin.
27
26
28
-
29
-
30
-
31
-
32
- This two-phase build process is slower and more elaborate than normal,
33
- but in practice is necessary to be a drop-in replacement for gcc in
34
- any build system. Approaches using the LTO framework in gcc and the
35
- gold linker plugin work for many cases, but fail in the presence of
36
- static libraries in builds. This approach has the distinct advantage
37
- of generating working binaries, in case some part of a build process
38
- actually requires that.
27
+ This two-phase build process is necessary to be a drop-in replacement
28
+ for gcc or g++ in any build system. Using the LTO framework in gcc
29
+ and the gold linker plugin works in many cases, but fails in the
30
+ presence of static libraries in builds. WLLVM's approach has the
31
+ distinct advantage of generating working binaries, in case some part
32
+ of a build process requires that.
39
33
40
34
41
35
Usage
42
36
=====
43
37
44
- The project provides a two wrappers, ` wllvm ` , for ` CC ` and ` wllvm++ ` , for ` CXX `
45
- and an auxillary tool ` extract-bc ` .
46
-
38
+ WLLVM includes two python executables: ` wllvm ` for compiling C code
39
+ and ` wllvm++ ` for C++, and an auxiliary tool ` extract-bc ` .
47
40
48
41
Three environment variables must be set to use these wrappers:
49
42
50
- * ` LLVM_COMPILER ` should be set to 'dragonegg' or 'clang'.
43
+ * ` LLVM_COMPILER ` should be set to either 'dragonegg' or 'clang'.
51
44
* ` LLVM_GCC_PREFIX ` should be set to the prefix for the version of gcc that should
52
45
be used with dragonegg. This can be empty if there is no prefix. This variable is
53
46
not used if ` $LLVM_COMPILER == clang ` .
@@ -73,7 +66,7 @@ In addition to the above environment variables the following can be optionally u
73
66
of the hidden bitcode files.
74
67
75
68
Building a bitcode module with clang
76
- ===============================
69
+ ====================================
77
70
78
71
export LLVM_COMPILER=clang
79
72
@@ -86,7 +79,7 @@ Building a bitcode module with clang
86
79
extract-bc pkg-config
87
80
88
81
Building a bitcode module with dragonegg
89
- ===============================
82
+ ========================================
90
83
91
84
export LLVM_COMPILER=dragonegg
92
85
export LLVM_GCC_PREFIX=llvm-
@@ -102,7 +95,7 @@ Building a bitcode module with dragonegg
102
95
103
96
104
97
Building bitcode archive
105
- ================================
98
+ ========================
106
99
107
100
export LLVM_COMPILER=clang
108
101
tar -xvf bullet-2.81-rev2613.tgz
@@ -114,11 +107,12 @@ Building bitcode archive
114
107
# Produces src/LinearMath/libLinearMath.bca
115
108
extract-bc src/LinearMath/libLinearMath.a
116
109
110
+
117
111
Building an Operating System
118
- ================================
112
+ ============================
119
113
120
- To see how to build freeBSD 10.0 from scratch check out the guide
121
- [ here .] ( ../master/README-freeBSD.md )
114
+ To see how to build freeBSD 10.0 from scratch check out this
115
+ [ guide .] ( ../master/README-freeBSD.md )
122
116
123
117
124
118
Configuring without building bitcode
@@ -127,7 +121,7 @@ Configuring without building bitcode
127
121
128
122
WLLVM_CONFIGURE_ONLY=1 CC=wllvm ./configure
129
123
CC=wllvm make
130
-
124
+
131
125
132
126
Debugging
133
127
=========
0 commit comments