scripts: generate_rust_analyzer: Add message to sysroot assertion
Subsystems (2)
PATCH v3 1/1 scripts: generate_rust_analyzer: Add message to sysroot assertion
The assertion that checks whether sysroot lies within sysroot_src currently fails without explaining why. Add an error message that prints both paths to make diagnosing toolchain issues easier.
--- scripts/generate_rust_analyzer.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
scripts/generate_rust_analyzer.py +7 -2
@@ -213,8 +213,13 @@ 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 + assert args.sysroot in args.sysroot_src.parents, \ + f""" + It seems like your sysroot and sysroot_src do not belong to the same toolchain. + The sysroot folder must be inside sysroot_src. + sysroot={args.sysroot} + sysroot_src={args.sysroot_src} + """ rust_project = { "crates": generate_crates(args.srctree, args.objtree, args.sysroot_src, args.exttree, args.cfgs, args.core_edition),
base-commit: 54e3eae855629702c566bd2e130d9f40e7f35bde
Signature · 1 line
2.50.1
Quoted 5 lines · Maurice Hieronymus
The assertion that checks whether sysroot lies within
sysroot_srccurrently fails without explaining why. Add an error message that prints both paths to make diagnosing toolchain issues easier.Signed-off-by Maurice Hieronymus <[email protected]> ---
Changes since v2: - Rebased on rust/rust-next - Remove redundant comment above assertion
Quoted 22 lines
scripts/generate_rust_analyzer.py| 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/scripts/generate_rust_analyzer.pyindex147d0cc94068..446d405ef68a100755 ---a/scripts/generate_rust_analyzer.py+++b/scripts/generate_rust_analyzer.py@@ -213,8 +213,13 @@ defmain():
level=logging.INFO if args.verbose else logging.WARNING )- # Making sure that the
sysrootandsysroot_srcbelong to the same toolchain. - assert args.sysroot in args.sysroot_src.parents
+ assert args.sysroot in args.sysroot_src.parents, \ + f""" + It seems like your sysroot andsysroot_srcdo not belong to the same toolchain. + The sysroot folder must be insidesysroot_src. + sysroot={args.sysroot} + sysroot_src={args.sysroot_src} + """
rust_project= { "crates":generate_crates(args.srctree, args.objtree, args.sysroot_src, args.exttree, args.cfgs, args.core_edition),base-commit:
54e3eae855629702c566bd2e130d9f40e7f35bde-- 2.50.1
Quoted 6 lines · Maurice Hieronymus
The assertion that checks whether sysroot lies within
sysroot_srccurrently fails without explaining why. Add an error message that prints both paths to make diagnosing toolchain issues easier.Signed-off-by Maurice Hieronymus <[email protected]>
It looks like we are removing the assertion, since there are cases where it does not hold true, like NixOS:
https://lore.kernel.org/rust-for-linux/[email protected]/
I will take that one as a fix, which will mean it will land earlier than things in rust-next (where this one would have been), so this one here will then not be applicable anymore since there will be no assertion anymore -- I am sorry Maurice, since I know it was one of your first patches...
I guess it could still be nice to somehow check that the sysroot_src belongs to the same toolchain as the sysroot even if it is in a different path, but I don't know if that is possible in the general case, and it is likely not worth the complexity even if there is an elegant way.
Cc'ing Tamir, Jesung and Onur.
Cheers,
Miguel