Skip to content

Commit 9380f5b

Browse files
authored
Make it compile on netbsd (#31)
Signed-off-by: Jay Lee <[email protected]>
1 parent d4411d7 commit 9380f5b

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# jemalloc-sys 0.5.1 - 2022-06-22
2+
3+
- Backport support for NetBSD (#31)
4+
- Watch environment variable change in build script (#31)
5+
16
# 0.5.0 - 2022-05-19
27

38
- Update jemalloc to 5.3.0 (#23)

jemalloc-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tikv-jemalloc-sys"
3-
version = "0.5.0+5.3.0"
3+
version = "0.5.1+5.3.0-patched"
44
authors = [
55
"Alex Crichton <[email protected]>",
66
"Gonzalo Brito Gadeschi <[email protected]>",

jemalloc-sys/build.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
use std::env;
12+
use std::ffi::OsString;
1213
use std::fs;
1314
use std::path::{Path, PathBuf};
1415
use std::process::Command;
@@ -25,6 +26,16 @@ macro_rules! warning {
2526
}
2627
}
2728

29+
fn read_and_watch_env(name: &str) -> Result<String, env::VarError> {
30+
println!("cargo:rerun-if-env-changed={}", name);
31+
env::var(name)
32+
}
33+
34+
fn read_and_watch_env_os(name: &str) -> Option<OsString> {
35+
println!("cargo:rerun-if-env-changed={}", name);
36+
env::var_os(name)
37+
}
38+
2839
// TODO: split main functions and remove following allow.
2940
#[allow(clippy::cognitive_complexity)]
3041
fn main() {
@@ -70,7 +81,7 @@ fn main() {
7081
println!("cargo:rustc-cfg=prefixed");
7182
}
7283

73-
if let Some(jemalloc) = env::var_os("JEMALLOC_OVERRIDE") {
84+
if let Some(jemalloc) = read_and_watch_env_os("JEMALLOC_OVERRIDE") {
7485
info!("jemalloc override set");
7586
let jemalloc = PathBuf::from(jemalloc);
7687
assert!(
@@ -176,7 +187,7 @@ fn main() {
176187
malloc_conf += "background_thread:false";
177188
}
178189

179-
if let Ok(malloc_conf_opts) = env::var("JEMALLOC_SYS_WITH_MALLOC_CONF") {
190+
if let Ok(malloc_conf_opts) = read_and_watch_env("JEMALLOC_SYS_WITH_MALLOC_CONF") {
180191
malloc_conf += &format!(
181192
"{}{}",
182193
if malloc_conf.is_empty() { "" } else { "," },
@@ -189,22 +200,22 @@ fn main() {
189200
cmd.arg(format!("--with-malloc-conf={}", malloc_conf));
190201
}
191202

192-
if let Ok(lg_page) = env::var("JEMALLOC_SYS_WITH_LG_PAGE") {
203+
if let Ok(lg_page) = read_and_watch_env("JEMALLOC_SYS_WITH_LG_PAGE") {
193204
info!("--with-lg-page={}", lg_page);
194205
cmd.arg(format!("--with-lg-page={}", lg_page));
195206
}
196207

197-
if let Ok(lg_hugepage) = env::var("JEMALLOC_SYS_WITH_LG_HUGEPAGE") {
208+
if let Ok(lg_hugepage) = read_and_watch_env("JEMALLOC_SYS_WITH_LG_HUGEPAGE") {
198209
info!("--with-lg-hugepage={}", lg_hugepage);
199210
cmd.arg(format!("--with-lg-hugepage={}", lg_hugepage));
200211
}
201212

202-
if let Ok(lg_quantum) = env::var("JEMALLOC_SYS_WITH_LG_QUANTUM") {
213+
if let Ok(lg_quantum) = read_and_watch_env("JEMALLOC_SYS_WITH_LG_QUANTUM") {
203214
info!("--with-lg-quantum={}", lg_quantum);
204215
cmd.arg(format!("--with-lg-quantum={}", lg_quantum));
205216
}
206217

207-
if let Ok(lg_vaddr) = env::var("JEMALLOC_SYS_WITH_LG_VADDR") {
218+
if let Ok(lg_vaddr) = read_and_watch_env("JEMALLOC_SYS_WITH_LG_VADDR") {
208219
info!("--with-lg-vaddr={}", lg_vaddr);
209220
cmd.arg(format!("--with-lg-vaddr={}", lg_vaddr));
210221
}
@@ -249,6 +260,7 @@ fn main() {
249260
.arg("-j")
250261
.arg(num_jobs.clone()));
251262

263+
// Skip watching this environment variables to avoid rebuild in CI.
252264
if env::var("JEMALLOC_SYS_RUN_JEMALLOC_TESTS").is_ok() {
253265
info!("Building and running jemalloc tests...");
254266
// Make tests:

jemalloc-sys/jemalloc

0 commit comments

Comments
 (0)