Skip to content

Commit

Permalink
Use --with-version when configuring jemalloc (#77)
Browse files Browse the repository at this point in the history
* 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 #76

Signed-off-by: Rafael Ávila de Espíndola <[email protected]>
  • Loading branch information
espindola authored Apr 1, 2024
1 parent 8029693 commit 714705e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
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.4+5.3.0-patched"
version = "0.5.4+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7"
authors = [
"Alex Crichton <[email protected]>",
"Gonzalo Brito Gadeschi <[email protected]>",
Expand Down
18 changes: 14 additions & 4 deletions jemalloc-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand All @@ -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");
Expand Down
1 change: 0 additions & 1 deletion jemalloc-sys/configure/VERSION

This file was deleted.

0 comments on commit 714705e

Please sign in to comment.