Permalink
Browse files

Add tcmalloc support for windows

Change-Id: I3b71a53c9cfef68d52065c71b2f50ae6bb362236
Reviewed-on: http://review.couchbase.org/14311
Reviewed-by: Steve Yen <steve.yen@gmail.com>
Tested-by: Bin Cui <bin.cui@gmail.com>
  • Loading branch information...
1 parent 77373cb commit b24ca6d62440a71eea33a5d417bafbb9205c9891 @bcui6611 bcui6611 committed Feb 15, 2012
Showing with 24 additions and 4 deletions.
  1. +24 −4 win32/Makefile.mingw
View
@@ -15,8 +15,24 @@ LOCALINC=-I${LOCAL}/include
DEST=${LOCAL}
INSTALLDIRS=${DEST}/bin ${DEST}/lib ${DEST}/include/memcached
+TCMALLOC_ROOT= /opt/gperftools
+TCMALLOC_LIB= ${TCMALLOC_ROOT}/lib
+TCMALLOC_INCLUDE = ${TCMALLOC_ROOT}/include
+
+TCMALLOC_FLAGS =
+TCMALLOC_FLAGS += -Wwrite-strings \
+ -Wno-sign-compare -DNO_FRAME_POINTER \
+ -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc \
+ -fno-builtin-calloc -fno-builtin-cfree \
+ -fno-builtin-memalign -fno-builtin-posix_memalign \
+ -fno-builtin-valloc -fno-builtin-pvalloc
+TCMALLOC_LIB_FLAGS =
+TCMALLOC_LIB_FLAGS += -Wl,-u__tcmalloc \
+ $(TCMALLOC_LIB)/libtcmalloc_minimal.a -lPsapi -lshlwapi \
+ -lstdc++.dll
+
OBJDIR = .libs \
- .libs/engines \
+ .libs/engines \
.libs/daemon \
.libs/engines/default_engine \
.libs/extensions/daemon \
@@ -30,8 +46,8 @@ OBJDIR = .libs \
BINARIES= mcstat.exe \
memcached.exe \
engine_testapp.exe \
- sizes.exe \
- .libs/ascii_scrub.so \
+ sizes.exe \
+ .libs/ascii_scrub.so \
.libs/basic_engine_testsuite.so \
.libs/default_engine.so \
.libs/example_protocol.so \
@@ -51,6 +67,7 @@ install: ${BINARIES} ${INSTALLDIRS}
CFLAGS = -std=gnu99 -O2 -g -DNDEBUG -fno-strict-aliasing -Wall \
-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations \
-Wredundant-decls \
+ $(TCMALLOC_FLAGS) \
${INCLUDE} -DHAVE_CONFIG_H
MCSTAT_SRC = programs/mcstat.c win32/win32.c
@@ -116,20 +133,23 @@ GENFILES=.libs/config_version.h
mcstat.exe: ${OBJDIR} ${GENFILES} $(MCSTAT_OBJS)
${LINK.c} -o $@ $(MCSTAT_OBJS) \
+ $(TCMALLOC_LIB_FLAGS) \
${LIB} -lmswsock -lws2_32
memcached.exe: ${OBJDIR} ${GENFILES} $(MEMCACHED_OBJS)
${LINK.c} -o $@ $(MEMCACHED_OBJS) \
+ $(TCMALLOC_LIB_FLAGS) \
${LIB} -levent -lmswsock \
-lws2_32 -lpthread
engine_testapp.exe: ${OBJDIR} ${GENFILES} $(ENGINE_TESTAPP_OBJS)
${LINK.c} -o $@ $(ENGINE_TESTAPP_OBJS) \
+ $(TCMALLOC_LIB_FLAGS) \
${LIB} -levent -lmswsock \
-lws2_32 -lpthread
sizes.exe: ${OBJDIR} ${GENFILES} $(SIZES_OBJS)
- ${LINK.c} -o $@ $(SIZES_OBJS)
+ ${LINK.c} -o $@ $(SIZES_OBJS) $(TCMALLOC_LIB_FLAGS)
.libs/default_engine.so: ${OBJDIR} $(DEFAULT_ENGINE_OBJS)
${LINK.c} -o $@ -shared ${DEFAULT_ENGINE_OBJS} \

0 comments on commit b24ca6d

Please sign in to comment.