Skip to content
This repository was archived by the owner on Feb 26, 2020. It is now read-only.
Merged
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
11 changes: 11 additions & 0 deletions rocksdb-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,22 @@ fn main() {

println!("cargo:rustc-link-lib=dylib={}", "rpcrt4");
println!("cargo:rustc-link-lib=dylib={}", "shlwapi");

let features = env::var("CARGO_CFG_TARGET_FEATURE").unwrap_or_default();
if features.contains("crt-static") {
cfg.define("WITH_MD_LIBRARY", "OFF");
}
} else {
cfg.define("SNAPPY_INCLUDE_DIR", snappy)
.define("SNAPPY_LIBRARIES", "/dev/null");
}

// NOTE: the cfg! macro doesn't work when cross-compiling, it would return values for the host
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default();
if target_arch == "arm" || target_arch == "aarch64" {
Copy link

Choose a reason for hiding this comment

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

IIUC, we assume that the host arch is x86_64? And, ideally, we should check for host_arch != target_arch? But I'm not sure if there is a simple way to find out the value of the host_arch.

Copy link
Author

Choose a reason for hiding this comment

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

Indeed, I think -march=native would work if the host was ARM and it was building for ARM, but the crate should build on ARM nonetheless with the current changes.
The current build file isn't terribly portable and yes it makes some assumptions regarding the build environment, i.e. my priority was to make it work on parity-ethereum's CI.

cfg.define("PORTABLE", "ON");
}

let out = cfg.build();

let mut build = out.join("build");
Expand Down