Make it compile on netbsd (#31)

Signed-off-by: Jay Lee <BusyJayLee@gmail.com>
This commit is contained in:
Jay 2022-06-23 23:54:29 -07:00 committed by GitHub
parent d4411d7977
commit 9380f5b27b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 8 deletions

View File

@ -1,3 +1,8 @@
# jemalloc-sys 0.5.1 - 2022-06-22
- Backport support for NetBSD (#31)
- Watch environment variable change in build script (#31)
# 0.5.0 - 2022-05-19 # 0.5.0 - 2022-05-19
- Update jemalloc to 5.3.0 (#23) - Update jemalloc to 5.3.0 (#23)

View File

@ -1,6 +1,6 @@
[package] [package]
name = "tikv-jemalloc-sys" name = "tikv-jemalloc-sys"
version = "0.5.0+5.3.0" version = "0.5.1+5.3.0-patched"
authors = [ authors = [
"Alex Crichton <alex@alexcrichton.com>", "Alex Crichton <alex@alexcrichton.com>",
"Gonzalo Brito Gadeschi <gonzalobg88@gmail.com>", "Gonzalo Brito Gadeschi <gonzalobg88@gmail.com>",

View File

@ -9,6 +9,7 @@
// except according to those terms. // except according to those terms.
use std::env; use std::env;
use std::ffi::OsString;
use std::fs; use std::fs;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::Command; use std::process::Command;
@ -25,6 +26,16 @@ macro_rules! warning {
} }
} }
fn read_and_watch_env(name: &str) -> Result<String, env::VarError> {
println!("cargo:rerun-if-env-changed={}", name);
env::var(name)
}
fn read_and_watch_env_os(name: &str) -> Option<OsString> {
println!("cargo:rerun-if-env-changed={}", name);
env::var_os(name)
}
// TODO: split main functions and remove following allow. // TODO: split main functions and remove following allow.
#[allow(clippy::cognitive_complexity)] #[allow(clippy::cognitive_complexity)]
fn main() { fn main() {
@ -70,7 +81,7 @@ fn main() {
println!("cargo:rustc-cfg=prefixed"); println!("cargo:rustc-cfg=prefixed");
} }
if let Some(jemalloc) = env::var_os("JEMALLOC_OVERRIDE") { if let Some(jemalloc) = read_and_watch_env_os("JEMALLOC_OVERRIDE") {
info!("jemalloc override set"); info!("jemalloc override set");
let jemalloc = PathBuf::from(jemalloc); let jemalloc = PathBuf::from(jemalloc);
assert!( assert!(
@ -176,7 +187,7 @@ fn main() {
malloc_conf += "background_thread:false"; malloc_conf += "background_thread:false";
} }
if let Ok(malloc_conf_opts) = env::var("JEMALLOC_SYS_WITH_MALLOC_CONF") { if let Ok(malloc_conf_opts) = read_and_watch_env("JEMALLOC_SYS_WITH_MALLOC_CONF") {
malloc_conf += &format!( malloc_conf += &format!(
"{}{}", "{}{}",
if malloc_conf.is_empty() { "" } else { "," }, if malloc_conf.is_empty() { "" } else { "," },
@ -189,22 +200,22 @@ fn main() {
cmd.arg(format!("--with-malloc-conf={}", malloc_conf)); cmd.arg(format!("--with-malloc-conf={}", malloc_conf));
} }
if let Ok(lg_page) = env::var("JEMALLOC_SYS_WITH_LG_PAGE") { if let Ok(lg_page) = read_and_watch_env("JEMALLOC_SYS_WITH_LG_PAGE") {
info!("--with-lg-page={}", lg_page); info!("--with-lg-page={}", lg_page);
cmd.arg(format!("--with-lg-page={}", lg_page)); cmd.arg(format!("--with-lg-page={}", lg_page));
} }
if let Ok(lg_hugepage) = env::var("JEMALLOC_SYS_WITH_LG_HUGEPAGE") { if let Ok(lg_hugepage) = read_and_watch_env("JEMALLOC_SYS_WITH_LG_HUGEPAGE") {
info!("--with-lg-hugepage={}", lg_hugepage); info!("--with-lg-hugepage={}", lg_hugepage);
cmd.arg(format!("--with-lg-hugepage={}", lg_hugepage)); cmd.arg(format!("--with-lg-hugepage={}", lg_hugepage));
} }
if let Ok(lg_quantum) = env::var("JEMALLOC_SYS_WITH_LG_QUANTUM") { if let Ok(lg_quantum) = read_and_watch_env("JEMALLOC_SYS_WITH_LG_QUANTUM") {
info!("--with-lg-quantum={}", lg_quantum); info!("--with-lg-quantum={}", lg_quantum);
cmd.arg(format!("--with-lg-quantum={}", lg_quantum)); cmd.arg(format!("--with-lg-quantum={}", lg_quantum));
} }
if let Ok(lg_vaddr) = env::var("JEMALLOC_SYS_WITH_LG_VADDR") { if let Ok(lg_vaddr) = read_and_watch_env("JEMALLOC_SYS_WITH_LG_VADDR") {
info!("--with-lg-vaddr={}", lg_vaddr); info!("--with-lg-vaddr={}", lg_vaddr);
cmd.arg(format!("--with-lg-vaddr={}", lg_vaddr)); cmd.arg(format!("--with-lg-vaddr={}", lg_vaddr));
} }
@ -249,6 +260,7 @@ fn main() {
.arg("-j") .arg("-j")
.arg(num_jobs.clone())); .arg(num_jobs.clone()));
// Skip watching this environment variables to avoid rebuild in CI.
if env::var("JEMALLOC_SYS_RUN_JEMALLOC_TESTS").is_ok() { if env::var("JEMALLOC_SYS_RUN_JEMALLOC_TESTS").is_ok() {
info!("Building and running jemalloc tests..."); info!("Building and running jemalloc tests...");
// Make tests: // Make tests:

@ -1 +1 @@
Subproject commit 54eaed1d8b56b1aa528be3bdd1877e59c56fa90c Subproject commit e13ca993e8ccb9ba9847cc330696e02839f328f7