Rustc-1.22.1

Introduction to Rust

The Rust programming language is designed to be a safe, concurrent, practical language.

As with many other programming languages, rustc (the rust compiler) needs a binary from which to bootstrap. It will download a stage0 binary, and several cargo files (these are actually .tar.gz source archives) at the start of the build, so you cannot compile it without an internet connection.

The current rustbuild 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.

At the moment Rust does not provide any guarantees of a stable ABI.

[Note]

Note

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 not seem to adequately explain the variations. Also, both the builder and the user running the install will need to download the cargo crates if they are not already present in ~/.cargo.

If you use a DESTDIR method to install, you will only need to download the crates once, for the build, saving about one-third of the build and install time (but using extra space for the install). Similarly if you were to build as root, or if your user is allowed to run sudo ./x.py install - but those methods are dangerous.

This package is known to build and work properly using an LFS-8.2 platform.

Package Information

  • Download (HTTP): https://static.rust-lang.org/dist/rustc-1.22.1-src.tar.gz

  • Download MD5 sum: 7272ddba14f512e6d2612ef60460bed8

  • Download size: 53 MB

  • Estimated disk space required: 4.1 GB (437 MB installed), (add 1.2GB for tests) including 226MB of ~/.cargo files for both the builder and root (from the install)

  • Estimated build time: 48 SBU (add 12 SBU for tests, both with 4 processors)

Rust Dependencies

Required

cURL-7.58.0, CMake-3.10.2, Python-2.7.14

Optional

GDB-8.1 (used by debuginfo-gdb in the testsuite)

User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/rust

Installation of Rust

[Note]

Note

This package is updated on a six-weekly release cycle. Because it is such a large and slow package to build, and is at the moment only used by two packages in this book, the BLFS editors take the view that it should only be updated when that is necessary.

First create a suitable config.toml file which will configure the build :

cat <<EOF > config.toml
# see config.toml.example for more possible options
[llvm]
targets = "X86"

[build]
# install cargo as well as rust
extended = true

[install]
prefix = "/usr"
docdir = "share/doc/rustc-1.22.1"

[rust]
channel = "stable"
rpath = false
EOF

Now install Rust by running the following commands:

./x.py build

To run the tests issue ./x.py test --verbose --no-fail-fast >../rustc-testlog: as with the build, that will use all available CPUs. This runs many suites of tests (in an apparently random order), three may fail: compile-fail/issue-37131.rs and run-make/target-without-atomics both try to compile for the thumbv6m-none-eabi target, but the BLFS build does not cater for that, and all 105 tests in debuginfo-gdb will fail if gdb has not been installed. Several other tests in run-make can also fail. With glibc-2.27 the stack guard page has been moved to just beyond the stack, instead of within it. That causes three run-pass tests (out-of-stack.rs, stack-probes-lto.rs, stack-probes.rs) to fail.

If you wish to look at the numbers for the results, you can find the total number of tests which were considered by running:

grep 'running .* tests' ../rustc-testlog | awk '{ sum += $2 } END { print sum }'

That should report 14854 tests. Similarly, the total tests which failed can be found by running:

grep '^test result:' ../rustc-testlog | awk  '{ sum += $6 } END { print sum }'

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.

Now, as the root user:

./x.py install

Command Explanations

targets = "X86": this avoids building all the available linux cross-compilers (Aarch64, MIPS, PowerPC, SystemZ, etc).

extended = true: this installs Cargo alongside Rust.

channel = "stable": this ensures only stable features can be used, the default in config.toml is to use development features, which is not appropriate for a released version.

rpath = false: by default, rust 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 ldd, showing the libraries in the place they were built, even if they have been deleted from there after the install.

--verbose: this switch can sometimes provide more information about a test which fails.

--no-fail-fast: this switch ensures that the testsuite will not stop at the first error.

PYTHON=/usr/bin/python3 ... tee buildlog: Because rust can use Python3 which was installed in LFS, this command tells it to use that instead of the deprecated Python2. For the moment this should be regarded as experimental and problems may be encountered. Because rust will use all CPUs, if an error happened the message may have scrolled out of the terminal's buffer. Logging makes it possible to find out what was reported.

Contents

Installed Programs: cargo, rls, rust-gdb, rust-lldb, rustc, rustdoc.
Installed Libraries: Many lib*<16-byte-hash>.so libraries.
Installed Directories: ~/.cargo, /usr/lib/rustlib, /usr/share/doc/rustc-1.22.1, and /usr/share/zsh/site-functions/

Short Descriptions

cargo

is the Package Manager for Rust.

rls

is the Rust Language Server. This can run in the background to provide IDEs, editors, and other tools with information about Rust programs.

rust-gdb

is a Python wrapper script for gdb.

rust-lldb

is a Python wrapper script for LLDB (the LLVM debugger).

rustc

is the rust compiler.

rustdoc

generates documentation from rust source code.

libstd-<16-byte-hash>.so

is the Rust Standard Library, the foundation of portable Rust software.

Last updated on 2018-02-26 01:09:38 -0800