#3 Add rls and analysis
Merged 6 years ago by jistone. Opened 6 years ago by dcallagh.
rpms/ dcallagh/rust rls  into  master

file added
+195
@@ -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

+ 

file modified
+151 -27
@@ -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 @@ 

  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 @@ 

  %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:  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(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 @@ 

  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 @@ 

  

  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 @@ 

  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 @@ 

  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 @@ 

  

  %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 @@ 

  

  %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 @@ 

  %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 @@ 

    --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 @@ 

  %{?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}/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 @@ 

  

  # 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 @@ 

  %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 @@ 

  %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.

  

This changes the build invocation so that, instead of doing a non-"extended" build and then explicitly installing rustfmt (which is one of the "extended" tools), it enables the extended build and passes --tools= to enable all the tools except cargo, which is packaged separately.

With this patch, the analysis JSON files are included in the main rust package, adding ~6MB on-disk installed size. Not sure if you think that is acceptable. An alternative would be to just include them with the rls subpackage, or introduce a new rust-analysis subpackage for the JSON files and have rls require that.

Forgot to add the patch 🙄

rebased onto 0a8a864

6 years ago

Hmm this still doesn't build inside mock though.

It seems that it now tries to build cargo even though it doesn't install it. I guess it's another bug with the tools selection in the build config. Cargo is supposed to be turned off by passing --tools=.

Cargo fails to build because it wants some openssl headers. I must have had those installed already when I was testing the build locally.

The size of rust-analysis isn't that big of a big deal, but I'm inclined to keep it as its own subpackage to match the upstream rustup components. Do you see any downside to this?

FWIW, I'm thinking about pulling cargo into rust.spec, to more closely align to how upstream does things. As you note, they tend to get built together, and upstream talks about their release together, but often the standalone release of cargo as a crate is arbitrarily delayed, kind of an afterthought. It would also simplify my updates that I wouldn't have to assemble cargo-%{version}-vendor sources any more, since rustc-src already includes a src/vendor/.

(We don't actually produce a package for using cargo as a crate, but if we ever do it should follow the more general rust packaging guidelines, including proper dependencies. Maybe someday rust.spec will follow that too, but we're far from it.)

Agreed, it makes sense to separate the analysis files into a subpackage matching the upstream component.

I also like the idea of building cargo here with rust, since as you note that seems to be upstream's preferred way of building it. And it would save me having to figure out why the --tools= option is not correctly excluding cargo from the build :-)

I can update this PR with both of the above changes.

rebased onto 473f958

6 years ago

Okay, commit 473f958 is attempt at doing this.

It builds now, but I haven't yet tested if the cargo package that comes out actually works or anything.

Please take a look and tell me if you think it looks sane. I copied all the important-looking bits from cargo.spec in order to produce what should be an equivalent cargo subpackage here.

Ohh this is still not quite right.

  - nothing provides rust(x86-64) = 0.125.1-2.fc27 needed by rust-analysis-1.25.0-2.fc27.x86_64

I guess at the point where the base package requirement for rust-analysis is defined:

Requires:       %{name}%{?_isa} = %{version}-%{release}

the %{version} macro is referring to the Version: tag on the rls-preview subpackage above it, instead of the Version: for the overall package. Hmm 🤔

instead of this, use pkgconfig(foo) for dependencies which are used through pkgconfig

Ohh yeah this is totally an accident. I had it commented out for testing (to speed up the build) but was not intending to commit it.

So I guess I will introduce a %{rustc_version} macro at the top, and then we use that instead of %{version} when we're requiring the base package. It's a bit messy but I don't see any other way of doing it, so long as there are sub-packages with their own independent Version:.

Okay, I think commit 90c9381 is good to go. It builds and installs and appears to work.

rebased onto 90c9381

6 years ago

I believe rls dynamically links to rustc's libraries, which we filter from auto-Provides/Requires so they're not available to external packages. So here you'll need to manually add that Requires: rust = ver-rel.

I think this might be more properly tied to rust-std-static.

Let's add globals for the independent subpackages too, so they can all be updated in one place.

Does ./x.py test also run tests for all the tools when we have the full --enable-extended? I had manually added the test command for rustfmt before.

Oh yes, quite right. Assuming it's all these ones like:

librustc_typeck-d814aa0133325bf4.so => /lib64/librustc_typeck-d814aa0133325bf4.so (0x00007f2c72d63000)

Okay. I don't fully understand what all these bits are built from or how rls uses them... so if you say so I'll believe you :-)

Ultimately anyone who installs rls will get all these subpackages together anyway through the various transitive dependencies...

Looks like x.py test doesn't automatically run the rls or cargo tests. So I'll try adding that too.

Commit a16727e is my latest attempt, addressing all the above issues.

rebased onto a16727e

6 years ago

I got a chance to pull this locally and try a build. Here are collected notes, since I don't really care for the way pagure shows inline reviews...

  • This needs a quick rebase on the 1.25.0-2 release I pushed out.
  • The conditional Provides: bundled(libgit2) should be moved to cargo and rls-preview.
  • cargo's %doc README.md should pull from its subdirectory.
  • Need a BuildRequires: git for a few cargo tests to pass.
  • rls-preview should package %doc src/tools/rls/README.md and %license files.
  • rls-preview should provide an rls alias, like rustfmt-preview does for rustfmt.

Also, this is not your problem, but I noticed that the debuginfo in each of the extended tools is limited to data from the standard library, with none for the tools themselves. I'll look into this upstream, to see why it's not respecting the global --enable-debuginfo.

According to my (rudimentary) grepping, the git2 crate is only used in cargo, not rustfmt. So I'll move it to cargo only.

Commit a62ce4f is updated to address the above feedback.

rebased onto a62ce4f

6 years ago

the git2 crate is only used in cargo, not rustfmt.

The other one I mentioned was rls, which does link libgit2 via its dependency on cargo itself. You can see this in the auto-Requires of the resulting rls-preview.rpm, and when we're instead bundling libgit2, that needs to be reflected.

One more thing I'm trying to figure out is how to obsolete the former cargo-debuginfo. We don't need to worry about that for Fedora >=27, as they'll still get separate subpackage debuginfo, but in Fedora 26 and EPEL7 it will all be in rust-debuginfo.

I've found some precedence that pcp obsoletes the pcp-gui-debuginfo package, but I'm not sure I like this. Another idea I had was to manually create a shim package to replace the old, something like:

%if 0%{?fedora} < 27
%package -n cargo-debuginfo
Summary:        Obsolete debuginfo for Cargo
Version:        %{cargo_version}
Requires:       %{name}-debuginfo%{?_isa} = %{rustc_version}-%{release}
%description -n cargo-debuginfo
%{summary}.
%files       -n cargo-debuginfo
%endif

But this is ugly too.

Is it even worth worrying about? I guess a similar problem will come up when these preview packages change their name -- we can have rustfmt obsolete rustfmt-preview, but I expect that won't affect the subpackage debuginfo. @ignatenkobrain, any advice about this?

The other one I mentioned was rls, which does link libgit2 via its dependency on cargo itself. You can see this in the auto-Requires of the resulting rls-preview.rpm, and when we're instead bundling libgit2, that needs to be reflected.

Oh, oops.

Commit 4fd41d0 is amended to fix this.

rebased onto 4fd41d0

6 years ago

Personally I would suggest to not worry about obsoleting debuginfo. I'm sure I have seen many packages over the years which just leave orphaned debuginfo. I think it is just assumed to be par for the course.

Please don't do anything related to debuginfo. If package disappears, that's fine.

It's not just an orphan, but also a file conflict. The old cargo-debuginfo and the unified rust-debuginfo will both contain /usr/lib/debug/usr/bin/cargo.debug. But if you both think this isn't a problem, I'll let it be.

Last nit is that we're missing the %bcond_with bundled_libgit2, but I'll go ahead and add this myself. Thanks a lot!

Pull-Request has been merged by jistone

6 years ago