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

Add the rust lib dir (containing std-<hash>.dll) to the path on windows #1093

Merged
merged 1 commit into from
May 17, 2017

Conversation

mcgoo
Copy link
Contributor

@mcgoo mcgoo commented May 5, 2017

I'm not sure if this is the right thing or not, but this fixes some of rust-lang/cargo#3394. My apologies if it undoes earlier path related fixes.

The dylib tests in the cargo testsuite work.
cargo test of a dylib crate works.
It does nothing for the cargo install case.

It adds sysroot/bin to the path on Windows which fixes finding libstd. A side effect of this is that rustc.exe is directly in the path although it is after CARGO_HOME/bin so the shim should be found first.

The behavior of prepend_path in case of a corrupt path is changed - it used to clobber the existing path with the new path, and now it will leave leave the existing path unchanged.

It leaves LD_LIBRARY_PATH set on Windows also as I believe it is used by MinGW.

Adds sysroot/bin to the path on Windows which fixes finding libstd in
dynamic builds. This fixes a load of dylib tests in the cargo testsuite
on Windows. This will result in rustc.exe being directly in the path
although it is after CARGO_HOME/bin so the shim should be found first.
@brson
Copy link
Contributor

brson commented May 5, 2017

Thanks for tackling this @mcgoo. This path munging code ... omg, so frustrating.

It's so hard to imagine what is going on at runtime with all the layers of indirection and environment frobbing.

A worry I have with this patch is that it might accidentally be reverting what the original PR that caused this was fixing - that all cargo invocations go through .cargo/bin. I think this patch preserves that quality from reading it over several times.

I guess I'm willing to try this and see what happens. The three failures on appveyor seem legit. Probably some patch-munging corner case that requires things to be perfectly right in a way that is contradictory to other goals.

bors added a commit to rust-lang/cargo that referenced this pull request May 9, 2017
fix `cargo test` of dylib projects for end user runs too

Fixes running `cargo test` and `cargo test --target <target>` for dylib projects.

Moves the logic just landed in #3996 into cargo itself, so cargo sets the dylib path for anyone running `cargo test` or `cargo run`. Current master sets the dylib path only for  `cargo test` on cargo itself.

This PR pins to rustup 1.2.0 for the purposes of testing. If rust-lang/rustup#1093 ends up working out, then this PR would only be important for non-rustup users and people doing cross testing, `cargo test --target <target>`.

Arguably https://github.com/mcgoo/cargo/blob/ed273851f8bc76f726eda4a2e2a7bb470c3718bc/src/cargo/ops/cargo_rustc/context.rs#L249-L253 should point to lib/rustlib/\<host triple\>/lib instead of sysroot/lib, because I think if the libs are different, you will never be able to compile a working plugin anyway, and for the host=target case you get the  lib/rustlib/\<host triple\>/lib anyhow. Is there ever a case where the lib/rustlib/\<host triple\>/lib and sysroot/lib versions of the libs would be expected to differ?

This is not a huge deal for me one way or the other - it doesn't impact my workflow at all. I nearly dropped it when I saw @alexcrichton had made it all work in 3996, but I think it's worth doing because it removes a surprise. It certainly would have saved me a couple of days of confusion. Either way, thanks for looking it over.
@Diggsey
Copy link
Contributor

Diggsey commented May 17, 2017

If this regresses something, it means we need more regression tests.

The test failures on appveyor are a known flaky test, but it's surprising that three failed, let's give bors a try...
@bors r+

@bors
Copy link
Contributor

bors commented May 17, 2017

📌 Commit 0555dbe has been approved by Diggsey

@mcgoo
Copy link
Contributor Author

mcgoo commented May 17, 2017

I actually ended up with this change in cargo that fixes the path for both cross and native builds, which rustup would not be able to do easily, so anything running under cargo is fixed already.

I still think this change is correct from the standpoint of consistency with other platforms, but I don't know what it actually fixes as such anymore. rustup run and the debuggers I guess?

@bors
Copy link
Contributor

bors commented May 17, 2017

⌛ Testing commit 0555dbe with merge 4bc7522...

bors added a commit that referenced this pull request May 17, 2017
Add the rust lib dir (containing std-<hash>.dll) to the path on windows

I'm not sure if this is the right thing or not, but this fixes some of rust-lang/cargo#3394. My apologies if it undoes earlier path related fixes.

The dylib tests in the cargo testsuite work.
`cargo test` of a dylib crate works.
It does nothing for the `cargo install` case.

It adds sysroot/bin to the path on Windows which fixes finding libstd. A side effect of this is that rustc.exe is directly in the path although it is after CARGO_HOME/bin so the shim should be found first.

The behavior of prepend_path in case of a corrupt path is changed - it used to clobber the existing path with the new path, and now it will leave leave the existing path unchanged.

It leaves LD_LIBRARY_PATH set on Windows also as I believe it is used by MinGW.
@bors
Copy link
Contributor

bors commented May 17, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: Diggsey
Pushing 4bc7522 to master...

@bors bors merged commit 0555dbe into rust-lang:master May 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants