Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added heap/simpleheap-jemalloc-5.3.0-static-aarch64
Binary file not shown.
2 changes: 2 additions & 0 deletions heap/src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jemalloc/
simpleheap
Comment on lines +1 to +2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why those additions? Don't we want the source?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are not the source. The makefile clones the jemalloc folder and produces the simpleheap binary. The actual sources are the Makefile and the simpleheap.c file.

78 changes: 63 additions & 15 deletions heap/src/Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
# Unified Makefile for simpleheap with static-linked jemalloc
#
# Usage:
# make -f Makefile-jemalloc VERSION=5.3.0 ARCH=x64
# make -f Makefile-jemalloc VERSION=4.5.0 ARCH=x32
# make VERSION=5.3.0 ARCH=amd64
# make VERSION=4.5.0 ARCH=i386
# make VERSION=5.3.0 ARCH=arm64
# make VERSION=5.3.0 ARCH=arm32
#
# Parameters:
# VERSION - jemalloc version (default: 5.3.0)
# ARCH - target architecture: x64 or x32 (default: x64)
# ARCH - target architecture: amd64, i386, arm64, or arm32 (default: amd64)

# Configuration parameters with defaults
VERSION ?= 5.3.0
ARCH ?= x64
ARCH ?= amd64

# Validate ARCH
ifneq ($(ARCH),x64)
ifneq ($(ARCH),x32)
$(error ARCH must be x64 or x32, got: $(ARCH))
ifneq ($(ARCH),amd64)
ifneq ($(ARCH),i386)
ifneq ($(ARCH),arm64)
ifneq ($(ARCH),arm32)
$(error ARCH must be amd64, i386, arm64, or arm32, got: $(ARCH))
endif
endif
endif
endif

Expand All @@ -25,16 +31,53 @@ JEMALLOC_BUILD = $(JEMALLOC_DIR)
JEMALLOC_LIB = $(JEMALLOC_BUILD)/lib/libjemalloc.a
JEMALLOC_INCLUDE = $(JEMALLOC_BUILD)/include

# Detect host architecture
HOST_ARCH := $(shell uname -m)

# Compiler and flags
CC = gcc

# Architecture-specific flags
ifeq ($(ARCH),x32)
ifeq ($(ARCH),i386)
CC = gcc
ARCH_CFLAGS = -m32
ARCH_LDFLAGS = -m32
AUTOGEN_ENV = CFLAGS="-m32" CXXFLAGS="-m32" LDFLAGS="-m32"
AUTOGEN_ARGS = --host=i686-pc-linux-gnu
else ifeq ($(ARCH),arm64)
# Use native gcc if on arm64, otherwise cross-compile
ifeq ($(HOST_ARCH),aarch64)
CC = gcc
ARCH_CFLAGS =
ARCH_LDFLAGS =
AUTOGEN_ENV =
AUTOGEN_ARGS =
else
CC = aarch64-linux-gnu-gcc
CXX = aarch64-linux-gnu-g++
ARCH_CFLAGS =
ARCH_LDFLAGS =
AUTOGEN_ENV = CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++
AUTOGEN_ARGS = --host=aarch64-linux-gnu
endif
else ifeq ($(ARCH),arm32)
# Use native gcc if on arm32, otherwise cross-compile
ifeq ($(filter arm%,$(HOST_ARCH)),$(HOST_ARCH))
CC = gcc
ARCH_CFLAGS =
ARCH_LDFLAGS =
AUTOGEN_ENV =
AUTOGEN_ARGS =
else
CC = arm-linux-gnueabihf-gcc
CXX = arm-linux-gnueabihf-g++
ARCH_CFLAGS =
ARCH_LDFLAGS =
AUTOGEN_ENV = CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++
AUTOGEN_ARGS = --host=arm-linux-gnueabihf
endif
else
CC = gcc
ARCH_CFLAGS =
ARCH_LDFLAGS =
AUTOGEN_ENV =
Expand All @@ -54,9 +97,12 @@ all: $(TARGET)

# Clone jemalloc and checkout specified version
$(JEMALLOC_DIR)/configure:
git clone https://github.com/jemalloc/jemalloc $(JEMALLOC_DIR)
@if [ ! -d $(JEMALLOC_DIR)/.git ]; then \
git clone https://github.com/jemalloc/jemalloc $(JEMALLOC_DIR); \
fi
cd $(JEMALLOC_DIR) && git checkout $(VERSION)
@echo "Jemalloc v$(VERSION) cloned and checked out"
cd $(JEMALLOC_DIR) && autoconf
@echo "Jemalloc v$(VERSION) ready"

jemalloc-clone: $(JEMALLOC_DIR)/configure

Expand Down Expand Up @@ -98,11 +144,11 @@ help:
@echo "Unified Makefile for simpleheap with jemalloc (static linking)"
@echo ""
@echo "Usage:"
@echo " make -f Makefile-jemalloc [VERSION=x.y.z] [ARCH=x64|x32] [target]"
@echo " make [VERSION=x.y.z] [ARCH=amd64|i386|arm64|arm32] [target]"
@echo ""
@echo "Parameters:"
@echo " VERSION - jemalloc version to use (default: 5.3.0)"
@echo " ARCH - target architecture: x64 or x32 (default: x64)"
@echo " ARCH - target architecture: amd64, i386, arm64, or arm32 (default: amd64)"
@echo ""
@echo "Current settings:"
@echo " VERSION = $(VERSION)"
Expand All @@ -120,6 +166,8 @@ help:
@echo " help - Show this help"
@echo ""
@echo "Examples:"
@echo " make -f Makefile-jemalloc VERSION=5.3.0 ARCH=x64"
@echo " make -f Makefile-jemalloc VERSION=4.5.0 ARCH=x32"
@echo " make -f Makefile-jemalloc VERSION=4.5.0 ARCH=x64 rebuild"
@echo " make VERSION=5.3.0 ARCH=amd64"
@echo " make VERSION=4.5.0 ARCH=i386"
@echo " make VERSION=5.3.0 ARCH=arm64"
@echo " make VERSION=5.3.0 ARCH=arm32"
@echo " make VERSION=4.5.0 ARCH=amd64 rebuild"
79 changes: 0 additions & 79 deletions heap/src/Makefile-jemalloc-5.3.0-static-x32

This file was deleted.

79 changes: 0 additions & 79 deletions heap/src/Makefile-jemalloc-5.3.0-static-x64

This file was deleted.

Loading