Add cargo, rls, and analysis

This commit is contained in:
Dan Callaghan 2018-04-16 13:47:49 +10:00
parent be4334fc3c
commit 4fd41d0a29
2 changed files with 346 additions and 27 deletions

195
pull-49959.patch Normal file
View File

@ -0,0 +1,195 @@
From f89f1b496c0c3b96aa8e41bef882131008dac6c3 Mon Sep 17 00:00:00 2001
From: Josh Stone <jistone@redhat.com>
Date: Fri, 13 Apr 2018 16:52:54 -0700
Subject: [PATCH 1/3] rustbuild: allow building tools with debuginfo
Debugging information for the extended tools is currently disabled for
concerns about the size. This patch adds `--enable-debuginfo-tools` to
let one opt into having that debuginfo.
This is useful for debugging the tools in distro packages. We always
strip debuginfo into separate packages anyway, so the extra size is not
a concern in regular use.
---
CONTRIBUTING.md | 1 +
config.toml.example | 4 ++++
src/bootstrap/builder.rs | 12 ++++++++----
src/bootstrap/config.rs | 5 +++++
src/bootstrap/configure.py | 1 +
5 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 70376c120f..fcd995b703 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -121,6 +121,7 @@ configuration used in the build process. Some options to note:
#### `[rust]`:
- `debuginfo = true` - Build a compiler with debuginfo. Makes building rustc slower, but then you can use a debugger to debug `rustc`.
- `debuginfo-lines = true` - An alternative to `debuginfo = true` that doesn't let you use a debugger, but doesn't make building rustc slower and still gives you line numbers in backtraces.
+- `debuginfo-tools = true` - Build the extended tools with debuginfo.
- `debug-assertions = true` - Makes the log output of `debug!` work.
- `optimize = false` - Disable optimizations to speed up compilation of stage1 rust, but makes the stage1 compiler x100 slower.
diff --git a/config.toml.example b/config.toml.example
index f153562a53..64e2f1b424 100644
--- a/config.toml.example
+++ b/config.toml.example
@@ -259,6 +259,10 @@
# standard library.
#debuginfo-only-std = false
+# Enable debuginfo for the extended tools: cargo, rls, rustfmt
+# Adding debuginfo increases their sizes by a factor of 3-4.
+#debuginfo-tools = false
+
# Whether or not jemalloc is built and enabled
#use-jemalloc = true
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index fcb78c479f..584c0cbe75 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -603,10 +603,14 @@ impl<'a> Builder<'a> {
cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(self.compiler(2, self.build.build)));
}
- if mode != Mode::Tool {
- // Tools don't get debuginfo right now, e.g. cargo and rls don't
- // get compiled with debuginfo.
- // Adding debuginfo increases their sizes by a factor of 3-4.
+ if mode == Mode::Tool {
+ // Tools like cargo and rls don't get debuginfo by default right now, but this can be
+ // enabled in the config. Adding debuginfo increases their sizes by a factor of 3-4.
+ if self.config.rust_debuginfo_tools {
+ cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string());
+ cargo.env("RUSTC_DEBUGINFO_LINES", self.config.rust_debuginfo_lines.to_string());
+ }
+ } else {
cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string());
cargo.env("RUSTC_DEBUGINFO_LINES", self.config.rust_debuginfo_lines.to_string());
cargo.env("RUSTC_FORCE_UNSTABLE", "1");
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index f3810ac869..ac64e6e8e3 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -88,6 +88,7 @@ pub struct Config {
pub rust_debuginfo: bool,
pub rust_debuginfo_lines: bool,
pub rust_debuginfo_only_std: bool,
+ pub rust_debuginfo_tools: bool,
pub rust_rpath: bool,
pub rustc_parallel_queries: bool,
pub rustc_default_linker: Option<String>,
@@ -271,6 +272,7 @@ struct Rust {
debuginfo: Option<bool>,
debuginfo_lines: Option<bool>,
debuginfo_only_std: Option<bool>,
+ debuginfo_tools: Option<bool>,
experimental_parallel_queries: Option<bool>,
debug_jemalloc: Option<bool>,
use_jemalloc: Option<bool>,
@@ -425,6 +427,7 @@ impl Config {
let mut llvm_assertions = None;
let mut debuginfo_lines = None;
let mut debuginfo_only_std = None;
+ let mut debuginfo_tools = None;
let mut debug = None;
let mut debug_jemalloc = None;
let mut debuginfo = None;
@@ -462,6 +465,7 @@ impl Config {
debuginfo = rust.debuginfo;
debuginfo_lines = rust.debuginfo_lines;
debuginfo_only_std = rust.debuginfo_only_std;
+ debuginfo_tools = rust.debuginfo_tools;
optimize = rust.optimize;
ignore_git = rust.ignore_git;
debug_jemalloc = rust.debug_jemalloc;
@@ -553,6 +557,7 @@ impl Config {
config.rust_thinlto = thinlto.unwrap_or(true);
config.rust_debuginfo_lines = debuginfo_lines.unwrap_or(default);
config.rust_debuginfo_only_std = debuginfo_only_std.unwrap_or(default);
+ config.rust_debuginfo_tools = debuginfo_tools.unwrap_or(default);
let default = debug == Some(true);
config.debug_jemalloc = debug_jemalloc.unwrap_or(default);
diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
index 99a3ee4e4c..689dd905fb 100755
--- a/src/bootstrap/configure.py
+++ b/src/bootstrap/configure.py
@@ -78,6 +78,7 @@ def v(*args):
o("debuginfo", "rust.debuginfo", "build with debugger metadata")
o("debuginfo-lines", "rust.debuginfo-lines", "build with line number debugger metadata")
o("debuginfo-only-std", "rust.debuginfo-only-std", "build only libstd with debugging information")
+o("debuginfo-tools", "rust.debuginfo-tools", "build extended tools with debugging information")
o("debug-jemalloc", "rust.debug-jemalloc", "build jemalloc with --enable-debug --enable-fill")
v("save-toolstates", "rust.save-toolstates", "save build and test status of external tools into this file")
--
2.14.3
From f0a43d3a9a4c28ea45d6bed430b1d9d561944e16 Mon Sep 17 00:00:00 2001
From: Josh Stone <jistone@redhat.com>
Date: Fri, 13 Apr 2018 21:57:53 -0700
Subject: [PATCH 2/3] Avoid specific claims about debuginfo size
---
config.toml.example | 2 +-
src/bootstrap/builder.rs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/config.toml.example b/config.toml.example
index 64e2f1b424..46be1ecab7 100644
--- a/config.toml.example
+++ b/config.toml.example
@@ -260,7 +260,7 @@
#debuginfo-only-std = false
# Enable debuginfo for the extended tools: cargo, rls, rustfmt
-# Adding debuginfo increases their sizes by a factor of 3-4.
+# Adding debuginfo makes them several times larger.
#debuginfo-tools = false
# Whether or not jemalloc is built and enabled
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 584c0cbe75..627a695884 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -605,7 +605,7 @@ impl<'a> Builder<'a> {
if mode == Mode::Tool {
// Tools like cargo and rls don't get debuginfo by default right now, but this can be
- // enabled in the config. Adding debuginfo increases their sizes by a factor of 3-4.
+ // enabled in the config. Adding debuginfo makes them several times larger.
if self.config.rust_debuginfo_tools {
cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string());
cargo.env("RUSTC_DEBUGINFO_LINES", self.config.rust_debuginfo_lines.to_string());
--
2.14.3
From 7ddb573a2ea41ad3c35f927b7b90fd545a6ab9da Mon Sep 17 00:00:00 2001
From: Josh Stone <jistone@redhat.com>
Date: Fri, 13 Apr 2018 21:58:21 -0700
Subject: [PATCH 3/3] Make debuginfo-tools always default false
---
src/bootstrap/config.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index ac64e6e8e3..06443ae6cd 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -557,7 +557,7 @@ impl Config {
config.rust_thinlto = thinlto.unwrap_or(true);
config.rust_debuginfo_lines = debuginfo_lines.unwrap_or(default);
config.rust_debuginfo_only_std = debuginfo_only_std.unwrap_or(default);
- config.rust_debuginfo_tools = debuginfo_tools.unwrap_or(default);
+ config.rust_debuginfo_tools = debuginfo_tools.unwrap_or(false);
let default = debug == Some(true);
config.debug_jemalloc = debug_jemalloc.unwrap_or(default);
--
2.14.3

178
rust.spec
View File

@ -39,11 +39,15 @@
%bcond_with lldb
%endif
# Some sub-packages are versioned independently of the rust compiler and runtime itself.
%global rustc_version 1.25.0
%global cargo_version 0.26.0
%global rustfmt_version 0.3.8
%global rls_version 0.125.1
Name: rust
Version: 1.25.0
Release: 2%{?dist}
Version: %{rustc_version}
Release: 3%{?dist}
Summary: The Rust Programming Language
License: (ASL 2.0 or MIT) and (BSD and ISC and MIT)
# ^ written as: (rust itself) and (bundled libraries)
@ -51,17 +55,17 @@ URL: https://www.rust-lang.org
ExclusiveArch: %{rust_arches}
%if "%{channel}" == "stable"
%global rustc_package rustc-%{version}-src
%global rustc_package rustc-%{rustc_version}-src
%else
%global rustc_package rustc-%{channel}-src
%endif
Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.xz
# https://github.com/rust-lang/rust/pull/49290
Patch1: 0001-Allow-installing-rustfmt-without-config.extended.patch
# https://github.com/rust-lang/rust/pull/49484
Patch2: 0001-Ignore-stack-probes-tests-on-powerpc-s390x-too.patch
Patch1: 0001-Ignore-stack-probes-tests-on-powerpc-s390x-too.patch
# https://github.com/rust-lang/rust/pull/49959
Patch2: pull-49959.patch
# Get the Rust triple for any arch.
%{lua: function rust_triple(arch)
@ -107,10 +111,10 @@ Provides: bundled(%{name}-bootstrap) = %{bootstrap_rust}
%else
BuildRequires: cargo >= %{bootstrap_cargo}
%if 0%{?fedora} >= 27
BuildRequires: (%{name} >= %{bootstrap_rust} with %{name} <= %{version})
BuildRequires: (%{name} >= %{bootstrap_rust} with %{name} <= %{rustc_version})
%else
BuildRequires: %{name} >= %{bootstrap_rust}
BuildConflicts: %{name} > %{version}
BuildConflicts: %{name} > %{rustc_version}
%endif
%global local_rust_root %{_prefix}
%endif
@ -119,8 +123,12 @@ BuildRequires: make
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: ncurses-devel
BuildRequires: zlib-devel
BuildRequires: curl
BuildRequires: pkgconfig(libcurl)
BuildRequires: pkgconfig(liblzma)
BuildRequires: pkgconfig(libssh2)
BuildRequires: pkgconfig(openssl)
BuildRequires: pkgconfig(zlib)
%if 0%{?rhel} && 0%{?rhel} <= 7
%global python python2
@ -163,11 +171,11 @@ Provides: bundled(libbacktrace) = 6.1.0
Provides: bundled(miniz) = 1.16~beta+r1
# Virtual provides for folks who attempt "dnf install rustc"
Provides: rustc = %{version}-%{release}
Provides: rustc%{?_isa} = %{version}-%{release}
Provides: rustc = %{rustc_version}-%{release}
Provides: rustc%{?_isa} = %{rustc_version}-%{release}
# Always require our exact standard library
Requires: %{name}-std-static%{?_isa} = %{version}-%{release}
Requires: %{name}-std-static%{?_isa} = %{rustc_version}-%{release}
# The C compiler is needed at runtime just for linking. Someday rustc might
# invoke the linker directly, and then we'll only need binutils.
@ -228,7 +236,7 @@ This package includes the common functionality for %{name}-gdb and %{name}-lldb.
Summary: GDB pretty printers for Rust
BuildArch: noarch
Requires: gdb
Requires: %{name}-debugger-common = %{version}-%{release}
Requires: %{name}-debugger-common = %{rustc_version}-%{release}
%description gdb
This package includes the rust-gdb script, which allows easier debugging of Rust
@ -245,7 +253,7 @@ Summary: LLDB pretty printers for Rust
Requires: lldb
Requires: python2-lldb
Requires: %{name}-debugger-common = %{version}-%{release}
Requires: %{name}-debugger-common = %{rustc_version}-%{release}
%description lldb
This package includes the rust-lldb script, which allows easier debugging of Rust
@ -266,20 +274,68 @@ This package includes HTML documentation for the Rust programming language and
its standard library.
%package -n cargo
Summary: Rust's package manager and build tool
Version: %{cargo_version}
%if %with bundled_libgit2
Provides: bundled(libgit2) = 0.26.0
%else
BuildRequires: pkgconfig(libgit2) >= 0.24
%endif
# For tests:
BuildRequires: git
# Cargo is not much use without Rust
Requires: rust
%description -n cargo
Cargo is a tool that allows Rust projects to declare their various dependencies
and ensure that you'll always get a repeatable build.
%package -n cargo-doc
Summary: Documentation for Cargo
Version: %{cargo_version}
BuildArch: noarch
# Cargo no longer builds its own documentation
# https://github.com/rust-lang/cargo/pull/4904
Requires: rust-doc
%description -n cargo-doc
This package includes HTML documentation for Cargo.
%package -n rustfmt-preview
Summary: Tool to find and fix Rust formatting issues
Version: 0.3.8
Version: %{rustfmt_version}
Requires: cargo
# Despite the lower version, our rustfmt-preview is newer than rustfmt-0.9.
# It's expected to stay "preview" until it's released as 1.0.
Obsoletes: rustfmt <= 0.9.0
Provides: rustfmt = %{version}
Provides: rustfmt = %{rustfmt_version}
%description -n rustfmt-preview
A tool for formatting Rust code according to style guidelines.
%package -n rls-preview
Summary: Rust Language Server for IDE integration
Version: %{rls_version}
Provides: rls = %{rls_version}
%if %with bundled_libgit2
Provides: bundled(libgit2) = 0.26.0
%endif
Requires: rust-analysis
# /usr/bin/rls is dynamically linked against internal rustc libs
Requires: %{name}%{?_isa} = %{rustc_version}-%{release}
%description -n rls-preview
The Rust Language Server provides a server that runs in the background,
providing IDEs, editors, and other tools with information about Rust programs.
It supports functionality such as 'goto definition', symbol search,
reformatting, and code completion, and enables renaming and refactorings.
%package src
Summary: Sources for the Rust standard library
BuildArch: noarch
@ -289,6 +345,16 @@ This package includes source files for the Rust standard library. It may be
useful as a reference for code completion tools in various editors.
%package analysis
Summary: Compiler analysis data for the Rust standard library
Requires: rust-std-static%{?_isa} = %{rustc_version}-%{release}
%description analysis
This package contains analysis data files produced with rustc's -Zsave-analysis
feature for the Rust standard library. The RLS (Rust Language Server) uses this
data to provide information about the Rust standard library.
%prep
%ifarch %{bootstrap_arches}
@ -301,8 +367,8 @@ test -f '%{local_rust_root}/bin/rustc'
%setup -q -n %{rustc_package}
%patch1 -p1 -b .dist-rustfmt
%patch2 -p1 -b .ignore-ibm
%patch1 -p1 -b .ignore-ibm
%patch2 -p1
%if "%{python}" == "python3"
sed -i.try-py3 -e '/try python2.7/i try python3 "$@"' ./configure
@ -350,6 +416,11 @@ find src/vendor -name .cargo-checksum.json \
%build
%if %without bundled_libgit2
# convince libgit2-sys to use the distro libgit2
export LIBGIT2_SYS_USE_PKG_CONFIG=1
%endif
%{?cmake_path:export PATH=%{cmake_path}:$PATH}
%{?library_path:export LIBRARY_PATH="%{library_path}"}
%{?rustflags:export RUSTFLAGS="%{rustflags}"}
@ -362,9 +433,9 @@ find src/vendor -name .cargo-checksum.json \
%ifarch %{arm}
# full debuginfo is exhausting memory; just do libstd for now
# https://github.com/rust-lang/rust/issues/45854
%define enable_debuginfo --enable-debuginfo --enable-debuginfo-only-std --disable-debuginfo-lines
%define enable_debuginfo --enable-debuginfo --enable-debuginfo-only-std --disable-debuginfo-tools --disable-debuginfo-lines
%else
%define enable_debuginfo --enable-debuginfo --disable-debuginfo-only-std --disable-debuginfo-lines
%define enable_debuginfo --enable-debuginfo --disable-debuginfo-only-std --enable-debuginfo-tools --disable-debuginfo-lines
%endif
%configure --disable-option-checking \
@ -376,11 +447,11 @@ find src/vendor -name .cargo-checksum.json \
--disable-jemalloc \
--disable-rpath \
%{enable_debuginfo} \
--enable-extended \
--enable-vendor \
--release-channel=%{channel}
%{python} ./x.py build
%{python} ./x.py build src/tools/rustfmt
%{python} ./x.py doc
@ -390,9 +461,6 @@ find src/vendor -name .cargo-checksum.json \
%{?rustflags:export RUSTFLAGS="%{rustflags}"}
DESTDIR=%{buildroot} %{python} ./x.py install
DESTDIR=%{buildroot} %{python} ./x.py install rustfmt
DESTDIR=%{buildroot} %{python} ./x.py install src
# Make sure the shared libraries are in the proper libdir
%if "%{_libdir}" != "%{common_libdir}"
@ -427,12 +495,38 @@ rm -f %{buildroot}%{_docdir}/%{name}/README.md
rm -f %{buildroot}%{_docdir}/%{name}/COPYRIGHT
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-APACHE
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-MIT
rm -f %{buildroot}%{_docdir}/%{name}/LICENSE-THIRD-PARTY
rm -f %{buildroot}%{_docdir}/%{name}/*.old
# Sanitize the HTML documentation
find %{buildroot}%{_docdir}/%{name}/html -empty -delete
find %{buildroot}%{_docdir}/%{name}/html -type f -exec chmod -x '{}' '+'
# Create the path for crate-devel packages
mkdir -p %{buildroot}%{_datadir}/cargo/registry
# Cargo no longer builds its own documentation
# https://github.com/rust-lang/cargo/pull/4904
mkdir -p %{buildroot}%{_docdir}/cargo/html
cat <<EOF > %{buildroot}%{_docdir}/cargo/html/index.html
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=../../rust/html/cargo/index.html">
<script type="text/javascript">
window.location.href = "../../rust/html/cargo/index.html"
</script>
<title>cargo-doc redirection</title>
</head>
<body>
Cargo documentation has been moved to the rust-doc package.
If you are not redirected automatically, please follow this
<a href="../../rust/html/cargo/index.html">link</a>.
</body>
</html>
EOF
%if %without lldb
rm -f %{buildroot}%{_bindir}/rust-lldb
rm -f %{buildroot}%{rustlibdir}/etc/lldb_*.py*
@ -446,7 +540,9 @@ rm -f %{buildroot}%{rustlibdir}/etc/lldb_*.py*
# The results are not stable on koji, so mask errors and just log it.
%{python} ./x.py test --no-fail-fast || :
%{python} ./x.py test --no-fail-fast src/tools/rustfmt || :
%{python} ./x.py test --no-fail-fast cargo || :
%{python} ./x.py test --no-fail-fast rls || :
%{python} ./x.py test --no-fail-fast rustfmt || :
%ldconfig_scriptlets
@ -507,6 +603,21 @@ rm -f %{buildroot}%{rustlibdir}/etc/lldb_*.py*
%license %{_docdir}/%{name}/html/*.txt
%files -n cargo
%license src/tools/cargo/LICENSE-APACHE src/tools/cargo/LICENSE-MIT src/tools/cargo/LICENSE-THIRD-PARTY
%doc src/tools/cargo/README.md
%{_bindir}/cargo
%{_mandir}/man1/cargo*.1*
%{_sysconfdir}/bash_completion.d/cargo
%{_datadir}/zsh/site-functions/_cargo
%dir %{_datadir}/cargo
%dir %{_datadir}/cargo/registry
%files -n cargo-doc
%{_docdir}/cargo/html
%files -n rustfmt-preview
%{_bindir}/rustfmt
%{_bindir}/cargo-fmt
@ -514,12 +625,25 @@ rm -f %{buildroot}%{rustlibdir}/etc/lldb_*.py*
%license src/tools/rustfmt/LICENSE-{APACHE,MIT}
%files -n rls-preview
%{_bindir}/rls
%doc src/tools/rls/{README.md,COPYRIGHT,debugging.md}
%license src/tools/rls/LICENSE-{APACHE,MIT}
%files src
%dir %{rustlibdir}
%{rustlibdir}/src
%files analysis
%{rustlibdir}/%{rust_triple}/analysis/
%changelog
* Mon Apr 16 2018 Dan Callaghan <dcallagh@redhat.com> - 1.25.0-3
- Add cargo, rls, and analysis
* Tue Apr 10 2018 Josh Stone <jistone@redhat.com> - 1.25.0-2
- Filter codegen-backends from Provides too.