Gentoo Archives: gentoo-commits

From: Dirkjan Ochtman <djc@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/rust/, dev-lang/rust/files/
Date: Sat, 27 Jan 2018 13:24:55
Message-Id: 1517059486.7b22a00d25f43b192b738b1393ffdcf5101939a1.djc@gentoo
1 commit: 7b22a00d25f43b192b738b1393ffdcf5101939a1
2 Author: Dirkjan Ochtman <djc <AT> gentoo <DOT> org>
3 AuthorDate: Sat Jan 27 13:24:28 2018 +0000
4 Commit: Dirkjan Ochtman <djc <AT> gentoo <DOT> org>
5 CommitDate: Sat Jan 27 13:24:46 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7b22a00d
7
8 dev-lang/rust: bump to 1.23.0-r1, fixing bugs found in 1.23.0
9
10 Bug 645466: moving the documentation is no longer necessary during the
11 install phase, since the doc dir is configured correctly in advance.
12
13 Bug 645498: add an "extended" use flag which will build and install
14 rls, rustfmt and cargo alongside rustc and rustdoc.
15
16 Bug 626136: prevent collisions for installed libraries.
17
18 Package-Manager: Portage-2.3.19, Repoman-2.3.6
19
20 dev-lang/rust/files/1.23.0-separate-libdir.patch | 180 +++++++++++++++++++++++
21 dev-lang/rust/metadata.xml | 2 +
22 dev-lang/rust/rust-1.23.0-r1.ebuild | 172 ++++++++++++++++++++++
23 3 files changed, 354 insertions(+)
24
25 diff --git a/dev-lang/rust/files/1.23.0-separate-libdir.patch b/dev-lang/rust/files/1.23.0-separate-libdir.patch
26 new file mode 100644
27 index 00000000000..dcf1762d2fa
28 --- /dev/null
29 +++ b/dev-lang/rust/files/1.23.0-separate-libdir.patch
30 @@ -0,0 +1,180 @@
31 +From c520b2dd277f13dc09e8e72c486e5c58fb97017d Mon Sep 17 00:00:00 2001
32 +From: O01eg <o01eg@××××××.ru>
33 +Date: Wed, 29 Nov 2017 12:32:03 +0300
34 +Subject: [PATCH] Fix #45345.
35 +
36 +Re-implement
37 +
38 +```bash
39 +CFG_LIBDIR_RELATIVE=`echo ${CFG_LIBDIR} | cut -c$((${#CFG_PREFIX}+${CAT_INC}))-`
40 +```
41 +
42 +from old `configure` script.
43 +
44 +Accept verbosity in rustdoc.
45 +
46 +Stage 1 and later use relative libdir.
47 +
48 +Build all stages with relative libdirs.
49 +
50 +Add library path for real rustdoc with `RUSTDOC_LIBDIR` environment variable.
51 +
52 +Remove unused argument `rustc_cargo`.
53 +
54 +Remove unused configuration parameter `libdir_relative`.
55 +---
56 + src/bootstrap/bin/rustdoc.rs | 13 ++++++++++++-
57 + src/bootstrap/builder.rs | 9 ++++++---
58 + src/bootstrap/check.rs | 2 +-
59 + src/bootstrap/compile.rs | 13 ++++---------
60 + src/bootstrap/config.rs | 1 -
61 + src/bootstrap/doc.rs | 2 +-
62 + 6 files changed, 24 insertions(+), 16 deletions(-)
63 +
64 +diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs
65 +index 4e975adc97..24312b50ec 100644
66 +--- a/src/bootstrap/bin/rustdoc.rs
67 ++++ b/src/bootstrap/bin/rustdoc.rs
68 +@@ -23,10 +23,17 @@ use std::path::PathBuf;
69 + fn main() {
70 + let args = env::args_os().skip(1).collect::<Vec<_>>();
71 + let rustdoc = env::var_os("RUSTDOC_REAL").expect("RUSTDOC_REAL was not set");
72 +- let libdir = env::var_os("RUSTC_LIBDIR").expect("RUSTC_LIBDIR was not set");
73 ++ let libdir = env::var_os("RUSTDOC_LIBDIR").expect("RUSTDOC_LIBDIR was not set");
74 + let stage = env::var("RUSTC_STAGE").expect("RUSTC_STAGE was not set");
75 + let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set");
76 +
77 ++ use std::str::FromStr;
78 ++
79 ++ let verbose = match env::var("RUSTC_VERBOSE") {
80 ++ Ok(s) => usize::from_str(&s).expect("RUSTC_VERBOSE should be an integer"),
81 ++ Err(_) => 0,
82 ++ };
83 ++
84 + let mut dylib_path = bootstrap::util::dylib_path();
85 + dylib_path.insert(0, PathBuf::from(libdir));
86 +
87 +@@ -59,6 +66,10 @@ fn main() {
88 + .arg("--crate-version").arg(version);
89 + }
90 +
91 ++ if verbose > 1 {
92 ++ eprintln!("rustdoc command: {:?}", cmd);
93 ++ }
94 ++
95 + std::process::exit(match cmd.status() {
96 + Ok(s) => s.code().unwrap_or(1),
97 + Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),
98 +diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
99 +index c76900882b..1927a604c5 100644
100 +--- a/src/bootstrap/builder.rs
101 ++++ b/src/bootstrap/builder.rs
102 +@@ -357,8 +357,8 @@ impl<'a> Builder<'a> {
103 +
104 + fn run(self, builder: &Builder) -> Interned<PathBuf> {
105 + let compiler = self.compiler;
106 +- let lib = if compiler.stage >= 2 && builder.build.config.libdir_relative.is_some() {
107 +- builder.build.config.libdir_relative.clone().unwrap()
108 ++ let lib = if compiler.stage >= 1 && builder.build.config.libdir.is_some() {
109 ++ builder.build.config.libdir.clone().unwrap()
110 + } else {
111 + PathBuf::from("lib")
112 + };
113 +@@ -416,7 +416,7 @@ impl<'a> Builder<'a> {
114 + let compiler = self.compiler(self.top_stage, host);
115 + cmd.env("RUSTC_STAGE", compiler.stage.to_string())
116 + .env("RUSTC_SYSROOT", self.sysroot(compiler))
117 +- .env("RUSTC_LIBDIR", self.sysroot_libdir(compiler, self.build.build))
118 ++ .env("RUSTDOC_LIBDIR", self.sysroot_libdir(compiler, self.build.build))
119 + .env("CFG_RELEASE_CHANNEL", &self.build.config.channel)
120 + .env("RUSTDOC_REAL", self.rustdoc(host))
121 + .env("RUSTDOC_CRATE_VERSION", self.build.rust_version())
122 +@@ -496,6 +496,9 @@ impl<'a> Builder<'a> {
123 + if let Some(target_linker) = self.build.linker(target) {
124 + cargo.env("RUSTC_TARGET_LINKER", target_linker);
125 + }
126 ++ if cmd != "build" {
127 ++ cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(self.compiler(2, self.build.build)));
128 ++ }
129 +
130 + if mode != Mode::Tool {
131 + // Tools don't get debuginfo right now, e.g. cargo and rls don't
132 +diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs
133 +index 4d69b19c73..d926c2b901 100644
134 +--- a/src/bootstrap/check.rs
135 ++++ b/src/bootstrap/check.rs
136 +@@ -1171,7 +1171,7 @@ impl Step for Crate {
137 + }
138 + Mode::Librustc => {
139 + builder.ensure(compile::Rustc { compiler, target });
140 +- compile::rustc_cargo(build, &compiler, target, &mut cargo);
141 ++ compile::rustc_cargo(build, target, &mut cargo);
142 + ("librustc", "rustc-main")
143 + }
144 + _ => panic!("can only test libraries"),
145 +diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
146 +index db013691bb..d60feb1aff 100644
147 +--- a/src/bootstrap/compile.rs
148 ++++ b/src/bootstrap/compile.rs
149 +@@ -485,7 +485,7 @@ impl Step for Rustc {
150 + build.clear_if_dirty(&stage_out, &libtest_stamp(build, compiler, target));
151 +
152 + let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "build");
153 +- rustc_cargo(build, &compiler, target, &mut cargo);
154 ++ rustc_cargo(build, target, &mut cargo);
155 + run_cargo(build,
156 + &mut cargo,
157 + &librustc_stamp(build, compiler, target));
158 +@@ -500,7 +500,6 @@ impl Step for Rustc {
159 +
160 + /// Same as `std_cargo`, but for libtest
161 + pub fn rustc_cargo(build: &Build,
162 +- compiler: &Compiler,
163 + target: Interned<String>,
164 + cargo: &mut Command) {
165 + cargo.arg("--features").arg(build.rustc_features())
166 +@@ -514,13 +513,9 @@ pub fn rustc_cargo(build: &Build,
167 + .env("CFG_VERSION", build.rust_version())
168 + .env("CFG_PREFIX", build.config.prefix.clone().unwrap_or_default());
169 +
170 +- if compiler.stage == 0 {
171 +- cargo.env("CFG_LIBDIR_RELATIVE", "lib");
172 +- } else {
173 +- let libdir_relative =
174 +- build.config.libdir_relative.clone().unwrap_or(PathBuf::from("lib"));
175 +- cargo.env("CFG_LIBDIR_RELATIVE", libdir_relative);
176 +- }
177 ++ let libdir_relative =
178 ++ build.config.libdir.clone().unwrap_or(PathBuf::from("lib"));
179 ++ cargo.env("CFG_LIBDIR_RELATIVE", libdir_relative);
180 +
181 + // If we're not building a compiler with debugging information then remove
182 + // these two env vars which would be set otherwise.
183 +diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
184 +index 35e62f17f2..1ca19187cf 100644
185 +--- a/src/bootstrap/config.rs
186 ++++ b/src/bootstrap/config.rs
187 +@@ -119,7 +119,6 @@ pub struct Config {
188 + pub docdir: Option<PathBuf>,
189 + pub bindir: Option<PathBuf>,
190 + pub libdir: Option<PathBuf>,
191 +- pub libdir_relative: Option<PathBuf>,
192 + pub mandir: Option<PathBuf>,
193 + pub codegen_tests: bool,
194 + pub nodejs: Option<PathBuf>,
195 +diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs
196 +index 3c12cfc4c7..1314d967d8 100644
197 +--- a/src/bootstrap/doc.rs
198 ++++ b/src/bootstrap/doc.rs
199 +@@ -616,7 +616,7 @@ impl Step for Rustc {
200 + t!(symlink_dir_force(&my_out, &out_dir));
201 +
202 + let mut cargo = builder.cargo(compiler, Mode::Librustc, target, "doc");
203 +- compile::rustc_cargo(build, &compiler, target, &mut cargo);
204 ++ compile::rustc_cargo(build, target, &mut cargo);
205 +
206 + if build.config.compiler_docs {
207 + // src/rustc/Cargo.toml contains a bin crate called rustc which
208 +--
209 +2.13.6
210 +
211
212 diff --git a/dev-lang/rust/metadata.xml b/dev-lang/rust/metadata.xml
213 index 050e235f719..c1882e581cf 100644
214 --- a/dev-lang/rust/metadata.xml
215 +++ b/dev-lang/rust/metadata.xml
216 @@ -7,6 +7,8 @@
217 </maintainer>
218 <use>
219 <flag name="clang">Use <pkg>sys-devel/clang</pkg> for building</flag>
220 + <flag name="extended">Build and install rls, rustfmt and cargo
221 + alongside the compiler and stdlib</flag>
222 <flag name="libcxx">Use <pkg>sys-libs/libcxx</pkg> as standard
223 library when building with <pkg>sys-devel/clang</pkg></flag>
224 <flag name="system-llvm">Use system <pkg>sys-devel/llvm</pkg> in
225
226 diff --git a/dev-lang/rust/rust-1.23.0-r1.ebuild b/dev-lang/rust/rust-1.23.0-r1.ebuild
227 new file mode 100644
228 index 00000000000..0f20423bb66
229 --- /dev/null
230 +++ b/dev-lang/rust/rust-1.23.0-r1.ebuild
231 @@ -0,0 +1,172 @@
232 +# Copyright 1999-2018 Gentoo Foundation
233 +# Distributed under the terms of the GNU General Public License v2
234 +
235 +EAPI=6
236 +
237 +PYTHON_COMPAT=( python2_7 )
238 +
239 +inherit python-any-r1 versionator toolchain-funcs
240 +
241 +if [[ ${PV} = *beta* ]]; then
242 + betaver=${PV//*beta}
243 + BETA_SNAPSHOT="${betaver:0:4}-${betaver:4:2}-${betaver:6:2}"
244 + MY_P="rustc-beta"
245 + SLOT="beta/${PV}"
246 + SRC="${BETA_SNAPSHOT}/rustc-beta-src.tar.gz"
247 + KEYWORDS=""
248 +else
249 + ABI_VER="$(get_version_component_range 1-2)"
250 + SLOT="stable/${ABI_VER}"
251 + MY_P="rustc-${PV}"
252 + SRC="${MY_P}-src.tar.gz"
253 + KEYWORDS="~amd64 ~x86"
254 +fi
255 +
256 +CHOST_amd64=x86_64-unknown-linux-gnu
257 +CHOST_x86=i686-unknown-linux-gnu
258 +
259 +RUST_STAGE0_VERSION="1.$(($(get_version_component_range 2) - 1)).0"
260 +RUST_STAGE0_amd64="rust-${RUST_STAGE0_VERSION}-${CHOST_amd64}"
261 +RUST_STAGE0_x86="rust-${RUST_STAGE0_VERSION}-${CHOST_x86}"
262 +
263 +CARGO_DEPEND_VERSION="0.$(($(get_version_component_range 2) + 1)).0"
264 +
265 +DESCRIPTION="Systems programming language from Mozilla"
266 +HOMEPAGE="http://www.rust-lang.org/"
267 +
268 +SRC_URI="https://static.rust-lang.org/dist/${SRC} -> rustc-${PV}-src.tar.gz
269 + amd64? ( https://static.rust-lang.org/dist/${RUST_STAGE0_amd64}.tar.gz )
270 + x86? ( https://static.rust-lang.org/dist/${RUST_STAGE0_x86}.tar.gz )
271 +"
272 +
273 +LICENSE="|| ( MIT Apache-2.0 ) BSD-1 BSD-2 BSD-4 UoI-NCSA"
274 +
275 +IUSE="debug doc extended +jemalloc"
276 +
277 +RDEPEND=">=app-eselect/eselect-rust-0.3_pre20150425
278 + jemalloc? ( dev-libs/jemalloc )"
279 +DEPEND="${RDEPEND}
280 + ${PYTHON_DEPS}
281 + || (
282 + >=sys-devel/gcc-4.7
283 + >=sys-devel/clang-3.5
284 + )
285 + dev-util/cmake
286 +"
287 +PDEPEND="!extended? ( >=dev-util/cargo-${CARGO_DEPEND_VERSION} )"
288 +
289 +PATCHES=( "${FILESDIR}/1.23.0-separate-libdir.patch" )
290 +
291 +S="${WORKDIR}/${MY_P}-src"
292 +
293 +toml_usex() {
294 + usex "$1" true false
295 +}
296 +
297 +src_prepare() {
298 + local rust_stage0_root="${WORKDIR}"/rust-stage0
299 +
300 + local rust_stage0_name="RUST_STAGE0_${ARCH}"
301 + local rust_stage0="${!rust_stage0_name}"
302 +
303 + "${WORKDIR}/${rust_stage0}"/install.sh --disable-ldconfig --destdir="${rust_stage0_root}" --prefix=/ || die
304 +
305 + default
306 +}
307 +
308 +src_configure() {
309 + local rust_stage0_root="${WORKDIR}"/rust-stage0
310 +
311 + local rust_target_name="CHOST_${ARCH}"
312 + local rust_target="${!rust_target_name}"
313 +
314 + cat <<- EOF > "${S}"/config.toml
315 + [llvm]
316 + optimize = $(toml_usex !debug)
317 + release-debuginfo = $(toml_usex debug)
318 + assertions = $(toml_usex debug)
319 + [build]
320 + build = "${rust_target}"
321 + host = ["${rust_target}"]
322 + target = ["${rust_target}"]
323 + cargo = "${rust_stage0_root}/bin/cargo"
324 + rustc = "${rust_stage0_root}/bin/rustc"
325 + docs = $(toml_usex doc)
326 + submodules = false
327 + python = "${EPYTHON}"
328 + locked-deps = true
329 + vendor = true
330 + verbose = 2
331 + extended = $(toml_usex extended)
332 + [install]
333 + prefix = "${EPREFIX}/usr"
334 + libdir = "$(get_libdir)"
335 + docdir = "share/doc/${P}"
336 + mandir = "share/${P}/man"
337 + [rust]
338 + optimize = $(toml_usex !debug)
339 + debuginfo = $(toml_usex debug)
340 + debug-assertions = $(toml_usex debug)
341 + use-jemalloc = $(toml_usex jemalloc)
342 + default-linker = "$(tc-getCC)"
343 + rpath = false
344 + [target.${rust_target}]
345 + cc = "$(tc-getBUILD_CC)"
346 + cxx = "$(tc-getBUILD_CXX)"
347 + linker = "$(tc-getCC)"
348 + ar = "$(tc-getAR)"
349 + EOF
350 +}
351 +
352 +src_compile() {
353 + ./x.py build --verbose --config="${S}"/config.toml || die
354 +}
355 +
356 +src_install() {
357 + env DESTDIR="${D}" ./x.py install || die
358 +
359 + mv "${D}/usr/bin/rustc" "${D}/usr/bin/rustc-${PV}" || die
360 + mv "${D}/usr/bin/rustdoc" "${D}/usr/bin/rustdoc-${PV}" || die
361 + mv "${D}/usr/bin/rust-gdb" "${D}/usr/bin/rust-gdb-${PV}" || die
362 + mv "${D}/usr/bin/rust-lldb" "${D}/usr/bin/rust-lldb-${PV}" || die
363 +
364 + dodoc COPYRIGHT
365 +
366 + cat <<-EOF > "${T}"/50${P}
367 + LDPATH="/usr/$(get_libdir)/${P}"
368 + MANPATH="/usr/share/${P}/man"
369 + EOF
370 + doenvd "${T}"/50${P}
371 +
372 + cat <<-EOF > "${T}/provider-${P}"
373 + /usr/bin/rustdoc
374 + /usr/bin/rust-gdb
375 + /usr/bin/rust-lldb
376 + EOF
377 + dodir /etc/env.d/rust
378 + insinto /etc/env.d/rust
379 + doins "${T}/provider-${P}"
380 +}
381 +
382 +pkg_postinst() {
383 + eselect rust update --if-unset
384 +
385 + elog "Rust installs a helper script for calling GDB and LLDB,"
386 + elog "for your convenience it is installed under /usr/bin/rust-{gdb,lldb}-${PV}."
387 +
388 + if has_version app-editors/emacs || has_version app-editors/emacs-vcs; then
389 + elog "install app-emacs/rust-mode to get emacs support for rust."
390 + fi
391 +
392 + if has_version app-editors/gvim || has_version app-editors/vim; then
393 + elog "install app-vim/rust-vim to get vim support for rust."
394 + fi
395 +
396 + if has_version 'app-shells/zsh'; then
397 + elog "install app-shells/rust-zshcomp to get zsh completion for rust."
398 + fi
399 +}
400 +
401 +pkg_postrm() {
402 + eselect rust unset --if-invalid
403 +}