source: chapter06/rustc.xml@ cc3fe5d

xry111/rust-wip-20221008
Last change on this file since cc3fe5d was 3ed3ce6, checked in by Xi Ruoyao <xry111@…>, 19 months ago

rust: chapter06: add Rustc

  • Property mode set to 100644
File size: 5.6 KB
Line 
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
48cp -v compiler/rustc_target/src/spec/i686_{unknown,lfs}_linux_gnu.rs
49cp -v compiler/rustc_target/src/spec/i586_{unknown,lfs}_linux_gnu.rs
50sed -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
59cat &gt; pass1.toml &lt;&lt; EOF<literal>
60[llvm]
61link-shared = true
62
63[build]
64# omit docs to save time and space (default is to build them)
65docs = false
66
67# install cargo as well as rustc, but skip other tools as they are
68# not necessary for temporary installation
69extended = true
70tools = ["cargo"]
71
72# don't download crates during build
73locked-deps = true
74vendor = true
75
76# build both the native compiler and the cross compiler
77# native compiler is necessary because Rust heavily uses meta-programming
78target = [ "</literal>$(./config.guess)<literal>", "</literal>$LFS_TGT<literal>" ]
79
80[rust]
81channel = "stable"
82
83# LFS does not install the FileCheck executable from llvm,
84# so disable codegen tests
85codegen-tests = false
86
87[target.</literal>$(./config.guess)<literal>]
88# link Rustc to LLVM pass 1
89llvm-config = "</literal>$LFS<literal>/tools/bin/llvm-config"
90
91[target.</literal>$LFS_TGT<literal>]
92cc = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-gcc"
93cxx = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-g++"
94ar = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-ar"
95ranlib = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-ranlib"
96
97# not ld: on Linux platforms Rustc uses GCC driver for linking
98linker = "</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 &gt; pass2.toml &lt;&lt; EOF<literal>
109[llvm]
110link-shared = true
111
112[build]
113docs = false
114extended = true
115tools = ["cargo"]
116locked-deps = true
117vendor = true
118
119# build the native compiler for this triplet
120host = [ "</literal>$LFS_TGT<literal>" ]
121
122[install]
123prefix = "/opt/rustc-&rustc-version;"
124docdir = "share/doc/rustc-&rustc-version;"
125
126[rust]
127channel = "stable"
128rpath = false
129
130# BLFS does not install the FileCheck executable from llvm,
131# so disable codegen tests
132codegen-tests = false
133
134[target.</literal>$(./config.guess)<literal>]
135llvm-config = "</literal>$LFS<literal>/tools/bin/llvm-config"
136
137[target.</literal>$LFS_TGT<literal>]
138cc = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-gcc"
139cxx = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-g++"
140ar = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-ar"
141ranlib = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-ranlib"
142linker = "</literal>$LFS<literal>/tools/bin/</literal>$LFS_TGT<literal>-gcc"
143
144# link Rustc to LLVM pass 2
145llvm-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 \
151python3 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 \
160python3 x.py install --keep-stage 0 \
161 --keep-stage-std 1 \
162 --stage 2 \
163 --config pass2.toml
164ln -sv rustc-&rustc-version; $LFS/opt/rustc</userinput></screen>
165
166 </sect2>
167
168 <sect2 role="content">
169 <title/>
170
171 <para>Details on this package are located in TODO.</para>
172 </sect2>
173
174</sect1>
Note: See TracBrowser for help on using the repository browser.