1
- Steps to build bitcode version of FreeBSD 10.0 world and kernel
2
- -----------------------------------------------
1
+ # Steps to build bitcode version of FreeBSD 10.0 world and kernel
3
2
4
3
The following instructions have been tested with FreeBSD 10.0 amd64.
5
4
6
- -- Prerequisites: --------------------------------------------------------------
5
+ ## Prerequisites
7
6
8
- 1 . FreeBSD
7
+ ### 1. FreeBSD
9
8
10
9
The ideal way to start is with a clean install of FreeBSD 10.0 with
11
10
sources installed. The simplest way to do this is to install from the
12
11
Release 10.0 ISO image and and on the "Distribution Select" screen
13
12
select just the following:
14
13
15
- [ * ] ports Ports tree
16
- [ * ] src System source code
14
+ [*] ports Ports tree
15
+ [*] src System source code
17
16
18
17
If you are on an existing system that has either an old version of the
19
18
source tree or is missing source, you can follow the instructions in the
20
19
FreeBSD Handbook Chapter 24 to get the relevant sources.
21
20
22
- 2 . Necessary ports
21
+ ### 2. Necessary ports
23
22
24
23
Upgrade the ports collection (as 'root'):
25
24
26
- su -
27
- portsnap fetch
28
- portsnap extract
29
- cd /usr/ports/ports-mgmt/portupgrade
30
- make -DBATCH install clean
31
- portupgrade -a --batch
25
+ su -
26
+ portsnap fetch
27
+ portsnap extract
28
+ cd /usr/ports/ports-mgmt/portupgrade
29
+ make -DBATCH install clean
30
+ portupgrade -a --batch
32
31
33
32
Install the following ports using the BSD port tree:
34
33
35
- bash git subversion python27 sudo wget
34
+ bash git subversion python27 sudo wget
36
35
37
36
(See the FreeBSD Handbook Chapter 5 for instructions.)
38
37
The quick way to do this is:
39
38
40
- su -
41
- cd /usr/ports
42
- cd shells/bash && make -DBATCH install clean && \
39
+ su -
40
+ cd /usr/ports
41
+ cd shells/bash && make -DBATCH install clean && \
43
42
cd ../../devel/git && make -DBATCH install clean && \
44
43
cd ../../devel/subversion && make -DBATCH install clean && \
45
44
cd ../../security/sudo && make -DBATCH install clean && \
@@ -49,7 +48,7 @@ The quick way to do this is:
49
48
50
49
Below we assume the shell being used is bash, that is:
51
50
52
- chsh -s /usr/local/bin/bash
51
+ chsh -s /usr/local/bin/bash
53
52
54
53
has been run. If you want to use another shell, replace bash-isms like
55
54
'export' with the appropriate equivalent.
@@ -58,101 +57,106 @@ We suggest installing 'sudo' and setting up your account as a sudoer, to
58
57
make installing programs easier. You can do this, or modify the commands
59
58
that use 'sudo' below.
60
59
61
- 3 . LLVM and Clang 3.3
60
+ ### 3. LLVM and Clang 3.3
62
61
63
62
Install LLVM and Clang version 3.3. (These instructions adapted from
64
63
http://llvm.org/docs/GettingStarted.html ) Decide where you want to
65
64
install LLVM. If you have 'root' access, you can use the default
66
65
'/usr/local', though any location is fine. You may then wish to add this
67
66
to your shell startup (in '~ /.profile' for bash):
68
67
69
- export LLVM_HOME=/usr/local/llvm-3.3
68
+ export LLVM_HOME=/usr/local/llvm-3.3
70
69
71
70
Get LLVM and Clang version 3.5:
72
71
73
- svn co http://llvm.org/svn/llvm-project/llvm/branches/release_33 llvm
74
- cd llvm/tools
75
- svn co http://llvm.org/svn/llvm-project/cfe/branches/release_33 clang
76
- cd ../projects
77
- svn co http://llvm.org/svn/llvm-project/compiler-rt/branches/release_33 compiler-rt
78
- cd ../..
72
+ svn co http://llvm.org/svn/llvm-project/llvm/branches/release_33 llvm
73
+ cd llvm/tools
74
+ svn co http://llvm.org/svn/llvm-project/cfe/branches/release_33 clang
75
+ cd ../projects
76
+ svn co http://llvm.org/svn/llvm-project/compiler-rt/branches/release_33 compiler-rt
77
+ cd ../..
79
78
80
79
Now finish the build and install:
81
80
82
- cd llvm
83
- mkdir build
84
- cd build
85
- ../configure --prefix=$LLVM_HOME --enable-assertions \
86
- --enable-targets=host-only --enable-optimized
87
- gmake
88
- sudo gmake install
81
+ cd llvm
82
+ mkdir build
83
+ cd build
84
+ ../configure --prefix=$LLVM_HOME --enable-assertions \
85
+ --enable-targets=host-only --enable-optimized
86
+ gmake
87
+ sudo gmake install
89
88
90
89
Note that the FreeBSD 10.0 base includes Clang 3.3 (but does not include
91
90
the complete LLVM framework, in particular llvm-link is not included).
92
91
93
92
So to make life easier, so that extract-bc can find it do:
94
93
95
- sudo ln -s $LLVM_HOME/bin/llvm-link /usr/bin/llvm-link
94
+ sudo ln -s $LLVM_HOME/bin/llvm-link /usr/bin/llvm-link
96
95
97
96
98
- 1 . Download SRI-modified version of WLLVM .
97
+ ### 4 . Download whole-program-wllvm .
99
98
100
- > cd ${HOME}
101
- > git clone https://github.com/SRI-CSL /whole-program-llvm
99
+ cd ${HOME}
100
+ git clone https://github.com/travitch /whole-program-llvm
102
101
103
- 2 . Create the hooks for interposing on compiler calls.
102
+ Create the hooks for interposing on compiler calls.
104
103
105
- > cd ${HOME}
106
- > mkdir ${HOME}/wllvm.bin
107
- > cd wllvm.bin
108
- > ln -s ${HOME}/whole-program-llvm/wllvm cc
109
- > ln -s ${HOME}/whole-program-llvm/wllvm++ c++
110
- > ln -s ${HOME}/whole-program-llvm/wllvm clang
111
- > ln -s ${HOME}/whole-program-llvm/wllvm++ clang++
112
- this next one is a hack (make buildworld doesn't find python with /usr/bin/env without it)
113
- > ln -s /usr/local/bin/python python
104
+ cd ${HOME}
105
+ mkdir ${HOME}/wllvm.bin
106
+ cd wllvm.bin
107
+ ln -s ${HOME}/whole-program-llvm/wllvm cc
108
+ ln -s ${HOME}/whole-program-llvm/wllvm++ c++
109
+ ln -s ${HOME}/whole-program-llvm/wllvm clang
110
+ ln -s ${HOME}/whole-program-llvm/wllvm++ clang++
114
111
115
- 3 . Insert the hooks into the build path.
112
+ This next one is a hack (make buildworld doesn't find python with /usr/bin/env without it)
116
113
117
- > diff /usr/src/Makefile.inc1 Makefile.inc1.original
114
+ ln -s /usr/local/bin/python python
115
+
116
+ ### 5. Insert the hooks into the build path.
117
+
118
+ ```
119
+ diff /usr/src/Makefile.inc1 Makefile.inc1.original
118
120
180c180
119
- < BPATH= ${HOME}/wllvm.bin:${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games:${WORLDTMP}/legacy/bin
121
+ BPATH= ${HOME}/wllvm.bin:${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games:${WORLDTMP}/legacy/bin
120
122
---
121
- > BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games:${WORLDTMP}/legacy/bin
123
+ BPATH= ${WORLDTMP}/legacy/usr/sbin:${WORLDTMP}/legacy/usr/bin:${WORLDTMP}/legacy/usr/games:${WORLDTMP}/legacy/bin
124
+ ```
122
125
123
- 4 . If the build location doesn't exist, create it.
126
+ ## Building the Puppy
124
127
125
- > mkdir ${HOME}/ build.world
128
+ If the build location doesn't exist, create it.
126
129
127
- 5 . Configure the environment for the build.
130
+ mkdir ${HOME}/ build.world
128
131
129
- > export MAKEOBJDIRPREFIX=${HOME}/build.world
130
- > export LLVM_COMPILER=clang
131
- > export LLVM_COMPILER_PATH=/usr/bin
132
- > export WLLVM_OUTPUT=DEBUG
132
+ Configure the environment for the build.
133
133
134
- 6 . Start the build.
134
+ export MAKEOBJDIRPREFIX=${HOME}/build.world
135
+ export LLVM_COMPILER=clang
136
+ export LLVM_COMPILER_PATH=/usr/bin
137
+ export WLLVM_OUTPUT=DEBUG
135
138
136
- > cd /usr/src
137
- > make buildworld
139
+ Start the build.
138
140
139
- 7 . Once that succeeds build the kernel
141
+ cd /usr/src
142
+ make buildworld
140
143
141
- > make buildkernel
144
+ Once that succeeds build the kernel
142
145
146
+ make buildkernel
143
147
144
- 8 . extract the bitcode:
148
+ Extract the bitcode:
145
149
146
150
147
- cd ${MAKEOBJDIRPREFIX}/usr/src/sys/GENERIC
151
+ cd ${MAKEOBJDIRPREFIX}/usr/src/sys/GENERIC
148
152
149
- > ${HOME}/whole-program-llvm/extract-bc kernel
153
+ ${HOME}/whole-program-llvm/extract-bc kernel
150
154
151
- > nm kernel | wc
152
- 53140 159418 2421852
155
+ nm kernel | wc
156
+ 53140 159418 2421852
153
157
154
- > ${LLVM_HOME}/bin/llvm-nm kernel.bc | wc
155
- 50664 101328 1910997
158
+ ${LLVM_HOME}/bin/llvm-nm kernel.bc | wc
159
+ 50664 101328 1910997
156
160
157
161
We are working on seeing if we can get these numbers to match.
158
162
But suspect their is some assembler causing this difference.
0 commit comments