Skip to content

Make sure to not add system dirs to linkage #565

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

Merged
merged 1 commit into from
Jan 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions openssl-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ build = "build.rs"
libc = "0.2"

[build-dependencies]
metadeps = "1"
pkg-config = "0.3.9"

[target.'cfg(windows)'.dependencies]
user32-sys = "0.2"
gdi32-sys = "0.2"

# We don't actually use metadeps for annoying reasons but this is still hear for tooling
[package.metadata.pkg-config]
openssl = "1.0.0" # We actually need 1.0.1, but OpenBSD reports as 1.0.0
openssl = "1.0.1"
21 changes: 17 additions & 4 deletions openssl-sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extern crate metadeps;
extern crate pkg_config;

use std::collections::HashSet;
use std::env;
Expand Down Expand Up @@ -172,8 +172,16 @@ fn try_pkg_config() {
// cflags dirs for showing us lots of `-I`.
env::set_var("PKG_CONFIG_ALLOW_SYSTEM_CFLAGS", "1");

let lib = match metadeps::probe() {
Ok(mut libs) => libs.remove("openssl").unwrap(),
// This is more complex than normal because we need to track down opensslconf.h.
// To do that, we need the inlude paths even if they're on the default search path, but the
// linkage directories emitted from that cause all kinds of issues if other libraries happen to
// live in them. So, we run pkg-config twice, once asking for system dirs but not emitting
// metadata, and a second time emitting metadata but not asking for system dirs. Yay.
let lib = match pkg_config::Config::new()
.cargo_metadata(false)
.print_system_libs(true)
.find("openssl") {
Ok(lib) => lib,
Err(_) => return,
};

Expand All @@ -196,7 +204,7 @@ specific to your distribution:
sudo dnf install openssl-devel

See rust-openssl README for more information:

https://github.com/sfackler/rust-openssl#linux
");
}
Expand All @@ -207,6 +215,11 @@ See rust-openssl README for more information:
println!("cargo:include={}", include.display());
}

pkg_config::Config::new()
.print_system_libs(false)
.find("openssl")
.unwrap();

std::process::exit(0);
}

Expand Down