source: general/prog/rust.xml@ 62f58c7a

bdubbs/svn
Last change on this file since 62f58c7a was 62f58c7a, checked in by Bruce Dubbs <bdubbs@…>, 6 years ago

Add a custom branch

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/branches/bdubbs@21035 af4574ff-66df-0310-9fd7-8a98e5e911e0

  • Property mode set to 100644
File size: 22.6 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 "366f049777e00d0d6f15d25895485efb">
10 <!ENTITY rust-size "152 MB">
11 <!-- Gentle Reminder: buildsize is how much the user requires for the real
12 install, i.e. the source with its DESTDIR *plus* the DESTDIR. You
13 can 'mkdir /tmp/RUST ; cp -a install/* /tmp/RUST' and then run 'du -sch'
14 to measure it. -->
15
16 <!ENTITY rust-buildsize "6.2 GB (475 MB installed) including 295MB of ~/.cargo files for the user building this. Add 1.5GB if installing the documentation (an extra 314MB is installed), and 2.0GB if running the tests">
17 <!ENTITY rust-time "34 SBU (add 3 SBU if installing the documentation and 15 SBU for tests, both with 4 processors)">
18]>
19
20<sect1 id="rust" xreflabel="rustc-&rust-version;">
21 <?dbhtml filename="rust.html"?>
22
23 <sect1info>
24 <othername>$LastChangedBy$</othername>
25 <date>$Date$</date>
26 </sect1info>
27
28 <title>Rustc-&rust-version;</title>
29
30 <indexterm zone="rust">
31 <primary sortas="a-rust">Rust</primary>
32 </indexterm>
33
34 <sect2 role="package">
35 <title>Introduction to Rust</title>
36
37 <para>
38 The <application>Rust</application> programming language is designed
39 to be a safe, concurrent, practical language.
40 </para>
41
42 <para>
43 This package is updated on a six-weekly release cycle. Because it is
44 such a large and slow package to build, and is at the moment only required
45 by five packages in this book, the BLFS editors take the view that it
46 should only be updated when that is necessary (either to fix problems,
47 or to allow a new version of <application>firefox</application> to build).
48 </para>
49
50 <para>
51 As with many other programming languages, rustc (the rust compiler)
52 needs a binary from which to bootstrap. It will download a stage0 binary
53 and many cargo crates (these are actually .tar.gz source archives) at
54 the start of the build, so you cannot compile it without an internet
55 connection.
56 </para>
57
58 <para>
59 These crates will then remain in various forms (cache, directories of
60 extracted source), in <filename class="directory">~/.cargo</filename> for
61 ever more. It is common for large <application>rust</application> packages
62 to use multiple versions of some crates. If you purge the files before
63 updating this package, very few crates will need to be updated by the
64 packages in this book which use it (and they will be downloaded as
65 required). But if you retain an older version as a fallback option and
66 then use it (that would require <emphasis>not</emphasis> building in
67 <filename class="directory">/usr</filename>), it is likely that it will
68 then have to re download some crates. For a full download (i.e. starting
69 with an empty or missing <filename class="directory">~/.cargo</filename>)
70 downloading the external cargo files for this version only takes a minute
71 or so on a fast network.
72 </para>
73
74 <note>
75 <para>
76 When you upgrade to a newer version, the new libraries will have various
77 hashes in their names and therefore there will be a mix of versions but
78 only one of each will be usable. A binary distribution would use its
79 package manager to delete all the old <application>rust</application>
80 installation before updating. You may wish to do the same to save space.
81 </para>
82
83 <para>
84 One alternative when working with multiple versions or just updating
85 to a new version is to place the files in the
86 <filename class="directory">/opt</filename> directory. The instructions
87 below provide optional commands to support better control of
88 new package versions or reinstallation of the current version.
89 </para>
90 </note>
91
92 <para>
93 The current <application>rustbuild</application> build-system will use
94 all available processors, although it does not scale well and often falls
95 back to just using one core while waiting for a library to compile.
96 </para>
97
98 <para>
99 At the moment <application>Rust</application> does not provide any
100 guarantees of a stable ABI.
101 </para>
102
103 <note>
104 <para>
105 Rustc defaults to building for ALL supported architectures, using a
106 shipped copy of LLVM. In BLFS the build is only for the X86 architecture.
107 If you intend to develop rust crates, this build may not be good
108 enough for your purposes.
109 </para>
110 <para>
111 Unlike with previous versions, the build times of this version when
112 repeated on the same machine seem reasonably consistent.
113 </para>
114 <para>
115 Unusually, a DESTDIR-style method is being used to install this package.
116 This is because running the install as root not only downloads all of the
117 cargo files again (to <filename>/root/.cargo</filename>), it then spends
118 a very long time recompiling. Using this method saves a lot of time, at
119 the cost of extra disk space.
120 </para>
121 </note>
122
123 &lfs83_checked;
124
125 <bridgehead renderas="sect3">Package Information</bridgehead>
126 <itemizedlist spacing="compact">
127 <listitem>
128 <para>
129 Download (HTTP): <ulink url="&rust-download-http;"/>
130 </para>
131 </listitem>
132 <listitem>
133 <para>
134 Download (FTP): <ulink url="&rust-download-ftp;"/>
135 </para>
136 </listitem>
137 <listitem>
138 <para>
139 Download MD5 sum: &rust-md5sum;
140 </para>
141 </listitem>
142 <listitem>
143 <para>
144 Download size: &rust-size;
145 </para>
146 </listitem>
147 <listitem>
148 <para>
149 Estimated disk space required: &rust-buildsize;
150 </para>
151 </listitem>
152 <listitem>
153 <para>
154 Estimated build time: &rust-time;
155 </para>
156 </listitem>
157 </itemizedlist>
158
159 <bridgehead renderas="sect3">Rust Dependencies</bridgehead>
160
161 <bridgehead renderas="sect4">Required</bridgehead>
162 <para role="required">
163 <xref linkend="curl"/>,
164 <xref linkend="cmake"/>,
165 <xref linkend="libssh2"/>, and
166 <xref linkend="python2"/>
167 </para>
168
169<!-- comment out while using shipped LLVM
170 <bridgehead renderas="sect4">Recommended</bridgehead>
171 <para role="recommended">
172 <package>clang</package> from <xref linkend="llvm"/>
173 (built with -DLLVM_LINK_LLVM_DYLIB=ON)
174 </para>-->
175
176 <bridgehead renderas="sect4">Optional</bridgehead>
177 <para role="optional">
178 <xref linkend="gdb"/> (used by the testsuite if it is present)
179 </para>
180
181 <para condition="html" role="usernotes">
182 User Notes: <ulink url="&blfs-wiki;/rust"/>
183 </para>
184 </sect2>
185
186 <sect2 role="installation">
187 <title>Installation of Rust</title>
188
189 <para>
190 If you are going to install into the
191 <filename class="directory">/opt</filename> directory, remove
192 conflicting entries. As the <systemitem class="username">root</systemitem>
193 user:
194 </para>
195
196<screen><userinput>rm -rf /opt/rustc /opt/rustc-&rust-version;</userinput></screen>
197
198 <para>
199 Create a suitable <filename>config.toml</filename> file which will
200 configure the build. Unlike with previous releases, where even quite old
201 system versions of <application>LLVM</application>worked well, this
202 version ships with a development version and using the current <xref
203 linkend="llvm"/> release is known to result in breakage in some
204 circumstances.
205 </para>
206
207<screen><userinput>cat &lt;&lt; EOF &gt; config.toml
208# see config.toml.example for more possible options
209[llvm]
210
211# use ninja
212ninja = true
213
214targets = "X86"
215# When compiling LLVM, the experimental targets (WebAssembly
216# and RISCV) are built by default - omit them
217experimental-targets = ""
218
219[build]
220# omit HTML docs to save time and space (comment this to build them)
221docs = false
222
223# install cargo as well as rust
224extended = true
225
226[install]
227prefix = "/usr"
228# docdir is used even if the full awesome docs are not installed
229docdir = "share/doc/rustc-&rust-version;"
230
231[rust]
232channel = "stable"
233rpath = false
234
235# BLFS does not install the FileCheck executable from llvm,
236# so disable codegen tests
237codegen-tests = false
238
239# get a trace if there is an Internal Compiler Exception
240backtrace-on-ice = true
241
242EOF</userinput></screen>
243
244 <para>
245 Now install <application>Rust</application> by running the following
246 commands:
247 </para>
248
249<screen><userinput>export RUSTFLAGS="$RUSTFLAGS -C link-args=-lffi" &amp;&amp;
250./x.py build --exclude src/tools/miri</userinput></screen>
251
252 <note>
253 <para>
254 The testsuite will generate some messages in the
255 <phrase revision="sysv">system log</phrase>
256 <phrase revision="systemd">systemd journal</phrase>
257 for traps on invalid opcodes, and for segmentation faults.
258 In themselves these are nothing to worry about, just a way for the
259 test to be terminated. But if the output from the testsuite reports tests
260 which FAIL with segmentation faults (signal 11) then there may be a
261 problem.
262 </para>
263 </note>
264
265 <para>
266 To run the tests issue
267 <command>./x.py test --verbose --no-fail-fast | tee rustc-testlog</command>:
268 as with the build, that will use all available CPUs.
269 </para>
270
271 <para>
272 The instructions above do not build ARM compilers, so the testsuite
273 <emphasis>will</emphasis> fail and the tests will be reported to end in
274 error, with a backtrace of the last failing test. On a good run, 3 tests
275 which need Thumb (ARM) compilers will fail, all in <filename
276 class="directory">ui/issues</filename> for issues 37131, 49851 and 50993.
277 Occasionally a fourth test, in run-make, 'sysroot-crates-are-unstable',
278 has been known to fail. That is probably harmless. As with all large
279 testsuites, other tests might fail on some machines - if the number of
280 failures is in the single digits, check the log for 'FAILED' and review
281 lines above that. Any mention of SIGSEGV or signal 11 in a failing test
282 is a cause for concern.
283 </para>
284
285 <para>
286 Therefore, you should determine the number of tests, failures, etc. The
287 total number of tests which were considered is found by running:
288 </para>
289
290<screen><command>grep 'running .* tests' rustc-testlog | awk '{ sum += $2 } END { print sum }'</command></screen>
291
292 <para>
293 That should report 15795 tests. Similarly, the total tests which failed can
294 be found by running:
295 </para>
296
297<screen><command>grep '^test result:' rustc-testlog | awk '{ sum += $6 } END { print sum }'</command></screen>
298
299 <para>
300 And similarly for the tests which passed use $4, for those which were ignored
301 (i.e. skipped) use $8 (and $10 for 'measured', $12 for 'filtered out' but both
302 are probably zero). The breakdown does not quite match the overall total.
303 </para>
304
305 <para>
306 Still as your normal user, do a DESTDIR install:
307 </para>
308
309<screen><userinput>export LIBSSH2_SYS_USE_PKG_CONFIG=1 &amp;&amp;
310DESTDIR=${PWD}/install ./x.py install &amp;&amp;
311unset LIBSSH2_SYS_USE_PKG_CONFIG</userinput></screen>
312
313 <para>
314 If installing in the <filename class="directory">/opt</filename>
315 directory, adjust the locations in the DESTDIR directory:
316 </para>
317
318<screen><command>mkdir -p install/opt/rustc-&rust-version; &amp;&amp;
319mv install/usr/* install/opt/rustc-&rust-version; &amp;&amp;
320rmdir install/usr</command></screen>
321
322 <para>
323 Now, as the <systemitem class="username">root</systemitem> user
324 install the files from the DESTDIR:
325 </para>
326
327<screen role="root"><userinput>chown -R root:root install &amp;&amp;
328cp -a install/* /</userinput></screen>
329
330 <para>
331 Finally, if the application is installed in the <filename
332 class="directory">/opt</filename> directory, create a symbolic link to
333 access the current version:
334 </para>
335
336<screen role="root"><userinput>ln -sfnv rustc-&rust-version; /opt/rustc</userinput></screen>
337
338 <note>
339 <para>
340 If multiple versions of <application>Rust</application> are installed
341 in <filename class="directory">/opt</filename>, changing to another
342 version only requires changing the <filename> /opt/rustc</filename>
343 symbolic link.
344 </para>
345 </note>
346
347
348 </sect2>
349
350 <sect2 role="commands">
351 <title>Command Explanations</title>
352
353 <para>
354 <command>targets = "X86"</command>: this avoids building all the available
355 linux cross-compilers (Aarch64, MIPS, PowerPC, SystemZ, etc). Unfortunately,
356 rust insists on installing source files for these below
357 <filename class="directory">/usr/lib/rustlib/src</filename>.
358 </para>
359
360 <para>
361 <command>extended = true</command>: this installs Cargo alongside Rust.
362 </para>
363
364 <para>
365 <command>channel = "stable"</command>: this ensures only stable features
366 can be used, the default in <filename>config.toml</filename> is to use
367 development features, which is not appropriate for a released version.
368 </para>
369
370 <para>
371 <command>rpath = false</command>: by default, <command>rust</command> can
372 be run from where it was built, without being installed. That adds DT_RPATH
373 entries to all of the ELF files, which produces very messy output from
374 <command>ldd</command>, showing the libraries in the place they were built,
375 even if they have been deleted from there after the install.
376 </para>
377
378 <!-- comment while using shipped LLVM
379 <para>
380 <command>[target.x86_64-unknown-linux-gnu]</command>: the syntax of
381 <filename>config.toml</filename> requires an <literal>llvm-config</literal>
382 entry for each target for which system-llvm is to be used. Change the target
383 to <literal>[target.i686-unknown-linux-gnu]</literal> if you are building
384 on 32-bit x86. This whole section may be omitted if you wish to build
385 against the shipped llvm, or do not have clang, but the resulting build will
386 be larger and take longer.
387 </para>-->
388
389 <para>
390 <command>export RUSTFLAGS="$RUSTFLAGS -C link-args=-lffi"</command>:
391 This adds a link to libffi to any RUSTFLAGS you may already be passing
392 to the build. On some systems, linking fails to include libffi unless
393 this is used. The reason why this is needed is not clear.
394 </para>
395
396 <para>
397 <command>--exclude src/tools/miri</command>: For a long time, the miri
398 crate (an interpreter for the Midlevel Intermediate Representation)
399 has failed to build on releases. It is optional, but the failure
400 messages can persuade people that the whole build failed.
401 </para>
402
403 <para>
404 <command>--verbose</command>: this switch can sometimes provide more
405 information about a test which fails.
406 </para>
407
408 <para>
409 <command>--no-fail-fast</command>: this switch ensures that the testsuite
410 will not stop at the first error.
411 </para>
412
413 <para>
414 <command>export LIBSSH2_SYS_USE_PKG_CONFIG=1</command>: On some systems,
415 cairo fails to link during the install because it cannot find libssh2.
416 This seems to fix it, but again the reason why the problem occurs is not
417 understood.
418 </para>
419
420 <para>
421 <command>DESTDIR=${PWD}/install ./x.py install</command>: This effects a
422 DESTDIR-style install in the source tree,creating an <filename
423 class="directory">install</filename> directory. Note that DESTDIR installs
424 need an absolute path, passing 'install' will not work.
425 </para>
426
427 <para>
428 <command>chown -R root:root install</command>: the DESTDIR install
429 was run by a regular user, who owns the files. For security, change their
430 owner before doing a simple copy to install them.
431 </para>
432
433 </sect2>
434
435 <sect2 role="configuration">
436 <title>Configuring Rust</title>
437
438 <sect3 id="rustc-config">
439 <title>Configuration Information</title>
440
441 <para>
442 If you installed <application>rustc</application> in
443 <filename class="directory">/opt</filename>, you need to update the
444 following configuration files so that <application>ruxtc</application> is
445 correctly found by other packages and system processes.
446 </para>
447
448 <para>
449 As the <systemitem class="username">root</systemitem> user, update
450 the <filename>/etc/ld.so.conf</filename> file and the dynamic linker's
451 run-time cache file:
452 </para>
453
454<screen role="root"><userinput>cat &gt;&gt; /etc/ld.so.conf &lt;&lt; EOF
455<literal># Begin rustc addition
456
457/opt/rustc/lib
458
459# End rustc addition</literal>
460EOF
461
462ldconfig</userinput></screen>
463
464 <indexterm zone="rustc rustc-config">
465 <primary sortas="e-etc-ld.so.conf">/etc/ld.so.conf</primary>
466 </indexterm>
467
468 <para>
469 As the <systemitem class="username">root</systemitem> user, create
470 the <filename>/etc/profile.d/rustc.sh</filename> file:
471 </para>
472
473<screen role="root"><userinput>cat &gt; /etc/profile.d/rustc.sh &lt;&lt; "EOF"
474<literal># Begin /etc/profile.d/rustc.sh
475
476pathprepend /opt/rustc/bin PATH
477
478# End /etc/profile.d/rustc.sh</literal>
479EOF</userinput></screen>
480
481 <para>Immediately after installation, update the current PATH
482 for your current shell as a normal user:</para>
483
484<screen><userinput>source /etc/profile.d/rustc.sh</userinput></screen>
485
486 </sect3>
487 </sect2>
488
489
490 <sect2 role="content">
491 <title>Contents</title>
492
493 <segmentedlist>
494 <segtitle>Installed Programs</segtitle>
495 <segtitle>Installed Libraries</segtitle>
496 <segtitle>Installed Directories</segtitle>
497
498 <seglistitem>
499 <seg>
500 cargo-clippy, cargo-fmt, cargo, clippy-driver, rls, rust-gdb, rust-lldb, rustc, rustdoc, rustfmt.
501 </seg>
502 <seg>
503 Many lib*&lt;16-byte-hash&gt;.so libraries.
504 </seg>
505 <seg>
506 ~/.cargo,
507 /usr/lib/rustlib,
508 /usr/share/doc/rustc-&rust-version;, and
509 /usr/share/zsh/site-functions/
510 </seg>
511 </seglistitem>
512 </segmentedlist>
513
514 <variablelist>
515 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
516 <?dbfo list-presentation="list"?>
517 <?dbhtml list-presentation="table"?>
518
519 <varlistentry id="cargo-clippy">
520 <term><command>cargo-clippy</command></term>
521 <listitem>
522 <para>
523 provides lint checks for a cargo package.
524 </para>
525 <indexterm zone="rust cargo-clippy">
526 <primary sortas="b-cargo-clippy">cargo-clippy</primary>
527 </indexterm>
528 </listitem>
529 </varlistentry>
530
531 <varlistentry id="cargo-fmt">
532 <term><command>cargo-fmt</command></term>
533 <listitem>
534 <para>
535 formats all bin and lib files of the current crate using
536 rustfmt.
537 </para>
538 <indexterm zone="rust cargo-fmt">
539 <primary sortas="b-cargo-fmt">cargo-fmt</primary>
540 </indexterm>
541 </listitem>
542 </varlistentry>
543
544 <varlistentry id="cargo">
545 <term><command>cargo</command></term>
546 <listitem>
547 <para>
548 is the Package Manager for Rust.
549 </para>
550 <indexterm zone="rust cargo">
551 <primary sortas="b-cargo">cargo</primary>
552 </indexterm>
553 </listitem>
554 </varlistentry>
555
556 <varlistentry id="clippy-driver">
557 <term><command>clippy-driver</command></term>
558 <listitem>
559 <para>
560 provides lint checks for Rust.
561 </para>
562 <indexterm zone="rust clippy-driver">
563 <primary sortas="b-clippy-driver">clippy-driver</primary>
564 </indexterm>
565 </listitem>
566 </varlistentry>
567
568 <varlistentry id="rls">
569 <term><command>rls</command></term>
570 <listitem>
571 <para>
572 is the Rust Language Server. This can run in the background to
573 provide IDEs, editors, and other tools with information about Rust
574 programs.
575 </para>
576 <indexterm zone="rust rls">
577 <primary sortas="b-rls">rls</primary>
578 </indexterm>
579 </listitem>
580 </varlistentry>
581
582 <varlistentry id="rust-gdb">
583 <term><command>rust-gdb</command></term>
584 <listitem>
585 <para>
586 is a wrapper script for gdb, pulling in Python
587 pretty-printing modules installed in <filename
588 class="directory">/usr/lib/rustlib/etc</filename>.
589 </para>
590 <indexterm zone="rust rust-gdb">
591 <primary sortas="b-rust-gdb">rust-gdb</primary>
592 </indexterm>
593 </listitem>
594 </varlistentry>
595
596 <varlistentry id="rust-lldb">
597 <term><command>rust-lldb</command></term>
598 <listitem>
599 <para>
600 is a wrapper script for LLDB (the LLVM debugger)
601 pulling in the Python pretty-printing modules.
602 </para>
603 <indexterm zone="rust rust-lldb">
604 <primary sortas="b-rust-lldb">rust=lldb</primary>
605 </indexterm>
606 </listitem>
607 </varlistentry>
608
609 <varlistentry id="rustc">
610 <term><command>rustc</command></term>
611 <listitem>
612 <para>
613 is the rust compiler.
614 </para>
615 <indexterm zone="rust rustc">
616 <primary sortas="b-rustc">rustc</primary>
617 </indexterm>
618 </listitem>
619 </varlistentry>
620
621 <varlistentry id="rustdoc">
622 <term><command>rustdoc</command></term>
623 <listitem>
624 <para>
625 generates documentation from rust source code.
626 </para>
627 <indexterm zone="rust rustdoc">
628 <primary sortas="b-rustdoc">rustdoc</primary>
629 </indexterm>
630 </listitem>
631 </varlistentry>
632
633 <varlistentry id="rustfmt">
634 <term><command>rustfmt</command></term>
635 <listitem>
636 <para>
637 formats rust code.
638 </para>
639 <indexterm zone="rust rustfmt">
640 <primary sortas="b-rustfmt">rustfmt</primary>
641 </indexterm>
642 </listitem>
643 </varlistentry>
644
645 <varlistentry id="libstd">
646 <term><filename class="libraryfile">libstd-&lt;16-byte-hash&gt;.so</filename></term>
647 <listitem>
648 <para>
649 is the Rust Standard Library, the foundation of portable Rust software.
650 </para>
651 <indexterm zone="rust libstd">
652 <primary sortas="c-libstd">libstd-&lt;16-byte-hash&gt;.so</primary>
653 </indexterm>
654 </listitem>
655 </varlistentry>
656 </variablelist>
657 </sect2>
658</sect1>
Note: See TracBrowser for help on using the repository browser.