%general-entities; ]> $LastChangedBy$ $Date$ Rustc-&rust-version; Rust 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 many cargo crates (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. 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. Unusually, a DESTDIR method is being used to install this package. This is because running the install as root not only downloads all of the cargo files again (to /root/.cargo), it then spends a very long time recompiling. Using a DESTDIR method saves 30 SBU on the 4-core machine where this was tested, at the cost of an extra 60MB of disk space for the extra files. &lfs82_checked; Package Information Download (HTTP): Download (FTP): Download MD5 sum: &rust-md5sum; Download size: &rust-size; Estimated disk space required: &rust-buildsize; Estimated build time: &rust-time; Rust Dependencies Required , , Recommended clang from Optional (used by debuginfo-gdb in the testsuite) User Notes: Installation of Rust 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" # When using system llvm prefer shared libraries link-shared = true [build] # install cargo as well as rust extended = true [install] prefix = "/usr" docdir = "share/doc/rustc-&rust-version;" [rust] channel = "stable" rpath = false # 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" EOF Now install Rust by running the following commands: ./x.py build The build will report it failed to compile miri because of multiple potential crates for `log`, but that should be followed by a message that the build completed successfully. 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 system log systemd journal 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. A mitigation is to install gdb and to run the tests with 'ulimit -C disabled' but this does not always prevent the system rebooting. 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), 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 gdb has not been installed. A few other tests might 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 13224 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. Still as your normal user, do a DESTDIR install: mkdir -v /sources/RUST && DESTDIR=/sources/RUST ./x.py install Now, as the root user install the files from the DESTDIR: chown -R root:root /sources/RUST && cp -a /sources/RUST/* / Command Explanations targets = "X86": this avoids building all the available linux cross-compilers (Aarch64, MIPS, PowerPC, SystemZ, etc). Unfortunately, rust insists on installing source files for these below /usr/lib/rustlib/src. 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. [target.x86_64-unknown-linux-gnu]: the syntax of config.toml requires an llvm-config entry for each target for which system-llvm is to be used. Change the target to [target.i686-unknown-linux-gnu] 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. --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. mkdir -v /sources/RUST: this is not strictly necessary, but it confirms that your regular user can write there, and that there is not an existing directory of this name left over from a previous install. By convention, BLFS builds in /sources but you can change this to another location where you can write (and similarly change the commands used by root). Note that DESTDIR installs need an absolute path, passing e.g. ../RUST will not work. chown -R root:root /sources/RUST: the DESTDIR install was run by a regular user, who owns the files. For security, change their owner before doing a simple copy to install them. Contents Installed Programs Installed Libraries Installed Directories cargo-fmt, cargo, rls, rust-gdb, rust-lldb, rustc, rustdoc, rustfmt. Many lib*<16-byte-hash>.so libraries. ~/.cargo, /usr/lib/rustlib, /usr/share/doc/rustc-&rust-version;, and /usr/share/zsh/site-functions/ Short Descriptions cargo-fmt formats all bin and lib files of the current crate using rustfmt. cargo-fmt cargo is the Package Manager for Rust. cargo rls is the Rust Language Server. This can run in the background to provide IDEs, editors, and other tools with information about Rust programs. rls rust-gdb is a wrapper script for gdb, pulling in Python pretty-printing modules installed in /usr/lib/rustlib/etc. rust-gdb rust-lldb is a wrapper script for LLDB (the LLVM debugger) pulling in the Python pretty-printing modules. rust=lldb rustc is the rust compiler. rustc rustdoc generates documentation from rust source code. rustdoc rustfmt formats rust code. rustfmt libstd-<16-byte-hash>.so is the Rust Standard Library, the foundation of portable Rust software. libstd-<16-byte-hash>.so