|
3 | 3 | This document explains how to build LLVM and Clang from source code.
|
4 | 4 |
|
5 | 5 | It's a process only recommended for developers that need to make changes to LLVM or Clang, or
|
6 |
| -build the binary packages needed for the CI system. |
| 6 | +build the binary packages needed for the CI system. If you just want to build CppSharp, then |
| 7 | +check out the getting started guide section on how to download our pre-compiled LLVM packages. |
7 | 8 |
|
8 |
| -Git repository URLs found here: [http://llvm.org/docs/GettingStarted.html#git-mirror] |
9 |
| -(http://llvm.org/docs/GettingStarted.html#git-mirror) |
| 9 | +## Compiling using the build script |
10 | 10 |
|
11 |
| -1. Clone LLVM to `<CppSharp>\deps\llvm` |
12 |
| -2. Clone Clang to `<CppSharp>\deps\llvm\tools\clang` |
| 11 | +This is the preferred way to compile LLVM for usage by CppSharp. |
13 | 12 |
|
14 |
| -Required LLVM/Clang commits: |
| 13 | +1. Before building, ensure Git, CMake and Ninja are installed and acessible from the command line. |
15 | 14 |
|
16 |
| -[LLVM: see /build/LLVM-commit.](https://github.com/mono/CppSharp/tree/master/build/LLVM-commit) |
17 |
| - |
18 |
| -[Clang: see /build/Clang-commit.](https://github.com/mono/CppSharp/tree/master/build/Clang-commit) |
| 15 | +Check the official download pages for each project for further instructions: |
19 | 16 |
|
20 |
| -## Compiling on Windows/Visual Studio |
| 17 | +- [Git](https://git-scm.com/downloads) |
| 18 | +- [Ninja](https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages) |
| 19 | +- [CMake](https://cmake.org/download/) |
21 | 20 |
|
22 |
| -```shell |
23 |
| -cd <CppSharp>\deps\llvm\build |
24 |
| - |
25 |
| -cmake -G "Visual Studio 12" -DCLANG_BUILD_EXAMPLES=false -DCLANG_INCLUDE_DOCS=false -DCLANG_INCLUDE_TESTS=false -DCLANG_INCLUDE_DOCS=false -DCLANG_BUILD_EXAMPLES=false -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_INCLUDE_EXAMPLES=false -DLLVM_INCLUDE_DOCS=false -DLLVM_INCLUDE_TESTS=false .. |
26 |
| - |
27 |
| -msbuild LLVM.sln /p:Configuration=RelWithDebInfo;Platform=Win32 /m |
| 21 | +2. Navigate to the `<CppSharp>/build` directory |
| 22 | +3. Clone, build and package LLVM with |
28 | 23 | ```
|
29 |
| - |
30 |
| -Or, if you need 64-bit binaries: |
31 |
| - |
32 |
| -```shell |
33 |
| -cd <CppSharp>\deps\llvm\build |
34 |
| - |
35 |
| -cmake -G "Visual Studio 12 Win64" -DCLANG_BUILD_EXAMPLES=false -DCLANG_INCLUDE_DOCS=false -DCLANG_INCLUDE_TESTS=false -DCLANG_INCLUDE_DOCS=false -DCLANG_BUILD_EXAMPLES=false -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_INCLUDE_EXAMPLES=false -DLLVM_INCLUDE_DOCS=false -DLLVM_INCLUDE_TESTS=false .. |
36 |
| - |
37 |
| -msbuild LLVM.sln /p:Configuration=RelWithDebInfo;Platform=x64 /m |
| 24 | +$PREMAKE --file=scripts/LLVM.lua clone_llvm |
| 25 | +$PREMAKE --file=scripts/LLVM.lua build_llvm |
| 26 | +$PREMAKE --file=scripts/LLVM.lua package_llvm |
38 | 27 | ```
|
39 | 28 |
|
40 |
| -## Compiling on Mac OS X |
| 29 | +`$PREMAKE` should be replaced with `premake5.exe`, `premake5-osx` or `premake5-linux-64` depending on environment. |
41 | 30 |
|
42 |
| -### Compiling manually |
| 31 | +You can specify an `--arch=x86` or `--arch=x64` flag to the invocations above to specify an explicit build architecture. |
43 | 32 |
|
44 |
| -1. Compile LLVM solution in *RelWithDebInfo* mode |
45 |
| - The following CMake variables should be enabled: |
46 |
| - - LLVM_ENABLE_LIBCXX (enables libc++ standard library support) |
47 |
| - - LLVM_BUILD_32_BITS for 32-bit builds (defaults to 64-bit) |
| 33 | +If the `clone_llvm` step fails, you can try to manually clone LLVM and Clang as explained below. |
| 34 | +You should still run clone_llvm to ensure that you are on the correct revision. |
48 | 35 |
|
49 |
| -```shell |
50 |
| -mkdir -p deps/llvm/build && cd deps/llvm/build |
| 36 | +## Cloning from Git |
51 | 37 |
|
52 |
| -cmake -G "Unix Makefiles" -DLLVM_ENABLE_LIBCXX=true -DLLVM_BUILD_32_BITS=true -DCMAKE_BUILD_TYPE=RelWithDebInfo .. |
| 38 | +1. Clone LLVM to `<CppSharp>\deps\llvm` |
53 | 39 |
|
54 |
| -make |
| 40 | +``` |
| 41 | +git clone http://llvm.org/git/llvm.git |
55 | 42 | ```
|
56 | 43 |
|
57 |
| -### Compiling using the build script |
58 |
| - |
59 |
| -Before building, ensure cmake is installed under Applications/Cmake.app and Ninja is installed in your PATH. |
| 44 | +2. Clone Clang to `<CppSharp>\deps\llvm\tools\clang` |
60 | 45 |
|
61 |
| -1. Navigate to `build/scripts` |
62 |
| -2. Clone, build and package LLVM with |
63 | 46 | ```
|
64 |
| -../premake5-osx --file=LLVM.lua clone_llvm |
65 |
| -../premake5-osx --file=LLVM.lua build_llvm |
66 |
| -../premake5-osx --file=LLVM.lua package_llvm |
| 47 | +cd llvm/tools |
| 48 | +git clone http://llvm.org/git/clang.git |
67 | 49 | ```
|
68 | 50 |
|
69 |
| -You can specify an `--arch=x86` or `--arch=x64` flag to the invocations above to specify an explicit build architecture. |
| 51 | +Official LLVM instructions can be found here: [http://llvm.org/docs/GettingStarted.html#git-mirror] |
| 52 | +(http://llvm.org/docs/GettingStarted.html#git-mirror) |
70 | 53 |
|
71 |
| -If the clone_llvm step fails, you can try to manually clone LLVM and Clang as explained above. You should still run clone_llvm to ensure that you are on the correct revision. |
| 54 | +Make sure to use the revisions specified below, or you will most likely get compilation errors. |
72 | 55 |
|
| 56 | +Required LLVM/Clang commits: |
73 | 57 |
|
74 |
| -## Compiling on Linux |
| 58 | +[LLVM: see /build/LLVM-commit.](https://github.com/mono/CppSharp/tree/master/build/LLVM-commit) |
| 59 | +[Clang: see /build/Clang-commit.](https://github.com/mono/CppSharp/tree/master/build/Clang-commit) |
75 | 60 |
|
76 |
| -If you do not have native build tools you can install them first with: |
| 61 | +To change to the revisions specified above you can run the following commands: |
77 | 62 |
|
78 |
| -```shell |
79 |
| -sudo apt-get install cmake ninja-build build-essential |
| 63 | +``` |
| 64 | +git -C deps/llvm reset --hard <llvm-rev> |
| 65 | +git -C deps/llvm/tools/clang reset --hard <clang-rev> |
80 | 66 | ```
|
81 | 67 |
|
82 |
| -And then build LLVM with: |
83 |
| - |
84 |
| -```shell |
85 |
| -cd deps/llvm/build |
86 | 68 |
|
87 |
| -cmake -G Ninja -DCLANG_BUILD_EXAMPLES=false -DCLANG_INCLUDE_DOCS=false -DCLANG_INCLUDE_TESTS=false -DCLANG_INCLUDE_DOCS=false -DCLANG_BUILD_EXAMPLES=false -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_INCLUDE_EXAMPLES=false -DLLVM_INCLUDE_DOCS=false -DLLVM_INCLUDE_TESTS=false .. |
88 | 69 |
|
89 |
| -ninja |
90 |
| -``` |
0 commit comments