[3ed3ce6] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
| 4 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
| 7 |
|
---|
| 8 | <sect1 id="ch-tools-rustc" role="wrap">
|
---|
| 9 | <?dbhtml filename="rustc.html"?>
|
---|
| 10 |
|
---|
| 11 | <sect1info condition="script">
|
---|
| 12 | <productname>Rustc</productname>
|
---|
| 13 | <productnumber>&rustc-version;</productnumber>
|
---|
| 14 | <address>&rustc-url;</address>
|
---|
| 15 | </sect1info>
|
---|
| 16 |
|
---|
| 17 | <title>Rustc-&rustc-version;</title>
|
---|
| 18 |
|
---|
| 19 | <indexterm zone="ch-tools-rustc">
|
---|
| 20 | <primary sortas="a-Rustc">Rustc</primary>
|
---|
| 21 | <secondary>tools</secondary>
|
---|
| 22 | </indexterm>
|
---|
| 23 |
|
---|
| 24 | <sect2 role="package">
|
---|
| 25 | <title/>
|
---|
| 26 |
|
---|
| 27 | <para>The Rust programming language is designed to be a safe,
|
---|
| 28 | concurrent, practical language.</para>
|
---|
| 29 |
|
---|
| 30 | <segmentedlist>
|
---|
| 31 | <segtitle>&buildtime;</segtitle>
|
---|
| 32 | <segtitle>&diskspace;</segtitle>
|
---|
| 33 |
|
---|
| 34 | <seglistitem>
|
---|
| 35 | <seg>&rustc-tmp-sbu;</seg>
|
---|
| 36 | <seg>&rustc-tmp-du;</seg>
|
---|
| 37 | </seglistitem>
|
---|
| 38 | </segmentedlist>
|
---|
| 39 |
|
---|
| 40 | </sect2>
|
---|
| 41 |
|
---|
| 42 | <sect2 role="installation">
|
---|
| 43 | <title>Installation of Rustc</title>
|
---|
| 44 |
|
---|
| 45 | <para>Tell Rustc how to support <envar>$LFS_TGT</envar> triplet:</para>
|
---|
| 46 |
|
---|
| 47 | <screen><userinput remap="pre">cp -v compiler/rustc_target/src/spec/x86_64_{unknown,lfs}_linux_gnu.rs
|
---|
| 48 | cp -v compiler/rustc_target/src/spec/i686_{unknown,lfs}_linux_gnu.rs
|
---|
| 49 | cp -v compiler/rustc_target/src/spec/i586_{unknown,lfs}_linux_gnu.rs
|
---|
| 50 | sed -i.orig compiler/rustc_target/src/spec/mod.rs \
|
---|
| 51 | -e '/targets!/a\ ("x86_64-lfs-linux-gnu", x86_64_lfs_linux_gnu),' \
|
---|
| 52 | -e '/targets!/a\ ("i686-lfs-linux-gnu", i686_lfs_linux_gnu),' \
|
---|
| 53 | -e '/targets!/a\ ("i586-lfs-linux-gnu", i586_lfs_linux_gnu),'</userinput></screen>
|
---|
| 54 |
|
---|
| 55 | <para>In the first pass, build Rustc as a cross compiler for
|
---|
| 56 | <envar>$LFS_TGT</envar>. Create a suitable configuration:</para>
|
---|
| 57 |
|
---|
| 58 | <screen><userinput remap="pre">install -vm755 src/llvm-project/llvm/cmake/config.guess config.guess
|
---|
| 59 | cat > pass1.toml << EOF<literal>
|
---|
| 60 | [llvm]
|
---|
| 61 | link-shared = true
|
---|
| 62 |
|
---|
| 63 | [build]
|
---|
| 64 | # omit docs to save time and space (default is to build them)
|
---|
| 65 | docs = false
|
---|
| 66 |
|
---|
| 67 | # install cargo as well as rustc, but skip other tools as they are
|
---|
| 68 | # not necessary for temporary installation
|
---|
| 69 | extended = true
|
---|
| 70 | tools = ["cargo"]
|
---|
| 71 |
|
---|
| 72 | # don't download crates during build
|
---|
| 73 | locked-deps = true
|
---|
| 74 | vendor = true
|
---|
| 75 |
|
---|
| 76 | # build both the native compiler and the cross compiler
|
---|
| 77 | # native compiler is necessary because Rust heavily uses meta-programming
|
---|
| 78 | target = [ "</literal>$(./config.guess)<literal>", "</literal>$LFS_TGT<literal>" ]
|
---|
| 79 |
|
---|
| 80 | [rust]
|
---|
| 81 | channel = "stable"
|
---|
| 82 |
|
---|
| 83 | # LFS does not install the FileCheck executable from llvm,
|
---|
| 84 | # so disable codegen tests
|
---|
| 85 | codegen-tests = false
|
---|
| 86 |
|
---|
| 87 | [target.</literal>$(./config.guess)<literal>]
|
---|
| 88 | # link Rustc to LLVM pass 1
|
---|
| 89 | llvm-config = "</literal>$LFS<literal>/tools/bin/llvm-config"
|
---|
| 90 |
|
---|
| 91 | [target.</literal>$LFS_TGT<literal>]
|
---|
| 92 | cc = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-gcc"
|
---|
| 93 | cxx = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-g++"
|
---|
| 94 | ar = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-ar"
|
---|
| 95 | ranlib = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-ranlib"
|
---|
| 96 |
|
---|
| 97 | # not ld: on Linux platforms Rustc uses GCC driver for linking
|
---|
| 98 | linker = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-gcc"
|
---|
| 99 | </literal>EOF</userinput></screen>
|
---|
| 100 |
|
---|
| 101 | <para>Build the cross compiler and target libraries:</para>
|
---|
| 102 |
|
---|
| 103 | <screen><userinput remap="make">python3 x.py build --stage 1 library --config pass1.toml</userinput></screen>
|
---|
| 104 |
|
---|
| 105 | <para>In the second pass, build Rustc as a native compiler on
|
---|
| 106 | <envar>$LFS_TGT</envar>:</para>
|
---|
| 107 |
|
---|
| 108 | <screen><userinput remap="pre">cat > pass2.toml << EOF<literal>
|
---|
| 109 | [llvm]
|
---|
| 110 | link-shared = true
|
---|
| 111 |
|
---|
| 112 | [build]
|
---|
| 113 | docs = false
|
---|
| 114 | extended = true
|
---|
| 115 | tools = ["cargo"]
|
---|
| 116 | locked-deps = true
|
---|
| 117 | vendor = true
|
---|
| 118 |
|
---|
| 119 | # build the native compiler for this triplet
|
---|
| 120 | host = [ "</literal>$LFS_TGT<literal>" ]
|
---|
| 121 |
|
---|
| 122 | [install]
|
---|
| 123 | prefix = "/opt/rustc-&rustc-version;"
|
---|
| 124 | docdir = "share/doc/rustc-&rustc-version;"
|
---|
| 125 |
|
---|
| 126 | [rust]
|
---|
| 127 | channel = "stable"
|
---|
| 128 | rpath = false
|
---|
| 129 |
|
---|
| 130 | # BLFS does not install the FileCheck executable from llvm,
|
---|
| 131 | # so disable codegen tests
|
---|
| 132 | codegen-tests = false
|
---|
| 133 |
|
---|
| 134 | [target.</literal>$(./config.guess)<literal>]
|
---|
| 135 | llvm-config = "</literal>$LFS<literal>/tools/bin/llvm-config"
|
---|
| 136 |
|
---|
| 137 | [target.</literal>$LFS_TGT<literal>]
|
---|
| 138 | cc = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-gcc"
|
---|
| 139 | cxx = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-g++"
|
---|
| 140 | ar = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-ar"
|
---|
| 141 | ranlib = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-ranlib"
|
---|
| 142 | linker = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-gcc"
|
---|
| 143 |
|
---|
| 144 | # link Rustc to LLVM pass 2
|
---|
| 145 | llvm-config = "</literal>$LFS<literal>/tools/</literal>$LFS_TGT<literal>/bin/llvm-config"
|
---|
| 146 | </literal>EOF</userinput></screen>
|
---|
| 147 |
|
---|
| 148 | <para>Build the native compiler:</para>
|
---|
| 149 |
|
---|
| 150 | <screen><userinput remap="make">env {X86_64,I{5,6}86}_LFS_LINUX_GNU_OPENSSL_DIR=$LFS/usr \
|
---|
| 151 | python3 x.py build --keep-stage 0 \
|
---|
| 152 | --keep-stage-std 1 \
|
---|
| 153 | --stage 2 \
|
---|
| 154 | --config pass2.toml</userinput></screen>
|
---|
| 155 |
|
---|
| 156 | <para>Install the package:</para>
|
---|
| 157 |
|
---|
| 158 | <screen><userinput remap="make">env {X86_64,I{5,6}86}_LFS_LINUX_GNU_OPENSSL_DIR=$LFS/usr \
|
---|
| 159 | DESTDIR=$LFS \
|
---|
| 160 | python3 x.py install --keep-stage 0 \
|
---|
| 161 | --keep-stage-std 1 \
|
---|
| 162 | --stage 2 \
|
---|
| 163 | --config pass2.toml
|
---|
| 164 | ln -sv rustc-&rustc-version; $LFS/opt/rustc</userinput></screen>
|
---|
| 165 |
|
---|
| 166 | </sect2>
|
---|
| 167 |
|
---|
| 168 | <sect2 role="content">
|
---|
| 169 | <title/>
|
---|
| 170 |
|
---|
[f11dfd8] | 171 | <para>Details on this package are located in
|
---|
| 172 | <xref linkend="contents-rustc" role="."/></para>
|
---|
[3ed3ce6] | 173 | </sect2>
|
---|
| 174 |
|
---|
| 175 | </sect1>
|
---|