Ignore:
Timestamp:
04/14/2018 01:41:40 AM (6 years ago)
Author:
Ken Moffat <ken@…>
Branches:
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
Children:
798c542
Parents:
f5a3b39
Message:

Rustc-1.25.0.
NB this is now using a DESTDIR install, and the book does not delete that. Be aware of this if you are copying the commands into a script: if you rebuild with different settings, or later follow the instructions for a newer version, trying to create the existing directory will fail.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • general/prog/rust.xml

    rf5a3b39 ra7b1bddc  
    77  <!ENTITY rust-download-http "https://static.rust-lang.org/dist/rustc-&rust-version;-src.tar.gz">
    88  <!ENTITY rust-download-ftp  " ">
    9   <!ENTITY rust-md5sum        "7272ddba14f512e6d2612ef60460bed8">
    10   <!ENTITY rust-size          "53 MB">
    11   <!ENTITY rust-buildsize     "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)">
    12   <!ENTITY rust-time          "48 SBU (add 12 SBU for tests, both with 4 processors)"> 
     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)">
    1313]>
    1414
     
    3737    <para>
    3838      As with many  other programming languages, rustc (the rust compiler)
    39       needs a binary from which to bootstrap. It will download a stage0 binary,
    40       and several cargo files (these are actually .tar.gz source archives) at
     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
    4141      the start of the build, so you cannot compile it without an internet
    4242      connection.
     
    5959        of build times. Some of this might be due to variations in downloading
    6060        the required cargo files if they are not already present, but this does
    61         not seem to adequately explain the variations. Also, both the builder
    62         and the user running the install will need to download the cargo crates
    63         if they are not already present in <filename>~/.cargo</filename>.
     61        not seem to adequately explain the variations.
    6462      </para>
    6563      <para>
    66         If you use a DESTDIR method to install, you will only need to download
    67         the crates once, for the build, saving about one-third of the build and
    68         install time (but using extra space for the install). Similarly if you
    69         were to build as root, or if your user is allowed to run <command>sudo
    70         ./x.py install</command> - but those methods are dangerous.
     64        Unusually, a DESTDIR method is being used to install this package. This
     65        is because running the install as root not only downloads all of the
     66        cargo files again (to <filename>/root/.cargo</filename>), it then spends
     67        a very long time recompiling. Using a DESTDIR method saves 30 SBU on the
     68        4-core machine where this was tested, at the cost of an extra 60MB of
     69        disk space for the extra files.
    7170      </para>
    7271    </note>
     
    114113      <xref linkend="curl"/>,
    115114      <xref linkend="cmake"/>,
    116 <!-- if changing this to use python3, also add python2 as a required
    117  dependency for firefox, because at the moment it picks that up from here -->
     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. -->
    118120      <xref linkend="python2"/>
     121    </para>
     122
     123    <bridgehead renderas="sect4">Recommended</bridgehead>
     124    <para role="recommended">
     125      <package>clang</package> from <xref linkend="llvm"/>
    119126    </para>
    120127
     
    151158targets = "X86"
    152159
     160# When using system llvm prefer shared libraries
     161link-shared = true
     162
    153163[build]
    154164# install cargo as well as rust
     
    162172channel = "stable"
    163173rpath = false
     174
     175# get reasonably clean output from the test harness
     176quiet-tests = true
     177
     178# BLFS does not install the FileCheck executable from llvm,
     179# so disable codegen tests
     180codegen-tests = false
     181
     182[target.x86_64-unknown-linux-gnu]
     183# delete this *section* if you are not using system llvm.
     184# NB the output of llvm-config (i.e. help options) may be
     185# dumped to the screen when config.toml is parsed.
     186llvm-config = "/usr/bin/llvm-config"
     187
    164188EOF</userinput></screen>
    165189
     
    170194
    171195<screen><userinput>./x.py build</userinput></screen>
     196
     197    <para>
     198      The build will report it failed to compile <filename>miri</filename>
     199      because of multiple potential crates for `log`, but that should be followed
     200      by a message that the build completed successfully.
     201    </para>
     202
     203    <caution>
     204      <para>
     205        On AMD Ryzen processors (family 17h), the non-optimized version of libstd
     206        which is compiled at the start of the tests contains two opcodes which are
     207        not implemented on this CPU family. These will be logged in the
     208        <phrase revision="sysv">system log</phrase>
     209        <phrase revision="systemd">systemd journal</phrase>
     210        and will be followed a few minutes later by segmentation faults. Despite
     211        that, the tests continue to run, apparently normally. But the system may
     212        reboot before the tests have completed. The normal optimized libraries
     213        run without this problem.
     214      </para>
     215      <para>
     216        A mitigation is to install gdb
     217        <!-- systemd apparently handles this with systemd-coredump -->
     218        <phrase revision="sysv">and to run the tests with 'ulimit -C disabled'</phrase>
     219        but this does not always prevent the system rebooting.
     220      </para>
     221    </caution>
    172222
    173223    <para>
     
    175225      <command>./x.py test --verbose --no-fail-fast &gt;../rustc-testlog</command>:
    176226      as with the build, that will use all available CPUs.  This runs many suites
    177       of tests (in an apparently random order), three may fail:
    178       compile-fail/issue-37131.rs and run-make/target-without-atomics both try to
    179       compile for the thumbv6m-none-eabi target, but the BLFS build does not cater for
    180       that, and all 105 tests in debuginfo-gdb will fail if
    181       <application>gdb</application> has not been installed. Several other tests in
    182       run-make can also fail. With <application>glibc-2.27</application> the stack
    183       guard page has been moved to just beyond the stack, instead of within it. That
    184       causes three run-pass tests (out-of-stack.rs, stack-probes-lto.rs,
    185       stack-probes.rs) to fail.
     227      of tests (in an apparently random order), at least one will fail:
     228      compile-fail/issue-37131.rs tries to
     229      compile for the thumbv6m-none-eabi target but the BLFS build does not cater for
     230      that, and many tests in debuginfo-gdb will fail if
     231      <application>gdb</application> has not been installed. A few other tests might
     232      fail.
    186233    </para>
    187234
     
    194241
    195242    <para>
    196       That should report 14854 tests. Similarly, the total tests which failed can
     243      That should report 13224 tests. Similarly, the total tests which failed can
    197244      be found by running:
    198245    </para>
     
    207254
    208255    <para>
    209       Now, as the <systemitem class="username">root</systemitem> user:
    210     </para>
    211 
    212 <screen role="root"><userinput>./x.py install</userinput></screen>
     256      Still as your normal user, do a DESTDIR install:
     257    </para>
     258
     259<screen><userinput>mkdir -v /sources/RUST               &amp;&amp;
     260DESTDIR=/sources/RUST ./x.py install</userinput></screen>
     261
     262    <para>
     263      Now, as the <systemitem class="username">root</systemitem> user
     264      install the files from the DESTDIR:
     265    </para>
     266
     267<screen role="root"><userinput>chown -R root:root /sources/RUST &amp;&amp;
     268cp -a /sources/RUST/* /</userinput></screen>
     269
    213270  </sect2>
    214271
     
    218275    <para>
    219276      <command>targets = "X86"</command>: this avoids building all the available
    220       linux cross-compilers (Aarch64, MIPS, PowerPC, SystemZ, etc).
     277      linux cross-compilers (Aarch64, MIPS, PowerPC, SystemZ, etc). Unfortunately,
     278      rust insists on installing source files for these below
     279      <filename class="directory">/usr/lib/rustlib/src</filename>.
    221280    </para>
    222281
     
    240299
    241300    <para>
     301      <command>[target.x86_64-unknown-linux-gnu]</command>: the syntax of
     302      <filename>config.toml</filename> requires an <literal>llvm-config</literal>
     303      entry for each target for which system-llvm is to be used. Change the target
     304      to <literal>[target.i686-unknown-linux-gnu]</literal> if you are building
     305      on 32-bit x86. This whole section may be omitted if you wish to build
     306      against the shipped llvm, or do not have clang, but the resulting build will
     307      be larger and take a little longer.
     308    </para>
     309
     310    <para>
    242311      <command>--verbose</command>: this switch can sometimes provide more
    243312      information about a test which fails.
     
    250319
    251320    <para>
    252       <option>PYTHON=/usr/bin/python3 ... tee buildlog</option>: Because rust
    253       can use <application>Python3</application> which was installed in LFS,
    254       this command tells it to use that instead of the deprecated
    255       <application>Python2</application>. For the moment this should be regarded
    256       as experimental and problems may be encountered. Because
    257       <application>rust</application> will use all CPUs, if an error happened the
    258       message may have scrolled out of the terminal's buffer. Logging makes it
    259       possible to find out what was reported.
     321      <command>mkdir -v /sources/RUST</command>: this is not strictly necessary,
     322      but it confirms that your regular user can write there, and that there is
     323      not an existing directory of this name left over from a previous install.
     324      By convention, BLFS builds in <filename class="directory">/sources</filename>
     325      but you can change this to another location where you can write (and
     326      similarly change the commands used by
     327      <systemitem class="username">root</systemitem>). Note that DESTDIR installs
     328      need an absolute path, passing e.g. ../RUST will not work.
     329    </para>
     330
     331    <para>
     332      <command>chown -R root:root /sources/RUST</command>: the DESTDIR install
     333      was run by a regular user, who owns the files. For security, change their
     334      owner before doing a simple copy to install them.
    260335    </para>
    261336
     
    272347      <seglistitem>
    273348        <seg>
    274           cargo, rls, rust-gdb, rust-lldb, rustc, rustdoc.
     349          cargo-fmt, cargo, rls, rust-gdb, rust-lldb, rustc, rustdoc, rustfmt.
    275350        </seg>
    276351        <seg>
     
    291366      <?dbhtml list-presentation="table"?>
    292367
     368      <varlistentry id="cargo-fmt">
     369        <term><command>cargo-fmt</command></term>
     370        <listitem>
     371          <para>
     372            formats all bin and lib files of the current crate using
     373            rustfmt.
     374          </para>
     375          <indexterm zone="rust cargo-fmt">
     376            <primary sortas="b-cargo-fmt">cargo-fmt</primary>
     377          </indexterm>
     378        </listitem>
     379      </varlistentry>
     380
    293381      <varlistentry id="cargo">
    294382        <term><command>cargo</command></term>
     
    321409        <listitem>
    322410          <para>
    323             is a Python wrapper script for gdb.
     411            is a wrapper script for gdb, pulling in Python
     412            pretty-printing modules installed in <filename
     413            class="directory">/usr/lib/rustlib/etc</filename>.
    324414          </para>
    325415          <indexterm zone="rust rust-gdb">
     
    333423        <listitem>
    334424          <para>
    335             is a Python wrapper script for LLDB (the LLVM debugger).
     425            is a wrapper script for LLDB (the LLVM debugger)
     426            pulling in the Python pretty-printing modules.
    336427          </para>
    337428          <indexterm zone="rust rust-lldb">
     
    361452          <indexterm zone="rust rustdoc">
    362453            <primary sortas="b-rustdoc">rustdoc</primary>
     454          </indexterm>
     455        </listitem>
     456      </varlistentry>
     457
     458      <varlistentry id="rustfmt">
     459        <term><command>rustfmt</command></term>
     460        <listitem>
     461          <para>
     462            formats rust code.
     463          </para>
     464          <indexterm zone="rust rustfmt">
     465            <primary sortas="b-rustfmt">rustfmt</primary>
    363466          </indexterm>
    364467        </listitem>
Note: See TracChangeset for help on using the changeset viewer.