* [PATCH] rust: Support latest version of `rust-anayzer`
@ 2024-07-19 8:07 Sarthak Singh
2024-07-23 8:54 ` Dirk Behme
0 siblings, 1 reply; 2+ messages in thread
From: Sarthak Singh @ 2024-07-19 8:07 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho
Cc: Sarthak Singh, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, rust-for-linux
Sets the `sysroot` field in rust-project.json which is now needed in
newer versions of rust-anaylzer instead of the `sysroot_src` field.
`sysroot` over `sysroot_src` has been working since rust 1.74.0 (which
was released on Nov 16, 2023). Since we are going to target rust 1.78.0
going forward we should set `sysroot` to support all currently used and
future versions of rust-analyzer.
Code editors like VS Code try to use the latest version of rust-analyzer
(which is updated every week) instead of the version of rust-analyzer
that comes with the rustup toolchain (which is updated every six weeks
along with the rust version).
Without this change rust-analyzer is breaking for anyone using VS Code.
Signed-off-by: Sarthak Singh <ss269@uw.edu>
---
rust/Makefile | 2 +-
scripts/generate_rust_analyzer.py | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/rust/Makefile b/rust/Makefile
index bf05e65365da..e3d0ba099b18 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -350,7 +350,7 @@ rust-analyzer:
$(Q)$(srctree)/scripts/generate_rust_analyzer.py \
--cfgs='core=$(core-cfgs)' --cfgs='alloc=$(alloc-cfgs)' \
$(realpath $(srctree)) $(realpath $(objtree)) \
- $(RUST_LIB_SRC) $(KBUILD_EXTMOD) > \
+ $(rustc_sysroot) $(RUST_LIB_SRC) $(KBUILD_EXTMOD) > \
$(if $(KBUILD_EXTMOD),$(extmod_prefix),$(objtree))/rust-project.json
redirect-intrinsics = \
diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_analyzer.py
index f270c7b0cf34..8529c3940136 100755
--- a/scripts/generate_rust_analyzer.py
+++ b/scripts/generate_rust_analyzer.py
@@ -145,6 +145,7 @@ def main():
parser.add_argument('--cfgs', action='append', default=[])
parser.add_argument("srctree", type=pathlib.Path)
parser.add_argument("objtree", type=pathlib.Path)
+ parser.add_argument("sysroot", type=pathlib.Path)
parser.add_argument("sysroot_src", type=pathlib.Path)
parser.add_argument("exttree", type=pathlib.Path, nargs="?")
args = parser.parse_args()
@@ -154,9 +155,12 @@ def main():
level=logging.INFO if args.verbose else logging.WARNING
)
+ # Making sure that the sysroot and sysroot_src belong to the same toolchain
+ assert args.sysroot in args.sysroot_src.parents
+
rust_project = {
"crates": generate_crates(args.srctree, args.objtree, args.sysroot_src, args.exttree, args.cfgs),
- "sysroot_src": str(args.sysroot_src),
+ "sysroot": str(args.sysroot),
}
json.dump(rust_project, sys.stdout, sort_keys=True, indent=4)
--
2.45.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] rust: Support latest version of `rust-anayzer`
2024-07-19 8:07 [PATCH] rust: Support latest version of `rust-anayzer` Sarthak Singh
@ 2024-07-23 8:54 ` Dirk Behme
0 siblings, 0 replies; 2+ messages in thread
From: Dirk Behme @ 2024-07-23 8:54 UTC (permalink / raw)
To: Sarthak Singh, Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho
Cc: Sarthak Singh, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, rust-for-linux
On 19.07.2024 10:07, Sarthak Singh wrote:
> Sets the `sysroot` field in rust-project.json which is now needed in
> newer versions of rust-anaylzer instead of the `sysroot_src` field.
Here and in the subject there are typos in 'analyzer';)
subject: rust-anayzer -> rust-analyzer
here: rust-anaylzer -> rust-analyzer
> `sysroot` over `sysroot_src` has been working since rust 1.74.0 (which
> was released on Nov 16, 2023). Since we are going to target rust 1.78.0
> going forward we should set `sysroot` to support all currently used and
> future versions of rust-analyzer.
>
> Code editors like VS Code try to use the latest version of rust-analyzer
> (which is updated every week) instead of the version of rust-analyzer
> that comes with the rustup toolchain (which is updated every six weeks
> along with the rust version).
>
> Without this change rust-analyzer is breaking for anyone using VS Code.
>
> Signed-off-by: Sarthak Singh <ss269@uw.edu>
I don't understand much of this, but having rust-analyzer reporting an
error about sysroot something in VS Code without this what is gone with
this change, let me add my
Tested-by: Dirk Behme <dirk.behme@de.bosch.com>
Thanks
Dirk
> ---
> rust/Makefile | 2 +-
> scripts/generate_rust_analyzer.py | 6 +++++-
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/rust/Makefile b/rust/Makefile
> index bf05e65365da..e3d0ba099b18 100644
> --- a/rust/Makefile
> +++ b/rust/Makefile
> @@ -350,7 +350,7 @@ rust-analyzer:
> $(Q)$(srctree)/scripts/generate_rust_analyzer.py \
> --cfgs='core=$(core-cfgs)' --cfgs='alloc=$(alloc-cfgs)' \
> $(realpath $(srctree)) $(realpath $(objtree)) \
> - $(RUST_LIB_SRC) $(KBUILD_EXTMOD) > \
> + $(rustc_sysroot) $(RUST_LIB_SRC) $(KBUILD_EXTMOD) > \
> $(if $(KBUILD_EXTMOD),$(extmod_prefix),$(objtree))/rust-project.json
>
> redirect-intrinsics = \
> diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_analyzer.py
> index f270c7b0cf34..8529c3940136 100755
> --- a/scripts/generate_rust_analyzer.py
> +++ b/scripts/generate_rust_analyzer.py
> @@ -145,6 +145,7 @@ def main():
> parser.add_argument('--cfgs', action='append', default=[])
> parser.add_argument("srctree", type=pathlib.Path)
> parser.add_argument("objtree", type=pathlib.Path)
> + parser.add_argument("sysroot", type=pathlib.Path)
> parser.add_argument("sysroot_src", type=pathlib.Path)
> parser.add_argument("exttree", type=pathlib.Path, nargs="?")
> args = parser.parse_args()
> @@ -154,9 +155,12 @@ def main():
> level=logging.INFO if args.verbose else logging.WARNING
> )
>
> + # Making sure that the sysroot and sysroot_src belong to the same toolchain
> + assert args.sysroot in args.sysroot_src.parents
> +
> rust_project = {
> "crates": generate_crates(args.srctree, args.objtree, args.sysroot_src, args.exttree, args.cfgs),
> - "sysroot_src": str(args.sysroot_src),
> + "sysroot": str(args.sysroot),
> }
>
> json.dump(rust_project, sys.stdout, sort_keys=True, indent=4)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-23 8:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-19 8:07 [PATCH] rust: Support latest version of `rust-anayzer` Sarthak Singh
2024-07-23 8:54 ` Dirk Behme
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).