1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
4 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
5 | %general-entities;
|
---|
6 | ]>
|
---|
7 |
|
---|
8 | <sect1 id="ch-tools-llvm-pass2" role="wrap">
|
---|
9 | <?dbhtml filename="llvm-pass2.html"?>
|
---|
10 |
|
---|
11 | <sect1info condition="script">
|
---|
12 | <productname>LLVM</productname>
|
---|
13 | <productnumber>&llvm-version;</productnumber>
|
---|
14 | <address>&llvm-url;</address>
|
---|
15 | </sect1info>
|
---|
16 |
|
---|
17 | <title>LLVM-&llvm-version; - Pass 2</title>
|
---|
18 |
|
---|
19 | <indexterm zone="ch-tools-llvm-pass2">
|
---|
20 | <primary sortas="a-LLVM">LLVM</primary>
|
---|
21 | <secondary>tools, pass 2</secondary>
|
---|
22 | </indexterm>
|
---|
23 |
|
---|
24 | <sect2 role="package">
|
---|
25 | <title/>
|
---|
26 |
|
---|
27 | <para>The LLVM package contains a collection of modular and reusable
|
---|
28 | compiler and toolchain technologies.</para>
|
---|
29 |
|
---|
30 | <segmentedlist>
|
---|
31 | <segtitle>&buildtime;</segtitle>
|
---|
32 | <segtitle>&diskspace;</segtitle>
|
---|
33 |
|
---|
34 | <seglistitem>
|
---|
35 | <seg>&llvm-tmpp2-sbu;</seg>
|
---|
36 | <seg>&llvm-tmpp2-du;</seg>
|
---|
37 | </seglistitem>
|
---|
38 | </segmentedlist>
|
---|
39 |
|
---|
40 | </sect2>
|
---|
41 |
|
---|
42 | <sect2 role="installation">
|
---|
43 | <title>Installation of LLVM</title>
|
---|
44 |
|
---|
45 | <para>Prepare some CMake modules needed by LLVM building system:</para>
|
---|
46 |
|
---|
47 | <screen><userinput remap="pre">tar -xf ../llvm-cmake-&llvm-version;.src.tar.xz
|
---|
48 | mv cmake-&llvm-version;.src ../cmake</userinput></screen>
|
---|
49 |
|
---|
50 | <para>The LLVM documentation recommends building LLVM in a dedicated
|
---|
51 | build directory:</para>
|
---|
52 |
|
---|
53 | <screen><userinput remap="pre">mkdir -v build
|
---|
54 | cd build</userinput></screen>
|
---|
55 |
|
---|
56 | <para>For cross-compiling LLVM, create a CMake toolchain description
|
---|
57 | file:</para>
|
---|
58 |
|
---|
59 | <screen><userinput remap="pre">cat > cross.cmake << EOF
|
---|
60 | <literal># the name of the target operating system
|
---|
61 | set(CMAKE_SYSTEM_NAME Linux)
|
---|
62 |
|
---|
63 | # which compilers to use for C and C++
|
---|
64 | set(CMAKE_C_COMPILER </literal>$LFS_TGT<literal>-gcc)
|
---|
65 | set(CMAKE_CXX_COMPILER </literal>$LFS_TGT<literal>-g++)
|
---|
66 |
|
---|
67 | # where is the target environment located
|
---|
68 | set(CMAKE_FIND_ROOT_PATH </literal>$LFS<literal>)
|
---|
69 |
|
---|
70 | # adjust the default behavior of the FIND_XXX() commands:
|
---|
71 | # search programs in the host environment
|
---|
72 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
---|
73 |
|
---|
74 | # search headers and libraries in the target environment
|
---|
75 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
---|
76 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)</literal>
|
---|
77 | EOF</userinput></screen>
|
---|
78 |
|
---|
79 | <para>Prepare LLVM for compilation:</para>
|
---|
80 |
|
---|
81 | <screen><userinput remap="configure">OPTS="-DLLVM_ENABLE_FFI=OFF;\
|
---|
82 | -DLLVM_BUILD_LLVM_DYLIB=ON;\
|
---|
83 | -DLLVM_LINK_LLVM_DYLIB=ON;\
|
---|
84 | -DLLVM_ENABLE_RTTI=ON;\
|
---|
85 | -DLLVM_TARGETS_TO_BUILD=host;\
|
---|
86 | -DLLVM_INCLUDE_BENCHMARKS=OFF"
|
---|
87 |
|
---|
88 | CC=gcc CXX=g++ cmake \
|
---|
89 | -DCMAKE_INSTALL_PREFIX=$LFS/tools/$LFS_TGT \
|
---|
90 | -DCMAKE_BUILD_TYPE=Release \
|
---|
91 | -DCMAKE_TOOLCHAIN_FILE=cross.cmake \
|
---|
92 | -DLLVM_TABLEGEN=$LFS/tools/bin/llvm-tblgen \
|
---|
93 | $(echo $OPTS | sed 's/;/ /g') \
|
---|
94 | -DCROSS_TOOLCHAIN_FLAGS_NATIVE=$OPTS \
|
---|
95 | -Wno-dev ..
|
---|
96 |
|
---|
97 | unset OPTS</userinput></screen>
|
---|
98 |
|
---|
99 | <variablelist>
|
---|
100 | <title>The meaning of the configure options:</title>
|
---|
101 |
|
---|
102 | <varlistentry>
|
---|
103 | <term><parameter>-DLLVM_ENABLE_FFI=OFF</parameter></term>
|
---|
104 | <listitem>
|
---|
105 | <para>Allow building LLVM without libffi installed in $LFS.</para>
|
---|
106 | </listitem>
|
---|
107 | </varlistentry>
|
---|
108 |
|
---|
109 | <varlistentry>
|
---|
110 | <term><parameter>-DLLVM_TABLEGEN=$LFS/tools/bin/llvm-tblgen</parameter></term>
|
---|
111 | <listitem>
|
---|
112 | <para>Use <command>llvm-tblgen</command> from LLVM pass 1, instead
|
---|
113 | of building it again for the host distro.</para>
|
---|
114 | </listitem>
|
---|
115 | </varlistentry>
|
---|
116 |
|
---|
117 | <varlistentry>
|
---|
118 | <term>
|
---|
119 | <command>OPTS=...</command>,
|
---|
120 | <parameter>$(echo $OPTS | sed 's/;/ ')</parameter>, and
|
---|
121 | <parameter>-DCROSS_TOOLCHAIN_FLAGS_NATIVE=$OPTS</parameter></term>
|
---|
122 | <listitem>
|
---|
123 | <para>Use the same configuration for cross compiling LLVM to
|
---|
124 | generate <command>llvm-config</command> which is runnable on the
|
---|
125 | host distro. <command>llvm-config</command> will be used building
|
---|
126 | Rustc Pass 2. This option ensures it will correctly output the
|
---|
127 | configuration of the cross compiled LLVM libraries. We save the
|
---|
128 | configuration in an environment variable to avoid typing the same
|
---|
129 | options again.</para>
|
---|
130 | </listitem>
|
---|
131 | </varlistentry>
|
---|
132 | </variablelist>
|
---|
133 |
|
---|
134 | <para>For the meaning of other CMake options, see TODO.</para>
|
---|
135 |
|
---|
136 | <para>Compile LLVM by running:</para>
|
---|
137 |
|
---|
138 | <screen><userinput remap="make">make</userinput></screen>
|
---|
139 |
|
---|
140 | <para>Install the headers and shared library:</para>
|
---|
141 |
|
---|
142 | <screen><userinput remap="install">DESTDIR=$PWD/dest make install
|
---|
143 | cp -av dest/$LFS/tools/$LFS_TGT/lib/libLLVM*.so \
|
---|
144 | $LFS/tools/$LFS_TGT/lib
|
---|
145 | cp -av dest/$LFS/tools/$LFS_TGT/include/* \
|
---|
146 | $LFS/tools/$LFS_TGT/include</userinput></screen>
|
---|
147 |
|
---|
148 | <para>Install another copy of the shared library into
|
---|
149 | <filename class='directory'>$LFS/usr/lib</filename>, so it will be able
|
---|
150 | to be used in the chroot environment:</para>
|
---|
151 |
|
---|
152 | <screen><userinput remap="install">cp -av dest/$LFS/tools/$LFS_TGT/lib/libLLVM*.so $LFS/usr/lib</userinput></screen>
|
---|
153 |
|
---|
154 | <para>Install <command>llvm-config</command>:</para>
|
---|
155 |
|
---|
156 | <screen><userinput remap="install">install -vm755 NATIVE/bin/llvm-config $LFS/tools/$LFS_TGT/bin</userinput></screen>
|
---|
157 |
|
---|
158 | <para>Clean up the source directory:</para>
|
---|
159 |
|
---|
160 | <screen><userinput remap="install">rm -rf ../../cmake</userinput></screen>
|
---|
161 |
|
---|
162 | </sect2>
|
---|
163 |
|
---|
164 | <sect2 role="content">
|
---|
165 | <title/>
|
---|
166 |
|
---|
167 | <para>Details on this package are located in
|
---|
168 | <xref linkend="contents-llvm" role="."/></para>
|
---|
169 | </sect2>
|
---|
170 |
|
---|
171 | </sect1>
|
---|