source: general/prog/rust.xml@ 6201485

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 8.4 9.0 9.1 bdubbs/svn elogind kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts lazarus lxqt plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk upgradedb xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since 6201485 was 6201485, checked in by Ken Moffat <ken@…>, 6 years ago

rustc-1.29.2

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@20638 af4574ff-66df-0310-9fd7-8a98e5e911e0

  • Property mode set to 100644
File size: 17.5 KB
Line 
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 <!ENTITY rust-download-http "https://static.rust-lang.org/dist/rustc-&rust-version;-src.tar.gz">
8 <!ENTITY rust-download-ftp " ">
9 <!ENTITY rust-md5sum "6790c24fe5e8fb5a5f7efbfbcc6fea65">
10 <!ENTITY rust-size "101 MB">
11 <!ENTITY rust-buildsize "6.5 GB (679 MB installed) including 270MB of ~/.cargo files for the user building this (add 1.4GB if running the tests)">
12 <!ENTITY rust-time "27 SBU (add 13 SBU for tests, both with 4 processors)">
13]>
14
15<sect1 id="rust" xreflabel="rustc-&rust-version;">
16 <?dbhtml filename="rust.html"?>
17
18 <sect1info>
19 <othername>$LastChangedBy$</othername>
20 <date>$Date$</date>
21 </sect1info>
22
23 <title>Rustc-&rust-version;</title>
24
25 <indexterm zone="rust">
26 <primary sortas="a-rust">Rust</primary>
27 </indexterm>
28
29 <sect2 role="package">
30 <title>Introduction to Rust</title>
31
32 <para>
33 The <application>Rust</application> programming language is designed
34 to be a safe, concurrent, practical language.
35 </para>
36
37 <para>
38 As with many other programming languages, rustc (the rust compiler)
39 needs a binary from which to bootstrap. It will download a stage0 binary
40 and many cargo crates (these are actually .tar.gz source archives) at
41 the start of the build, so you cannot compile it without an internet
42 connection.
43 </para>
44
45 <para>
46 The current <application>rustbuild</application> build-system will use
47 all available processors, although it does not scale well and often falls
48 back to just using one core while waiting for a library to compile.
49 </para>
50
51 <para>
52 At the moment <application>Rust</application> does not provide any
53 guarantees of a stable ABI.
54 </para>
55
56 <note>
57 <para>
58 Rustc defaults to building for ALL supported architectures, using a
59 shipped copy of LLVM. In BLFS the build is only for the X86 architecture.
60 Rustc still claims to require Python2, but that is only really necessary
61 when building some other architectures with the shipped LLVM. If you
62 intend to develop rust crates, this build may not be good enough for your
63 purposes.
64 </para>
65 <para>
66 Repeated builds of this package on the same machine show a wide range
67 of build times. Some of this might be due to variations in downloading
68 the required cargo files if they are not already present, but this does
69 not seem to adequately explain the variations.
70 </para>
71 <para>
72 Unusually, a DESTDIR-style method is being used to install this package.
73 This is because running the install as root not only downloads all of the
74 cargo files again (to <filename>/root/.cargo</filename>), it then spends
75 a very long time recompiling. Using this method saves a lot of time, at
76 the cost of extra disk space.
77 </para>
78 </note>
79
80 &lfs83_checked;
81
82 <bridgehead renderas="sect3">Package Information</bridgehead>
83 <itemizedlist spacing="compact">
84 <listitem>
85 <para>
86 Download (HTTP): <ulink url="&rust-download-http;"/>
87 </para>
88 </listitem>
89 <listitem>
90 <para>
91 Download (FTP): <ulink url="&rust-download-ftp;"/>
92 </para>
93 </listitem>
94 <listitem>
95 <para>
96 Download MD5 sum: &rust-md5sum;
97 </para>
98 </listitem>
99 <listitem>
100 <para>
101 Download size: &rust-size;
102 </para>
103 </listitem>
104 <listitem>
105 <para>
106 Estimated disk space required: &rust-buildsize;
107 </para>
108 </listitem>
109 <listitem>
110 <para>
111 Estimated build time: &rust-time;
112 </para>
113 </listitem>
114 </itemizedlist>
115
116 <bridgehead renderas="sect3">Rust Dependencies</bridgehead>
117
118 <bridgehead renderas="sect4">Required</bridgehead>
119 <para role="required">
120 <xref linkend="curl"/>,
121 <xref linkend="cmake"/>,
122 <xref linkend="libssh2"/>
123<!-- <xref linkend="python2"/> -->
124 </para>
125
126 <bridgehead renderas="sect4">Recommended</bridgehead>
127 <para role="recommended">
128 <package>clang</package> from <xref linkend="llvm"/>
129 (built with -DLLVM_LINK_LLVM_DYLIB=ON)
130 </para>
131
132 <bridgehead renderas="sect4">Optional</bridgehead>
133 <para role="optional">
134 <xref linkend="gdb"/> (recommended if running the testsuite)
135 </para>
136
137 <para condition="html" role="usernotes">
138 User Notes: <ulink url="&blfs-wiki;/rust"/>
139 </para>
140 </sect2>
141
142 <sect2 role="installation">
143 <title>Installation of Rust</title>
144
145 <note>
146 <para>
147 This package is updated on a six-weekly release cycle. Because it is
148 such a large and slow package to build, and is at the moment only required
149 by three packages in this book, the BLFS editors take the view that it
150 should only be updated when that is necessary.
151 </para>
152 </note>
153
154 <para>
155 First create a suitable <filename>config.toml</filename> file
156 which will configure the build :
157 </para>
158
159<screen><userinput>cat &lt;&lt; EOF &gt; config.toml
160# see config.toml.example for more possible options
161[llvm]
162targets = "X86"
163
164# When using system llvm prefer shared libraries
165link-shared = true
166
167[build]
168# install cargo as well as rust
169extended = true
170
171[install]
172prefix = "/usr"
173docdir = "share/doc/rustc-&rust-version;"
174
175[rust]
176channel = "stable"
177rpath = false
178
179# BLFS does not install the FileCheck executable from llvm,
180# so disable codegen tests
181codegen-tests = false
182
183[target.x86_64-unknown-linux-gnu]
184# delete this *section* if you are not using system llvm.
185# NB the output of llvm-config (i.e. help options) may be
186# dumped to the screen when config.toml is parsed.
187llvm-config = "/usr/bin/llvm-config"
188
189EOF</userinput></screen>
190
191 <para>
192 Now install <application>Rust</application> by running the following
193 commands:
194 </para>
195
196<screen><userinput>export RUSTFLAGS="$RUSTFLAGS -C link-args=-lffi" &amp;&amp;
197python3 ./x.py build</userinput></screen>
198
199 <para>
200 The build will report it failed to compile <filename>miri</filename>
201 because of multiple potential crates for `log`, but that should be followed
202 by a message that the build completed successfully.
203 </para>
204
205 <caution>
206 <para>
207 On AMD Ryzen processors (family 17h), the non-optimized version of libstd
208 which is compiled at the start of the tests contains two opcodes which are
209 not implemented on this CPU family. These will be logged in the
210 <phrase revision="sysv">system log</phrase>
211 <phrase revision="systemd">systemd journal</phrase>
212 and will be followed a few minutes later by segmentation faults. Despite
213 that, the tests continue to run, apparently normally. But the system may
214 reboot before the tests have completed. The normal optimized libraries
215 run without this problem.
216 </para>
217 <para>
218 A mitigation is to install gdb
219 <!-- systemd apparently handles this with systemd-coredump -->
220 <phrase revision="sysv">and to run the tests with 'ulimit -C disabled'</phrase>
221 but this does not always prevent the system rebooting.
222 </para>
223 </caution>
224
225 <para>
226 To run the tests issue
227 <command>python3 ./x.py test --verbose --no-fail-fast | tee rustc-testlog</command>:
228 as with the build, that will use all available CPUs. This runs many suites
229 of tests (in an apparently random order), several will fail in BLFS:
230 compile-fail/issue-37131.rs require a thumbv6m-none-eabi compiler but the
231 BLFS build does not cater for
232 that, ui/issue-49851/compiler-builtins-error.rs and ui/issue-50993.rs (both
233 run twice) require a thumbv7em-none-eabihf compiler, and seven tests in
234 debuginfo-gdb will fail because gdb-8.1 changed the output format. If
235 <application>gdb</application> has not been installed, most of the gdb tests
236 will fail.
237 </para>
238
239 <para>
240 If you wish to look at the numbers for the results, you can find the total
241 number of tests which were considered by running:
242 </para>
243
244<screen><command>grep 'running .* tests' rustc-testlog | awk '{ sum += $2 } END { print sum }'</command></screen>
245
246 <para>
247 That should report 17101 tests. Similarly, the total tests which failed can
248 be found by running:
249 </para>
250
251<screen><command>grep '^test result:' rustc-testlog | awk '{ sum += $6 } END { print sum }'</command></screen>
252
253 <para>
254 And similarly for the tests which passed use $4, for those which were ignored
255 (i.e. skipped) use $8 (and $10 for 'measured', $12 for 'filtered out' but both
256 are probably zero). The breakdown does not match the overall total.
257 </para>
258
259 <para>
260 Still as your normal user, do a DESTDIR install:
261 </para>
262
263<screen><userinput>export LIBSSH2_SYS_USE_PKG_CONFIG=1 &amp;&amp;
264DESTDIR=${PWD}/install python3 ./x.py install &amp;&amp;
265unset LIBSSH2_SYS_USE_PKG_CONFIG</userinput></screen>
266
267 <para>
268 Now, as the <systemitem class="username">root</systemitem> user
269 install the files from the DESTDIR:
270 </para>
271
272<screen role="root"><userinput>chown -R root:root install &amp;&amp;
273cp -a install/* /</userinput></screen>
274
275 </sect2>
276
277 <sect2 role="commands">
278 <title>Command Explanations</title>
279
280 <para>
281 <command>targets = "X86"</command>: this avoids building all the available
282 linux cross-compilers (Aarch64, MIPS, PowerPC, SystemZ, etc). Unfortunately,
283 rust insists on installing source files for these below
284 <filename class="directory">/usr/lib/rustlib/src</filename>.
285 </para>
286
287 <para>
288 <command>extended = true</command>: this installs Cargo alongside Rust.
289 </para>
290
291 <para>
292 <command>channel = "stable"</command>: this ensures only stable features
293 can be used, the default in <filename>config.toml</filename> is to use
294 development features, which is not appropriate for a released version.
295 </para>
296
297 <para>
298 <command>rpath = false</command>: by default, <command>rust</command> can
299 be run from where it was built, without being installed. That adds DT_RPATH
300 entries to all of the ELF files, which produces very messy output from
301 <command>ldd</command>, showing the libraries in the place they were built,
302 even if they have been deleted from there after the install.
303 </para>
304
305 <para>
306 <command>[target.x86_64-unknown-linux-gnu]</command>: the syntax of
307 <filename>config.toml</filename> requires an <literal>llvm-config</literal>
308 entry for each target for which system-llvm is to be used. Change the target
309 to <literal>[target.i686-unknown-linux-gnu]</literal> if you are building
310 on 32-bit x86. This whole section may be omitted if you wish to build
311 against the shipped llvm, or do not have clang, but the resulting build will
312 be larger and take longer.
313 </para>
314
315 <para>
316 <command>export RUSTFLAGS="$RUSTFLAGS -C link-args=-lffi"</command>:
317 This adds a link to libffi to any RUSTFLAGS you may already be passing
318 to the build. On some systems, linking fails to include libffi unless
319 this is used. The reason why this is needed is not clear.
320 </para>
321
322 <para>
323 <command>--verbose</command>: this switch can sometimes provide more
324 information about a test which fails.
325 </para>
326
327 <para>
328 <command>--no-fail-fast</command>: this switch ensures that the testsuite
329 will not stop at the first error.
330 </para>
331
332 <para>
333 <command>export LIBSSH2_SYS_USE_PKG_CONFIG=1</command>: On some systems,
334 cairo fails to link during the install because it cannot find libssh2.
335 This seems to fix it, but again the reason why the problem occurs is not
336 understood.
337 </para>
338
339 <para>
340 <command>DESTDIR=${PWD}/install ./x.py install</command>: This effects a
341 DESTDIR-style install in the source tree,creating an <filename
342 class="directory">install</filename> directory. Note that DESTDIR installs
343 need an absolute path, passing 'install' will not work.
344 </para>
345
346 <para>
347 <command>chown -R root:root install</command>: the DESTDIR install
348 was run by a regular user, who owns the files. For security, change their
349 owner before doing a simple copy to install them.
350 </para>
351
352 </sect2>
353
354 <sect2 role="content">
355 <title>Contents</title>
356
357 <segmentedlist>
358 <segtitle>Installed Programs</segtitle>
359 <segtitle>Installed Libraries</segtitle>
360 <segtitle>Installed Directories</segtitle>
361
362 <seglistitem>
363 <seg>
364 cargo-clippy, cargo-fmt, cargo, clippy-driver, rls, rust-gdb, rust-lldb, rustc, rustdoc, rustfmt.
365 </seg>
366 <seg>
367 Many lib*&lt;16-byte-hash&gt;.so libraries.
368 </seg>
369 <seg>
370 ~/.cargo,
371 /usr/lib/rustlib,
372 /usr/share/doc/rustc-&rust-version;, and
373 /usr/share/zsh/site-functions/
374 </seg>
375 </seglistitem>
376 </segmentedlist>
377
378 <variablelist>
379 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
380 <?dbfo list-presentation="list"?>
381 <?dbhtml list-presentation="table"?>
382
383 <varlistentry id="cargo-clippy">
384 <term><command>cargo-clippy</command></term>
385 <listitem>
386 <para>
387 provides lint checks for a cargo package.
388 </para>
389 <indexterm zone="rust cargo-clippy">
390 <primary sortas="b-cargo-clippy">cargo-clippy</primary>
391 </indexterm>
392 </listitem>
393 </varlistentry>
394
395 <varlistentry id="cargo-fmt">
396 <term><command>cargo-fmt</command></term>
397 <listitem>
398 <para>
399 formats all bin and lib files of the current crate using
400 rustfmt.
401 </para>
402 <indexterm zone="rust cargo-fmt">
403 <primary sortas="b-cargo-fmt">cargo-fmt</primary>
404 </indexterm>
405 </listitem>
406 </varlistentry>
407
408 <varlistentry id="cargo">
409 <term><command>cargo</command></term>
410 <listitem>
411 <para>
412 is the Package Manager for Rust.
413 </para>
414 <indexterm zone="rust cargo">
415 <primary sortas="b-cargo">cargo</primary>
416 </indexterm>
417 </listitem>
418 </varlistentry>
419
420 <varlistentry id="clippy-driver">
421 <term><command>clippy-driver</command></term>
422 <listitem>
423 <para>
424 provides lint checks for Rust.
425 </para>
426 <indexterm zone="rust clippy-driver">
427 <primary sortas="b-clippy-driver">clippy-driver</primary>
428 </indexterm>
429 </listitem>
430 </varlistentry>
431
432 <varlistentry id="rls">
433 <term><command>rls</command></term>
434 <listitem>
435 <para>
436 is the Rust Language Server. This can run in the background to
437 provide IDEs, editors, and other tools with information about Rust
438 programs.
439 </para>
440 <indexterm zone="rust rls">
441 <primary sortas="b-rls">rls</primary>
442 </indexterm>
443 </listitem>
444 </varlistentry>
445
446 <varlistentry id="rust-gdb">
447 <term><command>rust-gdb</command></term>
448 <listitem>
449 <para>
450 is a wrapper script for gdb, pulling in Python
451 pretty-printing modules installed in <filename
452 class="directory">/usr/lib/rustlib/etc</filename>.
453 </para>
454 <indexterm zone="rust rust-gdb">
455 <primary sortas="b-rust-gdb">rust-gdb</primary>
456 </indexterm>
457 </listitem>
458 </varlistentry>
459
460 <varlistentry id="rust-lldb">
461 <term><command>rust-lldb</command></term>
462 <listitem>
463 <para>
464 is a wrapper script for LLDB (the LLVM debugger)
465 pulling in the Python pretty-printing modules.
466 </para>
467 <indexterm zone="rust rust-lldb">
468 <primary sortas="b-rust-lldb">rust=lldb</primary>
469 </indexterm>
470 </listitem>
471 </varlistentry>
472
473 <varlistentry id="rustc">
474 <term><command>rustc</command></term>
475 <listitem>
476 <para>
477 is the rust compiler.
478 </para>
479 <indexterm zone="rust rustc">
480 <primary sortas="b-rustc">rustc</primary>
481 </indexterm>
482 </listitem>
483 </varlistentry>
484
485 <varlistentry id="rustdoc">
486 <term><command>rustdoc</command></term>
487 <listitem>
488 <para>
489 generates documentation from rust source code.
490 </para>
491 <indexterm zone="rust rustdoc">
492 <primary sortas="b-rustdoc">rustdoc</primary>
493 </indexterm>
494 </listitem>
495 </varlistentry>
496
497 <varlistentry id="rustfmt">
498 <term><command>rustfmt</command></term>
499 <listitem>
500 <para>
501 formats rust code.
502 </para>
503 <indexterm zone="rust rustfmt">
504 <primary sortas="b-rustfmt">rustfmt</primary>
505 </indexterm>
506 </listitem>
507 </varlistentry>
508
509 <varlistentry id="libstd">
510 <term><filename class="libraryfile">libstd-&lt;16-byte-hash&gt;.so</filename></term>
511 <listitem>
512 <para>
513 is the Rust Standard Library, the foundation of portable Rust software.
514 </para>
515 <indexterm zone="rust libstd">
516 <primary sortas="c-libstd">libstd-&lt;16-byte-hash&gt;.so</primary>
517 </indexterm>
518 </listitem>
519 </varlistentry>
520 </variablelist>
521 </sect2>
522</sect1>
Note: See TracBrowser for help on using the repository browser.