1. ferrocene-self-test tool

Requirement: Purpose REQ_LSGKACM

The tool is used to ensure that the Ferrocene toolchain is installed correctly.

Requirement: Environment REQ_THXJWWD

The tool should be executed on any of the host platforms listed in Compilation targets overview.

Requirement: Environment REQ_67EQEVF

The tool should only execute with success if it was distributed with the same Ferrocene toolchain that it is checking.

Requirement: Execution REQ_P2OXII1

The tool should be executed on the command line.

Requirement: Command line interface REQ_9A6740M

The tool accepts no command line arguments, and quits with a fail exit status when they are present.

Requirement: Output REQ_42QU5MK

The tool displays the checks it performs, and quits with a fail exit status when any of the checks fails.

1.1. Checks for executables

Requirement: REQ_0OAUY3U

These executables should be checked:

  • rustc

  • rustdoc

  • cargo (if installed)

Requirement: REQ_N1VBW46
implements: REQ_0OAUY3U

The executable should exist in the bin directory, relative to the root of the installation.

Requirement: REQ_R2UQ8D3
implements: REQ_0OAUY3U

The executable should be a regular file.

Requirement: REQ_NUP1G0D
implements: REQ_0OAUY3U

The executable should have read and execute permissions set for all users.

Requirement: REQ_GVLWOTQ
implements: REQ_0OAUY3U

Check the behavior of --verbose --version command-line options.

Requirement: REQ_6OAFM70
implements: REQ_GVLWOTQ

The executable should exit successfully.

Requirement: REQ_ABPRHHQ
implements: REQ_GVLWOTQ

The output of the executable should be UTF-8 text.

Requirement: REQ_SL5USTK
implements: REQ_GVLWOTQ

The output of the executable should have at least 3 key-value pairs, with these 3 keys: host, commit-hash, and release:

  • host is the target triple of the platform that the executable is built for

  • commit-hash is an identifier for the Git commit from which the Ferrocene release was built

  • release is the name of the upstream release from which the Ferrocene release was based

1.2. Checks for targets

Note

In the subsections below, we have these substitutions:

  • $target refers to any of the targets listed

  • $hash is a 16 character hexadecimal string

1.2.1. All targets

Note

These checks are for all locally-installed targets listed in Compilation targets overview.

Requirement: REQ_0640QY8
implemented by: REQ_XWYY918, REQ_TI55HCF

Inside of lib/rustlib/$target/lib directory, relative to the root of the installation, these regular files should be checked:

  • libcore-$hash.rlib

  • liballoc-$hash.rlib

Requirement: REQ_XWYY918
implements: REQ_0640QY8

The files should exist.

Requirement: REQ_TI55HCF
implements: REQ_0640QY8

The files should not have duplicates, which can happen if the $hash is different.

1.2.2. Targets with std

Note

These checks are for all locally-installed targets which are also marked as having Full standard library support in Compilation targets overview.

Requirement: REQ_RUCUMJJ
implemented by: REQ_GAPK9QF, REQ_IJN9ZPU

Inside of lib/rustlib/$target/lib directory, relative to the root of the installation, these regular files should be checked:

  • libstd-$hash.rlib

  • libtest-$hash.rlib

  • libproc_macro-$hash.rlib

Requirement: REQ_GAPK9QF
implements: REQ_RUCUMJJ

The files should exist.

Requirement: REQ_IJN9ZPU
implements: REQ_RUCUMJJ

The files should not have duplicates, which can happen if the $hash is different.

1.3. Checks for linkers

Note

These checks are for the host platform, which is where ferrocene-self-test is executed.

$target refers to this host platform.

Requirement: REQ_QQDV24N

Inside of lib/rustlib/$target/bin directory, relative to the root of the installation, should exist the regular file named rust-lld.

Requirement: REQ_J42HAPX

Inside of lib/rustlib/$target/bin/gcc-ld directory, relative to the root of the installation, should exist the regular file named ld.lld, which is the linker wrapper.

1.3.1. Platforms that need a C compiler

Note

The following checks apply to these Host platforms:

  • x86-64 Linux (glibc)

  • Armv8-A Linux (glibc)

Requirement: REQ_GR1AK1Q

Search for a system C compiler in the PATH environment variable.

Requirement: REQ_FCE5QJ5

Use the system C compiler to compile a sample program, and use the linker wrapper for the linking stage.

Requirement: REQ_5Q3NRL3

Check that the system C compiler passes -Wl,$arg arguments to the linker, where $arg is command line arguments that the system linker accepts.

Requirement: REQ_1MN4JOQ

Ensure that the linker command line arguments that can be accepted are of the form documented in the Safety Manual.

1.4. Checks for compilation

1.4.1. All targets

Note

These checks are for all locally-installed targets listed in Compilation targets overview.

Requirement: REQ_99TXVWC

Check if we can compile the following Rust crate types:

  • lib

  • staticlib

  • bin

Requirement: REQ_SV3CV3N

Check that only the following artefacts are produced by rustc for each crate type compilation, where $basename is the file name without the extension:

  • $basename.rlib for lib crate type

  • $basename.a for staticlib crate type

  • $basename for bin crate type

1.4.2. Host targets

Note

These checks are for the host platform, which is where ferrocene-self-test is executed.

Requirement: REQ_8TNOYG8

Check if a sample program that rustc produced can be executed.

Requirement: REQ_B07M5S2

Check if the output of the program is as expected.