|
| 1 | +# Compiling Apache on Ubuntu |
| 2 | + |
| 3 | + |
| 4 | +On a clean 16.04 server machine I will build apache. Desktop instructions should be no different. |
| 5 | + |
| 6 | +``` |
| 7 | +>pwd |
| 8 | +
|
| 9 | +/home/me/ |
| 10 | +
|
| 11 | +>more /etc/lsb-release |
| 12 | +
|
| 13 | +DISTRIB_ID=Ubuntu |
| 14 | +DISTRIB_RELEASE=16.04 |
| 15 | +DISTRIB_CODENAME=xenial |
| 16 | +DISTRIB_DESCRIPTION="Ubuntu 16.04 LTS" |
| 17 | +``` |
| 18 | + |
| 19 | + |
| 20 | +## Step 0. |
| 21 | + |
| 22 | +Checkout the wllvm repository |
| 23 | + |
| 24 | +``` |
| 25 | +>git clone https://github.com/SRI-CSL/whole-program-llvm.git |
| 26 | +``` |
| 27 | + |
| 28 | +## Step 1. |
| 29 | + |
| 30 | +Set up the environment |
| 31 | + |
| 32 | +``` |
| 33 | +>export WLLVM_HOME=/home/me/whole-program-llvm |
| 34 | +
|
| 35 | +>export PATH=${WLLVM_HOME}:${PATH} |
| 36 | +
|
| 37 | +>which wllvm |
| 38 | +
|
| 39 | +/home/me/whole-program-llvm/wllvm |
| 40 | +``` |
| 41 | + |
| 42 | +## Step 2. |
| 43 | + |
| 44 | +I am only going to build apache, not apr, so I first install the prerequisites. |
| 45 | + |
| 46 | +``` |
| 47 | +>sudo apt-get update |
| 48 | +
|
| 49 | +>sudo apt-get install llvm clang libapr1-dev libaprutil1-dev libpcre3-dev gcc make |
| 50 | +
|
| 51 | +``` |
| 52 | + |
| 53 | +At this point, you should check your clang version with `which clang` and `ls -l /usr/bin/clang`. It should be clang-3.8. |
| 54 | + |
| 55 | +## Step 3. |
| 56 | + |
| 57 | + Configure the wllvm tool to use clang and be relatively quiet: |
| 58 | + |
| 59 | +``` |
| 60 | +>export LLVM_COMPILER=clang |
| 61 | +
|
| 62 | +>export WLLVM_OUTPUT=WARNING |
| 63 | +``` |
| 64 | + |
| 65 | +## Step 4. |
| 66 | + |
| 67 | + Fetch apache, untar, configure, then build: |
| 68 | + |
| 69 | +``` |
| 70 | +>cd && pwd |
| 71 | +
|
| 72 | +/home/me |
| 73 | +
|
| 74 | +>wget http://apache.mirrors.pair.com/httpd/httpd-2.4.23.tar.gz |
| 75 | +
|
| 76 | +>tar xfz httpd-2.4.12.tar.gz |
| 77 | +
|
| 78 | +>cd httpd-2.4.23 |
| 79 | +
|
| 80 | +>CC=wllvm ./configure |
| 81 | +
|
| 82 | +>make |
| 83 | +``` |
| 84 | + |
| 85 | +## Step 5. |
| 86 | + |
| 87 | +Extract the bitcode. |
| 88 | + |
| 89 | +``` |
| 90 | +>extract-bc -l llvm-link-3.8 httpd |
| 91 | +
|
| 92 | +>ls -la httpd.bc |
| 93 | +-rw-r--r-- 1 vagrant vagrant 829960 Jun 1 2015 httpd.bc |
| 94 | +``` |
| 95 | + |
| 96 | +The extra command line argument to `extract-bc` is because `apt` |
| 97 | +installs `llvm-link` as `llvm-link-3.8` so we need to tell `extract-bc` |
| 98 | +to use that one. |
| 99 | + |
| 100 | +## Step 6. |
| 101 | + |
| 102 | +Turn the bitcode into a second executable binary. (optional -- just for fun and sanity checking) |
| 103 | + |
| 104 | +``` |
| 105 | +llgc httpd.bc -o httpd.s |
| 106 | +as httpd.s -o httpd.o |
| 107 | +gcc httpd.o -lpthread -lapr-1 -laprutil-1 -lpcre -o httpd.new |
| 108 | +``` |
0 commit comments