Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 819786 - dev-lang/rust-bin: create 'source' flag to allow download of rust sources alongside prebuilt binaries
Summary: dev-lang/rust-bin: create 'source' flag to allow download of rust sources alo...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Gentoo Rust Project
URL:
Whiteboard:
Keywords:
: 822297 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-10-23 17:30 UTC by Adriano Zambrana Marchetti
Modified: 2021-11-12 20:06 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Ebuild with added support for USE flag 'rust-src' (rust-bin-1.56.1.ebuild,5.90 KB, text/plain)
2021-11-10 22:42 UTC, Mikael Henriksson
Details
Diff for proposed Ebuild (rust-bin-1.56.1.ebuild.diff,625 bytes, patch)
2021-11-10 22:43 UTC, Mikael Henriksson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adriano Zambrana Marchetti 2021-10-23 17:30:54 UTC
As of now, the installation of 'rust-bin' does not include the installation of rust source code. This is a hindrance in some cases, such as usage of rust-analyzer, which needs the source code to work correctly.

I suggest rust-bin can come with an optional USE flag 'src', to include rust source code alongside the pre-built binaries, without having to use dev-lang/rust.

I post this since I have been stuck with the following error message while attempting to use 'rust-analyzer' : 

rust-analyzer failed to load workspace: Failed to find sysroot for Cargo.toml file <censored>/Cargo.toml. Is rust-src installed?: can't load standard library from sysroot
/opt/rust-bin-1.55.0
(discovered via `rustc --print sysroot`)
try installing the Rust source the same way you installed rustc


I have gone to them and have gotten confirmation that this is not a rust-analyzer issue, but a rust installation one. I have searched the specified sysroot and have found no source files, even when installing using the rls use flag. Finally, using dev-lang/rust this error does not occur.
Comment 1 Adriano Zambrana Marchetti 2021-10-23 17:35:54 UTC
Upon further search, it should be a 'source' flag, as more packages use that name.
Comment 2 Georgy Yakovlev archtester gentoo-dev 2021-11-09 01:42:49 UTC
*** Bug 822297 has been marked as a duplicate of this bug. ***
Comment 3 Georgy Yakovlev archtester gentoo-dev 2021-11-09 01:47:02 UTC
I will see if it's possible to add it.

what's ugly about src component is tarball comes from a date-prefixed url


> curl https://static.rust-lang.org/dist/channel-rust-stable.toml | grep "xz_url.*rust-src"

https://static.rust-lang.org/dist/2021-11-01/rust-src-1.56.1.tar.xz


Currently I don't know a way to programmatically predict it or get url of an old release.

just installing source tarball from github is not what we want, we need the tarball linked above.
Comment 4 Mikael Henriksson 2021-11-09 12:38:21 UTC
I found the follow way of reliably extracting the "rust-src" download url from `static.rust-lang.org`. Seems to work with any release version, stable and nightly:

> curl -L static.rust-lang.org/dist/channel-rust-${PV}.toml 2>/dev/null | grep "xz_url.*rust-src"

For example, to get the xz_url for rust-src from release 1.22.0:

> curl -L static.rust-lang.org/dist/channel-rust-1.22.0.toml 2>/dev/null | grep "xz_url.*rust-src"

Might I suggest calling the proposed USE flag `rust-src`, as it is a Rust component. Just as there already exists USE flags for the Rust components `clippy`, `rls` and `rustfmt`, to be consistent with the USE flag convention already in place for these ebuilds, I think it make sense if this flag named after the Rust component it includes, `rust-src`.

Med vänliga hälsningar,
Mikael Henriksson
Comment 5 Georgy Yakovlev archtester gentoo-dev 2021-11-09 19:34:19 UTC
thanks for that! that's good enough.

I'll poke it as I get more time.
another problem to solve is rust-src component comes with it's own installer, we need to run main installer and src installer, or maybe join the installers. idk how they interact yet or overwrite files or not.
Comment 6 Mikael Henriksson 2021-11-10 08:12:50 UTC
(In reply to Georgy Yakovlev from comment #5)
> thanks for that! that's good enough.
> 
> I'll poke it as I get more time.
> another problem to solve is rust-src component comes with it's own
> installer, we need to run main installer and src installer, or maybe join
> the installers. idk how they interact yet or overwrite files or not.

Tell me if there is something I can do to help. In the mean time I'll see if I can find out how rust-src is installed with Rustup and try to make a mookup ebuild replicating the behaviour.
Comment 7 Mikael Henriksson 2021-11-10 22:42:41 UTC
Created attachment 750240 [details]
Ebuild with added support for USE flag 'rust-src'
Comment 8 Mikael Henriksson 2021-11-10 22:43:57 UTC
Created attachment 750243 [details, diff]
Diff for proposed Ebuild
Comment 9 Mikael Henriksson 2021-11-10 22:59:22 UTC
I've attached an Ebuild for rust-bin-1.56.1, with diff between it and original ebuild, which I've used to successfully install rust-bin-1.56.1 with the Rust component `rust-src` on my system.

It is still lacking in that it uses hardcoded uri of the rust-src tarball in the SRC_URI variable, this due to the annoying date stamp in the upstream source url. I don't know how to get Ebuild + Manifest working together without hardcoding the SRC_URI variable. This is of-course tedious as the package-maintainer of rust-bin would have to manually update the link in SRC_URI each time a new version of rust is released.

Anyway, I hope this can come to some help.

Med vänliga hälsningar,
Mikael Henriksson
Comment 10 Georgy Yakovlev archtester gentoo-dev 2021-11-11 01:49:39 UTC
thanks I test once I have a spare minute.
my main interest is what happens to installed files after 2 installers run. there are some MANIFESTS and other files.
does it merge it or replaces file?

Basically I'll be looking at diff of the installation image, what changes besides addition of src component directory itself.

if you wanna dig it - feel free to, help is always appreciated.
that's just my plan and I'll do it anyways.
Comment 11 Larry the Git Cow gentoo-dev 2021-11-12 19:42:36 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=144bf206556b77df750f5c79917d9dc8c4322242

commit 144bf206556b77df750f5c79917d9dc8c4322242
Author:     Georgy Yakovlev <gyakovlev@gentoo.org>
AuthorDate: 2021-11-12 19:37:22 +0000
Commit:     Georgy Yakovlev <gyakovlev@gentoo.org>
CommitDate: 2021-11-12 19:41:11 +0000

    dev-lang/rust-bin: add rust-src useflag
    
    This is useful for many developer tools and for build-std too.
    linux-next rust code also requires this to be installed.
    
    Bug: https://bugs.gentoo.org/800785
    Bug: https://bugs.gentoo.org/819786
    Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>

 dev-lang/rust-bin/Manifest               |  1 +
 dev-lang/rust-bin/metadata.xml           |  1 +
 dev-lang/rust-bin/rust-bin-1.56.1.ebuild | 30 ++++++++++++++++++++++++++----
 3 files changed, 28 insertions(+), 4 deletions(-)
Comment 12 Georgy Yakovlev archtester gentoo-dev 2021-11-12 19:44:07 UTC
found a better way of installing it.

basically I just combine installers, adding src component to original installer and use single installer invocation.

will probably add a bit of sanity-check, like comparing 'git-commit-hash' file in both installers to match.
Comment 13 Larry the Git Cow gentoo-dev 2021-11-12 20:01:55 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d2e9fc2c57ca98303914d5632c20edce74f846a6

commit d2e9fc2c57ca98303914d5632c20edce74f846a6
Author:     Georgy Yakovlev <gyakovlev@gentoo.org>
AuthorDate: 2021-11-12 19:56:17 +0000
Commit:     Georgy Yakovlev <gyakovlev@gentoo.org>
CommitDate: 2021-11-12 20:01:35 +0000

    dev-lang/rust: add rust-src useflag
    
    previously 'src' component was installed by 'rls' useflag.
    let's split it out for people who want 'src' but don't need rls.
    
    Bug: https://bugs.gentoo.org/800785
    Bug: https://bugs.gentoo.org/819786
    Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>

 dev-lang/rust/metadata.xml       | 1 +
 dev-lang/rust/rust-1.56.1.ebuild | 8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)
Comment 14 Georgy Yakovlev archtester gentoo-dev 2021-11-12 20:06:04 UTC
I believe this can be closed.

no plans on backporting to versions prior to 1.56.1 as they'll be gone in about a month.