Skip to content

Commit 12c0574

Browse files
committed
Add reproducibility build for jemalloc-sys
1 parent 3431d03 commit 12c0574

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

Dockerfile.reproducible

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ARG RUST_IMAGE="rust:1.88-bullseye@sha256:8e3c421122bf4cd3b2a866af41a4dd52d87ad9
33
FROM ${RUST_IMAGE} AS builder
44

55
# Install specific version of the build dependencies
6-
RUN apt-get update && apt-get install -y libclang-dev=1:11.0-51+nmu5 cmake=3.18.4-2+deb11u1
6+
RUN apt-get update && apt-get install -y libclang-dev=1:11.0-51+nmu5 cmake=3.18.4-2+deb11u1 libjemalloc-dev=5.2.1-3
77

88
ARG RUST_TARGET="x86_64-unknown-linux-gnu"
99

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ TZ_VAL = UTC
102102
# Default profile
103103
PROFILE ?= release
104104

105+
# Features for reproducible builds
106+
FEATURES_REPRODUCIBLE = $(CROSS_FEATURES),jemalloc-unprefixed
107+
108+
# Derive the architecture-specific library path from RUST_TARGET
109+
JEMALLOC_LIB_ARCH = $(word 1,$(subst -, ,$(RUST_TARGET)))
110+
JEMALLOC_OVERRIDE = /usr/lib/$(JEMALLOC_LIB_ARCH)-linux-gnu/libjemalloc.a
111+
105112
# Default target architecture
106113
RUST_TARGET ?= x86_64-unknown-linux-gnu
107114

@@ -116,7 +123,8 @@ build-reproducible: ## Build the lighthouse binary into `target` directory with
116123
CARGO_INCREMENTAL=${CARGO_INCREMENTAL_VAL} \
117124
LC_ALL=${LOCALE_VAL} \
118125
TZ=${TZ_VAL} \
119-
cargo build --bin lighthouse --features "$(CROSS_FEATURES)" --profile "$(PROFILE)" --locked --target $(RUST_TARGET)
126+
JEMALLOC_OVERRIDE=${JEMALLOC_OVERRIDE} \
127+
cargo build --bin lighthouse --features "$(FEATURES_REPRODUCIBLE)" --profile "$(PROFILE)" --locked --target $(RUST_TARGET)
120128

121129
.PHONY: build-reproducible-x86_64
122130
build-reproducible-x86_64: ## Build reproducible x86_64 Docker image

common/malloc_utils/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jemalloc-profiling = ["tikv-jemallocator/profiling"]
2121
# Force the use of system malloc (or glibc) rather than jemalloc.
2222
# This is a no-op on Windows where jemalloc is always disabled.
2323
sysmalloc = []
24+
# Enable jemalloc with unprefixed malloc (recommended for reproducible builds)
25+
jemalloc-unprefixed = ["jemalloc", "tikv-jemallocator/unprefixed_malloc_on_supported_platforms"]
2426

2527
[dependencies]
2628
libc = "0.2.79"

0 commit comments

Comments
 (0)