Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fasterthanlime opened this issue Jul 22, 2022 · 6 comments
Open

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

fasterthanlime opened this issue Jul 22, 2022 · 6 comments
Labels
A-contributor-roadblock Area: Makes things more difficult for new or seasoned contributors to Rust P-low Low priority T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@fasterthanlime
Copy link
Contributor

(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

@jyn514 jyn514 added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) A-contributor-roadblock Area: Makes things more difficult for new or seasoned contributors to Rust labels Jul 22, 2022
@jyn514
Copy link
Member

jyn514 commented Jul 23, 2022

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

@jyn514
Copy link
Member

jyn514 commented Sep 19, 2022

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

@jyn514 jyn514 added the P-low Low priority label Sep 19, 2022
@onur-ozkan
Copy link
Member

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

@jyn514
Copy link
Member

jyn514 commented Dec 25, 2023

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?

@onur-ozkan
Copy link
Member

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

@jyn514
Copy link
Member

jyn514 commented Dec 25, 2023

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
Labels
A-contributor-roadblock Area: Makes things more difficult for new or seasoned contributors to Rust P-low Low priority T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

3 participants