Differences between revisions 10 and 12 (spanning 2 versions)
Revision 10 as of 2018-02-27 15:25:52
Size: 3670
Editor: ?AdrianGlaubitz
Comment: Add missing DEB_BUILD_OPTIONS="nocheck" for rustc
Revision 12 as of 2018-03-01 02:37:36
Size: 3594
Editor: PaulWise
Comment: typo
Deletions are marked like this. Additions are marked like this.
Line 19: Line 19:
In case the download fails because of missing certificates, just add "--no-check-certificate" In case the download fails because of missing certificates, install the CA certificates and retry:
Line 22: Line 22:
$ wget --no-check-certificate https://static.rust-lang.org/dist/rust-1.20.0-powerpc64-unknown-linux-gnu.tar.gz # apt install ca-certificates

Bootstrapping Rust for a new architecture

Install build dependencies (as root)

# apt install debhelper dpkg-dev python:native llvm-4.0-dev:native llvm-4.0-tools:native libllvm4.0 autotools-dev cmake gperf zlib1g-dev liblzma-dev binutils git procps antlr4 bison flex gdb default-jdk-headless

Building the Debian package with pre-compiled binaries

Pre-compiled Rust binaries can be downloaded from: https://static.rust-lang.org/dist/index.html

Download pre-compiled rust and cargo binaries

$ wget https://static.rust-lang.org/dist/rust-1.20.0-powerpc64-unknown-linux-gnu.tar.gz

In case the download fails because of missing certificates, install the CA certificates and retry:

# apt install ca-certificates

Unpack and install Rust into a local directory

$ tar xf rust-1.20.0-powerpc64-unknown-linux-gnu.tar.gz

$ cd rust-1.20.0-ppc64-unknown-linux-gnu

$ ./install.sh --destdir=/home/${USER}/rust
install: creating uninstall script at /home/$USER/rust/usr/local/lib/rustlib/uninstall.sh
install: installing component 'rustc'
install: installing component 'cargo'
install: installing component 'rust-analysis-ppc64-unknown-linux-gnu'
install: installing component 'rust-docs'
install: installing component 'rust-std-ppc64-unknown-linux-gnu'
install: WARNING: failed to run ldconfig. this may happen when not installing as root. run with --verbose to see the error

    Rust is ready to roll.

$ cd ~

Download source of Rust Debian package

$ mkdir debian
$ cd debian
$ dget -u http://deb.debian.org/debian/pool/main/r/rustc/rustc_1.21.0+dfsg1-1.dsc
$ cd rustc-1.21.0+dfsg1

Modify debian/config.toml.in to point to the correct paths for rustc and cargo

glaubitz@ikarus:/tmp/rustc-1.23.0+dfsg1$ diff -u debian/config.toml.in.orig debian/config.toml.in
--- debian/config.toml.in.orig  2018-01-13 17:50:19.000000000 +0100
+++ debian/config.toml.in       2018-02-27 16:22:43.079889382 +0100
@@ -4,8 +4,8 @@
 locked-deps = false
 verbose = 2
-rustc = "RUST_DESTDIR/usr/bin/rustc"
-cargo = "RUST_DESTDIR/usr/bin/cargo"
+rustc = "/home/$USER/rust/usr/local/bin/rustc"
+cargo = "/home/$USER/rust/usr/local/bin/cargo"
 host = ["DEB_HOST_RUST_TYPE"]

Build rustc package (as normal user)

$ DEB_BUILD_PROFILES="nocheck" DEB_BUILD_OPTIONS="nocheck" dpkg-buildpackage -B -d

Building rustc and cargo without pre-compiled binaries

Cross-compiling cargo

  • Define the linker name for the target architecture in your cargo config:

glaubitz@z6:~> cat .cargo/config 
linker = "powerpc-linux-gnu-gcc"
  • Install the build dependencies for the cross-compilation

# apt build-dep cargo
# apt install gcc-powerpc-linux-gnu g++-powerpc-linux-gnu
# dpkg --add-architecture powerpc # Note: For ports architectures, you need to add ftp.ports.debian.org/debian-ports to your sources.list
# apt update
# apt install libcurl4-gnutls-dev:powerpc libssh2-1-dev:powerpc libgit2-dev:powerpc libhttp-parser-dev:powerpc libssl-dev:powerpc zlib1g-dev:powerpc
  • Download the source for the current cargo package:

$ apt-get source cargo
$ cd cargo-0.25.0
  • Cross-compile the Debian package

$ DEB_BUILD_PROFILES="nocheck" DEB_BUILD_OPTIONS="nocheck" dpkg-buildpackage -B -d --host-arch=powerpc