source: general/prog/rust.xml@ bb0652ca

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 8.3 8.4 9.0 9.1 basic bdubbs/svn elogind kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts lazarus lxqt perl-modules 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 bb0652ca was bb0652ca, checked in by Ken Moffat <ken@…>, 6 years ago

Attempt to make rustc build agaisnt system llvm for everyone.

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

  • Property mode set to 100644
File size: 16.2 KB
RevLine 
[03d537cd]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
[614fc25f]7 <!ENTITY rust-download-http "https://static.rust-lang.org/dist/rustc-&rust-version;-src.tar.gz">
[d9bcc5f]8 <!ENTITY rust-download-ftp " ">
[a7b1bddc]9 <!ENTITY rust-md5sum "d8d4d30c8d0b905f978bee3fdd618db5">
10 <!ENTITY rust-size "95 MB">
11 <!ENTITY rust-buildsize "5.1 GB (440 MB installed) including 379MB of ~/.cargo files for the user building this and 440MB of files in the DESTDIR (add 1.2GB if running the tests)">
12 <!ENTITY rust-time "33 SBU (add 17 SBU for tests, both with 4 processors)">
[03d537cd]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)
[a7b1bddc]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
[03d537cd]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
[4c6edac]53 guarantees of a stable ABI.
[03d537cd]54 </para>
55
[326f830]56 <note>
57 <para>
58 Repeated builds of this package on the same machine show a wide range
59 of build times. Some of this might be due to variations in downloading
60 the required cargo files if they are not already present, but this does
[a7b1bddc]61 not seem to adequately explain the variations.
[326f830]62 </para>
63 <para>
[bb0652ca]64 Unusually, a DESTDIR-style method is being used to install this package.
65 This is because running the install as root not only downloads all of the
[a7b1bddc]66 cargo files again (to <filename>/root/.cargo</filename>), it then spends
[bb0652ca]67 a very long time recompiling. Using this method saves 30 SBU on the
[a7b1bddc]68 4-core machine where this was tested, at the cost of an extra 60MB of
69 disk space for the extra files.
[326f830]70 </para>
71 </note>
72
[0a43695]73 &lfs82_checked;
[03d537cd]74
75 <bridgehead renderas="sect3">Package Information</bridgehead>
76 <itemizedlist spacing="compact">
77 <listitem>
78 <para>
79 Download (HTTP): <ulink url="&rust-download-http;"/>
80 </para>
81 </listitem>
82 <listitem>
83 <para>
84 Download (FTP): <ulink url="&rust-download-ftp;"/>
85 </para>
86 </listitem>
87 <listitem>
88 <para>
89 Download MD5 sum: &rust-md5sum;
90 </para>
91 </listitem>
92 <listitem>
93 <para>
94 Download size: &rust-size;
95 </para>
96 </listitem>
97 <listitem>
98 <para>
99 Estimated disk space required: &rust-buildsize;
100 </para>
101 </listitem>
102 <listitem>
103 <para>
104 Estimated build time: &rust-time;
105 </para>
106 </listitem>
107 </itemizedlist>
108
109 <bridgehead renderas="sect3">Rust Dependencies</bridgehead>
110
111 <bridgehead renderas="sect4">Required</bridgehead>
112 <para role="required">
113 <xref linkend="curl"/>,
[4c6edac]114 <xref linkend="cmake"/>,
[a7b1bddc]115<!-- Although this appears to build with python3, there are sometimes strange
116 script errors in the compilation (i.e. it exits after the build, without
117 any obvious errors and with a good status. Also ,it ships with a configure
118 script which invokes python2.7 to create config.toml, and some of the files
119 in the package use python2.7. -->
[03d537cd]120 <xref linkend="python2"/>
121 </para>
122
[a7b1bddc]123 <bridgehead renderas="sect4">Recommended</bridgehead>
124 <para role="recommended">
125 <package>clang</package> from <xref linkend="llvm"/>
[bb0652ca]126 (built with -DLLVM_LINK_LLVM_DYLIB=ON)
[a7b1bddc]127 </para>
128
[03d537cd]129 <bridgehead renderas="sect4">Optional</bridgehead>
130 <para role="optional">
[60ddbaf]131 <xref linkend="gdb"/> (used by debuginfo-gdb in the testsuite)
[03d537cd]132 </para>
133
134 <para condition="html" role="usernotes">
135 User Notes: <ulink url="&blfs-wiki;/rust"/>
136 </para>
137 </sect2>
138
139 <sect2 role="installation">
140 <title>Installation of Rust</title>
141
[4c6edac]142 <note>
143 <para>
144 This package is updated on a six-weekly release cycle. Because it is
145 such a large and slow package to build, and is at the moment only used
[948f91a1]146 by two packages in this book, the BLFS editors take the view that it
[4c6edac]147 should only be updated when that is necessary.
148 </para>
149 </note>
150
[03d537cd]151 <para>
[4c6edac]152 First create a suitable <filename>config.toml</filename> file
153 which will configure the build :
154 </para>
155
156<screen><userinput>cat &lt;&lt;EOF &gt; config.toml
[326f830]157# see config.toml.example for more possible options
[4c6edac]158[llvm]
159targets = "X86"
160
[a7b1bddc]161# When using system llvm prefer shared libraries
162link-shared = true
163
[4c6edac]164[build]
165# install cargo as well as rust
166extended = true
167
168[install]
169prefix = "/usr"
[326f830]170docdir = "share/doc/rustc-&rust-version;"
171
172[rust]
[4c6edac]173channel = "stable"
[326f830]174rpath = false
[a7b1bddc]175
176# get reasonably clean output from the test harness
177quiet-tests = true
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
[4c6edac]189EOF</userinput></screen>
190
191 <para>
192 Now install <application>Rust</application> by running the following
[03d537cd]193 commands:
194 </para>
195
[bb0652ca]196<screen><userinput>export RUSTFLAGS="$RUSTFLAGS -C link-args=-lffi" &amp;&amp;
197./x.py build</userinput></screen>
[03d537cd]198
[a7b1bddc]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
[03d537cd]225 <para>
[4c6edac]226 To run the tests issue
227 <command>./x.py test --verbose --no-fail-fast &gt;../rustc-testlog</command>:
[9dc2505]228 as with the build, that will use all available CPUs. This runs many suites
[a7b1bddc]229 of tests (in an apparently random order), at least one will fail:
230 compile-fail/issue-37131.rs tries to
231 compile for the thumbv6m-none-eabi target but the BLFS build does not cater for
232 that, and many tests in debuginfo-gdb will fail if
233 <application>gdb</application> has not been installed. A few other tests might
234 fail.
[03d537cd]235 </para>
236
237 <para>
[4c6edac]238 If you wish to look at the numbers for the results, you can find the total
239 number of tests which were considered by running:
[03d537cd]240 </para>
241
[4c6edac]242<screen><command>grep 'running .* tests' ../rustc-testlog | awk '{ sum += $2 } END { print sum }'</command></screen>
243
[03d537cd]244 <para>
[a7b1bddc]245 That should report 13224 tests. Similarly, the total tests which failed can
[4c6edac]246 be found by running:
[03d537cd]247 </para>
248
[4c6edac]249<screen><command>grep '^test result:' ../rustc-testlog | awk '{ sum += $6 } END { print sum }'</command></screen>
[03d537cd]250
[4c6edac]251 <para>
252 And similarly for the tests which passed use $4, for those which were ignored
253 (i.e. skipped) use $8 (and $10 for 'measured', $12 for 'filtered out' but both
254 are probably zero). The breakdown does not match the overall total.
255 </para>
256
257 <para>
[a7b1bddc]258 Still as your normal user, do a DESTDIR install:
[4c6edac]259 </para>
260
[bb0652ca]261<screen><userinput>DESTDIR=${PWD}/install ./x.py install</userinput></screen>
[a7b1bddc]262
263 <para>
264 Now, as the <systemitem class="username">root</systemitem> user
265 install the files from the DESTDIR:
266 </para>
267
[bb0652ca]268<screen role="root"><userinput>chown -R root:root install &amp;&amp;
269cp -a install/* /</userinput></screen>
[a7b1bddc]270
[03d537cd]271 </sect2>
272
273 <sect2 role="commands">
274 <title>Command Explanations</title>
275
276 <para>
[4c6edac]277 <command>targets = "X86"</command>: this avoids building all the available
[a7b1bddc]278 linux cross-compilers (Aarch64, MIPS, PowerPC, SystemZ, etc). Unfortunately,
279 rust insists on installing source files for these below
280 <filename class="directory">/usr/lib/rustlib/src</filename>.
[03d537cd]281 </para>
282
283 <para>
[4c6edac]284 <command>extended = true</command>: this installs Cargo alongside Rust.
[03d537cd]285 </para>
286
287 <para>
[4c6edac]288 <command>channel = "stable"</command>: this ensures only stable features
289 can be used, the default in <filename>config.toml</filename> is to use
290 development features, which is not appropriate for a released version.
[03d537cd]291 </para>
292
[326f830]293 <para>
294 <command>rpath = false</command>: by default, <command>rust</command> can
295 be run from where it was built, without being installed. That adds DT_RPATH
296 entries to all of the ELF files, which produces very messy output from
297 <command>ldd</command>, showing the libraries in the place they were built,
298 even if they have been deleted from there after the install.
299 </para>
300
[a7b1bddc]301 <para>
302 <command>[target.x86_64-unknown-linux-gnu]</command>: the syntax of
303 <filename>config.toml</filename> requires an <literal>llvm-config</literal>
304 entry for each target for which system-llvm is to be used. Change the target
305 to <literal>[target.i686-unknown-linux-gnu]</literal> if you are building
306 on 32-bit x86. This whole section may be omitted if you wish to build
307 against the shipped llvm, or do not have clang, but the resulting build will
308 be larger and take a little longer.
309 </para>
310
[bb0652ca]311 <para>
312 <command>export RUSTFLAGS="$RUSTFLAGS -C link-args=-lffi"</command>:
313 This adds a link to libffi to any RUSTFLAGS you may already be passing
314 to the build. On some systems, linking fails to include libffi unless
315 this is used. The reason why this is needed is not clear.
316 </para>
317
[03d537cd]318 <para>
[4c6edac]319 <command>--verbose</command>: this switch can sometimes provide more
320 information about a test which fails.
[03d537cd]321 </para>
[4c6edac]322
323 <para>
324 <command>--no-fail-fast</command>: this switch ensures that the testsuite
325 will not stop at the first error.
326 </para>
327
[326f830]328 <para>
[bb0652ca]329 <command>DESTDIR=${PWD}/install ./x.py install</command>: This effects a
330 DESTDIR-style install in the source tree,creating an <filename
331 class="directory">install</filename> directory. Note that DESTDIR installs
332 need an absolute path, passing 'install' will not work.
[a7b1bddc]333 </para>
334
335 <para>
[bb0652ca]336 <command>chown -R root:root install</command>: the DESTDIR install
[a7b1bddc]337 was run by a regular user, who owns the files. For security, change their
338 owner before doing a simple copy to install them.
[326f830]339 </para>
340
[03d537cd]341 </sect2>
342
343 <sect2 role="content">
344 <title>Contents</title>
345
346 <segmentedlist>
[78399edc]347 <segtitle>Installed Programs</segtitle>
348 <segtitle>Installed Libraries</segtitle>
349 <segtitle>Installed Directories</segtitle>
[03d537cd]350
351 <seglistitem>
352 <seg>
[a7b1bddc]353 cargo-fmt, cargo, rls, rust-gdb, rust-lldb, rustc, rustdoc, rustfmt.
[03d537cd]354 </seg>
355 <seg>
[4c6edac]356 Many lib*&lt;16-byte-hash&gt;.so libraries.
[03d537cd]357 </seg>
358 <seg>
359 ~/.cargo,
[4c6edac]360 /usr/lib/rustlib,
361 /usr/share/doc/rustc-&rust-version;, and
362 /usr/share/zsh/site-functions/
[03d537cd]363 </seg>
364 </seglistitem>
365 </segmentedlist>
366
367 <variablelist>
368 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
369 <?dbfo list-presentation="list"?>
370 <?dbhtml list-presentation="table"?>
371
[a7b1bddc]372 <varlistentry id="cargo-fmt">
373 <term><command>cargo-fmt</command></term>
374 <listitem>
375 <para>
376 formats all bin and lib files of the current crate using
377 rustfmt.
378 </para>
379 <indexterm zone="rust cargo-fmt">
380 <primary sortas="b-cargo-fmt">cargo-fmt</primary>
381 </indexterm>
382 </listitem>
383 </varlistentry>
384
[4c6edac]385 <varlistentry id="cargo">
386 <term><command>cargo</command></term>
387 <listitem>
388 <para>
389 is the Package Manager for Rust.
390 </para>
391 <indexterm zone="rust cargo">
392 <primary sortas="b-cargo">cargo</primary>
393 </indexterm>
394 </listitem>
395 </varlistentry>
396
[326f830]397 <varlistentry id="rls">
398 <term><command>rls</command></term>
399 <listitem>
400 <para>
401 is the Rust Language Server. This can run in the background to
402 provide IDEs, editors, and other tools with information about Rust
403 programs.
404 </para>
405 <indexterm zone="rust rls">
406 <primary sortas="b-rls">rls</primary>
407 </indexterm>
408 </listitem>
409 </varlistentry>
410
[03d537cd]411 <varlistentry id="rust-gdb">
412 <term><command>rust-gdb</command></term>
413 <listitem>
414 <para>
[a7b1bddc]415 is a wrapper script for gdb, pulling in Python
416 pretty-printing modules installed in <filename
417 class="directory">/usr/lib/rustlib/etc</filename>.
[03d537cd]418 </para>
419 <indexterm zone="rust rust-gdb">
420 <primary sortas="b-rust-gdb">rust-gdb</primary>
421 </indexterm>
422 </listitem>
423 </varlistentry>
424
425 <varlistentry id="rust-lldb">
426 <term><command>rust-lldb</command></term>
427 <listitem>
428 <para>
[a7b1bddc]429 is a wrapper script for LLDB (the LLVM debugger)
430 pulling in the Python pretty-printing modules.
[03d537cd]431 </para>
432 <indexterm zone="rust rust-lldb">
433 <primary sortas="b-rust-lldb">rust=lldb</primary>
434 </indexterm>
435 </listitem>
436 </varlistentry>
437
438 <varlistentry id="rustc">
439 <term><command>rustc</command></term>
440 <listitem>
441 <para>
442 is the rust compiler.
443 </para>
444 <indexterm zone="rust rustc">
445 <primary sortas="b-rustc">rustc</primary>
446 </indexterm>
447 </listitem>
448 </varlistentry>
449
450 <varlistentry id="rustdoc">
451 <term><command>rustdoc</command></term>
452 <listitem>
453 <para>
454 generates documentation from rust source code.
455 </para>
456 <indexterm zone="rust rustdoc">
457 <primary sortas="b-rustdoc">rustdoc</primary>
458 </indexterm>
459 </listitem>
460 </varlistentry>
461
[a7b1bddc]462 <varlistentry id="rustfmt">
463 <term><command>rustfmt</command></term>
464 <listitem>
465 <para>
466 formats rust code.
467 </para>
468 <indexterm zone="rust rustfmt">
469 <primary sortas="b-rustfmt">rustfmt</primary>
470 </indexterm>
471 </listitem>
472 </varlistentry>
473
[03d537cd]474 <varlistentry id="libstd">
475 <term><filename class="libraryfile">libstd-&lt;16-byte-hash&gt;.so</filename></term>
476 <listitem>
477 <para>
478 is the Rust Standard Library, the foundation of portable Rust software.
479 </para>
480 <indexterm zone="rust libstd">
481 <primary sortas="c-libstd">libstd-&lt;16-byte-hash&gt;.so</primary>
482 </indexterm>
483 </listitem>
484 </varlistentry>
485 </variablelist>
486 </sect2>
487</sect1>
Note: See TracBrowser for help on using the repository browser.