1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
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 | <!ENTITY rust-download-http "https://static.rust-lang.org/dist/rustc-&rust-version;-src.tar.xz">
|
---|
8 | <!ENTITY rust-download-ftp " ">
|
---|
9 | <!ENTITY rust-md5sum "4f202568150660f369de3afbfb410970">
|
---|
10 | <!ENTITY rust-size "207 MB">
|
---|
11 | <!ENTITY rust-buildsize "8.9 GB (298 MB installed); add 6.4 GB if running the tests">
|
---|
12 | <!ENTITY rust-time "6.7 SBU (including download time; add 6.2 SBU for tests, both using parallelism=8)">
|
---|
13 | ]>
|
---|
14 |
|
---|
15 | <sect1 id="rust" xreflabel="rustc-&rust-version;">
|
---|
16 | <?dbhtml filename="rust.html"?>
|
---|
17 |
|
---|
18 |
|
---|
19 | <title>Rustc-&rust-version;</title>
|
---|
20 |
|
---|
21 | <indexterm zone="rust">
|
---|
22 | <primary sortas="a-rust">Rust</primary>
|
---|
23 | </indexterm>
|
---|
24 |
|
---|
25 | <sect2 role="package">
|
---|
26 | <title>Introduction to Rust</title>
|
---|
27 | <para>
|
---|
28 | The <application>Rust</application> programming language is designed
|
---|
29 | to be a safe, concurrent, practical language.
|
---|
30 | </para>
|
---|
31 |
|
---|
32 | <para>
|
---|
33 | This package is updated on a six-weekly release cycle. Because it is
|
---|
34 | such a large and slow package to build, is at the moment only required
|
---|
35 | by a few packages in this book, and particularly because newer versions
|
---|
36 | tend to break older mozilla packages, the BLFS editors take the view that
|
---|
37 | it should only be updated when that is necessary (either to fix problems,
|
---|
38 | or to allow a new version of a package to build).
|
---|
39 | </para>
|
---|
40 |
|
---|
41 | <para>
|
---|
42 | As with many other programming languages, rustc (the rust compiler)
|
---|
43 | needs a binary from which to bootstrap. It will download a stage0
|
---|
44 | binary at the start of the build, so you cannot compile it without an
|
---|
45 | Internet connection.
|
---|
46 | </para>
|
---|
47 |
|
---|
48 | <note>
|
---|
49 | <para>
|
---|
50 | Although BLFS usually installs in <filename
|
---|
51 | class="directory">/usr</filename>, when you later upgrade to a newer
|
---|
52 | version of <application>rust</application> the old libraries in <filename
|
---|
53 | class="directory">/usr/lib/rustlib</filename> will remain, with various
|
---|
54 | hashes in their names, but will not be usable and will waste space. The
|
---|
55 | editors recommend placing the files in the <filename
|
---|
56 | class="directory">/opt</filename> directory. In particular, if you
|
---|
57 | have reason to rebuild with a modified configuration (e.g. using the
|
---|
58 | shipped LLVM after building with shared LLVM, perhaps to compile crates
|
---|
59 | for architectures which the BLFS LLVM build does not support)
|
---|
60 | it is possible for the install to leave a broken
|
---|
61 | <command>cargo</command> program. In such a situation, either remove
|
---|
62 | the existing installation first, or use a different prefix such as
|
---|
63 | /opt/rustc-&rust-version;-build2.
|
---|
64 | </para>
|
---|
65 |
|
---|
66 | <para>
|
---|
67 | If you prefer, you can of course change the prefix to <filename
|
---|
68 | class="directory">/usr</filename>.
|
---|
69 | </para>
|
---|
70 | </note>
|
---|
71 |
|
---|
72 | <para>
|
---|
73 | The current <application>rustbuild</application> build-system will use
|
---|
74 | all processors, although it does not scale well and often falls
|
---|
75 | back to just using one core while waiting for a library to compile.
|
---|
76 | However it can be mostly limited to a specified number of processors by
|
---|
77 | a combination of adding the switch <literal>--jobs <N></literal>
|
---|
78 | (e.g. '--jobs 4' to limit to 4 processors) on each invocation of
|
---|
79 | <command>python3 x.py</command> <emphasis>and</emphasis> using an
|
---|
80 | environment variable <envar>CARGO_BUILD_JOBS=<N></envar>. At the
|
---|
81 | moment this is not effective when some of the rustc tests are run.
|
---|
82 | </para>
|
---|
83 |
|
---|
84 | <para>
|
---|
85 | The current version of rust's num_cpus crate now recognizes that cgroups
|
---|
86 | can be used to restrict which processors it is allowed to use. So if your
|
---|
87 | machine lacks DRAM (typically, less than 2 GB DRAM per core) that might be
|
---|
88 | an alternative to taking CPUs offline.
|
---|
89 | Read <xref linkend='build-in-cgroup'/> for how to use a cgroup.
|
---|
90 | </para>
|
---|
91 |
|
---|
92 | <para>
|
---|
93 | At the moment <application>Rust</application> does not provide any
|
---|
94 | guarantees of a stable ABI.
|
---|
95 | </para>
|
---|
96 |
|
---|
97 | <note>
|
---|
98 | <para>
|
---|
99 | Rustc defaults to building for ALL supported architectures, using a
|
---|
100 | shipped copy of LLVM. In BLFS the build is only for the X86
|
---|
101 | architecture.
|
---|
102 | If you intend to develop rust crates, this build may not be good
|
---|
103 | enough for your purposes.
|
---|
104 | </para>
|
---|
105 | <para>
|
---|
106 | The build times of this version when repeated on the same machine are
|
---|
107 | often reasonably consistent, but as with all compilations using
|
---|
108 | <command>rustc</command> there can be some very slow outliers.
|
---|
109 | </para>
|
---|
110 | </note>
|
---|
111 |
|
---|
112 | &lfs122_checked;
|
---|
113 |
|
---|
114 | <bridgehead renderas="sect3">Package Information</bridgehead>
|
---|
115 | <itemizedlist spacing="compact">
|
---|
116 | <listitem>
|
---|
117 | <para>
|
---|
118 | Download (HTTP): <ulink url="&rust-download-http;"/>
|
---|
119 | </para>
|
---|
120 | </listitem>
|
---|
121 | <listitem>
|
---|
122 | <para>
|
---|
123 | Download (FTP): <ulink url="&rust-download-ftp;"/>
|
---|
124 | </para>
|
---|
125 | </listitem>
|
---|
126 | <listitem>
|
---|
127 | <para>
|
---|
128 | Download MD5 sum: &rust-md5sum;
|
---|
129 | </para>
|
---|
130 | </listitem>
|
---|
131 | <listitem>
|
---|
132 | <para>
|
---|
133 | Download size: &rust-size;
|
---|
134 | </para>
|
---|
135 | </listitem>
|
---|
136 | <listitem>
|
---|
137 | <para>
|
---|
138 | Estimated disk space required: &rust-buildsize;
|
---|
139 | </para>
|
---|
140 | </listitem>
|
---|
141 | <listitem>
|
---|
142 | <para>
|
---|
143 | Estimated build time: &rust-time;
|
---|
144 | </para>
|
---|
145 | </listitem>
|
---|
146 | </itemizedlist>
|
---|
147 | <!-- only keep this here for reuse in case we need a patch
|
---|
148 | <bridgehead renderas="sect3">Additional Downloads</bridgehead>
|
---|
149 | <itemizedlist spacing="compact">
|
---|
150 | <listitem>
|
---|
151 | <para>
|
---|
152 | Optional patch (recommended if running the test suite):
|
---|
153 | <ulink url="&patch-root;/rustc-&rust-version;-testsuite_fix-1.patch"/>
|
---|
154 | </para>
|
---|
155 | </listitem>
|
---|
156 | </itemizedlist>
|
---|
157 | -->
|
---|
158 | <bridgehead renderas="sect3">Rust Dependencies</bridgehead>
|
---|
159 |
|
---|
160 | <bridgehead renderas="sect4">Required</bridgehead>
|
---|
161 | <para role="required">
|
---|
162 | <xref linkend="cmake"/> and
|
---|
163 | <!-- Required for downloading stage 0 binaries.
|
---|
164 | Otherwise it's recommended (if not installed, a vendored copy
|
---|
165 | will be built). -->
|
---|
166 | <xref linkend="curl"/>
|
---|
167 | </para>
|
---|
168 |
|
---|
169 | &build-use-internet;
|
---|
170 |
|
---|
171 | <bridgehead renderas="sect4">Recommended</bridgehead>
|
---|
172 | <para role="recommended">
|
---|
173 | <xref linkend="libssh2"/>,
|
---|
174 | <xref linkend="llvm"/>
|
---|
175 | (built with -D LLVM_LINK_LLVM_DYLIB=ON so that rust can link to
|
---|
176 | system LLVM instead of building its shipped version), and
|
---|
177 | <xref linkend="sqlite"/>
|
---|
178 | </para>
|
---|
179 |
|
---|
180 | <note>
|
---|
181 | <para>
|
---|
182 | If a recommended dependency is not installed, a shipped copy in the
|
---|
183 | Rustc source tarball will be built and used.
|
---|
184 | </para>
|
---|
185 | </note>
|
---|
186 |
|
---|
187 | <bridgehead renderas="sect4">Optional</bridgehead>
|
---|
188 | <para role="optional">
|
---|
189 | <xref linkend="gdb"/> (used by the test suite if it is present),
|
---|
190 | <xref linkend="git"/> (required by the test suite),
|
---|
191 | <ulink url="https://github.com/bytecodealliance/wasmtime/tree/main/cranelift">cranelift</ulink>,
|
---|
192 | <ulink url="https://jemalloc.net/">jemalloc</ulink>,
|
---|
193 | libgccjit (read command explanation in
|
---|
194 | <xref role="nodep" linkend="gcc"/>), and
|
---|
195 | <ulink url='https://libgit2.org/'>libgit2</ulink>
|
---|
196 | </para>
|
---|
197 |
|
---|
198 | <para condition="html" role="usernotes">
|
---|
199 | Editor Notes: <ulink url="&blfs-wiki;/rust"/>
|
---|
200 | </para>
|
---|
201 | </sect2>
|
---|
202 |
|
---|
203 | <sect2 role="installation">
|
---|
204 | <title>Installation of Rust</title>
|
---|
205 |
|
---|
206 | <para>
|
---|
207 | To install into the
|
---|
208 | <filename class="directory">/opt</filename> directory, remove any
|
---|
209 | existing <filename>/opt/rustc</filename> symlink
|
---|
210 | and create a new directory (i.e. with a different name if trying a
|
---|
211 | modified build of the same version).
|
---|
212 | As the <systemitem class="username">root</systemitem>
|
---|
213 | user:
|
---|
214 | </para>
|
---|
215 |
|
---|
216 | <screen role="root"><userinput>mkdir -pv /opt/rustc-&rust-version; &&
|
---|
217 | ln -svfn rustc-&rust-version; /opt/rustc</userinput></screen>
|
---|
218 |
|
---|
219 | <note>
|
---|
220 | <para>
|
---|
221 | If multiple versions of <application>Rust</application> are installed
|
---|
222 | in <filename class="directory">/opt</filename>, changing to another
|
---|
223 | version only requires changing the <filename> /opt/rustc</filename>
|
---|
224 | symbolic link and then running <command>ldconfig</command>.
|
---|
225 | </para>
|
---|
226 | </note>
|
---|
227 |
|
---|
228 | <para>
|
---|
229 | Create a suitable <filename>config.toml</filename> file which will
|
---|
230 | configure the build.
|
---|
231 | </para>
|
---|
232 |
|
---|
233 | <screen><userinput>cat << EOF > config.toml
|
---|
234 | <literal># see config.toml.example for more possible options
|
---|
235 | # See the 8.4 book for an old example using shipped LLVM
|
---|
236 | # e.g. if not installing clang, or using a version before 13.0
|
---|
237 |
|
---|
238 | # Tell x.py the editors have reviewed the content of this file
|
---|
239 | # and updated it to follow the major changes of the building system,
|
---|
240 | # so x.py will not warn us to do such a review.
|
---|
241 | change-id = 127866
|
---|
242 |
|
---|
243 | [llvm]
|
---|
244 | # by default, rust will build for a myriad of architectures
|
---|
245 | targets = "X86"
|
---|
246 |
|
---|
247 | # When using system llvm prefer shared libraries
|
---|
248 | link-shared = true
|
---|
249 |
|
---|
250 | [build]
|
---|
251 | # omit docs to save time and space (default is to build them)
|
---|
252 | docs = false
|
---|
253 |
|
---|
254 | # install extended tools: cargo, clippy, etc
|
---|
255 | extended = true
|
---|
256 |
|
---|
257 | # Do not query new versions of dependencies online.
|
---|
258 | locked-deps = true
|
---|
259 |
|
---|
260 | # Specify which extended tools (those from the default install).
|
---|
261 | tools = ["cargo", "clippy", "rustdoc", "rustfmt"]
|
---|
262 |
|
---|
263 | # Use the source code shipped in the tarball for the dependencies.
|
---|
264 | # The combination of this and the "locked-deps" entry avoids downloading
|
---|
265 | # many crates from Internet, and makes the Rustc build more stable.
|
---|
266 | vendor = true
|
---|
267 |
|
---|
268 | [install]
|
---|
269 | prefix = "/opt/rustc-&rust-version;"
|
---|
270 | docdir = "share/doc/rustc-&rust-version;"
|
---|
271 |
|
---|
272 | [rust]
|
---|
273 | channel = "stable"
|
---|
274 | description = "for BLFS &version;"
|
---|
275 |
|
---|
276 | # Enable the same optimizations as the official upstream build.
|
---|
277 | lto = "thin"
|
---|
278 | codegen-units = 1
|
---|
279 |
|
---|
280 | [target.x86_64-unknown-linux-gnu]
|
---|
281 | # NB the output of llvm-config (i.e. help options) may be
|
---|
282 | # dumped to the screen when config.toml is parsed.
|
---|
283 | llvm-config = "/usr/bin/llvm-config"
|
---|
284 |
|
---|
285 | [target.i686-unknown-linux-gnu]
|
---|
286 | # NB the output of llvm-config (i.e. help options) may be
|
---|
287 | # dumped to the screen when config.toml is parsed.
|
---|
288 | llvm-config = "/usr/bin/llvm-config"</literal>
|
---|
289 | EOF</userinput></screen>
|
---|
290 | <!-- It seems gone in 1.81.0 but not confirmed upstream
|
---|
291 | <note>
|
---|
292 | <para>
|
---|
293 | The <command>python3 x.py</command> commands may output a warning
|
---|
294 | message complaining <computeroutput>no codegen-backends
|
---|
295 | config matched the requested path to build a codegen
|
---|
296 | backend</computeroutput>. And the provided
|
---|
297 | <quote>suggestion</quote> (<computeroutput>add backend to
|
---|
298 | codegen-backends in config.toml</computeroutput>) will not silence
|
---|
299 | it. This warning is <ulink
|
---|
300 | url='https://github.com/rust-lang/rust/issues/110692'>bogus</ulink>
|
---|
301 | and it should be ignored.
|
---|
302 | </para>
|
---|
303 | </note>
|
---|
304 | -->
|
---|
305 | <!-- https://github.com/rust-lang/rust/issues/128493
|
---|
306 | https://github.com/rust-lang/rust/issues/130018
|
---|
307 | https://github.com/rust-lang/rust/pull/130034 -->
|
---|
308 | <para>
|
---|
309 | Now remove some tests triggering a full rebuild of the Rust standard
|
---|
310 | library and compiler, remove a special case for supporting the
|
---|
311 | <command>cargo</command> test suite (that we don't run because it's
|
---|
312 | expected to be running in a Rustc git repository) but triggering a rebuild
|
---|
313 | of <command>cargo</command> when running
|
---|
314 | <command>python3 x.py install</command>, and prevent building one
|
---|
315 | component useless for BLFS:
|
---|
316 | </para>
|
---|
317 |
|
---|
318 | <screen><userinput>sed '/MirOpt/d' -i src/bootstrap/src/core/builder.rs &&
|
---|
319 |
|
---|
320 | sed 's/!path.ends_with("cargo")/true/' \
|
---|
321 | -i src/bootstrap/src/core/build_steps/tool.rs &&
|
---|
322 |
|
---|
323 | sed 's/^.*build_wasm.*$/#[allow(unreachable_code)]&return false;/' \
|
---|
324 | -i src/bootstrap/src/lib.rs</userinput></screen>
|
---|
325 |
|
---|
326 | <para>
|
---|
327 | Disable one experimental feature which fails to build with LLVM
|
---|
328 | 19.1 or newer, and remove the tests for it:
|
---|
329 | </para>
|
---|
330 |
|
---|
331 | <screen><userinput>sed '/CondBitmap/,/^}/s/LLVM_VERSION.*/& \&\& LLVM_VERSION_LT(19, 0)/' \
|
---|
332 | -i compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp &&
|
---|
333 |
|
---|
334 | rm -v tests/coverage/mcdc/{cond*,if,inline*,nest*,non_*}.rs</userinput></screen>
|
---|
335 |
|
---|
336 | <para>
|
---|
337 | Compile <application>Rust</application> by running the following
|
---|
338 | commands:
|
---|
339 | </para>
|
---|
340 |
|
---|
341 | <!-- fixed in 1.58.0, retain as a reminder that fixed crates can be used
|
---|
342 | <screen><userinput>sed -i -e '/^curl /s/0.4.38/0.4.40/' \
|
---|
343 | -e '/^curl-sys /s/0.4.48/0.4.50/' \
|
---|
344 | src/tools/cargo/Cargo.toml && -->
|
---|
345 |
|
---|
346 | <screen><userinput>[ ! -e /usr/include/libssh2.h ] || export LIBSSH2_SYS_USE_PKG_CONFIG=1
|
---|
347 | [ ! -e /usr/include/sqlite3.h ] || export LIBSQLITE3_SYS_USE_PKG_CONFIG=1
|
---|
348 | python3 x.py build</userinput></screen>
|
---|
349 |
|
---|
350 | <note>
|
---|
351 | <para>
|
---|
352 | The test suite will generate some messages in the
|
---|
353 | <phrase revision="sysv">system log</phrase>
|
---|
354 | <phrase revision="systemd">systemd journal</phrase>
|
---|
355 | for traps on invalid opcodes, and for segmentation faults.
|
---|
356 | In themselves these are nothing to worry about, just a way for the
|
---|
357 | test to be terminated.
|
---|
358 | </para>
|
---|
359 | </note>
|
---|
360 |
|
---|
361 | <para>
|
---|
362 | To run the tests (again using all available CPUs) issue:
|
---|
363 | </para>
|
---|
364 |
|
---|
365 | <screen remap="test"><userinput>python3 x.py test --verbose --no-fail-fast | tee rustc-testlog</userinput></screen>
|
---|
366 |
|
---|
367 | <para>
|
---|
368 | Four tests in the
|
---|
369 | <filename class='directory'>tests/run-make</filename> directory are
|
---|
370 | known to fail because they need targets not enabled
|
---|
371 | in the BLFS <xref linkend='llvm'/> configuration (nor the
|
---|
372 | <literal>llvm.targets</literal> in <filename>config.toml</filename>,
|
---|
373 | in case building with the shipped LLVM). One test named
|
---|
374 | <literal>core::config::tests::download_ci_llvm</literal> is known to
|
---|
375 | fail. And, one test named <filename>121444.rs</filename> is known
|
---|
376 | to fail with LLVM 19.1 or newer because a crash is fixed with the new
|
---|
377 | LLVM but the Rustc test harness does not have the concept of
|
---|
378 | unexpected passes.
|
---|
379 | </para>
|
---|
380 |
|
---|
381 | <!-- Let's just comment this out. Nobody has tested on a system w/o
|
---|
382 | FileCheck for a long time.
|
---|
383 | <para>
|
---|
384 | If <command>FileCheck</command> from <application>LLVM</application> has
|
---|
385 | not been installed, all 47 tests from the <quote>assembly</quote> suite
|
---|
386 | will fail.
|
---|
387 | </para>
|
---|
388 | -->
|
---|
389 | <para>
|
---|
390 | As with all large test suites, some tests might fail on some machines -
|
---|
391 | if the number of additional failures is low,
|
---|
392 | check the log for 'failures:' and review lines above that, particularly the
|
---|
393 | 'stderr:' lines. Any mention of
|
---|
394 | SIGSEGV or signal 11 in a failing test is a cause for concern.
|
---|
395 | </para>
|
---|
396 |
|
---|
397 | <para>
|
---|
398 | If you get any <emphasis>other</emphasis> failing test which reports an
|
---|
399 | issue number then you should search for that issue. For example, when
|
---|
400 | rustc >= 1.41.1 was built with a version of sysllvm before 10.0 the test
|
---|
401 | for issue 69225 failed <ulink
|
---|
402 | url="https://github.com/rust-lang/rust/issues/69225"/> and that should be
|
---|
403 | regarded as a critical failure (they released 1.41.1 because of it).
|
---|
404 | Most other failures will not be critical.
|
---|
405 | </para>
|
---|
406 |
|
---|
407 | <para>
|
---|
408 | Therefore, you should determine the number of failures.
|
---|
409 | The number of tests which passed and failed can be found by running:
|
---|
410 | </para>
|
---|
411 |
|
---|
412 | <!-- split into two lines for narrower screen windows -->
|
---|
413 | <screen remap="test"><userinput>grep '^test result:' rustc-testlog |
|
---|
414 | awk '{sum1 += $4; sum2 += $6} END { print sum1 " passed; " sum2 " failed" }'</userinput></screen>
|
---|
415 |
|
---|
416 | <para>
|
---|
417 | The other available fields are $8 for those which were ignored
|
---|
418 | (i.e. skipped), $10 for 'measured' and $12 for 'filtered out' but both
|
---|
419 | those last two are probably zero.
|
---|
420 | </para>
|
---|
421 |
|
---|
422 | <para>
|
---|
423 | Now, as the &root; user, install the package:
|
---|
424 | </para>
|
---|
425 |
|
---|
426 | <note>
|
---|
427 | <para>
|
---|
428 | If <command>sudo</command> or <command>su</command> is invoked for
|
---|
429 | switching to the &root; user, ensure
|
---|
430 | <envar>LIBSSH2_SYS_USE_PKG_CONFIG</envar> and
|
---|
431 | <envar>LIBSQLITE3_SYS_USE_PKG_CONFIG</envar> are correctly passed or
|
---|
432 | the following command may rebuild <command>cargo</command> with
|
---|
433 | shipped copies of libssh2 and sqlite. For <command>sudo</command>,
|
---|
434 | use the
|
---|
435 | <option>--preserve-env=LIB{SSH2,SQLITE3}_SYS_USE_PKG_CONFIG</option>
|
---|
436 | option. For <command>su</command>, do <emphasis>not</emphasis> use
|
---|
437 | the <option>-</option> or <option>--login</option> options.
|
---|
438 | </para>
|
---|
439 | </note>
|
---|
440 |
|
---|
441 | <screen role='root'><userinput>python3 x.py install rustc std &&
|
---|
442 | python3 x.py install --stage=1 cargo clippy rustfmt</userinput></screen>
|
---|
443 |
|
---|
444 | <para>
|
---|
445 | Still as the &root; user, fix the installation of documentation,
|
---|
446 | symlink a <application>Zsh</application>
|
---|
447 | completion file into the correct location, and move a
|
---|
448 | <application>Bash</application> completion file into the location
|
---|
449 | recommended by the <application>Bash</application> completion
|
---|
450 | maintainers:
|
---|
451 | </para>
|
---|
452 |
|
---|
453 | <screen role='root'><userinput>rm -fv /opt/rustc-&rust-version;/share/doc/rustc-&rust-version;/*.old &&
|
---|
454 | install -vm644 README.md \
|
---|
455 | /opt/rustc-&rust-version;/share/doc/rustc-&rust-version; &&
|
---|
456 |
|
---|
457 | install -vdm755 /usr/share/zsh/site-functions &&
|
---|
458 | ln -sfv /opt/rustc/share/zsh/site-functions/_cargo \
|
---|
459 | /usr/share/zsh/site-functions
|
---|
460 |
|
---|
461 | mv -v /etc/bash_completion.d/cargo /usr/share/bash-completion/completions</userinput></screen>
|
---|
462 |
|
---|
463 | <para>
|
---|
464 | Finally, unset the exported environment variables:
|
---|
465 | </para>
|
---|
466 |
|
---|
467 | <screen><userinput>unset LIB{SSH2,SQLITE3}_SYS_USE_PKG_CONFIG</userinput></screen>
|
---|
468 |
|
---|
469 | </sect2>
|
---|
470 |
|
---|
471 | <sect2 role="commands">
|
---|
472 | <title>Command Explanations</title>
|
---|
473 |
|
---|
474 | <para>
|
---|
475 | <command>ln -svfn rustc-&rust-version; /opt/rustc</command>: if this is
|
---|
476 | not the first use of the <filename class="directory">/opt/rustc</filename>
|
---|
477 | symlink, overwrite it by forcing, and use the '-n' flag to avoid getting
|
---|
478 | confusing results from e.g. <command>ls -l</command>.
|
---|
479 | </para>
|
---|
480 |
|
---|
481 | <para>
|
---|
482 | <literal>targets = "X86"</literal>: this avoids building all the available
|
---|
483 | linux cross-compilers (AArch64, MIPS, PowerPC, SystemZ, etc). Unfortunately,
|
---|
484 | rust insists on installing source files for these below
|
---|
485 | <filename class="directory">/opt/rustc/lib/src</filename>.
|
---|
486 | </para>
|
---|
487 |
|
---|
488 | <para>
|
---|
489 | <literal>extended = true</literal>: this installs several tools
|
---|
490 | (specified by the <literal>tools</literal> entry) alongside
|
---|
491 | <command>rustc</command>.
|
---|
492 | </para>
|
---|
493 |
|
---|
494 | <para>
|
---|
495 | <literal>tools = ["cargo", "clippy", "rustdoc", "rustfmt"]</literal>:
|
---|
496 | only build the tools from the 'default' profile in binary command
|
---|
497 | <command>rustup</command> which are recommended for most users.
|
---|
498 | The other tools are unlikely to be useful unless using (old) code
|
---|
499 | analyzers or editing the standard library.
|
---|
500 | </para>
|
---|
501 |
|
---|
502 | <para>
|
---|
503 | <literal>channel = "stable"</literal>: this ensures only stable features
|
---|
504 | can be used, the default in <filename>config.toml</filename> is to use
|
---|
505 | development features, which is not appropriate for a released version.
|
---|
506 | </para>
|
---|
507 |
|
---|
508 | <!-- comment while using shipped LLVM -->
|
---|
509 | <para>
|
---|
510 | <literal>[target.x86_64-unknown-linux-gnu]</literal>: the syntax of
|
---|
511 | <filename>config.toml</filename> requires an <literal>llvm-config</literal>
|
---|
512 | entry for each target for which system-llvm is to be used. Change the target
|
---|
513 | to <literal>[target.i686-unknown-linux-gnu]</literal> if you are building
|
---|
514 | on 32-bit x86. This whole section may be omitted if you wish to build
|
---|
515 | against the shipped llvm, or do not have clang, but the resulting build will
|
---|
516 | be larger and take longer.
|
---|
517 | </para>
|
---|
518 |
|
---|
519 | <!--<para>
|
---|
520 | <command>sed -i -e '/^curl /s/0.4.38/0.4.40/' ... </command>: two crates
|
---|
521 | normally downloaded for this release do not correctly initialise
|
---|
522 | <application>curl</application> if using
|
---|
523 | <application>openssl-3.0.0</application>. Upstream has fixed that for a
|
---|
524 | future release, this sed causes the fixed versions to be used.
|
---|
525 | </para>-->
|
---|
526 |
|
---|
527 | <!-- https://github.com/alexcrichton/ssh2-rs/issues/173 -->
|
---|
528 | <para>
|
---|
529 | <command>export LIBSSH2_SYS_USE_PKG_CONFIG=1</command>: Allow
|
---|
530 | <command>cargo</command> to link to system libssh2.
|
---|
531 | </para>
|
---|
532 |
|
---|
533 | <!-- src/tools/cargo/Cargo.toml is specifying "bundled" as the
|
---|
534 | upstream is suggesting to avoid issues building for Windoge.
|
---|
535 | We don't care about Windoge so override this if we have
|
---|
536 | system sqlite3. -->
|
---|
537 | <para>
|
---|
538 | <command>export LIBSQLITE3_SYS_USE_PKG_CONFIG=1</command>: Allow
|
---|
539 | <command>cargo</command> to link to system sqlite.
|
---|
540 | </para>
|
---|
541 |
|
---|
542 | <!--<para>
|
---|
543 | <command>export RUSTFLAGS="$RUSTFLAGS -C link-args=-lffi"</command>:
|
---|
544 | This adds a link to libffi to any RUSTFLAGS you may already be passing
|
---|
545 | to the build. On some systems, linking fails to include libffi unless
|
---|
546 | this is used. The reason why this is needed is not clear.
|
---|
547 | 2023-01-14 : assumed to be no longer needed, but it is some years
|
---|
548 | since one person reported needing this, keep it commented for the moment.
|
---|
549 | </para>-->
|
---|
550 |
|
---|
551 | <para>
|
---|
552 | <parameter>--verbose</parameter>: this switch can sometimes provide more
|
---|
553 | information about a test which fails.
|
---|
554 | </para>
|
---|
555 |
|
---|
556 | <para>
|
---|
557 | <parameter>--no-fail-fast</parameter>: this switch ensures that the test suite
|
---|
558 | will not stop at the first error.
|
---|
559 | </para>
|
---|
560 |
|
---|
561 | <!-- https://github.com/rust-lang/rust/issues/94147 -->
|
---|
562 | <para>
|
---|
563 | <parameter>--stage=1</parameter>: this switch works around an issue
|
---|
564 | causing some Rustc components unnecessarily rebuilt running
|
---|
565 | <command>python3 x.py install</command>.
|
---|
566 | </para>
|
---|
567 |
|
---|
568 | </sect2>
|
---|
569 |
|
---|
570 | <sect2 role="configuration">
|
---|
571 | <title>Configuring Rust</title>
|
---|
572 |
|
---|
573 | <sect3 id="rustc-config">
|
---|
574 | <title>Configuration Information</title>
|
---|
575 |
|
---|
576 | <para>
|
---|
577 | If you installed <application>rustc</application> in
|
---|
578 | <filename class="directory">/opt</filename>, you need to update the
|
---|
579 | following configuration files so that <application>rustc</application>
|
---|
580 | is correctly found by other packages and system processes.
|
---|
581 | </para>
|
---|
582 |
|
---|
583 | <para>
|
---|
584 | As the <systemitem class="username">root</systemitem> user, create
|
---|
585 | the <filename>/etc/profile.d/rustc.sh</filename> file:
|
---|
586 | </para>
|
---|
587 |
|
---|
588 | <screen role="root"><userinput>cat > /etc/profile.d/rustc.sh << "EOF"
|
---|
589 | <literal># Begin /etc/profile.d/rustc.sh
|
---|
590 |
|
---|
591 | pathprepend /opt/rustc/bin PATH
|
---|
592 |
|
---|
593 | # End /etc/profile.d/rustc.sh</literal>
|
---|
594 | EOF</userinput></screen>
|
---|
595 |
|
---|
596 | <para>
|
---|
597 | Immediately after installation, update the current PATH
|
---|
598 | for your current shell as a normal user:
|
---|
599 | </para>
|
---|
600 |
|
---|
601 | <screen><userinput>source /etc/profile.d/rustc.sh</userinput></screen>
|
---|
602 |
|
---|
603 | </sect3>
|
---|
604 | </sect2>
|
---|
605 |
|
---|
606 |
|
---|
607 | <sect2 role="content">
|
---|
608 | <title>Contents</title>
|
---|
609 |
|
---|
610 | <segmentedlist>
|
---|
611 | <segtitle>Installed Programs</segtitle>
|
---|
612 | <segtitle>Installed Libraries</segtitle>
|
---|
613 | <segtitle>Installed Directories</segtitle>
|
---|
614 |
|
---|
615 | <seglistitem>
|
---|
616 | <seg>
|
---|
617 | cargo-clippy, cargo-fmt, cargo, clippy-driver, rust-gdb,
|
---|
618 | rust-gdbgui, rust-lldb, rustc, rustdoc, and rustfmt
|
---|
619 | </seg>
|
---|
620 | <seg>
|
---|
621 | librustc-driver-<16-byte-hash>.so,
|
---|
622 | libstd-<16-byte-hash>.so, and
|
---|
623 | libtest-<16-byte-hash>.so
|
---|
624 | </seg>
|
---|
625 | <seg>
|
---|
626 | ~/.cargo,
|
---|
627 | /opt/rustc, symbolic link to
|
---|
628 | /opt/rustc-&rust-version;
|
---|
629 | </seg>
|
---|
630 | </seglistitem>
|
---|
631 | </segmentedlist>
|
---|
632 |
|
---|
633 | <variablelist>
|
---|
634 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
635 | <?dbfo list-presentation="list"?>
|
---|
636 | <?dbhtml list-presentation="table"?>
|
---|
637 |
|
---|
638 | <varlistentry id="cargo-clippy">
|
---|
639 | <term><command>cargo-clippy</command></term>
|
---|
640 | <listitem>
|
---|
641 | <para>
|
---|
642 | provides lint checks for a cargo package
|
---|
643 | </para>
|
---|
644 | <indexterm zone="rust cargo-clippy">
|
---|
645 | <primary sortas="b-cargo-clippy">cargo-clippy</primary>
|
---|
646 | </indexterm>
|
---|
647 | </listitem>
|
---|
648 | </varlistentry>
|
---|
649 |
|
---|
650 | <varlistentry id="cargo-fmt">
|
---|
651 | <term><command>cargo-fmt</command></term>
|
---|
652 | <listitem>
|
---|
653 | <para>
|
---|
654 | formats all bin and lib files of the current crate using
|
---|
655 | rustfmt
|
---|
656 | </para>
|
---|
657 | <indexterm zone="rust cargo-fmt">
|
---|
658 | <primary sortas="b-cargo-fmt">cargo-fmt</primary>
|
---|
659 | </indexterm>
|
---|
660 | </listitem>
|
---|
661 | </varlistentry>
|
---|
662 |
|
---|
663 | <!-- <varlistentry id="cargo-miri">
|
---|
664 | <term><command>cargo-miri</command></term>
|
---|
665 | <listitem>
|
---|
666 | <para>
|
---|
667 | is for use by Miri to interpret bin crates and tests. It is
|
---|
668 | not installed by default.
|
---|
669 | </para>
|
---|
670 | <indexterm zone="rust cargo-miri">
|
---|
671 | <primary sortas="b-cargo-miri">cargo-miri</primary>
|
---|
672 | </indexterm>
|
---|
673 | </listitem>
|
---|
674 | </varlistentry>-->
|
---|
675 |
|
---|
676 | <varlistentry id="cargo">
|
---|
677 | <term><command>cargo</command></term>
|
---|
678 | <listitem>
|
---|
679 | <para>
|
---|
680 | is the Package Manager for Rust
|
---|
681 | </para>
|
---|
682 | <indexterm zone="rust cargo">
|
---|
683 | <primary sortas="b-cargo">cargo</primary>
|
---|
684 | </indexterm>
|
---|
685 | </listitem>
|
---|
686 | </varlistentry>
|
---|
687 |
|
---|
688 | <varlistentry id="clippy-driver">
|
---|
689 | <term><command>clippy-driver</command></term>
|
---|
690 | <listitem>
|
---|
691 | <para>
|
---|
692 | provides lint checks for Rust
|
---|
693 | </para>
|
---|
694 | <indexterm zone="rust clippy-driver">
|
---|
695 | <primary sortas="b-clippy-driver">clippy-driver</primary>
|
---|
696 | </indexterm>
|
---|
697 | </listitem>
|
---|
698 | </varlistentry>
|
---|
699 |
|
---|
700 | <!-- <varlistentry id="miri">
|
---|
701 | <term><command>miri</command></term>
|
---|
702 | <listitem>
|
---|
703 | <para>
|
---|
704 | is an interpreter for Rust's mid-level intermediate representation
|
---|
705 | (MIR). It is not installed by default.
|
---|
706 | </para>
|
---|
707 | <indexterm zone="rust miri">
|
---|
708 | <primary sortas="b-miri">miri</primary>
|
---|
709 | </indexterm>
|
---|
710 | </listitem>
|
---|
711 | </varlistentry>
|
---|
712 |
|
---|
713 | <varlistentry id="rls">
|
---|
714 | <term><command>rls</command></term>
|
---|
715 | <listitem>
|
---|
716 | <para>
|
---|
717 | is the Rust Language Server. This can run in the background to
|
---|
718 | provide IDEs, editors, and other tools with information about Rust
|
---|
719 | programs
|
---|
720 | </para>
|
---|
721 | <indexterm zone="rust rls">
|
---|
722 | <primary sortas="b-rls">rls</primary>
|
---|
723 | </indexterm>
|
---|
724 | </listitem>
|
---|
725 | </varlistentry>
|
---|
726 |
|
---|
727 | <varlistentry id="rust-analyzer">
|
---|
728 | <term><command>rust-analyzer</command></term>
|
---|
729 | <listitem>
|
---|
730 | <para>
|
---|
731 | is an implementation of Language Server Protocol for the Rust
|
---|
732 | programming language.
|
---|
733 | </para>
|
---|
734 | <indexterm zone="rust rust-analyzer">
|
---|
735 | <primary sortas="b-rust-analyzer">rust-analyzer</primary>
|
---|
736 | </indexterm>
|
---|
737 | </listitem>
|
---|
738 | </varlistentry>
|
---|
739 |
|
---|
740 | <varlistentry id="rust-demangler">
|
---|
741 | <term><command>rust-demangler</command></term>
|
---|
742 | <listitem>
|
---|
743 | <para>
|
---|
744 | converts a list of Rust mangled symbols into a
|
---|
745 | corresponding list of demangled symbols
|
---|
746 | </para>
|
---|
747 | <indexterm zone="rust rust-demangler">
|
---|
748 | <primary sortas="b-rust-demangler">rust-demangler</primary>
|
---|
749 | </indexterm>
|
---|
750 | </listitem>
|
---|
751 | </varlistentry> -->
|
---|
752 |
|
---|
753 | <varlistentry id="rust-gdb">
|
---|
754 | <term><command>rust-gdb</command></term>
|
---|
755 | <listitem>
|
---|
756 | <para>
|
---|
757 | is a wrapper script for gdb, pulling in Python pretty-printing
|
---|
758 | modules installed in
|
---|
759 | <filename class="directory">/opt/rustc-&rust-version;/lib/rustlib/etc</filename>
|
---|
760 | </para>
|
---|
761 | <indexterm zone="rust rust-gdb">
|
---|
762 | <primary sortas="b-rust-gdb">rust-gdb</primary>
|
---|
763 | </indexterm>
|
---|
764 | </listitem>
|
---|
765 | </varlistentry>
|
---|
766 |
|
---|
767 | <varlistentry id="rust-gdbgui">
|
---|
768 | <term><command>rust-gdbgui</command></term>
|
---|
769 | <listitem>
|
---|
770 | <para>
|
---|
771 | is a wrapper script for a graphical front end to gdb that runs in a
|
---|
772 | browser
|
---|
773 | </para>
|
---|
774 | <indexterm zone="rust rust-gdbgui">
|
---|
775 | <primary sortas="b-rust-gdbgui">rust-gdbgui</primary>
|
---|
776 | </indexterm>
|
---|
777 | </listitem>
|
---|
778 | </varlistentry>
|
---|
779 |
|
---|
780 | <varlistentry id="rust-lldb">
|
---|
781 | <term><command>rust-lldb</command></term>
|
---|
782 | <listitem>
|
---|
783 | <para>
|
---|
784 | is a wrapper script for LLDB (the LLVM debugger)
|
---|
785 | pulling in the Python pretty-printing modules
|
---|
786 | </para>
|
---|
787 | <indexterm zone="rust rust-lldb">
|
---|
788 | <primary sortas="b-rust-lldb">rust=lldb</primary>
|
---|
789 | </indexterm>
|
---|
790 | </listitem>
|
---|
791 | </varlistentry>
|
---|
792 |
|
---|
793 | <varlistentry id="rustc">
|
---|
794 | <term><command>rustc</command></term>
|
---|
795 | <listitem>
|
---|
796 | <para>
|
---|
797 | is the rust compiler
|
---|
798 | </para>
|
---|
799 | <indexterm zone="rust rustc">
|
---|
800 | <primary sortas="b-rustc">rustc</primary>
|
---|
801 | </indexterm>
|
---|
802 | </listitem>
|
---|
803 | </varlistentry>
|
---|
804 |
|
---|
805 | <varlistentry id="rustdoc">
|
---|
806 | <term><command>rustdoc</command></term>
|
---|
807 | <listitem>
|
---|
808 | <para>
|
---|
809 | generates documentation from rust source code
|
---|
810 | </para>
|
---|
811 | <indexterm zone="rust rustdoc">
|
---|
812 | <primary sortas="b-rustdoc">rustdoc</primary>
|
---|
813 | </indexterm>
|
---|
814 | </listitem>
|
---|
815 | </varlistentry>
|
---|
816 |
|
---|
817 | <varlistentry id="rustfmt">
|
---|
818 | <term><command>rustfmt</command></term>
|
---|
819 | <listitem>
|
---|
820 | <para>
|
---|
821 | formats rust code
|
---|
822 | </para>
|
---|
823 | <indexterm zone="rust rustfmt">
|
---|
824 | <primary sortas="b-rustfmt">rustfmt</primary>
|
---|
825 | </indexterm>
|
---|
826 | </listitem>
|
---|
827 | </varlistentry>
|
---|
828 |
|
---|
829 | <varlistentry id="libstd">
|
---|
830 | <term><filename class="libraryfile">libstd-<16-byte-hash>.so</filename></term>
|
---|
831 | <listitem>
|
---|
832 | <para>
|
---|
833 | is the Rust Standard Library, the foundation of portable Rust software
|
---|
834 | </para>
|
---|
835 | <indexterm zone="rust libstd">
|
---|
836 | <primary sortas="c-libstd">libstd-<16-byte-hash>.so</primary>
|
---|
837 | </indexterm>
|
---|
838 | </listitem>
|
---|
839 | </varlistentry>
|
---|
840 | </variablelist>
|
---|
841 | </sect2>
|
---|
842 |
|
---|
843 | </sect1>
|
---|