Gentoo Archives: gentoo-commits

From: Mikhail Pukhlikov <cynede@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/rust:master commit in: dev-lang/rust/, dev-lang/rust/files/, virtual/rust/
Date: Tue, 01 Sep 2020 06:09:35
Message-Id: 1598940562.cc2208c51917e8e0ce9104f5d79a3100fc504dd4.cynede@gentoo
1 commit: cc2208c51917e8e0ce9104f5d79a3100fc504dd4
2 Author: o01eg <o01eg <AT> yandex <DOT> ru>
3 AuthorDate: Mon Aug 31 19:06:38 2020 +0000
4 Commit: Mikhail Pukhlikov <cynede <AT> gentoo <DOT> org>
5 CommitDate: Tue Sep 1 06:09:22 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/rust.git/commit/?id=cc2208c5
7
8 Update dev-lang/rust-9999 and virtual/rust-9999
9
10 Closes: https://github.com/gentoo/gentoo-rust/pull/501
11 Signed-off-by: Mikhail Pukhlikov <cynede <AT> gentoo.org>
12
13 dev-lang/rust/files/1.43.1-fix-libdir.patch | 70 ----------
14 dev-lang/rust/rust-9999.ebuild | 191 +++++++++++++++++++++-------
15 virtual/rust/rust-9999.ebuild | 10 +-
16 3 files changed, 152 insertions(+), 119 deletions(-)
17
18 diff --git a/dev-lang/rust/files/1.43.1-fix-libdir.patch b/dev-lang/rust/files/1.43.1-fix-libdir.patch
19 deleted file mode 100644
20 index e1dccf3..0000000
21 --- a/dev-lang/rust/files/1.43.1-fix-libdir.patch
22 +++ /dev/null
23 @@ -1,70 +0,0 @@
24 -diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
25 -index eb0199fd020..c33657549ba 100644
26 ---- a/src/bootstrap/builder.rs
27 -+++ b/src/bootstrap/builder.rs
28 -@@ -646,6 +646,7 @@ impl<'a> Builder<'a> {
29 - pub fn sysroot_libdir_relative(&self, compiler: Compiler) -> &Path {
30 - match self.config.libdir_relative() {
31 - Some(relative_libdir) if compiler.stage >= 1 => relative_libdir,
32 -+ _ if compiler.stage == 0 => &self.build.initial_libdir,
33 - _ => Path::new("lib"),
34 - }
35 - }
36 -diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
37 -index a476d25f102..7fe4496ca45 100644
38 ---- a/src/bootstrap/lib.rs
39 -+++ b/src/bootstrap/lib.rs
40 -@@ -242,6 +242,7 @@ pub struct Build {
41 - initial_rustc: PathBuf,
42 - initial_cargo: PathBuf,
43 - initial_lld: PathBuf,
44 -+ initial_libdir: PathBuf,
45 -
46 - // Runtime state filled in later on
47 - // C/C++ compilers and archiver for all targets
48 -@@ -343,18 +344,38 @@ impl Build {
49 - // we always try to use git for LLVM builds
50 - let in_tree_llvm_info = channel::GitInfo::new(false, &src.join("src/llvm-project"));
51 -
52 -- let initial_sysroot = config.initial_rustc.parent().unwrap().parent().unwrap();
53 -- let initial_lld = initial_sysroot
54 -- .join("lib")
55 -- .join("rustlib")
56 -- .join(config.build)
57 -- .join("bin")
58 -- .join("rust-lld");
59 -+ let initial_target_libdir_str = output(
60 -+ Command::new(&config.initial_rustc)
61 -+ .arg("--target")
62 -+ .arg(config.build)
63 -+ .arg("--print")
64 -+ .arg("target-libdir"),
65 -+ );
66 -+ let initial_target_dir = Path::new(&initial_target_libdir_str).parent().unwrap();
67 -+ let initial_lld = initial_target_dir.join("bin").join("rust-lld");
68 -+
69 -+ let initial_sysroot = output(
70 -+ Command::new(&config.initial_rustc)
71 -+ .arg("--print")
72 -+ .arg("sysroot"),
73 -+ );
74 -+ println!("stage0 sysroot: {}", initial_sysroot);
75 -+ let initial_libdir_full = initial_target_dir
76 -+ .parent()
77 -+ .unwrap()
78 -+ .parent()
79 -+ .unwrap();
80 -+ println!("stage0 libdir: {}", initial_libdir_full.display());
81 -+ let initial_libdir = initial_libdir_full
82 -+ .strip_prefix(initial_sysroot.trim())
83 -+ .unwrap()
84 -+ .to_path_buf();
85 -
86 - let mut build = Build {
87 - initial_rustc: config.initial_rustc.clone(),
88 - initial_cargo: config.initial_cargo.clone(),
89 - initial_lld,
90 -+ initial_libdir,
91 - local_rebuild: config.local_rebuild,
92 - fail_fast: config.cmd.fail_fast(),
93 - doc_tests: config.cmd.doc_tests(),
94
95 diff --git a/dev-lang/rust/rust-9999.ebuild b/dev-lang/rust/rust-9999.ebuild
96 index b96c023..ab98c35 100644
97 --- a/dev-lang/rust/rust-9999.ebuild
98 +++ b/dev-lang/rust/rust-9999.ebuild
99 @@ -50,12 +50,24 @@ LLVM_DEPEND="
100 "
101 LLVM_MAX_SLOT=10
102
103 -# libgit2 should be at least same as bungled into libgit-sys #707746
104 -COMMON_DEPEND="
105 +BDEPEND="${PYTHON_DEPS}
106 + app-eselect/eselect-rust
107 + || (
108 + >=sys-devel/gcc-4.7
109 + >=sys-devel/clang-3.5
110 + )
111 + !system-llvm? (
112 + dev-util/cmake
113 + dev-util/ninja
114 + )
115 +"
116 +
117 +# libgit2 should be at least same as bundled into libgit-sys #707746
118 +DEPEND="
119 >=dev-libs/libgit2-0.99:=
120 net-libs/libssh2:=
121 net-libs/http-parser:=
122 - net-misc/curl:=[ssl]
123 + net-misc/curl:=[http2,ssl]
124 sys-libs/zlib:=
125 !libressl? ( dev-libs/openssl:0= )
126 libressl? ( dev-libs/libressl:0= )
127 @@ -65,20 +77,8 @@ COMMON_DEPEND="
128 )
129 "
130
131 -DEPEND="${COMMON_DEPEND}
132 - ${PYTHON_DEPS}
133 - || (
134 - >=sys-devel/gcc-4.7
135 - >=sys-devel/clang-3.5
136 - )
137 - !system-llvm? (
138 - dev-util/cmake
139 - dev-util/ninja
140 - )
141 -"
142 -
143 -RDEPEND="${COMMON_DEPEND}
144 - >=app-eselect/eselect-rust-20190311
145 +RDEPEND="${DEPEND}
146 + app-eselect/eselect-rust
147 "
148
149 REQUIRED_USE="|| ( ${ALL_LLVM_TARGETS[*]} )
150 @@ -87,22 +87,25 @@ REQUIRED_USE="|| ( ${ALL_LLVM_TARGETS[*]} )
151 ?? ( system-llvm sanitize )
152 "
153
154 +# we don't use cmake.eclass, but can get a warnin -l
155 +CMAKE_WARN_UNUSED_CLI=no
156 +
157 QA_FLAGS_IGNORED="
158 usr/bin/.*-${PV}
159 - usr/lib.*/lib.*.so
160 - usr/lib.*/${P}/rustlib/.*/codegen-backends/librustc_codegen_llvm-llvm.so
161 - usr/lib.*/${P}/rustlib/.*/lib/lib.*.so
162 + usr/lib.*/${P}/lib.*.so.*
163 + usr/lib.*/${P}/rustlib/.*/bin/.*
164 + usr/lib.*/${P}/rustlib/.*/lib/lib.*.so.*
165 +"
166 +
167 +QA_SONAME="
168 + usr/lib.*/${P}/lib.*.so.*
169 + usr/lib.*/${P}/rustlib/.*/lib/lib.*.so.*
170 "
171
172 # tests need a bit more work, currently they are causing multiple
173 # re-compilations and somewhat fragile.
174 RESTRICT="test network-sandbox"
175
176 -QA_SONAME="usr/lib.*/librustc_macros.*.so"
177 -
178 -PATCHES=(
179 - "${FILESDIR}"/1.43.1-fix-libdir.patch
180 -)
181
182 S="${WORKDIR}/${MY_P}-src"
183
184 @@ -111,13 +114,21 @@ toml_usex() {
185 }
186
187 pre_build_checks() {
188 - CHECKREQS_DISK_BUILD="9G"
189 + local M=6144
190 + M=$(( $(usex clippy 128 0) + ${M} ))
191 + M=$(( $(usex miri 128 0) + ${M} ))
192 + M=$(( $(usex rls 512 0) + ${M} ))
193 + M=$(( $(usex rustfmt 256 0) + ${M} ))
194 + M=$(( $(usex system-llvm 0 2048) + ${M} ))
195 + M=$(( $(usex wasm 256 0) + ${M} ))
196 + M=$(( $(usex debug 15 10) * ${M} / 10 ))
197 eshopts_push -s extglob
198 if is-flagq '-g?(gdb)?([1-9])'; then
199 - CHECKREQS_DISK_BUILD="15G"
200 + M=$(( 15 * ${M} / 10 ))
201 fi
202 eshopts_pop
203 - check-reqs_pkg_setup
204 + M=$(( $(usex doc 256 0) + ${M} ))
205 + CHECKREQS_DISK_BUILD=${M}M check-reqs_pkg_${EBUILD_PHASE}
206 }
207
208 pkg_pretend() {
209 @@ -167,6 +178,11 @@ src_configure() {
210 done
211 if use wasm; then
212 rust_targets="${rust_targets},\"wasm32-unknown-unknown\""
213 + if use system-llvm; then
214 + # un-hardcode rust-lld linker for this target
215 + # https://bugs.gentoo.org/715348
216 + sed -i '/linker:/ s/rust-lld/wasm-ld/' src/librustc_target/spec/wasm32_base.rs || die
217 + fi
218 fi
219 rust_targets="${rust_targets#,}"
220
221 @@ -184,8 +200,6 @@ src_configure() {
222 tools="\"rustfmt\",$tools"
223 fi
224
225 - local rust_stage0_root="${WORKDIR}"/rust-stage0
226 -
227 rust_target="$(rust_abi)"
228
229 cat <<- EOF > "${S}"/config.toml
230 @@ -274,6 +288,83 @@ src_configure() {
231 EOF
232 fi
233
234 + if [[ -n ${I_KNOW_WHAT_I_AM_DOING_CROSS} ]]; then #whitespace intentionally shifted below
235 + # experimental cross support
236 + # discussion: https://bugs.gentoo.org/679878
237 + # TODO: c*flags, clang, system-llvm, cargo.eclass target support
238 + # it would be much better if we could split out stdlib
239 + # complilation to separate ebuild and abuse CATEGORY to
240 + # just install to /usr/lib/rustlib/<target>
241 +
242 + # extra targets defined as a bash array
243 + # spec format: <LLVM target>:<rust-target>:<CTARGET>
244 + # best place would be /etc/portage/env/dev-lang/rust
245 + # Example:
246 + # RUST_CROSS_TARGETS=(
247 + # "AArch64:aarch64-unknown-linux-gnu:aarch64-unknown-linux-gnu"
248 + # )
249 + # no extra hand holding is done, no target transformations, all
250 + # values are passed as-is with just basic checks, so it's up to user to supply correct values
251 + # valid rust targets can be obtained with
252 + # rustc --print target-list
253 + # matching cross toolchain has to be installed
254 + # matching LLVM_TARGET has to be enabled for both rust and llvm (if using system one)
255 + # only gcc toolchains installed with crossdev are checked for now.
256 +
257 + # BUG: we can't pass host flags to cross compiler, so just filter for now
258 + # BUG: this should be more fine-grained.
259 + filter-flags '-mcpu=*' '-march=*' '-mtune=*'
260 +
261 + local cross_target_spec
262 + for cross_target_spec in "${RUST_CROSS_TARGETS[@]}";do
263 + # extracts first element form <LLVM target>:<rust-target>:<CTARGET>
264 + local cross_llvm_target="${cross_target_spec%%:*}"
265 + # extracts toolchain triples, <rust-target>:<CTARGET>
266 + local cross_triples="${cross_target_spec#*:}"
267 + # extracts first element after before : separator
268 + local cross_rust_target="${cross_triples%%:*}"
269 + # extracts last element after : separator
270 + local cross_toolchain="${cross_triples##*:}"
271 + use llvm_targets_${cross_llvm_target} || die "need llvm_targets_${cross_llvm_target} target enabled"
272 + command -v ${cross_toolchain}-gcc > /dev/null 2>&1 || die "need ${cross_toolchain} cross toolchain"
273 +
274 + cat <<- EOF >> "${S}"/config.toml
275 + [target.${cross_rust_target}]
276 + cc = "${cross_toolchain}-gcc"
277 + cxx = "${cross_toolchain}-g++"
278 + linker = "${cross_toolchain}-gcc"
279 + ar = "${cross_toolchain}-ar"
280 + EOF
281 + if use system-llvm; then
282 + cat <<- EOF >> "${S}"/config.toml
283 + llvm-config = "$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin/llvm-config"
284 + EOF
285 + fi
286 +
287 + # append cross target to "normal" target list
288 + # example 'target = ["powerpc64le-unknown-linux-gnu"]'
289 + # becomes 'target = ["powerpc64le-unknown-linux-gnu","aarch64-unknown-linux-gnu"]'
290 +
291 + rust_targets="${rust_targets},\"${cross_rust_target}\""
292 + sed -i "/^target = \[/ s#\[.*\]#\[${rust_targets}\]#" config.toml || die
293 +
294 + ewarn
295 + ewarn "Enabled ${cross_rust_target} rust target"
296 + ewarn "Using ${cross_toolchain} cross toolchain"
297 + ewarn
298 + if ! has_version -b 'sys-devel/binutils[multitarget]' ; then
299 + ewarn "'sys-devel/binutils[multitarget]' is not installed"
300 + ewarn "'strip' will be unable to strip cross libraries"
301 + ewarn "cross targets will be installed with full debug information"
302 + ewarn "enable 'multitarget' USE flag for binutils to be able to strip object files"
303 + ewarn
304 + ewarn "Alternatively llvm-strip can be used, it supports stripping any target"
305 + ewarn "define STRIP=\"llvm-strip\" to use it (experimental)"
306 + ewarn
307 + fi
308 + done
309 + fi # I_KNOW_WHAT_I_AM_DOING_CROSS
310 +
311 einfo "Rust configured with the following settings:"
312 cat "${S}"/config.toml || die
313 }
314 @@ -300,8 +391,6 @@ src_test() {
315 }
316
317 src_install() {
318 - local rust_target abi_libdir
319 -
320 env $(cat "${S}"/config.env) DESTDIR="${D}" \
321 "${EPYTHON}" ./x.py install -vv --config="${S}"/config.toml -j$(makeopts_jobs) || die
322
323 @@ -311,8 +400,8 @@ src_install() {
324 dobashcomp build/tmp/dist/cargo-image/etc/bash_completion.d/cargo
325
326 # fix collision with stable rust #675026
327 - rmdir "${ED}"/usr/share/bash-completion/completions/cargo || die
328 - rmdir "${ED}"/usr/share/zsh/site-functions/_cargo || die
329 + rm "${ED}"/usr/share/bash-completion/completions/cargo || die
330 + rm "${ED}"/usr/share/zsh/site-functions/_cargo || die
331
332 mv "${ED}/usr/bin/rustc" "${ED}/usr/bin/rustc-${PV}" || die
333 mv "${ED}/usr/bin/rustdoc" "${ED}/usr/bin/rustdoc-${PV}" || die
334 @@ -336,22 +425,34 @@ src_install() {
335 mv "${ED}/usr/bin/cargo-fmt" "${ED}/usr/bin/cargo-fmt-${PV}" || die
336 fi
337
338 + # Copy shared library versions of standard libraries for all targets
339 + # into the system's abi-dependent lib directories because the rust
340 + # installer only does so for the native ABI.
341 +
342 + local abi_libdir rust_target
343 + for v in $(multilib_get_enabled_abi_pairs); do
344 + if [ ${v##*.} = ${DEFAULT_ABI} ]; then
345 + continue
346 + fi
347 + abi_libdir=$(get_abi_LIBDIR ${v##*.})
348 + rust_target=$(rust_abi $(get_abi_CHOST ${v##*.}))
349 + mkdir -p "${ED}/usr/${abi_libdir}/${P}"
350 + cp "${ED}/usr/$(get_libdir)/${P}/rustlib/${rust_target}/lib"/*.so \
351 + "${ED}/usr/${abi_libdir}/${P}" || die
352 + done
353 +
354 + # versioned libdir/mandir support
355 + newenvd - "50${P}" <<-_EOF_
356 + LDPATH="${EPREFIX}/usr/$(get_libdir)/${P}"
357 + MANPATH="${EPREFIX}/usr/share/${P}/man"
358 + _EOF_
359 +
360 dodoc COPYRIGHT
361 + rm -rf "${ED}/usr/$(get_libdir)/${P}"/*.old || die
362 rm "${ED}/usr/share/doc/${P}"/*.old || die
363 rm "${ED}/usr/share/doc/${P}/LICENSE-APACHE" || die
364 rm "${ED}/usr/share/doc/${P}/LICENSE-MIT" || die
365
366 - cat <<-EOF > "${T}"/50${P}
367 - LDPATH="${EPREFIX}/usr/$(get_libdir)/${P}"
368 - MANPATH="${EPREFIX}/usr/share/${P}/man"
369 - EOF
370 - if use rls; then
371 - cat <<-EOF >> "${T}"/50${P}
372 - RUST_SRC_PATH="${EPREFIX}/usr/lib/${P}/rustlib/src/rust/src/"
373 - EOF
374 - fi
375 - doenvd "${T}"/50${P}
376 -
377 # note: eselect-rust adds EROOT to all paths below
378 cat <<-EOF > "${T}/provider-${P}"
379 /usr/bin/cargo
380
381 diff --git a/virtual/rust/rust-9999.ebuild b/virtual/rust/rust-9999.ebuild
382 index 8e78f71..3627fb6 100644
383 --- a/virtual/rust/rust-9999.ebuild
384 +++ b/virtual/rust/rust-9999.ebuild
385 @@ -1,7 +1,9 @@
386 -# Copyright 1999-2018 Gentoo Foundation
387 +# Copyright 1999-2020 Gentoo Authors
388 # Distributed under the terms of the GNU General Public License v2
389
390 -EAPI="6"
391 +EAPI=7
392 +
393 +inherit multilib-build
394
395 DESCRIPTION="Virtual for Rust language compiler"
396 HOMEPAGE=""
397 @@ -11,5 +13,5 @@ LICENSE=""
398 SLOT="0"
399 KEYWORDS=""
400
401 -DEPEND=""
402 -RDEPEND="|| ( =dev-lang/rust-${PV}* =dev-lang/rust-bin-${PV}* )"
403 +BDEPEND=""
404 +RDEPEND="|| ( =dev-lang/rust-${PVR}*[${MULTILIB_USEDEP}] =dev-lang/rust-bin-${PV}*[${MULTILIB_USEDEP}] )"