Differences between revisions 1 and 12 (spanning 11 versions)
Revision 1 as of 2017-10-21 20:05:05
Size: 5740
Editor: ?AdrianGlaubitz
Comment: Add initial version
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 3: Line 3:
== Download pre-compiled rust and cargo binaries == == 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 ===
Line 9: 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 12: 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
Line 15: Line 25:
== Unpack and install Rust into a local directory == === Unpack and install Rust into a local directory ===
Line 40: Line 50:
== Download source of Rust Debian package == === Download source of Rust Debian package ===
Line 49: Line 59:
== Modify debian/rules to edit configure options == === Modify debian/config.toml.in to point to the correct paths for rustc and cargo ===
Line 52: Line 62:
--- debian/rules.orig 2017-10-16 22:23:26.000000000 +0000
+++ debian/rules 2017-10-21 15:58:25.909374685 +0000
@@ -86,36 +86,38 @@
 #ifneq (,$(filter $(DEB_HOST_ARCH), amd64 arm64 armhf i386 powerpc ppc64el s390x))
 # HAVE_BINARY_TARBALL := 0
 #endif
-ifeq (0,$(HAVE_BINARY_TARBALL))
- # Case A (Building from source): the extracted source tree does not include
- # a bootstrapping tarball for the current architecture e.g. because the
- # distro already has a rustc for this arch, or the uploader expects that
- # this requirement be fulfilled in some other way.
- #
- # Case A-1: the builder did not select the "pkg.rustc.dlstage0" build profile.
- # In this case, we use the distro's rustc - either the previous or current version.
- ifeq (,$(findstring pkg.rustc.dlstage0,$(DEB_BUILD_PROFILES)))
- DEB_CONFIGURE_FLAGS += --enable-local-rust --local-rust-root=/usr
- endif
- #
- # Case A-2: the builder selected the "dlstage0" build profile.
- # In this case, the rust build scripts will download a stage0 into stage0/ and use that.
- # We don't need to do anything specific in this build file, so this case is empty.
-else
- # Case B (Bootstrapping a new distro): the extracted source tree does
- # include a bootstrapping tarball for the current architecture; see the
- # `source_orig-stage0` target below on how to build this.
- #
- # In this case, we'll bootstrap from the stage0 given in that tarball.
- # To ensure the uploader of the .dsc didn't make a mistake, we first check
- # that rustc isn't a Build-Depends for the current architecture.
- ifneq (,$(shell $(SED_RUSTC_BUILDDEP)))
- ifeq (,$(shell $(SED_RUSTC_BUILDDEP) | grep '!$(DEB_HOST_ARCH)'))
- PRECONFIGURE_CHECK = $(error found matches for stage0/*/*$(DEB_HOST_RUST_TYPE)*, \
- but rustc might be a Build-Depends for $(DEB_HOST_ARCH))
- endif
- endif
-endif
+# ifeq (0,$(HAVE_BINARY_TARBALL))
+# # Case A (Building from source): the extracted source tree does not include
+# # a bootstrapping tarball for the current architecture e.g. because the
+# # distro already has a rustc for this arch, or the uploader expects that
+# # this requirement be fulfilled in some other way.
+# #
+# # Case A-1: the builder did not select the "pkg.rustc.dlstage0" build profile.
+# # In this case, we use the distro's rustc - either the previous or current version.
+# ifeq (,$(findstring pkg.rustc.dlstage0,$(DEB_BUILD_PROFILES)))
+# DEB_CONFIGURE_FLAGS += --enable-local-rust --local-rust-root=/usr
+# endif
+# #
+# # Case A-2: the builder selected the "dlstage0" build profile.
+# # In this case, the rust build scripts will download a stage0 into stage0/ and use that.
+# # We don't need to do anything specific in this build file, so this case is empty.
+# else
+# # Case B (Bootstrapping a new distro): the extracted source tree does
+# # include a bootstrapping tarball for the current architecture; see the
+# # `source_orig-stage0` target below on how to build this.
+# #
+# # In this case, we'll bootstrap from the stage0 given in that tarball.
+# # To ensure the uploader of the .dsc didn't make a mistake, we first check
+# # that rustc isn't a Build-Depends for the current architecture.
+# ifneq (,$(shell $(SED_RUSTC_BUILDDEP)))
+# ifeq (,$(shell $(SED_RUSTC_BUILDDEP) | grep '!$(DEB_HOST_ARCH)'))
+# PRECONFIGURE_CHECK = $(error found matches for stage0/*/*$(DEB_HOST_RUST_TYPE)*, \
+# but rustc might be a Build-Depends for $(DEB_HOST_ARCH))
+# endif
+# endif
+# endif
+
+DEB_CONFIGURE_FLAGS += --enable-local-rust --local-rust-root=/home/$USER/rust/usr/local
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
Line 121: Line 69:
 BUILD_DOCS = 1
 ifneq (,$(findstring nodoc,$(DEB_BUILD_PROFILES)))
-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"
 
 build = "DEB_BUILD_RUST_TYPE"
 host = ["DEB_HOST_RUST_TYPE"]
glaubitz@ikarus:/tmp/rustc-1.23.0+dfsg1$
Line 125: Line 79:
== Install build dependencies (as root) == === Build rustc package (as normal user) ===
Line 128: Line 82:
# 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 nodejs valgrind git procps antlr4 bison flex gdb default-jdk-headless $ DEB_BUILD_PROFILES="nocheck" DEB_BUILD_OPTIONS="nocheck" dpkg-buildpackage -B -d
Line 131: Line 85:
== Build rustc package (as normal user) == == Building rustc and cargo without pre-compiled binaries ==

=== Cross-compiling cargo ===

 * Define the linker name for the target architecture in your cargo config:
Line 134: Line 92:
$ DEB_BUILD_OPTIONS="nocheck" dpkg-buildpackage -B -d glaubitz@z6:~> cat .cargo/config
[target.powerpc-unknown-linux-gnu]
linker = "powerpc-linux-gnu-gcc"
glaubitz@z6:~>
Line 136: Line 97:

 * 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
}}}

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"
 
 build = "DEB_BUILD_RUST_TYPE"
 host = ["DEB_HOST_RUST_TYPE"]
glaubitz@ikarus:/tmp/rustc-1.23.0+dfsg1$

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 
[target.powerpc-unknown-linux-gnu]
linker = "powerpc-linux-gnu-gcc"
glaubitz@z6:~>
  • 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