Skip to content

Commit b0df2e9

Browse files
authored
Add binary for jemalloc v4.5.0 runtime testing (#236)
1 parent 351f2e5 commit b0df2e9

File tree

3 files changed

+125
-0
lines changed

3 files changed

+125
-0
lines changed
2.21 MB
Binary file not shown.
2.45 MB
Binary file not shown.

heap/src/Makefile

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Unified Makefile for simpleheap with static-linked jemalloc
2+
#
3+
# Usage:
4+
# make -f Makefile-jemalloc VERSION=5.3.0 ARCH=x64
5+
# make -f Makefile-jemalloc VERSION=4.5.0 ARCH=x32
6+
#
7+
# Parameters:
8+
# VERSION - jemalloc version (default: 5.3.0)
9+
# ARCH - target architecture: x64 or x32 (default: x64)
10+
11+
# Configuration parameters with defaults
12+
VERSION ?= 5.3.0
13+
ARCH ?= x64
14+
15+
# Validate ARCH
16+
ifneq ($(ARCH),x64)
17+
ifneq ($(ARCH),x32)
18+
$(error ARCH must be x64 or x32, got: $(ARCH))
19+
endif
20+
endif
21+
22+
# Directories
23+
JEMALLOC_DIR = jemalloc
24+
JEMALLOC_BUILD = $(JEMALLOC_DIR)
25+
JEMALLOC_LIB = $(JEMALLOC_BUILD)/lib/libjemalloc.a
26+
JEMALLOC_INCLUDE = $(JEMALLOC_BUILD)/include
27+
28+
# Compiler and flags
29+
CC = gcc
30+
31+
# Architecture-specific flags
32+
ifeq ($(ARCH),x32)
33+
ARCH_CFLAGS = -m32
34+
ARCH_LDFLAGS = -m32
35+
AUTOGEN_ENV = CFLAGS="-m32" CXXFLAGS="-m32" LDFLAGS="-m32"
36+
AUTOGEN_ARGS = --host=i686-pc-linux-gnu
37+
else
38+
ARCH_CFLAGS =
39+
ARCH_LDFLAGS =
40+
AUTOGEN_ENV =
41+
AUTOGEN_ARGS =
42+
endif
43+
44+
CFLAGS = $(ARCH_CFLAGS) -g -O0 -DUSE_JEMALLOC -I$(JEMALLOC_INCLUDE)
45+
LDFLAGS = $(ARCH_LDFLAGS) $(JEMALLOC_LIB) -lpthread -ldl -lm
46+
47+
# Targets
48+
TARGET = simpleheap
49+
SRC = simpleheap.c
50+
51+
.PHONY: all clean jemalloc-clean jemalloc-configure jemalloc-build rebuild jemalloc-clone help
52+
53+
all: $(TARGET)
54+
55+
# Clone jemalloc and checkout specified version
56+
$(JEMALLOC_DIR)/configure:
57+
git clone https://github.com/jemalloc/jemalloc $(JEMALLOC_DIR)
58+
cd $(JEMALLOC_DIR) && git checkout $(VERSION)
59+
@echo "Jemalloc v$(VERSION) cloned and checked out"
60+
61+
jemalloc-clone: $(JEMALLOC_DIR)/configure
62+
63+
# Build simpleheap
64+
$(TARGET): $(SRC) $(JEMALLOC_LIB)
65+
$(CC) $(CFLAGS) -o $(TARGET) $(SRC) $(LDFLAGS)
66+
@echo "Built $(TARGET) successfully ($(ARCH), static, jemalloc $(VERSION))"
67+
68+
# Configure jemalloc
69+
$(JEMALLOC_BUILD)/Makefile: $(JEMALLOC_DIR)/configure
70+
cd $(JEMALLOC_DIR) && $(AUTOGEN_ENV) ./autogen.sh $(AUTOGEN_ARGS)
71+
@echo "Jemalloc configured ($(ARCH))"
72+
73+
# Build jemalloc
74+
$(JEMALLOC_LIB): $(JEMALLOC_BUILD)/Makefile
75+
$(MAKE) -C $(JEMALLOC_DIR)
76+
@echo "Jemalloc built successfully"
77+
78+
# Convenience targets
79+
jemalloc-configure: $(JEMALLOC_BUILD)/Makefile
80+
81+
jemalloc-build: $(JEMALLOC_LIB)
82+
83+
# Clean targets
84+
clean:
85+
rm -f $(TARGET)
86+
87+
jemalloc-clean:
88+
$(MAKE) -C $(JEMALLOC_DIR) clean || true
89+
90+
distclean: clean jemalloc-clean
91+
cd $(JEMALLOC_DIR) && git clean -fdx || true
92+
93+
# Rebuild everything from scratch
94+
rebuild: distclean all
95+
96+
# Help
97+
help:
98+
@echo "Unified Makefile for simpleheap with jemalloc (static linking)"
99+
@echo ""
100+
@echo "Usage:"
101+
@echo " make -f Makefile-jemalloc [VERSION=x.y.z] [ARCH=x64|x32] [target]"
102+
@echo ""
103+
@echo "Parameters:"
104+
@echo " VERSION - jemalloc version to use (default: 5.3.0)"
105+
@echo " ARCH - target architecture: x64 or x32 (default: x64)"
106+
@echo ""
107+
@echo "Current settings:"
108+
@echo " VERSION = $(VERSION)"
109+
@echo " ARCH = $(ARCH)"
110+
@echo ""
111+
@echo "Targets:"
112+
@echo " all - Build simpleheap (default)"
113+
@echo " jemalloc-clone - Clone jemalloc from GitHub"
114+
@echo " jemalloc-configure - Configure jemalloc"
115+
@echo " jemalloc-build - Build jemalloc library"
116+
@echo " clean - Remove simpleheap binary"
117+
@echo " jemalloc-clean - Clean jemalloc build"
118+
@echo " distclean - Clean everything including jemalloc"
119+
@echo " rebuild - Rebuild from scratch"
120+
@echo " help - Show this help"
121+
@echo ""
122+
@echo "Examples:"
123+
@echo " make -f Makefile-jemalloc VERSION=5.3.0 ARCH=x64"
124+
@echo " make -f Makefile-jemalloc VERSION=4.5.0 ARCH=x32"
125+
@echo " make -f Makefile-jemalloc VERSION=4.5.0 ARCH=x64 rebuild"

0 commit comments

Comments
 (0)