diff --git a/chapter06/chapter06.xml b/chapter06/chapter06.xml index 27741424c..b9fb4f922 100644 --- a/chapter06/chapter06.xml +++ b/chapter06/chapter06.xml @@ -32,5 +32,6 @@ + diff --git a/chapter06/rustc.xml b/chapter06/rustc.xml new file mode 100644 index 000000000..384861de9 --- /dev/null +++ b/chapter06/rustc.xml @@ -0,0 +1,174 @@ + + + %general-entities; +]> + + + + + + Rustc + &rustc-version; +
&rustc-url;
+
+ + Rustc-&rustc-version; + + + Rustc + tools + + + + + + <para>The Rust programming language is designed to be a safe, + concurrent, practical language.</para> + + <segmentedlist> + <segtitle>&buildtime;</segtitle> + <segtitle>&diskspace;</segtitle> + + <seglistitem> + <seg>&rustc-tmp-sbu;</seg> + <seg>&rustc-tmp-du;</seg> + </seglistitem> + </segmentedlist> + + </sect2> + + <sect2 role="installation"> + <title>Installation of Rustc + + Tell Rustc how to support $LFS_TGT triplet: + +cp -v compiler/rustc_target/src/spec/x86_64_{unknown,lfs}_linux_gnu.rs +cp -v compiler/rustc_target/src/spec/i686_{unknown,lfs}_linux_gnu.rs +cp -v compiler/rustc_target/src/spec/i586_{unknown,lfs}_linux_gnu.rs +sed -i.orig compiler/rustc_target/src/spec/mod.rs \ + -e '/targets!/a\ ("x86_64-lfs-linux-gnu", x86_64_lfs_linux_gnu),' \ + -e '/targets!/a\ ("i686-lfs-linux-gnu", i686_lfs_linux_gnu),' \ + -e '/targets!/a\ ("i586-lfs-linux-gnu", i586_lfs_linux_gnu),' + + In the first pass, build Rustc as a cross compiler for + $LFS_TGT. Create a suitable configuration: + +install -vm755 src/llvm-project/llvm/cmake/config.guess config.guess +cat > pass1.toml << EOF +[llvm] +link-shared = true + +[build] +# omit docs to save time and space (default is to build them) +docs = false + +# install cargo as well as rustc, but skip other tools as they are +# not necessary for temporary installation +extended = true +tools = ["cargo"] + +# don't download crates during build +locked-deps = true +vendor = true + +# build both the native compiler and the cross compiler +# native compiler is necessary because Rust heavily uses meta-programming +target = [ "$(./config.guess)", "$LFS_TGT" ] + +[rust] +channel = "stable" + +# LFS does not install the FileCheck executable from llvm, +# so disable codegen tests +codegen-tests = false + +[target.$(./config.guess)] +# link Rustc to LLVM pass 1 +llvm-config = "$LFS/tools/bin/llvm-config" + +[target.$LFS_TGT] +cc = "$LFS/tools/bin/$LFS_TGT-gcc" +cxx = "$LFS/tools/bin/$LFS_TGT-g++" +ar = "$LFS/tools/bin/$LFS_TGT-ar" +ranlib = "$LFS/tools/bin/$LFS_TGT-ranlib" + +# not ld: on Linux platforms Rustc uses GCC driver for linking +linker = "$LFS/tools/bin/$LFS_TGT-gcc" +EOF + + Build the cross compiler and target libraries: + +python3 x.py build --stage 1 library --config pass1.toml + + In the second pass, build Rustc as a native compiler on + $LFS_TGT: + +cat > pass2.toml << EOF +[llvm] +link-shared = true + +[build] +docs = false +extended = true +tools = ["cargo"] +locked-deps = true +vendor = true + +# build the native compiler for this triplet +host = [ "$LFS_TGT" ] + +[install] +prefix = "/opt/rustc-&rustc-version;" +docdir = "share/doc/rustc-&rustc-version;" + +[rust] +channel = "stable" +rpath = false + +# BLFS does not install the FileCheck executable from llvm, +# so disable codegen tests +codegen-tests = false + +[target.$(./config.guess)] +llvm-config = "$LFS/tools/bin/llvm-config" + +[target.$LFS_TGT] +cc = "$LFS/tools/bin/$LFS_TGT-gcc" +cxx = "$LFS/tools/bin/$LFS_TGT-g++" +ar = "$LFS/tools/bin/$LFS_TGT-ar" +ranlib = "$LFS/tools/bin/$LFS_TGT-ranlib" +linker = "$LFS/tools/bin/$LFS_TGT-gcc" + +# link Rustc to LLVM pass 2 +llvm-config = "$LFS/tools/$LFS_TGT/bin/llvm-config" +EOF + + Build the native compiler: + +env {X86_64,I{5,6}86}_LFS_LINUX_GNU_OPENSSL_DIR=$LFS/usr \ +python3 x.py build --keep-stage 0 \ + --keep-stage-std 1 \ + --stage 2 \ + --config pass2.toml + + Install the package: + +env {X86_64,I{5,6}86}_LFS_LINUX_GNU_OPENSSL_DIR=$LFS/usr \ + DESTDIR=$LFS \ +python3 x.py install --keep-stage 0 \ + --keep-stage-std 1 \ + --stage 2 \ + --config pass2.toml +ln -sv rustc-&rustc-version; $LFS/opt/rustc + + + + + + + <para>Details on this package are located in TODO.</para> + </sect2> + +</sect1> diff --git a/packages.ent b/packages.ent index f62966edd..e6467f58c 100644 --- a/packages.ent +++ b/packages.ent @@ -632,6 +632,16 @@ <!ENTITY readline-fin-du "15 MB"> <!ENTITY readline-fin-sbu "0.1 SBU"> +<!ENTITY rustc-version "1.64.0"> +<!ENTITY rustc-size "134,612 KB"> +<!ENTITY rustc-url "https://static.rust-lang.org/dist/rustc-&rustc-version;-src.tar.xz"> +<!ENTITY rustc-md5 "e77ac3a786d013604061b17f99dd9b27"> +<!ENTITY rustc-home "https://www.rust-lang.org/"> +<!ENTITY rustc-tmp-sbu "21 SBU"> +<!ENTITY rustc-tmp-du "10,000 MB"> +<!ENTITY rustc-final-sbu "21 SBU"> +<!ENTITY rustc-final-du "10,000 MB"> + <!ENTITY sed-version "4.8"> <!ENTITY sed-size "1,317 KB"> <!ENTITY sed-url "&gnu;sed/sed-&sed-version;.tar.xz">