blob: f4451f743596a2ac3aca05bc0e32a68a5ceef023 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: rust-toolchain.eclass
# @MAINTAINER:
# Rust Project <rust@gentoo.org>
# @SUPPORTED_EAPIS: 8
# @BLURB: helps map gentoo arches to rust ABIs
# @DESCRIPTION:
# This eclass contains a src_unpack default phase function, and
# helper functions, to aid in proper rust-ABI handling for various
# gentoo arches.
case ${EAPI} in
8) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
inherit multilib-build
# @ECLASS_VARIABLE: RUST_TOOLCHAIN_BASEURL
# @DESCRIPTION:
# This variable specifies the base URL used by the
# rust_arch_uri and rust_all_arch_uris functions when
# generating the URI output list.
: "${RUST_TOOLCHAIN_BASEURL:=https://static.rust-lang.org/dist/}"
# @FUNCTION: rust_abi
# @USAGE: [CHOST-value]
# @DESCRIPTION:
# Outputs the Rust ABI name from a CHOST value, uses CHOST in the
# environment if none is specified.
rust_abi() {
local CTARGET=${1:-${CHOST}}
case ${CTARGET%%*-} in
aarch64*gnu) echo aarch64-unknown-linux-gnu;;
aarch64*musl) echo aarch64-unknown-linux-musl;;
armv6j*h*) echo arm-unknown-linux-gnueabihf;;
armv6j*s*) echo arm-unknown-linux-gnueabi;;
armv7a*h*) echo armv7-unknown-linux-gnueabihf;;
i?86*) echo i686-unknown-linux-gnu;;
loongarch64*) echo loongarch64-unknown-linux-gnu;;
mips64el*) echo mips64el-unknown-linux-gnuabi64;;
mips64*) echo mips64-unknown-linux-gnuabi64;;
mipsel*) echo mipsel-unknown-linux-gnu;;
mips*) echo mips-unknown-linux-gnu;;
powerpc64le*) echo powerpc64le-unknown-linux-gnu;;
powerpc64*) echo powerpc64-unknown-linux-gnu;;
powerpc*) echo powerpc-unknown-linux-gnu;;
riscv64*) echo riscv64gc-unknown-linux-gnu;;
s390x*) echo s390x-unknown-linux-gnu;;
x86_64*gnu) echo x86_64-unknown-linux-gnu;;
x86_64*musl) echo x86_64-unknown-linux-musl;;
*) echo ${CTARGET};;
esac
}
# @FUNCTION: rust_all_abis
# @DESCRIPTION:
# Outputs a list of all the enabled Rust ABIs
rust_all_abis() {
if use multilib; then
local abi
local ALL_ABIS=()
for abi in $(multilib_get_enabled_abis); do
ALL_ABIS+=( $(rust_abi $(get_abi_CHOST ${abi})) )
done
local abi_list
IFS=, eval 'abi_list=${ALL_ABIS[*]}'
echo ${abi_list}
else
rust_abi
fi
}
# @FUNCTION: rust_arch_uri
# @USAGE: <rust-ABI> <base-uri> [alt-distfile-basename]
# @DESCRIPTION:
# Output the URI for use in SRC_URI, combining $RUST_TOOLCHAIN_BASEURL
# and the URI suffix provided in ARG2 with the rust ABI in ARG1, and
# optionally renaming to the distfile basename specified in ARG3.
#
# @EXAMPLE:
# SRC_URI="amd64? (
# $(rust_arch_uri x86_64-unknown-linux-gnu rustc-${STAGE0_VERSION})
# )"
#
rust_arch_uri() {
if [ -n "$3" ]; then
echo "${RUST_TOOLCHAIN_BASEURL}${2}-${1}.tar.xz -> ${3}-${1}.tar.xz"
else
echo "${RUST_TOOLCHAIN_BASEURL}${2}-${1}.tar.xz"
echo "verify-sig? ( ${RUST_TOOLCHAIN_BASEURL}${2}-${1}.tar.xz.asc )"
fi
}
# @FUNCTION: rust_all_arch_uris
# @USAGE: <base-uri> [alt-distfile-basename]
# @DESCRIPTION:
# Outputs the URIs for SRC_URI to help fetch dependencies, using a base URI
# provided as an argument. Optionally allows for distfile renaming via a specified
# basename.
#
# @EXAMPLE:
# SRC_URI="$(rust_all_arch_uris rustc-${STAGE0_VERSION})"
#
rust_all_arch_uris()
{
echo "
abi_x86_32? ( $(rust_arch_uri i686-unknown-linux-gnu "$@") )
abi_x86_64? (
elibc_glibc? ( $(rust_arch_uri x86_64-unknown-linux-gnu "$@") )
elibc_musl? ( $(rust_arch_uri x86_64-unknown-linux-musl "$@") )
)
arm? (
$(rust_arch_uri arm-unknown-linux-gnueabi "$@")
$(rust_arch_uri arm-unknown-linux-gnueabihf "$@")
$(rust_arch_uri armv7-unknown-linux-gnueabihf "$@")
)
arm64? (
elibc_glibc? ( $(rust_arch_uri aarch64-unknown-linux-gnu "$@") )
elibc_musl? ( $(rust_arch_uri aarch64-unknown-linux-musl "$@") )
)
mips? (
abi_mips_o32? (
big-endian? ( $(rust_arch_uri mips-unknown-linux-gnu "$@") )
!big-endian? ( $(rust_arch_uri mipsel-unknown-linux-gnu "$@") )
)
abi_mips_n64? (
big-endian? ( $(rust_arch_uri mips64-unknown-linux-gnuabi64 "$@") )
!big-endian? ( $(rust_arch_uri mips64el-unknown-linux-gnuabi64 "$@") )
)
)
ppc? ( $(rust_arch_uri powerpc-unknown-linux-gnu "$@") )
ppc64? (
big-endian? ( $(rust_arch_uri powerpc64-unknown-linux-gnu "$@") )
!big-endian? ( $(rust_arch_uri powerpc64le-unknown-linux-gnu "$@") )
)
riscv? ( $(rust_arch_uri riscv64gc-unknown-linux-gnu "$@") )
s390? ( $(rust_arch_uri s390x-unknown-linux-gnu "$@") )
"
# Upstream did not gain support for loong until v1.71.0.
# NOTE: Merge this into the block above after every <1.71.0 version is
# gone from tree.
local arg_version="${1##*-}"
if ver_test "${arg_version:-$PV}" -ge 1.71.0; then
echo "loong? ( $(rust_arch_uri loongarch64-unknown-linux-gnu "$@") )"
fi
}
|