2017-04-15 00:32:03 +08:00
<?xml version="1.0" encoding="ISO-8859-1"?>
< !DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % general-entities SYSTEM "../../general.ent">
%general-entities;
2017-04-21 01:28:42 +08:00
<!ENTITY rust-download-http "https://static.rust-lang.org/dist/rustc-&rust-version;-src.tar.gz">
2017-09-12 12:00:04 +08:00
<!ENTITY rust-download-ftp " ">
2018-04-14 09:41:40 +08:00
<!ENTITY rust-md5sum "d8d4d30c8d0b905f978bee3fdd618db5">
<!ENTITY rust-size "95 MB">
<!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)">
<!ENTITY rust-time "33 SBU (add 17 SBU for tests, both with 4 processors)">
2017-04-15 00:32:03 +08:00
]>
<sect1 id= "rust" xreflabel= "rustc-&rust-version;" >
<?dbhtml filename="rust.html"?>
<sect1info >
<othername > $LastChangedBy$</othername>
<date > $Date$</date>
</sect1info>
<title > Rustc-&rust-version; </title>
<indexterm zone= "rust" >
<primary sortas= "a-rust" > Rust</primary>
</indexterm>
<sect2 role= "package" >
<title > Introduction to Rust</title>
<para >
The <application > Rust</application> programming language is designed
to be a safe, concurrent, practical language.
</para>
<para >
As with many other programming languages, rustc (the rust compiler)
2018-04-14 09:41:40 +08:00
needs a binary from which to bootstrap. It will download a stage0 binary
and many cargo crates (these are actually .tar.gz source archives) at
2017-04-15 00:32:03 +08:00
the start of the build, so you cannot compile it without an internet
connection.
</para>
<para >
The current <application > rustbuild</application> build-system will use
all available processors, although it does not scale well and often falls
back to just using one core while waiting for a library to compile.
</para>
<para >
At the moment <application > Rust</application> does not provide any
2017-08-29 03:55:17 +08:00
guarantees of a stable ABI.
2017-04-15 00:32:03 +08:00
</para>
2018-01-24 09:54:48 +08:00
<note >
<para >
Repeated builds of this package on the same machine show a wide range
of build times. Some of this might be due to variations in downloading
the required cargo files if they are not already present, but this does
2018-04-14 09:41:40 +08:00
not seem to adequately explain the variations.
2018-01-24 09:54:48 +08:00
</para>
<para >
2018-04-16 09:00:07 +08:00
Unusually, a DESTDIR-style method is being used to install this package.
This is because running the install as root not only downloads all of the
2018-04-14 09:41:40 +08:00
cargo files again (to <filename > /root/.cargo</filename> ), it then spends
2018-04-16 09:00:07 +08:00
a very long time recompiling. Using this method saves 30 SBU on the
2018-04-14 09:41:40 +08:00
4-core machine where this was tested, at the cost of an extra 60MB of
disk space for the extra files.
2018-01-24 09:54:48 +08:00
</para>
</note>
2018-08-20 05:04:57 +08:00
&lfs83_checked;
2017-04-15 00:32:03 +08:00
<bridgehead renderas= "sect3" > Package Information</bridgehead>
<itemizedlist spacing= "compact" >
<listitem >
<para >
Download (HTTP): <ulink url= "&rust-download-http;" />
</para>
</listitem>
<listitem >
<para >
Download (FTP): <ulink url= "&rust-download-ftp;" />
</para>
</listitem>
<listitem >
<para >
Download MD5 sum: &rust-md5sum;
</para>
</listitem>
<listitem >
<para >
Download size: &rust-size;
</para>
</listitem>
<listitem >
<para >
Estimated disk space required: &rust-buildsize;
</para>
</listitem>
<listitem >
<para >
Estimated build time: &rust-time;
</para>
</listitem>
</itemizedlist>
<bridgehead renderas= "sect3" > Rust Dependencies</bridgehead>
<bridgehead renderas= "sect4" > Required</bridgehead>
<para role= "required" >
<xref linkend= "curl" /> ,
2017-08-29 03:55:17 +08:00
<xref linkend= "cmake" /> ,
2018-08-20 05:04:57 +08:00
<xref linkend= "libssh2" /> ,
2018-04-14 09:41:40 +08:00
<!-- Although this appears to build with python3, there are sometimes strange
script errors in the compilation (i.e. it exits after the build, without
any obvious errors and with a good status. Also ,it ships with a configure
script which invokes python2.7 to create config.toml, and some of the files
in the package use python2.7. -->
2017-04-15 00:32:03 +08:00
<xref linkend= "python2" />
</para>
2018-04-14 09:41:40 +08:00
<bridgehead renderas= "sect4" > Recommended</bridgehead>
<para role= "recommended" >
<package > clang</package> from <xref linkend= "llvm" />
2018-04-16 09:00:07 +08:00
(built with -DLLVM_LINK_LLVM_DYLIB=ON)
2018-04-14 09:41:40 +08:00
</para>
2017-04-15 00:32:03 +08:00
<bridgehead renderas= "sect4" > Optional</bridgehead>
<para role= "optional" >
2017-10-16 02:23:25 +08:00
<xref linkend= "gdb" /> (used by debuginfo-gdb in the testsuite)
2017-04-15 00:32:03 +08:00
</para>
<para condition= "html" role= "usernotes" >
User Notes: <ulink url= "&blfs-wiki;/rust" />
</para>
</sect2>
<sect2 role= "installation" >
<title > Installation of Rust</title>
2017-08-29 03:55:17 +08:00
<note >
<para >
This package is updated on a six-weekly release cycle. Because it is
2018-08-19 06:23:25 +08:00
such a large and slow package to build, and is at the moment only required
by three packages in this book, the BLFS editors take the view that it
2017-08-29 03:55:17 +08:00
should only be updated when that is necessary.
</para>
</note>
2017-04-15 00:32:03 +08:00
<para >
2017-08-29 03:55:17 +08:00
First create a suitable <filename > config.toml</filename> file
which will configure the build :
</para>
2018-08-20 05:04:57 +08:00
<screen > <userinput > cat < < EOF > config.toml
2018-01-24 09:54:48 +08:00
# see config.toml.example for more possible options
2017-08-29 03:55:17 +08:00
[llvm]
targets = "X86"
2018-04-14 09:41:40 +08:00
# When using system llvm prefer shared libraries
link-shared = true
2017-08-29 03:55:17 +08:00
[build]
# install cargo as well as rust
extended = true
[install]
prefix = "/usr"
2018-01-24 09:54:48 +08:00
docdir = "share/doc/rustc-&rust-version; "
[rust]
2017-08-29 03:55:17 +08:00
channel = "stable"
2018-01-24 09:54:48 +08:00
rpath = false
2018-04-14 09:41:40 +08:00
# get reasonably clean output from the test harness
quiet-tests = true
# BLFS does not install the FileCheck executable from llvm,
# so disable codegen tests
codegen-tests = false
[target.x86_64-unknown-linux-gnu]
# delete this *section* if you are not using system llvm.
# NB the output of llvm-config (i.e. help options) may be
# dumped to the screen when config.toml is parsed.
llvm-config = "/usr/bin/llvm-config"
2017-08-29 03:55:17 +08:00
EOF</userinput> </screen>
<para >
Now install <application > Rust</application> by running the following
2017-04-15 00:32:03 +08:00
commands:
</para>
2018-04-16 09:00:07 +08:00
<screen > <userinput > export RUSTFLAGS="$RUSTFLAGS -C link-args=-lffi" & &
./x.py build</userinput> </screen>
2017-04-15 00:32:03 +08:00
2018-04-14 09:41:40 +08:00
<para >
The build will report it failed to compile <filename > miri</filename>
because of multiple potential crates for `log`, but that should be followed
by a message that the build completed successfully.
</para>
<caution >
<para >
On AMD Ryzen processors (family 17h), the non-optimized version of libstd
which is compiled at the start of the tests contains two opcodes which are
not implemented on this CPU family. These will be logged in the
<phrase revision= "sysv" > system log</phrase>
<phrase revision= "systemd" > systemd journal</phrase>
and will be followed a few minutes later by segmentation faults. Despite
that, the tests continue to run, apparently normally. But the system may
reboot before the tests have completed. The normal optimized libraries
run without this problem.
</para>
<para >
A mitigation is to install gdb
<!-- systemd apparently handles this with systemd - coredump -->
<phrase revision= "sysv" > and to run the tests with 'ulimit -C disabled'</phrase>
but this does not always prevent the system rebooting.
</para>
</caution>
2017-04-15 00:32:03 +08:00
<para >
2017-08-29 03:55:17 +08:00
To run the tests issue
<command > ./x.py test --verbose --no-fail-fast > ../rustc-testlog</command> :
2017-09-28 23:06:12 +08:00
as with the build, that will use all available CPUs. This runs many suites
2018-04-14 09:41:40 +08:00
of tests (in an apparently random order), at least one will fail:
compile-fail/issue-37131.rs tries to
compile for the thumbv6m-none-eabi target but the BLFS build does not cater for
that, and many tests in debuginfo-gdb will fail if
<application > gdb</application> has not been installed. A few other tests might
fail.
2017-04-15 00:32:03 +08:00
</para>
<para >
2017-08-29 03:55:17 +08:00
If you wish to look at the numbers for the results, you can find the total
number of tests which were considered by running:
2017-04-15 00:32:03 +08:00
</para>
2017-08-29 03:55:17 +08:00
<screen > <command > grep 'running .* tests' ../rustc-testlog | awk '{ sum += $2 } END { print sum }'</command> </screen>
2017-04-15 00:32:03 +08:00
<para >
2018-04-14 09:41:40 +08:00
That should report 13224 tests. Similarly, the total tests which failed can
2017-08-29 03:55:17 +08:00
be found by running:
2017-04-15 00:32:03 +08:00
</para>
2017-08-29 03:55:17 +08:00
<screen > <command > grep '^test result:' ../rustc-testlog | awk '{ sum += $6 } END { print sum }'</command> </screen>
2017-04-15 00:32:03 +08:00
2017-08-29 03:55:17 +08:00
<para >
And similarly for the tests which passed use $4, for those which were ignored
(i.e. skipped) use $8 (and $10 for 'measured', $12 for 'filtered out' but both
are probably zero). The breakdown does not match the overall total.
</para>
<para >
2018-04-14 09:41:40 +08:00
Still as your normal user, do a DESTDIR install:
2017-08-29 03:55:17 +08:00
</para>
2018-09-23 05:46:42 +08:00
<screen > <userinput > export LIBSSH2_SYS_USE_PKG_CONFIG=1 & &
DESTDIR=${PWD}/install ./x.py install & &
unset LIBSSH2_SYS_USE_PKG_CONFIG</userinput> </screen>
2018-04-14 09:41:40 +08:00
<para >
Now, as the <systemitem class= "username" > root</systemitem> user
install the files from the DESTDIR:
</para>
2018-04-16 09:00:07 +08:00
<screen role= "root" > <userinput > chown -R root:root install & &
cp -a install/* /</userinput> </screen>
2018-04-14 09:41:40 +08:00
2017-04-15 00:32:03 +08:00
</sect2>
<sect2 role= "commands" >
<title > Command Explanations</title>
<para >
2017-08-29 03:55:17 +08:00
<command > targets = "X86"</command> : this avoids building all the available
2018-04-14 09:41:40 +08:00
linux cross-compilers (Aarch64, MIPS, PowerPC, SystemZ, etc). Unfortunately,
rust insists on installing source files for these below
<filename class= "directory" > /usr/lib/rustlib/src</filename> .
2017-04-15 00:32:03 +08:00
</para>
<para >
2017-08-29 03:55:17 +08:00
<command > extended = true</command> : this installs Cargo alongside Rust.
2017-04-15 00:32:03 +08:00
</para>
<para >
2017-08-29 03:55:17 +08:00
<command > channel = "stable"</command> : this ensures only stable features
can be used, the default in <filename > config.toml</filename> is to use
development features, which is not appropriate for a released version.
2017-04-15 00:32:03 +08:00
</para>
2018-01-24 09:54:48 +08:00
<para >
<command > rpath = false</command> : by default, <command > rust</command> can
be run from where it was built, without being installed. That adds DT_RPATH
entries to all of the ELF files, which produces very messy output from
<command > ldd</command> , showing the libraries in the place they were built,
even if they have been deleted from there after the install.
</para>
2018-04-14 09:41:40 +08:00
<para >
<command > [target.x86_64-unknown-linux-gnu]</command> : the syntax of
<filename > config.toml</filename> requires an <literal > llvm-config</literal>
entry for each target for which system-llvm is to be used. Change the target
to <literal > [target.i686-unknown-linux-gnu]</literal> if you are building
on 32-bit x86. This whole section may be omitted if you wish to build
against the shipped llvm, or do not have clang, but the resulting build will
be larger and take a little longer.
</para>
2018-04-16 09:00:07 +08:00
<para >
<command > export RUSTFLAGS="$RUSTFLAGS -C link-args=-lffi"</command> :
This adds a link to libffi to any RUSTFLAGS you may already be passing
to the build. On some systems, linking fails to include libffi unless
this is used. The reason why this is needed is not clear.
</para>
2017-04-15 00:32:03 +08:00
<para >
2017-08-29 03:55:17 +08:00
<command > --verbose</command> : this switch can sometimes provide more
information about a test which fails.
2017-04-15 00:32:03 +08:00
</para>
2017-08-29 03:55:17 +08:00
<para >
<command > --no-fail-fast</command> : this switch ensures that the testsuite
will not stop at the first error.
</para>
2018-09-23 05:46:42 +08:00
<para >
<command > export LIBSSH2_SYS_USE_PKG_CONFIG=1</command> : On some systems,
cairo fails to link during the install because it cannot find libssh2.
This seems to fix it, but again the reason why the problem occurs is not
understood.
</para>
2018-01-24 09:54:48 +08:00
<para >
2018-04-16 09:00:07 +08:00
<command > DESTDIR=${PWD}/install ./x.py install</command> : This effects a
DESTDIR-style install in the source tree,creating an <filename
class="directory">install</filename> directory. Note that DESTDIR installs
need an absolute path, passing 'install' will not work.
2018-04-14 09:41:40 +08:00
</para>
<para >
2018-04-16 09:00:07 +08:00
<command > chown -R root:root install</command> : the DESTDIR install
2018-04-14 09:41:40 +08:00
was run by a regular user, who owns the files. For security, change their
owner before doing a simple copy to install them.
2018-01-24 09:54:48 +08:00
</para>
2017-04-15 00:32:03 +08:00
</sect2>
<sect2 role= "content" >
<title > Contents</title>
<segmentedlist >
2017-05-10 05:33:35 +08:00
<segtitle > Installed Programs</segtitle>
<segtitle > Installed Libraries</segtitle>
<segtitle > Installed Directories</segtitle>
2017-04-15 00:32:03 +08:00
<seglistitem >
<seg >
2018-04-14 09:41:40 +08:00
cargo-fmt, cargo, rls, rust-gdb, rust-lldb, rustc, rustdoc, rustfmt.
2017-04-15 00:32:03 +08:00
</seg>
<seg >
2017-08-29 03:55:17 +08:00
Many lib*< 16-byte-hash> .so libraries.
2017-04-15 00:32:03 +08:00
</seg>
<seg >
~/.cargo,
2017-08-29 03:55:17 +08:00
/usr/lib/rustlib,
/usr/share/doc/rustc-&rust-version; , and
/usr/share/zsh/site-functions/
2017-04-15 00:32:03 +08:00
</seg>
</seglistitem>
</segmentedlist>
<variablelist >
<bridgehead renderas= "sect3" > Short Descriptions</bridgehead>
<?dbfo list-presentation="list"?>
<?dbhtml list-presentation="table"?>
2018-04-14 09:41:40 +08:00
<varlistentry id= "cargo-fmt" >
<term > <command > cargo-fmt</command> </term>
<listitem >
<para >
formats all bin and lib files of the current crate using
rustfmt.
</para>
<indexterm zone= "rust cargo-fmt" >
<primary sortas= "b-cargo-fmt" > cargo-fmt</primary>
</indexterm>
</listitem>
</varlistentry>
2017-08-29 03:55:17 +08:00
<varlistentry id= "cargo" >
<term > <command > cargo</command> </term>
<listitem >
<para >
is the Package Manager for Rust.
</para>
<indexterm zone= "rust cargo" >
<primary sortas= "b-cargo" > cargo</primary>
</indexterm>
</listitem>
</varlistentry>
2018-01-24 09:54:48 +08:00
<varlistentry id= "rls" >
<term > <command > rls</command> </term>
<listitem >
<para >
is the Rust Language Server. This can run in the background to
provide IDEs, editors, and other tools with information about Rust
programs.
</para>
<indexterm zone= "rust rls" >
<primary sortas= "b-rls" > rls</primary>
</indexterm>
</listitem>
</varlistentry>
2017-04-15 00:32:03 +08:00
<varlistentry id= "rust-gdb" >
<term > <command > rust-gdb</command> </term>
<listitem >
<para >
2018-04-14 09:41:40 +08:00
is a wrapper script for gdb, pulling in Python
pretty-printing modules installed in <filename
class="directory">/usr/lib/rustlib/etc</filename> .
2017-04-15 00:32:03 +08:00
</para>
<indexterm zone= "rust rust-gdb" >
<primary sortas= "b-rust-gdb" > rust-gdb</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id= "rust-lldb" >
<term > <command > rust-lldb</command> </term>
<listitem >
<para >
2018-04-14 09:41:40 +08:00
is a wrapper script for LLDB (the LLVM debugger)
pulling in the Python pretty-printing modules.
2017-04-15 00:32:03 +08:00
</para>
<indexterm zone= "rust rust-lldb" >
<primary sortas= "b-rust-lldb" > rust=lldb</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id= "rustc" >
<term > <command > rustc</command> </term>
<listitem >
<para >
is the rust compiler.
</para>
<indexterm zone= "rust rustc" >
<primary sortas= "b-rustc" > rustc</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id= "rustdoc" >
<term > <command > rustdoc</command> </term>
<listitem >
<para >
generates documentation from rust source code.
</para>
<indexterm zone= "rust rustdoc" >
<primary sortas= "b-rustdoc" > rustdoc</primary>
</indexterm>
</listitem>
</varlistentry>
2018-04-14 09:41:40 +08:00
<varlistentry id= "rustfmt" >
<term > <command > rustfmt</command> </term>
<listitem >
<para >
formats rust code.
</para>
<indexterm zone= "rust rustfmt" >
<primary sortas= "b-rustfmt" > rustfmt</primary>
</indexterm>
</listitem>
</varlistentry>
2017-04-15 00:32:03 +08:00
<varlistentry id= "libstd" >
<term > <filename class= "libraryfile" > libstd-< 16-byte-hash> .so</filename> </term>
<listitem >
<para >
is the Rust Standard Library, the foundation of portable Rust software.
</para>
<indexterm zone= "rust libstd" >
<primary sortas= "c-libstd" > libstd-< 16-byte-hash> .so</primary>
</indexterm>
</listitem>
</varlistentry>
</variablelist>
</sect2>
</sect1>