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 record multiple native dirs per package #2763

Merged
merged 3 commits into from
Jun 7, 2016

Conversation

mbrubeck
Copy link
Contributor

@mbrubeck mbrubeck commented Jun 2, 2016

This fixes a bug when a package's build script outputs multiple library search
paths. Because Compilation::native_dirs is a HashMap<PackageId, PathBuf> it
can only store one path per package. Currently if there are multiple paths,
all but the last will be inserted and then overwritten.

The key from this map is never used anyway, so this fixes the bug by changing
it from a HashMap to a HashSet.

@rust-highfive
Copy link

r? @wycats

(rust_highfive has picked a reviewer for you, use r? to override)

@mbrubeck
Copy link
Contributor Author

mbrubeck commented Jun 2, 2016

Added a second commit with a fix for #2765, since it depended on the other commit here. See the issue and the commit for details.

search_path.push(dir.clone());

// Add -L arguments, after stripping off prefixes like "native=" or "framework=".
let search_path_prefix = Regex::new("^([:alpha:]+=)").unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

Instead of using Regex can this just use .splitn('=', 2)?

@alexcrichton
Copy link
Member

Thanks! Could you be sure to add a test for both bugs as well?

mbrubeck added 2 commits June 6, 2016 09:24
This fixes a bug when a package's build script outputs multiple library search
paths.  Because Compilation::native_dirs is a `HashMap<PackageId, PathBuf>` it
can only store one path per package.  Currently if there are multiple paths,
all but the last will be inserted and then overwritten.

The key from this map is never used anyway, so this fixes the bug by changing
it from a HashMap to a HashSet.
@mbrubeck
Copy link
Contributor Author

mbrubeck commented Jun 6, 2016

Could you be sure to add a test for both bugs as well?

Done.

Instead of using Regex can this just use .splitn('=', 2)?

Done. I also made the prefix search more specific, so it exactly matches rustc's behavior. This is a bit annoying, but it's the only way to get correct results in the presence of directories with = in their names. Included a test for this.

Also changed for i in &native_dirs to for i in native_dirs.iter().

@alexcrichton
Copy link
Member

@bors: r+ 0cf0ce7

Thanks!

@bors
Copy link
Contributor

bors commented Jun 7, 2016

⌛ Testing commit 0cf0ce7 with merge 3e70312...

bors added a commit that referenced this pull request Jun 7, 2016
Correctly record multiple native dirs per package

This fixes a bug when a package's build script outputs multiple library search
paths.  Because Compilation::native_dirs is a `HashMap<PackageId, PathBuf>` it
can only store one path per package.  Currently if there are multiple paths,
all but the last will be inserted and then overwritten.

The key from this map is never used anyway, so this fixes the bug by changing
it from a HashMap to a HashSet.
@bors
Copy link
Contributor

bors commented Jun 7, 2016

@bors bors merged commit 0cf0ce7 into rust-lang:master Jun 7, 2016
sgrif added a commit to sgrif/pq-sys that referenced this pull request Aug 12, 2016
So this is a bit weird to do, and it's somewhat of a hack. However since
rust-lang/cargo#2763, cargo will now put any `-L`
arguments onto `DYLD_LIBRARY_PATH` when using `cargo test` or `cargo run`. For
installations using Homebrew, this means that we will try to stick
`/usr/local/lib` in `DYLD_LIBRARY_PATH`. If there's anything in there that
conflicts with system libraries (such as `libJPEG`) everything blows up.

It is certainly possible for this configuration issue to affect platforms other
than Mac, but this is not meant to be a catch-all solution for platform
configuration problems. For Mac users though, this is a very common setup that
is easy to resolve. After this commit, the directory will be something like
`/usr/local/Cellar/postgresql/9.5.3/lib` and not `/usr/local/lib`.
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.

5 participants