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-rustc" role="wrap">
|
---|
9 | <?dbhtml filename="rustc.html"?>
|
---|
10 |
|
---|
11 | <sect1info condition="script">
|
---|
12 | <productname>Rustc</productname>
|
---|
13 | <productnumber>&rustc-version;</productnumber>
|
---|
14 | <address>&rustc-url;</address>
|
---|
15 | </sect1info>
|
---|
16 |
|
---|
17 | <title>Rustc-&rustc-version;</title>
|
---|
18 |
|
---|
19 | <indexterm zone="ch-tools-rustc">
|
---|
20 | <primary sortas="a-Rustc">Rustc</primary>
|
---|
21 | <secondary>tools</secondary>
|
---|
22 | </indexterm>
|
---|
23 |
|
---|
24 | <sect2 role="package">
|
---|
25 | <title/>
|
---|
26 |
|
---|
27 | <para>The Rust programming language is designed to be a safe,
|
---|
28 | concurrent, practical language.</para>
|
---|
29 |
|
---|
30 | <segmentedlist>
|
---|
31 | <segtitle>&buildtime;</segtitle>
|
---|
32 | <segtitle>&diskspace;</segtitle>
|
---|
33 |
|
---|
34 | <seglistitem>
|
---|
35 | <seg>&rustc-tmp-sbu;</seg>
|
---|
36 | <seg>&rustc-tmp-du;</seg>
|
---|
37 | </seglistitem>
|
---|
38 | </segmentedlist>
|
---|
39 |
|
---|
40 | </sect2>
|
---|
41 |
|
---|
42 | <sect2 role="installation">
|
---|
43 | <title>Installation of Rustc</title>
|
---|
44 |
|
---|
45 | <para>Tell Rustc how to support <envar>$LFS_TGT</envar> triplet:</para>
|
---|
46 |
|
---|
47 | <screen><userinput remap="pre">cp -v compiler/rustc_target/src/spec/x86_64_{unknown,lfs}_linux_gnu.rs
|
---|
48 | cp -v compiler/rustc_target/src/spec/i686_{unknown,lfs}_linux_gnu.rs
|
---|
49 | cp -v compiler/rustc_target/src/spec/i586_{unknown,lfs}_linux_gnu.rs
|
---|
50 | sed -i.orig compiler/rustc_target/src/spec/mod.rs \
|
---|
51 | -e '/targets!/a\ ("x86_64-lfs-linux-gnu", x86_64_lfs_linux_gnu),' \
|
---|
52 | -e '/targets!/a\ ("i686-lfs-linux-gnu", i686_lfs_linux_gnu),' \
|
---|
53 | -e '/targets!/a\ ("i586-lfs-linux-gnu", i586_lfs_linux_gnu),'</userinput></screen>
|
---|
54 |
|
---|
55 | <para>In the first pass, build Rustc as a cross compiler for
|
---|
56 | <envar>$LFS_TGT</envar>. The cross compiler will link to LLVM Pass 1,
|
---|
57 | so we need to tell the dynamic linker of the host distro where to find
|
---|
58 | the LLVM Pass 1 dynamic library:</para>
|
---|
59 |
|
---|
60 | <screen><userinput remap="pre">export LD_LIBRARY_PATH=$LFS/tools/lib</userinput></screen>
|
---|
61 |
|
---|
62 | <para>Create a suitable configuration:</para>
|
---|
63 |
|
---|
64 | <screen><userinput remap="pre">install -vm755 src/llvm-project/llvm/cmake/config.guess config.guess
|
---|
65 | cat > pass1.toml << EOF<literal>
|
---|
66 | [llvm]
|
---|
67 | link-shared = true
|
---|
68 |
|
---|
69 | [build]
|
---|
70 | # omit docs to save time and space (default is to build them)
|
---|
71 | docs = false
|
---|
72 |
|
---|
73 | # install cargo as well as rustc, but skip other tools as they are
|
---|
74 | # not necessary for temporary installation
|
---|
75 | extended = true
|
---|
76 | tools = ["cargo"]
|
---|
77 |
|
---|
78 | # don't download crates during build
|
---|
79 | locked-deps = true
|
---|
80 | vendor = true
|
---|
81 |
|
---|
82 | # build both the native compiler and the cross compiler
|
---|
83 | # native compiler is necessary because Rust heavily uses meta-programming
|
---|
84 | target = [ "</literal>$(./config.guess)<literal>", "</literal>$LFS_TGT<literal>" ]
|
---|
85 |
|
---|
86 | [rust]
|
---|
87 | channel = "stable"
|
---|
88 |
|
---|
89 | # LFS does not install the FileCheck executable from llvm,
|
---|
90 | # so disable codegen tests
|
---|
91 | codegen-tests = false
|
---|
92 |
|
---|
93 | [target.</literal>$(./config.guess)<literal>]
|
---|
94 | # link Rustc to LLVM pass 1
|
---|
95 | llvm-config = "</literal>$LFS<literal>/tools/bin/llvm-config"
|
---|
96 |
|
---|
97 | [target.</literal>$LFS_TGT<literal>]
|
---|
98 | cc = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-gcc"
|
---|
99 | cxx = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-g++"
|
---|
100 | ar = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-ar"
|
---|
101 | ranlib = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-ranlib"
|
---|
102 |
|
---|
103 | # not ld: on Linux platforms Rustc uses GCC driver for linking
|
---|
104 | linker = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-gcc"
|
---|
105 | </literal>EOF</userinput></screen>
|
---|
106 |
|
---|
107 | <para>Build the cross compiler and target libraries:</para>
|
---|
108 |
|
---|
109 | <screen><userinput remap="make">python3 x.py build --stage 1 library --config pass1.toml</userinput></screen>
|
---|
110 |
|
---|
111 | <para>In the second pass, build Rustc as a native compiler on
|
---|
112 | <envar>$LFS_TGT</envar>:</para>
|
---|
113 |
|
---|
114 | <screen><userinput remap="pre">cat > pass2.toml << EOF<literal>
|
---|
115 | [llvm]
|
---|
116 | link-shared = true
|
---|
117 |
|
---|
118 | [build]
|
---|
119 | docs = false
|
---|
120 | extended = true
|
---|
121 | tools = ["cargo"]
|
---|
122 | locked-deps = true
|
---|
123 | vendor = true
|
---|
124 |
|
---|
125 | # build the native compiler for this triplet
|
---|
126 | host = [ "</literal>$LFS_TGT<literal>" ]
|
---|
127 |
|
---|
128 | [install]
|
---|
129 | prefix = "/opt/rustc-&rustc-version;"
|
---|
130 | docdir = "share/doc/rustc-&rustc-version;"
|
---|
131 |
|
---|
132 | [rust]
|
---|
133 | channel = "stable"
|
---|
134 | rpath = false
|
---|
135 |
|
---|
136 | # BLFS does not install the FileCheck executable from llvm,
|
---|
137 | # so disable codegen tests
|
---|
138 | codegen-tests = false
|
---|
139 |
|
---|
140 | [target.</literal>$(./config.guess)<literal>]
|
---|
141 | llvm-config = "</literal>$LFS<literal>/tools/bin/llvm-config"
|
---|
142 |
|
---|
143 | [target.</literal>$LFS_TGT<literal>]
|
---|
144 | cc = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-gcc"
|
---|
145 | cxx = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-g++"
|
---|
146 | ar = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-ar"
|
---|
147 | ranlib = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-ranlib"
|
---|
148 | linker = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-gcc"
|
---|
149 |
|
---|
150 | # link Rustc to LLVM pass 2
|
---|
151 | llvm-config = "</literal>$LFS<literal>/tools/</literal>$LFS_TGT<literal>/bin/llvm-config"
|
---|
152 | </literal>EOF</userinput></screen>
|
---|
153 |
|
---|
154 | <para>Build the native compiler:</para>
|
---|
155 |
|
---|
156 | <screen><userinput remap="make">env {X86_64,I{5,6}86}_LFS_LINUX_GNU_OPENSSL_DIR=$LFS/usr \
|
---|
157 | python3 x.py build --keep-stage 0 \
|
---|
158 | --keep-stage-std 1 \
|
---|
159 | --stage 2 \
|
---|
160 | --config pass2.toml</userinput></screen>
|
---|
161 |
|
---|
162 | <para>Install the package:</para>
|
---|
163 |
|
---|
164 | <screen><userinput remap="make">env {X86_64,I{5,6}86}_LFS_LINUX_GNU_OPENSSL_DIR=$LFS/usr \
|
---|
165 | DESTDIR=$LFS \
|
---|
166 | python3 x.py install --keep-stage 0 \
|
---|
167 | --keep-stage-std 1 \
|
---|
168 | --stage 2 \
|
---|
169 | --config pass2.toml
|
---|
170 | ln -sv rustc-&rustc-version; $LFS/opt/rustc</userinput></screen>
|
---|
171 |
|
---|
172 | <!-- Maybe we should just set LD_LIBRARY_PATH=$LFS/tools
|
---|
173 | during the entire chapter 5 and 6. But doing so will need to
|
---|
174 | modify .bashrc of lfs user. For now just unset it, so the manual
|
---|
175 | build is consistent with jhalfs. -->
|
---|
176 | <para>Clean up the environment:</para>
|
---|
177 |
|
---|
178 | <screen><userinput remap="make">unset LD_LIBRARY_PATH</userinput></screen>
|
---|
179 |
|
---|
180 | </sect2>
|
---|
181 |
|
---|
182 | <sect2 role="content">
|
---|
183 | <title/>
|
---|
184 |
|
---|
185 | <para>Details on this package are located in
|
---|
186 | <xref linkend="contents-rustc" role="."/></para>
|
---|
187 | </sect2>
|
---|
188 |
|
---|
189 | </sect1>
|
---|