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

Make it compile on netbsd #31

Merged
merged 3 commits into from
Jun 24, 2022
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: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

- Update jemalloc to 5.3.0 (#23)
Expand Down
2 changes: 1 addition & 1 deletion jemalloc-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tikv-jemalloc-sys"
version = "0.5.0+5.3.0"
version = "0.5.1+5.3.0-patched"
authors = [
"Alex Crichton <alex@alexcrichton.com>",
"Gonzalo Brito Gadeschi <gonzalobg88@gmail.com>",
Expand Down
24 changes: 18 additions & 6 deletions jemalloc-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

use std::env;
use std::ffi::OsString;
use std::fs;
use std::path::{Path, PathBuf};
use std::process::Command;
Expand All @@ -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.
#[allow(clippy::cognitive_complexity)]
fn main() {
Expand Down Expand Up @@ -70,7 +81,7 @@ fn main() {
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");
let jemalloc = PathBuf::from(jemalloc);
assert!(
Expand Down Expand Up @@ -176,7 +187,7 @@ fn main() {
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!(
"{}{}",
if malloc_conf.is_empty() { "" } else { "," },
Expand All @@ -189,22 +200,22 @@ fn main() {
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);
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);
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);
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);
cmd.arg(format!("--with-lg-vaddr={}", lg_vaddr));
}
Expand Down Expand Up @@ -249,6 +260,7 @@ fn main() {
.arg("-j")
.arg(num_jobs.clone()));

// Skip watching this environment variables to avoid rebuild in CI.
if env::var("JEMALLOC_SYS_RUN_JEMALLOC_TESTS").is_ok() {
info!("Building and running jemalloc tests...");
// Make tests:
Expand Down
2 changes: 1 addition & 1 deletion jemalloc-sys/jemalloc
Submodule jemalloc updated 1 files
+13 −7 Makefile.in