]>
Commit | Line | Data |
---|---|---|
94b46f34 | 1 | #!/usr/bin/env bash |
94b46f34 XL |
2 | |
3 | set -ex | |
4 | ||
5 | source shared.sh | |
6 | ||
60c5eb7d | 7 | LLVM=llvmorg-9.0.0 |
94b46f34 | 8 | |
9fa01778 XL |
9 | mkdir llvm-project |
10 | cd llvm-project | |
94b46f34 | 11 | |
9fa01778 | 12 | curl -L https://github.com/llvm/llvm-project/archive/$LLVM.tar.gz | \ |
0731742a | 13 | tar xzf - --strip-components=1 |
94b46f34 | 14 | |
60c5eb7d XL |
15 | yum install -y patch |
16 | patch -Np1 < ../llvm-project-centos.patch | |
17 | ||
0731742a XL |
18 | mkdir clang-build |
19 | cd clang-build | |
94b46f34 XL |
20 | |
21 | # For whatever reason the default set of include paths for clang is different | |
22 | # than that of gcc. As a result we need to manually include our sysroot's | |
23 | # include path, /rustroot/include, to clang's default include path. | |
24 | # | |
25 | # Alsow there's this weird oddity with gcc where there's an 'include-fixed' | |
26 | # directory that it generates. It turns out [1] that Centos 5's headers are so | |
27 | # old that they're incompatible with modern C semantics. While gcc automatically | |
28 | # fixes that clang doesn't account for this. Tell clang to manually include the | |
29 | # fixed headers so we can successfully compile code later on. | |
30 | # | |
31 | # [1]: https://sourceware.org/ml/crossgcc/2008-11/msg00028.html | |
32 | INC="/rustroot/include" | |
9fa01778 | 33 | INC="$INC:/rustroot/lib/gcc/x86_64-unknown-linux-gnu/5.5.0/include-fixed" |
94b46f34 XL |
34 | INC="$INC:/usr/include" |
35 | ||
36 | hide_output \ | |
9fa01778 | 37 | cmake ../llvm \ |
94b46f34 XL |
38 | -DCMAKE_C_COMPILER=/rustroot/bin/gcc \ |
39 | -DCMAKE_CXX_COMPILER=/rustroot/bin/g++ \ | |
40 | -DCMAKE_BUILD_TYPE=Release \ | |
41 | -DCMAKE_INSTALL_PREFIX=/rustroot \ | |
42 | -DLLVM_TARGETS_TO_BUILD=X86 \ | |
9fa01778 | 43 | -DLLVM_ENABLE_PROJECTS="clang;lld" \ |
94b46f34 XL |
44 | -DC_INCLUDE_DIRS="$INC" |
45 | ||
46 | hide_output make -j10 | |
47 | hide_output make install | |
48 | ||
49 | cd ../.. | |
9fa01778 | 50 | rm -rf llvm-project |