2023-08-06 12:08:21 +00:00
|
|
|
# Maintainer: Oliver Smith <ollieparanoid@postmarketos.org>
|
|
|
|
# https://wiki.postmarketos.org/wiki/Pmbootstrap:_Cross_Compiling
|
|
|
|
#
|
2019-02-16 05:20:14 +00:00
|
|
|
# Wrapper for the "crossdirect" compilation method.
|
|
|
|
# pmbootstrap mounts the native chroot in the foreign arch (e.g. armhf) chroot
|
|
|
|
# as /native. This package gets installed into the native chroot, and creates
|
|
|
|
# wrappers like:
|
|
|
|
#
|
|
|
|
# /native/usr/lib/crossdirect/armhf/gcc
|
|
|
|
# -> /native/usr/bin/armv6-alpine-linux-muslgnueabihf-gcc
|
2020-01-02 15:16:20 +00:00
|
|
|
# /native/usr/lib/crossdirect/armhf/rustc
|
|
|
|
# -> /native/usr/bin/rustc --target=armv6-alpine-linux-musleabihf ...
|
2019-02-16 05:20:14 +00:00
|
|
|
#
|
|
|
|
# When building packages in the armhf chroot, PATH will get prepended with
|
|
|
|
# "/native/usr/lib/crossdirect/armhf". The end game is of course invoking the
|
|
|
|
# cross compiler from the native chroot, running at native speed, whenever
|
|
|
|
# calling the compiler from the foreign arch chroot. See crossdirect.c for
|
2020-01-02 15:16:20 +00:00
|
|
|
# implementation details of the C version (llvm, fakeroot, rpath). The rust
|
|
|
|
# version is implemented as simple shell wrappers.
|
2019-02-16 05:20:14 +00:00
|
|
|
|
|
|
|
pkgname=crossdirect
|
2023-08-06 12:08:21 +00:00
|
|
|
pkgver=5.1.0
|
2023-07-06 08:20:23 +00:00
|
|
|
pkgrel=0
|
2019-02-16 05:20:14 +00:00
|
|
|
pkgdesc="Wrappers to launch native cross compilers in foreign chroots"
|
|
|
|
url="https://postmarketOS.org"
|
|
|
|
arch="all"
|
|
|
|
license="MIT"
|
2020-01-02 15:16:20 +00:00
|
|
|
options="!check"
|
2023-07-06 08:20:23 +00:00
|
|
|
source="cargo.sh crossdirect.c rustc.sh rust-qemu-linker.sh"
|
2019-02-16 05:20:14 +00:00
|
|
|
|
|
|
|
build() {
|
|
|
|
cd "$srcdir"
|
|
|
|
# Architectures and binaries
|
|
|
|
_archs="x86_64 armhf armv7 aarch64"
|
|
|
|
for _arch in $_archs; do
|
|
|
|
[ "$_arch" == "$CARCH" ] && continue
|
|
|
|
_hostspec="$(arch_to_hostspec $_arch)"
|
2019-04-03 18:45:16 +00:00
|
|
|
|
|
|
|
# Build with -Werror, because we maintain this short program. (If
|
|
|
|
# upstream is elsewhere, having -Werror is usually not desired.)
|
|
|
|
$CC -o "crossdirect-$_arch" \
|
|
|
|
-static \
|
|
|
|
-Werror \
|
|
|
|
-DHOSTSPEC="\"$_hostspec\"" \
|
2019-02-16 05:20:14 +00:00
|
|
|
crossdirect.c
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
package() {
|
|
|
|
# Architectures and binaries
|
|
|
|
_archs="x86_64 armhf armv7 aarch64"
|
|
|
|
_bins="c++ cc cpp g++ gcc clang clang++"
|
|
|
|
|
2023-07-06 08:20:23 +00:00
|
|
|
# Rust wrappers
|
2020-01-02 15:16:20 +00:00
|
|
|
install -Dm755 "$srcdir/rust-qemu-linker.sh" \
|
|
|
|
"$pkgdir/usr/lib/crossdirect/rust-qemu-linker"
|
2023-07-06 08:20:23 +00:00
|
|
|
install -Dm755 "$srcdir/cargo.sh" "$pkgdir/usr/lib/crossdirect/cargo.sh"
|
|
|
|
install -Dm755 "$srcdir/rustc.sh" "$pkgdir/usr/lib/crossdirect/rustc.sh"
|
2020-01-02 15:16:20 +00:00
|
|
|
|
2019-02-16 05:20:14 +00:00
|
|
|
# Iterate over architectures
|
|
|
|
for _arch in $_archs; do
|
|
|
|
[ "$_arch" == "$CARCH" ] && continue
|
|
|
|
|
2020-01-02 15:16:20 +00:00
|
|
|
# GCC: put arch-specific crossdirect wrapper in arch-specific
|
|
|
|
# bin folder
|
2019-02-16 05:20:14 +00:00
|
|
|
_bindir="$pkgdir/usr/lib/crossdirect/$_arch"
|
|
|
|
_hostspec="$(arch_to_hostspec $_arch)"
|
|
|
|
mkdir -p "$_bindir"
|
|
|
|
cd "$_bindir"
|
|
|
|
cp "$srcdir/crossdirect-$_arch" "./"
|
|
|
|
|
2020-01-02 15:16:20 +00:00
|
|
|
# GCC: create compiler symlinks
|
2019-02-16 05:20:14 +00:00
|
|
|
for _bin in $_bins; do
|
|
|
|
ln -s "crossdirect-$_arch" "$_bin"
|
|
|
|
ln -s "crossdirect-$_arch" "$_hostspec-$_bin"
|
|
|
|
done
|
2020-01-02 15:16:20 +00:00
|
|
|
|
2023-07-06 08:20:23 +00:00
|
|
|
ln -s ../cargo.sh cargo
|
|
|
|
ln -s ../rustc.sh rustc
|
2019-02-16 05:20:14 +00:00
|
|
|
done
|
|
|
|
}
|
2023-08-06 12:08:21 +00:00
|
|
|
|
2023-07-06 08:20:23 +00:00
|
|
|
sha512sums="
|
|
|
|
0f4b48f250425dc57f63955fc8b38477d23db793bee367c3fbe03c3d2a559ba576434d07518310db4cae9d90d501af4051b80038b10fae94b980e537fc9374ad cargo.sh
|
|
|
|
500107e5aff8b34e74b54982ebcd447fc41bc8283956d506561b031a055cb30ec12698047c2604918b4b6d8560fe03db427a63dff2b83c907e8494b7f5233f29 crossdirect.c
|
2023-08-06 12:08:21 +00:00
|
|
|
de2aa6929bbff5db9132673e667f4525b333d062cb1f7a0597dd924de9e5c7215a9f8e2e6263b6fb5ace06f2c4b64f4ebfd0ede9b78add07c2cd08ec8613e98f rustc.sh
|
2023-07-06 08:20:23 +00:00
|
|
|
ea9bf8db3810d03d0a7395057f3d6e57f7127d87c55deaedc171c255288f5f3cc6fbcc680a5a1b92786cf573875d5dc22521173799fe2639acc97d0715ff905b rust-qemu-linker.sh
|
|
|
|
"
|