-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.sh
executable file
·89 lines (53 loc) · 2.34 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
if [ -z "$MCFI_SDK" ]
then
export MCFI_SDK=$HOME/MCFI/toolchain
mkdir -p $MCFI_SDK
fi
if [ -z "$LLVM_HOME" ]
then
LLVM_HOME=$HOME/llvm
fi
MCFI=$PWD
# Build runtime
cd $MCFI/runtime && make
# Build the compiler
mkdir -p $MCFI/compiler/llvm-3.5.0.src/release && cd $MCFI/compiler/llvm-3.5.0.src/release
../configure --enable-targets=x86_64 --disable-debug-runtime --disable-debug-symbols --disable-jit --enable-optimized --prefix=$MCFI_SDK --exec-prefix=$MCFI_SDK
make -j8
make install
# Build the linker
mkdir -p $MCFI/compiler/binutils-2.24/build && cd $MCFI/compiler/binutils-2.24/build
../configure --prefix=$MCFI_SDK --exec-prefix=$MCFI_SDK CFLAGS="-Wno-error -g -O2"
make -j8
make install
# Build crt
cd $MCFI/lib/cxxstart && ./build.sh
# Build musl
cd $MCFI/lib/musl-1.0.4
./configure --prefix=$MCFI_SDK --exec-prefix=$MCFI_SDK CC=$MCFI_SDK/bin/clang CFLAGS=-O3 --disable-static
make install -j8
# Build libunwind-1.1
mkdir -p $MCFI/lib/libunwind-1.1/build && cd $MCFI/lib/libunwind-1.1
autoreconf
automake --add-missing
autoreconf
cd build
../configure --enable-cxx-exceptions --disable-static --prefix=$MCFI_SDK --exec-prefix=$MCFI_SDK CC=$MCFI_SDK/bin/clang CFLAGS=-O3
make install
# Build libcxx-3.5 against libstdc++
mkdir -p $MCFI/lib/libcxx-3.5.0.src/build_std && cd $MCFI/lib/libcxx-3.5.0.src/build_std
CC=$LLVM_HOME/bin/clang CXX=$LLVM_HOME/bin/clang++ cmake -G "Unix Makefiles" -DLIBCXX_CXX_ABI=libstdc++ -DLIBCXX_LIBSUPCXX_INCLUDE_PATHS="/usr/include/c++/4.8/;/usr/include/x86_64-linux-gnu/c++/4.8/" -DCMAKE_BUILD_TYPE=Release ../ -DCMAKE_INSTALL_PREFIX=$MCFI_SDK
make install -j8
#Build libcxxabi-3.5 against the already-built libcxx-3.5
cd $MCFI/lib/libcxxabi-3.5.0.src/lib
./buildit
# Build libcxx-3.5 against the already-built libcxxabi-3.5
mkdir -p $MCFI/lib/libcxx-3.5.0.src/build_libcxxabi && cd $MCFI/lib/libcxx-3.5.0.src/build_libcxxabi
# trick cmake to pass the Makefile generation
mv $MCFI_SDK/bin/clang $MCFI_SDK/bin/clang.new
ln -s $LLVM_HOME/bin/clang $MCFI_SDK/bin/clang
CC=$MCFI_SDK/bin/clang CXX="$MCFI_SDK/bin/clang++ -D__MUSL__ -U__GLIBC__ -O3" cmake -G "Unix Makefiles" -DLIBCXX_CXX_ABI=libcxxabi -DLIBCXX_LIBCXXABI_INCLUDE_PATHS="$MCFI_SDK/include" -DCMAKE_BUILD_TYPE=Release ../ -DCMAKE_INSTALL_PREFIX=$MCFI_SDK
# change clang back
mv $MCFI_SDK/bin/clang.new $MCFI_SDK/bin/clang
make install -j8