From 714705e15f6d38424c6645abe2eef877ec828967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Mon, 1 Apr 2024 03:28:04 +0000 Subject: [PATCH] Use --with-version when configuring jemalloc (#77) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Use --with-version when configuring jemalloc 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 | 18 ++++++++++++++---- jemalloc-sys/configure/VERSION | 1 - 3 files changed, 15 insertions(+), 6 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 fd11cf652..dc07fc35d 100644 --- a/jemalloc-sys/build.rs +++ b/jemalloc-sys/build.rs @@ -55,14 +55,23 @@ 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"); + 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); @@ -147,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 { @@ -170,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