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

Correctly handle a case where build dependencies are also declared as non-build dependencies #1508

Merged
merged 5 commits into from
Apr 14, 2015

Conversation

mohtar
Copy link
Contributor

@mohtar mohtar commented Apr 11, 2015

Fix #876.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @wycats (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see CONTRIBUTING.md for more information.

(dep, pkg.dependencies().iter().find(|d| {
d.name() == dep.name()
}).unwrap())
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this logic be left here actually? It's still used in multiple places below, and the call to find could be replaced with filter and then the cases below could use the iterator if necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to do that, but then the compiler complains: dep does not live long enough

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may have to use the move keyword on the closure to ensure it doesn't try to capture a local reference

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK that's fine. But the cases would be rewritten like this

base.extend(deps.filter(|&(_, dep)| dep.any(|d| d.is_build()))
                .map(|(id, _)| (id, Stage::Libraries)));

And the compiler compains again "cannot move out of borrowed content". I tried ref dep and ref mut dep but still it won't work out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you generate a patch that I could apply locally? I may have to poke a bit as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see what's going on, I guess this won't work out as nicely as I hoped :(

Oh well, sorry for the runaround!

@alexcrichton alexcrichton assigned alexcrichton and unassigned wycats Apr 13, 2015
@alexcrichton
Copy link
Member

Nice! Thanks for fixing this!

Could you add some tests for this as well?

.filter(|id| pkg.dependencies().iter()
.find(|d| d.name() == id.name() && d.is_build())
.is_some())
.map(|id| (id, Stage::Libraries)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This formatting is a bit confusing because the alignment of .filter with .extend normally indicates that the filter is happening on the return value of extend, perhaps this could be formatted as:

                base.extend(deps.filter(|id| {
                    pkg.dependencies().iter().find(|d| {
                        d.name() == id.name() && d.is_build()
                    }).is_some()
                }).map(|id| (id, Stage::Libraries)));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I also replaced find(...).is_some() with any(...)

@jakerr
Copy link
Contributor

jakerr commented Apr 14, 2015

I'm really glad someone found the time to pick this up, thanks @mohtar !!

I thought I'd found a bug but it was a false alarm. Safe to ignore the rest of this comment.

I've pulled your patch and am noticing some failure when building libz-sys in it's custom build which doesn't occur at master

Build failed, waiting for other jobs to finish...
failed to run custom build command for `libz-sys v0.1.2`
Process didn't exit successfully: `/Users/jakerr/code/rustws/rustecspong/target/debug/build/libz-sys-bab95f842f454018/build-script-build` (signal: 5)
--- stderr
dyld: Symbol not found: __ZN11collections4hash5table26RawTable$LT$K$C$$u20$V$GT$16first_bucket_raw10_FILE_LINE20h536f24f1e96e3184q4cE
  Referenced from: /Users/jakerr/code/rustws/rustecspong/target/debug/build/libz-sys-bab95f842f454018/build-script-build
  Expected in: /Users/jakerr/.multirust/toolchains/nightly/lib/libstd-4e7c5e5c.dylib
 in /Users/jakerr/code/rustws/rustecspong/target/debug/build/libz-sys-bab95f842f454018/build-script-build

I'm going to try to distill into a failing test case or at the least a minimal cargo project exhibiting the bug.

@jakerr
Copy link
Contributor

jakerr commented Apr 14, 2015

Sorry, false alarm! This had to do with me trying to compile for a target architecture without updating my DYLD_LIBRARY_PATH as per brson/multirust#43

@alexcrichton
Copy link
Member

@bors: r+ 4596554

Thanks!

@bors
Copy link
Contributor

bors commented Apr 14, 2015

⌛ Testing commit 4596554 with merge 67bc575...

bors added a commit that referenced this pull request Apr 14, 2015
@bors
Copy link
Contributor

bors commented Apr 14, 2015

☀️ Test successful - cargo-linux-32, cargo-linux-64, cargo-mac-32, cargo-mac-64, cargo-win-32, cargo-win-64

@bors bors merged commit 4596554 into rust-lang:master Apr 14, 2015
@mohtar mohtar deleted the dupdepsbug branch April 15, 2015 08:37
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.

Build dependencies fail if also declared as non-build dependencies.
6 participants