Skip to content

Figure out why x.py test --stage 0 rust-analyzer doesn't work #99610

Open

Description

@fasterthanlime

(This issue only makes sense after #99603 lands)

@jyn514 is convinced it should if the proper sysroot is used to compile both the proc-macro-srv and proc-macro-test-impl crates.

There's one nested invocation of rustc in proc-macro-srv's build script, but it uses $RUSTC (all it does is grab the trimmed output of rustc -v).

There's one nested invocation of cargo in proc-macro-test's build script (to build proc-macro-test-impl in a temp dir), but it uses $CARGO.

Here's the output of ./x.py test --stage 0 -vv rust-analyzer --test-args like_macro_clone_literals: https://gist.github.com/fasterthanlime/3de46b62906d0762c8c3ac0e295892a4

Activity

  1. added
    T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
    A-contributor-roadblockArea: Makes things more difficult for new or seasoned contributors to Rust
    on Jul 22, 2022
  2. jyn514 commented on Jul 23, 2022

    @jyn514
    Member

    fix here:

    diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
    index 7c37621d417..0f20b74bcb4 100644
    --- a/src/bootstrap/tool.rs
    +++ b/src/bootstrap/tool.rs
    @@ -250,6 +250,15 @@ pub fn prepare_tool_cargo(
             }
         }
     
    +    if path.ends_with("rust-analyzer") {
    +        // RA wants to load proc macros at runtime for one of its tests. But by default, proc macros
    +        // are built with the beta proc_macro, not the in-tree proc_macro. Explicitly override this
    +        // in the rustc shim.
    +        // This is ok because rust-analyzer is `Mode::ToolStd`, so proc_macro is always built before.
    +        cargo.rustflag("--sysroot");
    +        cargo.rustflag(builder.sysroot(compiler).as_os_str().to_str().unwrap());
    +    }
    +
         // clippy tests need to know about the stage sysroot. Set them consistently while building to
         // avoid rebuilding when running tests.
         cargo.env("SYSROOT", builder.sysroot(compiler));

    will try to write this up more thoroughly soon

  3. jyn514 commented on Sep 19, 2022

    @jyn514
    Member

    Oh fun, this isn't possible to test unless the proc-macro ABI changed in the last release 🤦

  4. onur-ozkan commented on Dec 25, 2023

    @onur-ozkan
    Contributor

    This no longer seems to be a problem.

    Tested on HEAD: f736079

    x test --stage 0 rust-analyzer:

    running 13 tests
    .............
    
    test result: ok. 13 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.27ms
    
            finished in 9.789 seconds
  5. jyn514 commented on Dec 25, 2023

    @jyn514
    Member

    you need to combine it with a breaking change to the proc macro lib format in the same release cycle.

    maybe that's rare enough this isn't worth worrying about?

  6. onur-ozkan commented on Dec 25, 2023

    @onur-ozkan
    Contributor

    you need to combine it with a breaking change to the proc macro lib format in the same release cycle.

    Sounds similar to #119172 (comment) problem (when public api changes on compiler crates, ra fails to build).

    maybe that's rare enough this isn't worth worrying about?

    I think so

  7. jyn514 commented on Dec 25, 2023

    @jyn514
    Member

    Sounds similar to #119172 (comment) problem (when public api changes on compiler crates, ra fails to build).

    kinda, but in this case a sync will only fix it for stage 1, not for stage 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-contributor-roadblockArea: Makes things more difficult for new or seasoned contributors to RustP-lowLow priorityT-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions