From e926fb0902d7c11738253a522ed250ffcfd22f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Christian=20Gr=C3=BCnhage?= Date: Fri, 19 Aug 2022 19:07:34 +0200 Subject: [PATCH] rust-bootstrap: document cross compiled distfile generation --- .../files/generating-distfiles.md | 67 +++++++++++++++++++ srcpkgs/rust-bootstrap/template | 1 + 2 files changed, 68 insertions(+) create mode 100644 srcpkgs/rust-bootstrap/files/generating-distfiles.md diff --git a/srcpkgs/rust-bootstrap/files/generating-distfiles.md b/srcpkgs/rust-bootstrap/files/generating-distfiles.md new file mode 100644 index 00000000000..ed5aa0da859 --- /dev/null +++ b/srcpkgs/rust-bootstrap/files/generating-distfiles.md @@ -0,0 +1,67 @@ +## Generating self-hosted rust and cargo bootstrap distfiles + +Rust doesn't ship binaries for some of the targets we support bootstrapping on, +so we have to generate distfiles for a few architectures as well, namely +`ppc64le-musl` and `ppc64` for `rust-bootstrap`, and additionally `ppc` for +`cargo-bootstrap`, as the `ppc` cargo binaries provided by upstream have +problems. + +### Set up appropriate masterdirs and remote-repositories + +This guide assumes you're on an x86\_64 machine. If you're not, please adapt the +appropriate sections. + +First, we bootstrap our masterdirs. We need both a glibc one and a musl one: + +``` +$ ./xbps-src -m masterdir-glibc binary-bootstrap x86_64 +$ ./xbps-src -m masterdir-musl binary-bootstrap x86_64-musl +``` + +In addition to those, we need to set up binary remotes for the ppc repos. As +they aren't officially maintained by Voidlinux, they aren't included in this +repo, but you can include them locally by creating these three files: + +- `etc/xbps.d/repos-remote-ppc.conf`, with + `repository=https://repo.voidlinux-ppc.org/current/ppc` in it. +- `etc/xbps.d/repos-remote-ppc64.conf`, with + `repository=https://repo.voidlinux-ppc.org/current/be` in it. +- `etc/xbps.d/repos-remote-ppc64le-musl.conf`, with + `repository=https://repo.voidlinux-ppc.org/current/musl` in it. + +### Bootstrapping on your native architecture + +Assuming you've already adjusted the version and checksums for the distfiles +provided by upstream, we can now start building rust for our native +architecture, with both glibc and musl. Run this for both masterdirs +bootstrapped above + +``` +$ ./xbps-src -m pkg cargo +``` + +This builds `rust-bootstrap`, `cargo-bootstrap`, `rust` and `cargo` for your +native architecture, which we will need for the next step. + +### Crosscompiling for the target architectures and generating distfiles + +Now that we have the our native architecture covered, we cross build for the +architectures we need to generate distfiles for: + +``` +$ ./xbps-src -m -a pkg -o bindist rust +$ ./xbps-src -m -a pkg rust +$ ./xbps-src -m -a pkg -o bindist cargo +``` + +Repeat these three steps for `masterdir-glibc` with `ppc`, `masterdir-musl` with +`ppc64le-musl` and `masterdir-glibc` with `ppc64`. In the case of `ppc`, you can +skip the `bindist` build for rust, as we are taking those from upstream. + +Now that we have run those commands, the generated distfiles are available in +`hostdir/sources/distfiles`. Generate a `sha256sum` for each of those files, and +set the hashes in the appropriate places in the `rust-bootstrap` and +`cargo-bootstrap` templates. If you want to verify you did things correctly, you +can copy the generated distfiles over into `hostdir/sources/rust-bootstrap-${version}` +and `hostdir/sources/cargo-bootstrap-${version}`, and try cross-building the +bootstrap packages for those architectures. diff --git a/srcpkgs/rust-bootstrap/template b/srcpkgs/rust-bootstrap/template index 47742bf17ea..b756b9ade94 100644 --- a/srcpkgs/rust-bootstrap/template +++ b/srcpkgs/rust-bootstrap/template @@ -19,6 +19,7 @@ _bootstrap_url="https://static.rust-lang.org/dist" case "$XBPS_TARGET_MACHINE" in x86_64*|i686|ppc64le|ppc) ;; + # See srcpkgs/rust-bootstrap/files/generating-distfiles.md for details *) _bootstrap_url="https://repo-default.voidlinux.org/distfiles";; esac