Skip to content

Commit 85be4c4

Browse files
committed
dev-lang/rust: add rust-1.39.0-r667 with pr65474
pr65474 minimizes the amount of files needed for the install of a rust-std component by not merging certain dev-header files and other instable components. more information: rust-lang/rust#64823 rust-lang/rust#65474 I opted for +-r1 and dropped keywords, for testing. Also included pr66103, it shouldn't hurt anyone. Signed-off-by: Steffen Kuhn <[email protected]>
1 parent 02433a8 commit 85be4c4

File tree

1 file changed

+296
-0
lines changed

1 file changed

+296
-0
lines changed

dev-lang/rust/rust-1.39.0-r667.ebuild

+296
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,296 @@
1+
# Copyright 1999-2019 Gentoo Authors
2+
# Distributed under the terms of the GNU General Public License v2
3+
4+
EAPI=6
5+
6+
PYTHON_COMPAT=( python2_7 python3_{5,6,7} pypy )
7+
8+
inherit multiprocessing multilib-build python-any-r1 toolchain-funcs versionator
9+
10+
ABI_VER="$(get_version_component_range 1-2)"
11+
SLOT="dev/${ABI_VER}"
12+
MY_P="rustc-${PV}"
13+
SRC="${MY_P}-src.tar.xz"
14+
#KEYWORDS="~amd64 ~arm64 ~x86"
15+
16+
CHOST_amd64=x86_64-unknown-linux-gnu
17+
CHOST_x86=i686-unknown-linux-gnu
18+
CHOST_arm64=aarch64-unknown-linux-gnu
19+
CHOST_arm=armv7-unknown-linux-gnueabihf
20+
21+
RUST_STAGE0_VERSION="1.$(($(get_version_component_range 2) - 1)).0"
22+
RUST_STAGE0_amd64="rust-${RUST_STAGE0_VERSION}-${CHOST_amd64}"
23+
RUST_STAGE0_x86="rust-${RUST_STAGE0_VERSION}-${CHOST_x86}"
24+
RUST_STAGE0_arm64="rust-${RUST_STAGE0_VERSION}-${CHOST_arm64}"
25+
RUST_STAGE0_armv7="rust-${RUST_STAGE0_VERSION}-${CHOST_arm}"
26+
27+
CARGO_DEPEND_VERSION="0.$(($(get_version_component_range 2))).0"
28+
29+
DESCRIPTION="Systems programming language from Mozilla"
30+
HOMEPAGE="https://www.rust-lang.org/"
31+
32+
SRC_URI="https://static.rust-lang.org/dist/${SRC} -> rustc-${PV}-src.tar.xz
33+
amd64? ( https://static.rust-lang.org/dist/${RUST_STAGE0_amd64}.tar.xz )
34+
x86? ( https://static.rust-lang.org/dist/${RUST_STAGE0_x86}.tar.xz )
35+
arm64? ( https://static.rust-lang.org/dist/${RUST_STAGE0_arm64}.tar.xz )
36+
arm? ( https://static.rust-lang.org/dist/${RUST_STAGE0_armv7}.tar.xz )
37+
"
38+
39+
ALL_LLVM_TARGETS=( AArch64 AMDGPU ARM BPF Hexagon Lanai Mips MSP430
40+
NVPTX PowerPC Sparc SystemZ X86 XCore )
41+
ALL_LLVM_TARGETS=( "${ALL_LLVM_TARGETS[@]/#/llvm_targets_}" )
42+
LLVM_TARGET_USEDEPS=${ALL_LLVM_TARGETS[@]/%/?}
43+
44+
LICENSE="|| ( MIT Apache-2.0 ) BSD-1 BSD-2 BSD-4 UoI-NCSA"
45+
46+
IUSE="clippy debug doc libressl rls rustfmt thumbv7neon wasm ${ALL_LLVM_TARGETS[*]}"
47+
48+
RDEPEND=">=app-eselect/eselect-rust-20190311
49+
sys-libs/zlib
50+
!libressl? ( <dev-libs/openssl-1.1.2:= >=dev-libs/openssl-1.0.1:= )
51+
libressl? ( <=dev-libs/libressl-2.9.0:= >=dev-libs/libressl-2.5:= )
52+
net-libs/libssh2
53+
net-libs/http-parser
54+
net-misc/curl[ssl]
55+
"
56+
DEPEND="${RDEPEND}
57+
${PYTHON_DEPS}
58+
|| (
59+
>=sys-devel/gcc-4.7
60+
>=sys-devel/clang-3.5
61+
)
62+
!dev-util/cargo
63+
rustfmt? ( !dev-util/rustfmt )
64+
dev-util/cmake
65+
"
66+
PDEPEND=""
67+
68+
REQUIRED_USE="|| ( ${ALL_LLVM_TARGETS[*]} )"
69+
70+
PATCHES=(
71+
# https://github.com/rust-lang/rust/pull/65474
72+
"${FILESDIR}"/pr65474.patch
73+
"${FILESDIR}"/pr66103.patch
74+
)
75+
76+
77+
S="${WORKDIR}/${MY_P}-src"
78+
79+
toml_usex() {
80+
usex "$1" true false
81+
}
82+
83+
src_prepare() {
84+
local rust_stage0_root="${WORKDIR}"/rust-stage0
85+
86+
local rust_stage0_name="RUST_STAGE0_${ARCH}"
87+
local rust_stage0="${!rust_stage0_name}"
88+
89+
"${WORKDIR}/${rust_stage0}"/install.sh --disable-ldconfig --destdir="${rust_stage0_root}" --prefix=/ || die
90+
91+
default
92+
}
93+
94+
src_configure() {
95+
local rust_target="" rust_targets="" rust_target_name arch_cflags
96+
97+
# Collect rust target names to compile standard libs for all ABIs.
98+
for v in $(multilib_get_enabled_abi_pairs); do
99+
rust_target_name="CHOST_${v##*.}"
100+
rust_targets="${rust_targets},\"${!rust_target_name}\""
101+
done
102+
if use wasm; then
103+
rust_targets="${rust_targets},\"wasm32-unknown-unknown\""
104+
fi
105+
if use arm && use thumbv7neon; then
106+
rust_targets="${rust_targets},\"thumbv7neon-unknown-linux-gnueabihf\""
107+
fi
108+
109+
rust_targets="${rust_targets#,}"
110+
111+
local extended="true" tools="\"cargo\","
112+
if use clippy; then
113+
tools="\"clippy\",$tools"
114+
fi
115+
if use rls; then
116+
tools="\"rls\",\"analysis\",\"src\",$tools"
117+
fi
118+
if use rustfmt; then
119+
tools="\"rustfmt\",$tools"
120+
fi
121+
122+
local rust_stage0_root="${WORKDIR}"/rust-stage0
123+
124+
rust_target_name="CHOST_${ARCH}"
125+
rust_target="${!rust_target_name}"
126+
127+
cat <<- EOF > "${S}"/config.toml
128+
[llvm]
129+
optimize = $(toml_usex !debug)
130+
release-debuginfo = $(toml_usex debug)
131+
assertions = $(toml_usex debug)
132+
targets = "${LLVM_TARGETS// /;}"
133+
experimental-targets = ""
134+
[build]
135+
build = "${rust_target}"
136+
host = ["${rust_target}"]
137+
target = [${rust_targets}]
138+
cargo = "${rust_stage0_root}/bin/cargo"
139+
rustc = "${rust_stage0_root}/bin/rustc"
140+
docs = $(toml_usex doc)
141+
submodules = false
142+
python = "${EPYTHON}"
143+
locked-deps = true
144+
vendor = true
145+
extended = ${extended}
146+
tools = [${tools}]
147+
verbose = 2
148+
[install]
149+
prefix = "${EPREFIX}/usr"
150+
libdir = "$(get_libdir)"
151+
docdir = "share/doc/${P}"
152+
mandir = "share/${P}/man"
153+
[rust]
154+
optimize = $(toml_usex !debug)
155+
debug = $(toml_usex debug)
156+
debug-assertions = $(toml_usex debug)
157+
default-linker = "$(tc-getCC)"
158+
rpath = false
159+
lld = $(toml_usex wasm)
160+
EOF
161+
162+
for v in $(multilib_get_enabled_abi_pairs); do
163+
rust_target=$(get_abi_CHOST ${v##*.})
164+
arch_cflags="$(get_abi_CFLAGS ${v##*.})"
165+
166+
cat <<- EOF >> "${S}"/config.env
167+
CFLAGS_${rust_target}=${arch_cflags}
168+
EOF
169+
170+
cat <<- EOF >> "${S}"/config.toml
171+
[target.${rust_target}]
172+
cc = "$(tc-getBUILD_CC)"
173+
cxx = "$(tc-getBUILD_CXX)"
174+
linker = "$(tc-getCC)"
175+
ar = "$(tc-getAR)"
176+
EOF
177+
done
178+
179+
if use wasm; then
180+
cat <<- EOF >> "${S}"/config.toml
181+
[target.wasm32-unknown-unknown]
182+
linker = "lld"
183+
EOF
184+
fi
185+
186+
if use arm && use thumbv7neon; then
187+
cat <<- EOF >> "${S}"/config.toml
188+
[target.thumbv7neon-unknown-linux-gnueabihf]
189+
cc = "$(tc-getBUILD_CC)"
190+
cxx = "$(tc-getBUILD_CXX)"
191+
linker = "$(tc-getCC)"
192+
ar = "$(tc-getAR)"
193+
EOF
194+
fi
195+
}
196+
197+
src_compile() {
198+
env $(cat "${S}"/config.env)\
199+
./x.py build --config="${S}"/config.toml -j$(makeopts_jobs) \
200+
--exclude src/tools/miri || die # https://github.com/rust-lang/rust/issues/52305
201+
}
202+
203+
src_install() {
204+
local rust_target abi_libdir
205+
206+
env DESTDIR="${D}" ./x.py install || die
207+
208+
mv "${D}/usr/bin/rustc" "${D}/usr/bin/rustc-${PV}" || die
209+
mv "${D}/usr/bin/rustdoc" "${D}/usr/bin/rustdoc-${PV}" || die
210+
mv "${D}/usr/bin/rust-gdb" "${D}/usr/bin/rust-gdb-${PV}" || die
211+
mv "${D}/usr/bin/rust-lldb" "${D}/usr/bin/rust-lldb-${PV}" || die
212+
mv "${D}/usr/bin/cargo" "${D}/usr/bin/cargo-${PV}" || die
213+
if use clippy; then
214+
mv "${D}/usr/bin/clippy-driver" "${D}/usr/bin/clippy-driver-${PV}" || die
215+
mv "${D}/usr/bin/cargo-clippy" "${D}/usr/bin/cargo-clippy-${PV}" || die
216+
fi
217+
if use rls; then
218+
mv "${D}/usr/bin/rls" "${D}/usr/bin/rls-${PV}" || die
219+
fi
220+
if use rustfmt; then
221+
mv "${D}/usr/bin/rustfmt" "${D}/usr/bin/rustfmt-${PV}" || die
222+
mv "${D}/usr/bin/cargo-fmt" "${D}/usr/bin/cargo-fmt-${PV}" || die
223+
fi
224+
225+
# Copy shared library versions of standard libraries for all targets
226+
# into the system's abi-dependent lib directories because the rust
227+
# installer only does so for the native ABI.
228+
for v in $(multilib_get_enabled_abi_pairs); do
229+
if [ ${v##*.} = ${DEFAULT_ABI} ]; then
230+
continue
231+
fi
232+
abi_libdir=$(get_abi_LIBDIR ${v##*.})
233+
rust_target=$(get_abi_CHOST ${v##*.})
234+
mkdir -p "${D}/usr/${abi_libdir}"
235+
cp "${D}/usr/$(get_libdir)/rustlib/${rust_target}/lib"/*.so \
236+
"${D}/usr/${abi_libdir}" || die
237+
done
238+
239+
dodoc COPYRIGHT
240+
241+
# FIXME:
242+
# Really not sure if that env is needed, specailly LDPATH
243+
cat <<-EOF > "${T}"/50${P}
244+
LDPATH="/usr/$(get_libdir)/${P}"
245+
MANPATH="/usr/share/${P}/man"
246+
EOF
247+
doenvd "${T}"/50${P}
248+
249+
cat <<-EOF > "${T}/provider-${P}"
250+
/usr/bin/rustdoc
251+
/usr/bin/rust-gdb
252+
/usr/bin/rust-lldb
253+
EOF
254+
echo /usr/bin/cargo >> "${T}/provider-${P}"
255+
if use clippy; then
256+
echo /usr/bin/clippy-driver >> "${T}/provider-${P}"
257+
echo /usr/bin/cargo-clippy >> "${T}/provider-${P}"
258+
fi
259+
if use rls; then
260+
echo /usr/bin/rls >> "${T}/provider-${P}"
261+
fi
262+
if use rustfmt; then
263+
echo /usr/bin/rustfmt >> "${T}/provider-${P}"
264+
echo /usr/bin/cargo-fmt >> "${T}/provider-${P}"
265+
fi
266+
dodir /etc/env.d/rust
267+
insinto /etc/env.d/rust
268+
doins "${T}/provider-${P}"
269+
}
270+
271+
pkg_postinst() {
272+
eselect rust update --if-unset
273+
274+
elog "Rust installs a helper script for calling GDB and LLDB,"
275+
elog "for your convenience it is installed under /usr/bin/rust-{gdb,lldb}-${PV}."
276+
277+
ewarn "cargo is now installed from dev-lang/rust{,-bin} instead of dev-util/cargo."
278+
ewarn "This might have resulted in a dangling symlink for /usr/bin/cargo on some"
279+
ewarn "systems. This can be resolved by calling 'sudo eselect rust set ${P}'."
280+
281+
if has_version app-editors/emacs || has_version app-editors/emacs-vcs; then
282+
elog "install app-emacs/rust-mode to get emacs support for rust."
283+
fi
284+
285+
if has_version app-editors/gvim || has_version app-editors/vim; then
286+
elog "install app-vim/rust-vim to get vim support for rust."
287+
fi
288+
289+
if has_version 'app-shells/zsh'; then
290+
elog "install app-shells/rust-zshcomp to get zsh completion for rust."
291+
fi
292+
}
293+
294+
pkg_postrm() {
295+
eselect rust unset --if-invalid
296+
}

0 commit comments

Comments
 (0)