From 2a26bb36d59b93cc0c63f3a6fd882aae73055bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Thu, 28 Mar 2024 13:10:49 -0100 Subject: [PATCH 1/2] Add a expect_env helper function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rafael Ávila de Espíndola --- jemalloc-sys/build.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/jemalloc-sys/build.rs b/jemalloc-sys/build.rs index fd11cf652..cec3e0c8a 100644 --- a/jemalloc-sys/build.rs +++ b/jemalloc-sys/build.rs @@ -55,12 +55,16 @@ fn copy_recursively(src: &Path, dst: &Path) -> io::Result<()> { Ok(()) } +fn expect_env(name: &str) -> String { + env::var(name).unwrap_or_else(|_| panic!("{} was not set", name)) +} + // TODO: split main functions and remove following allow. #[allow(clippy::cognitive_complexity)] fn main() { - let target = env::var("TARGET").expect("TARGET was not set"); - let host = env::var("HOST").expect("HOST was not set"); - let num_jobs = env::var("NUM_JOBS").expect("NUM_JOBS was not set"); + let target = expect_env("TARGET"); + let host = expect_env("HOST"); + let num_jobs = expect_env("NUM_JOBS"); let out_dir = PathBuf::from(env::var_os("OUT_DIR").expect("OUT_DIR was not set")); let src_dir = env::current_dir().expect("failed to get current directory"); From f5ac3c0c89513edb9ae34c2fb61012b48f5725ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Thu, 28 Mar 2024 13:10:49 -0100 Subject: [PATCH 2/2] Use --with-version when configuring jemalloc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This also changes the metadata of the version so that jemalloc still reports the same version as before. Fixes tikv/jemallocator#76 Signed-off-by: Rafael Ávila de Espíndola --- jemalloc-sys/Cargo.toml | 2 +- jemalloc-sys/build.rs | 8 +++++++- jemalloc-sys/configure/VERSION | 1 - 3 files changed, 8 insertions(+), 3 deletions(-) delete mode 100644 jemalloc-sys/configure/VERSION diff --git a/jemalloc-sys/Cargo.toml b/jemalloc-sys/Cargo.toml index 0e854dd8f..4c30478a1 100644 --- a/jemalloc-sys/Cargo.toml +++ b/jemalloc-sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tikv-jemalloc-sys" -version = "0.5.4+5.3.0-patched" +version = "0.5.4+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7" authors = [ "Alex Crichton ", "Gonzalo Brito Gadeschi ", diff --git a/jemalloc-sys/build.rs b/jemalloc-sys/build.rs index cec3e0c8a..dc07fc35d 100644 --- a/jemalloc-sys/build.rs +++ b/jemalloc-sys/build.rs @@ -67,6 +67,11 @@ fn main() { let num_jobs = expect_env("NUM_JOBS"); let out_dir = PathBuf::from(env::var_os("OUT_DIR").expect("OUT_DIR was not set")); let src_dir = env::current_dir().expect("failed to get current directory"); + let version = expect_env("CARGO_PKG_VERSION"); + let je_version = version + .split_once('+') + .expect("jemalloc version is missing") + .1; info!("TARGET={}", target); info!("HOST={}", host); @@ -151,7 +156,7 @@ fn main() { assert!(build_dir.exists()); // Configuration files - let config_files = ["configure", "VERSION"]; + let config_files = ["configure"]; // Copy the configuration files to jemalloc's source directory for f in &config_files { @@ -174,6 +179,7 @@ fn main() { .env("CFLAGS", cflags.clone()) .env("LDFLAGS", cflags.clone()) .env("CPPFLAGS", cflags) + .arg(format!("--with-version={je_version}")) .arg("--disable-cxx") .arg("--enable-doc=no") .arg("--enable-shared=no"); diff --git a/jemalloc-sys/configure/VERSION b/jemalloc-sys/configure/VERSION deleted file mode 100644 index 1dcfea03f..000000000 --- a/jemalloc-sys/configure/VERSION +++ /dev/null @@ -1 +0,0 @@ -5.3.0-0-g54eaed1d8b56b1aa528be3bdd1877e59c56fa90c