-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMake.html
86 lines (72 loc) · 2.39 KB
/
CMake.html
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
<!DOCTYPE html>
<html>
<head>
<link rel="Stylesheet" type="text/css" href="style.css">
<title>CMake</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id="Building steps"><h2 id="Building steps" class="header"><a href="#Building steps">Building steps</a></h2></div>
<ol>
<li>
Clone the repo: git clone <a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
<li>
Create a build directory under the root of llvm-project then cd into it
<li>
Proceed with: <br>
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DLLVM_ENABLE_PROJECTS="clang" \<br>
-DCMAKE_EXPORT_COMPILE_COMMANDS=On -DLLVM_TARGETS_TO_BUILD=Hexagon \<br>
-DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang \<br>
-DBUILD_SHARED_LIBS=True -DLLVM_CCACHE_BUILD=True -DLLVM_USE_SPLIT_DWARF=True
\<br>
-DLLVM_USE_LINKER=lld \<br>
-DCMAKE_EXE_LINKER_FLAGS=-Wl,--gdb-index \<br>
-DCMAKE_SHARED_LINKER_FLAGS=-Wl,--gdb-index \<br>
../llvm
<li>
Run ninja in the terminal
</ol>
<p>
With all the time saving options turned on; one line of code change in
HexagonAsmParser.cpp only takes about 36s to rebuild comparing to 20min without
using ninja and options listed below.
</p>
<div id="Optional"><h2 id="Optional" class="header"><a href="#Optional">Optional</a></h2></div>
<p>
-DLLVM_BUILD_INSTRUMENTED_COVERAGE=On
</p>
<div id="Useful options to reduce build time"><h2 id="Useful options to reduce build time" class="header"><a href="#Useful options to reduce build time">Useful options to reduce build time</a></h2></div>
<p>
LLVM_USE_LINKER=lld
</p>
<blockquote>
lld is much faster than ld in our case
</blockquote>
<p>
LLVM_TARGETS_TO_BUILD:STRING
</p>
<blockquote>
Semicolon-separated list of targets to build, or all for building all
targets. Case-sensitive. Defaults to <em>all</em>. <br>
Example:
-DLLVM_TARGETS_TO_BUILD="X86;PowerPC".
</blockquote>
<p>
BUILD_SHARED_LIBS:BOOL
</p>
<blockquote>
As this will reduce re-linking all the objects into all the executables. This
will reduce the number of steps and freezing.
</blockquote>
<p>
LLVM_CCACHE_BUILD:BOOL
</p>
<p>
LLVM_USE_SPLIT_DWARF:BOOL
</p>
<blockquote>
<a href="https://www.productive-cpp.com/improving-cpp-builds-with-split-dwarf/">https://www.productive-cpp.com/improving-cpp-builds-with-split-dwarf/</a>
</blockquote>
</body>
</html>