-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
More Rust/RLS integration #42146
More Rust/RLS integration #42146
Conversation
"tools/rls/test_data/goto_def", | ||
"tools/rls/test_data/highlight", | ||
"tools/rls/test_data/hover", | ||
"tools/rls/test_data/rename", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to instead specify:
exclude = [
"tools/rls/test_data",
]
?
(this is a relatively new feature of Cargo)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't work - I get "error: failed to read /home/ncameron/rust2/src/tools/rls/test_data/Cargo.toml
"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, no I don't. Testing again...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error:
thread '<unnamed>' panicked at 'could not create cargo workspace: current package believes it's in a workspace when it's not:
current: /home/ncameron/rust2/src/tools/rls/test_data/highlight/Cargo.toml
workspace: /home/ncameron/rust2/src/Cargo.toml
this may be fixable by adding `tools/rls/test_data/highlight` to the `workspace.members` array of the manifest located at: /home/ncameron/rust2/src/Cargo.toml', src/libcore/result.rs:859
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bah! Mind opening an issue on Cargo for this so we can be sure to fix it for the next release? And then you can leave a comment here saying # TODO: move these to exclude
or something like that for the next release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm this logic makes me think that exclude
could work. Are you sure the above doesn't work? I've just added a test case to Cargo locally to and this works as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tried again after a rebase to Rust master, checked Cargo submod is also on master, and updated system Rust for luck, still get the same error. Note that I get the error on running the RLS tests - so these are test directories inside the RLS directory inside Rust. I wonder if the nesting is exposing a Cargo bug?
src/bootstrap/check.rs
Outdated
|
||
let mut dylib_path = dylib_path(); | ||
dylib_path.insert(0, build.sysroot_libdir(&compiler, host)); | ||
cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh we've actually got a helper for this I think
src/bootstrap/check.rs
Outdated
cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap()); | ||
|
||
// Avoid using the rustc shim. | ||
cargo.env("RUSTC", build.compiler_path(compiler)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be sufficient do to env_remove
here perhaps?
src/bootstrap/check.rs
Outdated
// Avoid using the rustc shim. | ||
cargo.env("RUSTC", build.compiler_path(compiler)); | ||
|
||
build.run(cargo.env("PATH", &path_for_cargo(build, compiler))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the rls work the same way as cargo in the sense that it's matching output? Cargo will print the value of RUSTC
at some point during testing which the testing itself didn't expect, so Cargo's tests are basically asserting that RUSTC=rustc
so that's why this was necessary. Ideally though this modification of PATH
wouldn't be necessary, but do the rls tests do basically the same thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The RLS does not do this. However, if I don't do this PATH hack, I get an error about different versions of the bitflags crate. Possibly cargo culting and I need to change something else?
@@ -474,6 +474,10 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules { | |||
.dep(|s| s.name("tool-cargo")) | |||
.host(true) | |||
.run(move |s| check::cargo(build, s.stage, s.target)); | |||
rules.test("check-rls", "src/tools/rls") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This'll need to be coupled with a change to
rust/src/bootstrap/mk/Makefile.in
Lines 57 to 65 in 81734e0
src/tools/cargotest \ | |
cargo \ | |
src/test/pretty \ | |
src/test/run-pass/pretty \ | |
src/test/run-fail/pretty \ | |
src/test/run-pass-valgrind/pretty \ | |
src/test/run-pass-fulldeps/pretty \ | |
src/test/run-fail-fulldeps/pretty \ | |
$(BOOTSTRAP_ARGS) |
Also, while you're at it, mind doing a bit of cleanup for Cargo? The cargo
path in test("check-cargo", "cargo")
above should be src/tools/cargo
and the Makefile.in
entry should change as well (the submodule has moved now)
@alexcrichton review commit makes requested changes (unless I commented inline). |
src/bootstrap/check.rs
Outdated
// Avoid using the rustc shim. | ||
cargo.env_remove("RUSTC"); | ||
|
||
build.run(cargo.env("PATH", &path_for_cargo(build, compiler))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm so just to confirm, did you test not setting PATH
but setting RUSTC
to the actual compiler itself? (not the shim)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it both ways and got (different) errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you gist what you're seeing and the various combinations? This whole construction worries me a bit...
src/bootstrap/check.rs
Outdated
build.add_rustc_lib_path(compiler, &mut cargo); | ||
|
||
// Avoid using the rustc shim. | ||
cargo.env_remove("RUSTC"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Er wait hang on, I think I may have spoken too soon!
So Cargo's a pretty special flower here. I'm remembering now that we do use the shim rustc to compile Cargo itself. This correctly accounts for things like optimization flags, debuginfo flags, etc. When we run tests, however, Cargo would use the RUSTC
env var configured but all of Cargo's tests actually explicitly ignore this env var relying on rustc
instead. That means that the PATH
modification is purely done for tests and RUSTC
is purely done for compiling Cargo itself. Weird, no?
So now we've got a question for the rls itself. I believe the rls should be compiling with RUSTC
(the shim) actually to get the right flags, so I believe I was mistaken to request this env_remove
. Down below though it still seems that the PATH
modification should not be necessary. Does the test suite for the rls tamper with RUSTC
at all? If it's invoking Cargo and/or respecting RUSTC
then I'd actually expect the rls to basically ignore the PATH
below, always relying on RUSTC
itself (a different compiler).
You mentioned errors with the bitflags crate, but some of those may have actually been very recently fixed, so maybe a rebase, remove env_remove
, remove PATH
changes, and see if it works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, baseline is with the env.remove and setting the PATH, and tests pass. If I remove both of them, I get:
thread '<unnamed>' panicked at 'could not run cargo: ChainedError { error: failed to run `rustc` to learn about target-specific information, cause: process didn't exit successfully: `/home/ncameron/rust2/build/bootstrap/debug/rustc - --crate-name ___ --print=file-names -Zunstable-options -Zcontinue-parse-after-error --error-format=json -Zsave-analysis --crate-type bin --crate-type rlib --target x86_64-unknown-linux-gnu` (exit code: 101)
--- stderr
error: Option 'error-format' given more than once.
For each test. I think because the rustc shim adds --error-format
even though the RLS has added it already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although, it must do so indirectly since it is not in the shim
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exact change:
diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs
index 6da19e8..095fe08 100644
--- a/src/bootstrap/check.rs
+++ b/src/bootstrap/check.rs
@@ -123,9 +123,9 @@ pub fn rls(build: &Build, stage: u32, host: &str) {
build.add_rustc_lib_path(compiler, &mut cargo);
// Avoid using the rustc shim.
- cargo.env_remove("RUSTC");
+ //cargo.env_remove("RUSTC");
- build.run(cargo.env("PATH", &path_for_cargo(build, compiler)));
+ build.run(&mut cargo);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think because the rustc shim adds --error-format even though the RLS has added it already.
But error-format
as a string shows up nowhere inside the src/bootstrap
directory?
Something seems really fishy here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't recall where, but I thought the test infrastructure sets it somewhere? IIRC, compiletest or something intercepts error messages so it can do compile-fail etc and uses json errors for that
src/bootstrap/check.rs
Outdated
let path = build.sysroot(compiler).join("bin"); | ||
let old_path = ::std::env::var("PATH").expect(""); | ||
let sep = if cfg!(windows) { ";" } else {":" }; | ||
format!("{}{}{}", path.display(), sep, old_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably os os::split_paths
and os::join_paths
@nrc mind separate and merge the submodule update first? |
@nrc I'm trying to check this out locally to test this out and see these errors, but it's not building? Missing commits in rustfmt? (that itself is also something we should be concerned about!) |
This was added in rust-lang#38072 but I can't recall why and AFAIK Cargo already handles this. This was discovered through rust-lang#42146 where passing duplicate flags was causing problems.
RUSTFLAGS duplication is because of this bug -- #42382 |
Ok there's a lot of other fishy logic in the rls. This is why I'm hesitant to merge workaround as it seems like there's a number of legitimate bugs?
|
☔ The latest upstream changes (presumably #42381) made this pull request unmergeable. Please resolve the merge conflicts. |
…rk-Simulacrum rustbuild: Remove RUSTFLAGS logic in rustc shim This was added in rust-lang#38072 but I can't recall why and AFAIK Cargo already handles this. This was discovered through rust-lang#42146 where passing duplicate flags was causing problems.
…rk-Simulacrum rustbuild: Remove RUSTFLAGS logic in rustc shim This was added in rust-lang#38072 but I can't recall why and AFAIK Cargo already handles this. This was discovered through rust-lang#42146 where passing duplicate flags was causing problems.
ping @nrc, thoughts on my most recent comment? |
Sorry, been busy with other things. Will get back to this soon... |
This is partly by design and partly just because we haven't got round to supporting this stuff in the RLS. The 'by design' bit is because we use our own (linked) rustc for the regular builds and letting the user specify the rustc used from Cargo seems like a good way to get incompatible crates. I hope we can work around this by carefully setting up the rustc here in Rustbuild.
Not exactly sure what is going on there. I think that this only applies to env vars for setting up the tool chain and that this is ok because we don't support cross-compilation. However, that seems wrong because one could cross-compile the RLS. This looks like it needs fixing in the RLS. |
Oh, and sorry for taking so long to respond. |
This commit fixes the compile time/runtime env vars issue: rust-lang/rls@c750c66 |
Updating the RLS is blocked on rust-lang/cargo#4178 |
You can merge the branch beforehand and git will handle the duplicates afterward. |
📌 Commit d023e75 has been approved by |
@bors r=alexcrichton |
💡 This pull request was already approved, no need to approve it again.
|
📌 Commit d023e75 has been approved by |
⌛ Testing commit d023e7508e977b5f28bdf90b665eb6782a65d92c with merge 62d527953e7cb73db46385257636f52c0ae55f22... |
💔 Test failed - status-travis |
@bors: retry
…On Thu, Jul 13, 2017 at 3:06 AM, bors ***@***.***> wrote:
💔 Test failed - status-travis
<https://travis-ci.org/rust-lang/rust/builds/253095953?utm_source=github_status&utm_medium=notification>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#42146 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAD95DaSww1ksDftL3EYCrZwW-iowMSoks5sNdARgaJpZM4Nhz21>
.
|
⌛ Testing commit d023e7508e977b5f28bdf90b665eb6782a65d92c with merge 75042aaf587e2ac3245b9221df111719ea45f91b... |
💔 Test failed - status-travis |
|
☔ The latest upstream changes (presumably #43207) made this pull request unmergeable. Please resolve the merge conflicts. |
@bors r=alexcrichton I'm not sure if the jobserver test failure is real, but I can't repro locally, it looks vaguely suspicious to me and no-one was around on irc to help, so I figured it was worth trying again. |
📌 Commit 04415dc has been approved by |
More Rust/RLS integration r? @alexcrichton cc rust-lang/rls#310 closes #41199 closes #41197
☀️ Test successful - status-appveyor, status-travis |
r? @alexcrichton
cc rust-lang/rls#310
closes #41199
closes #41197