Skip to content

Commit eaabca6

Browse files
committed
auto merge of #14792 : alexcrichton/rust/local-jemalloc, r=brson
This configures the makefiles to copy a local jemalloc/libuv library into place instead of building the local copy of one. Additionally, this switches our travis builds to using the system-provided jemalloc instead of a custom-built jemalloc to exercise this functionality.
2 parents fce98e5 + fa7b7bc commit eaabca6

File tree

3 files changed

+40
-9
lines changed

3 files changed

+40
-9
lines changed

.travis.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ install:
1212
- sudo apt-get update -qq
1313
- sudo apt-get install -qq --force-yes -y llvm-$LLVM_VERSION
1414
llvm-${LLVM_VERSION}-dev clang-$LLVM_VERSION lldb-$LLVM_VERSION
15+
libjemalloc-dev
1516

1617

1718
# All of the llvm tools are suffixed with "-$VERS" which we don't want, so
@@ -27,7 +28,8 @@ before_script:
2728
- ln -nsf /usr/bin/llvm-dis-$LLVM_VERSION local-llvm/bin/llvm-dis
2829
- ln -nsf /usr/bin/llc-$LLVM_VERSION local-llvm/bin/llc
2930
- ln -nsf /usr/include/llvm-$LLVM_VERSION local-llvm/include
30-
- ./configure --disable-optimize-tests --llvm-root=`pwd`/local-llvm --enable-fast-make --enable-clang
31+
- ./configure --disable-optimize-tests --llvm-root=`pwd`/local-llvm
32+
--enable-fast-make --enable-clang --jemalloc-root=/usr/lib
3133

3234
# Tidy everything up first, then build a few things, and then run a few tests.
3335
# Note that this is meant to run in a "fairly small" amount of time, so this

configure

+4
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,8 @@ opt verify-install 1 "verify installed binaries work"
425425
valopt prefix "/usr/local" "set installation prefix"
426426
valopt local-rust-root "/usr/local" "set prefix for local rust binary"
427427
valopt llvm-root "" "set LLVM root"
428+
valopt jemalloc-root "" "set directory where libjemalloc_pic.a is located"
429+
valopt libuv-root "" "set directory where libuv.a is located"
428430
valopt android-cross-path "/opt/ndk_standalone" "Android NDK standalone path"
429431
valopt mingw32-cross-path "" "MinGW32 cross compiler path"
430432

@@ -1198,6 +1200,8 @@ putvar CFG_ANDROID_CROSS_PATH
11981200
putvar CFG_MINGW32_CROSS_PATH
11991201
putvar CFG_MANDIR
12001202
putvar CFG_DISABLE_INJECT_STD_VERSION
1203+
putvar CFG_JEMALLOC_ROOT
1204+
putvar CFG_LIBUV_ROOT
12011205

12021206
# Avoid spurious warnings from clang by feeding it original source on
12031207
# ccache-miss rather than preprocessed input.

mk/rt.mk

+33-8
Original file line numberDiff line numberDiff line change
@@ -204,19 +204,17 @@ $$(LIBUV_MAKEFILE_$(1)): $$(LIBUV_DEPS) $$(MKFILE_DEPS) $$(LIBUV_STAMP_$(1))
204204
# theory when we support msvc then we should be using gyp's msvc output instead
205205
# of mingw's makefile for windows
206206
ifdef CFG_WINDOWSY_$(1)
207-
$$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS) $$(MKFILE_DEPS)
207+
LIBUV_LOCAL_$(1) := $$(S)src/libuv/libuv.a
208+
$$(LIBUV_LOCAL_$(1)): $$(LIBUV_DEPS) $$(MKFILE_DEPS)
208209
$$(Q)$$(MAKE) -C $$(S)src/libuv -f Makefile.mingw \
209210
LDFLAGS="$$(CFG_GCCISH_LINK_FLAGS_$(1))" \
210211
CC="$$(CC_$(1)) $$(LIBUV_CFLAGS_$(1)) $$(SNAP_DEFINES)" \
211212
CXX="$$(CXX_$(1))" \
212213
AR="$$(AR_$(1))" \
213214
V=$$(VERBOSE)
214-
$$(Q)cp $$(S)src/libuv/libuv.a $$@
215215
else
216-
$$(LIBUV_LIB_$(1)): $$(LIBUV_DIR_$(1))/Release/libuv.a $$(MKFILE_DEPS)
217-
$$(Q)cp $$< $$@
218-
$$(LIBUV_DIR_$(1))/Release/libuv.a: $$(LIBUV_DEPS) $$(LIBUV_MAKEFILE_$(1)) \
219-
$$(MKFILE_DEPS)
216+
LIBUV_LOCAL_$(1) := $$(LIBUV_DIR_$(1))/Release/libuv.a
217+
$$(LIBUV_LOCAL_$(1)): $$(LIBUV_DEPS) $$(LIBUV_MAKEFILE_$(1)) $$(MKFILE_DEPS)
220218
$$(Q)$$(MAKE) -C $$(LIBUV_DIR_$(1)) \
221219
CFLAGS="$$(LIBUV_CFLAGS_$(1)) $$(SNAP_DEFINES)" \
222220
LDFLAGS="$$(CFG_GCCISH_LINK_FLAGS_$(1))" \
@@ -231,6 +229,19 @@ $$(LIBUV_DIR_$(1))/Release/libuv.a: $$(LIBUV_DEPS) $$(LIBUV_MAKEFILE_$(1)) \
231229

232230
endif
233231

232+
ifeq ($(1),$$(CFG_BUILD))
233+
ifneq ($$(CFG_LIBUV_ROOT),)
234+
$$(LIBUV_LIB_$(1)): $$(CFG_LIBUV_ROOT)/libuv.a
235+
$$(Q)cp $$< $$@
236+
else
237+
$$(LIBUV_LIB_$(1)): $$(LIBUV_LOCAL_$(1))
238+
$$(Q)cp $$< $$@
239+
endif
240+
else
241+
$$(LIBUV_LIB_$(1)): $$(LIBUV_LOCAL_$(1))
242+
$$(Q)cp $$< $$@
243+
endif
244+
234245
################################################################################
235246
# jemalloc
236247
################################################################################
@@ -253,8 +264,9 @@ else
253264
endif
254265
JEMALLOC_LIB_$(1) := $$(RT_OUTPUT_DIR_$(1))/$$(JEMALLOC_NAME_$(1))
255266
JEMALLOC_BUILD_DIR_$(1) := $$(RT_OUTPUT_DIR_$(1))/jemalloc
267+
JEMALLOC_LOCAL_$(1) := $$(JEMALLOC_BUILD_DIR_$(1))/lib/$$(JEMALLOC_REAL_NAME_$(1))
256268

257-
$$(JEMALLOC_LIB_$(1)): $$(JEMALLOC_DEPS) $$(MKFILE_DEPS)
269+
$$(JEMALLOC_LOCAL_$(1)): $$(JEMALLOC_DEPS) $$(MKFILE_DEPS)
258270
@$$(call E, make: jemalloc)
259271
cd "$$(JEMALLOC_BUILD_DIR_$(1))"; "$(S)src/jemalloc/configure" \
260272
$$(JEMALLOC_ARGS_$(1)) --enable-cc-silence --with-jemalloc-prefix=je_ \
@@ -265,7 +277,20 @@ $$(JEMALLOC_LIB_$(1)): $$(JEMALLOC_DEPS) $$(MKFILE_DEPS)
265277
CPPFLAGS="-I $(S)src/rt/" \
266278
EXTRA_CFLAGS="$$(CFG_CFLAGS_$(1)) -g1"
267279
$$(Q)$$(MAKE) -C "$$(JEMALLOC_BUILD_DIR_$(1))" build_lib_static
268-
$$(Q)cp $$(JEMALLOC_BUILD_DIR_$(1))/lib/$$(JEMALLOC_REAL_NAME_$(1)) $$(JEMALLOC_LIB_$(1))
280+
281+
ifeq ($(1),$$(CFG_BUILD))
282+
ifneq ($$(CFG_JEMALLOC_ROOT),)
283+
$$(JEMALLOC_LIB_$(1)): $$(CFG_JEMALLOC_ROOT)/libjemalloc_pic.a
284+
@$$(call E, copy: jemalloc)
285+
$$(Q)cp $$< $$@
286+
else
287+
$$(JEMALLOC_LIB_$(1)): $$(JEMALLOC_LOCAL_$(1))
288+
$$(Q)cp $$< $$@
289+
endif
290+
else
291+
$$(JEMALLOC_LIB_$(1)): $$(JEMALLOC_LOCAL_$(1))
292+
$$(Q)cp $$< $$@
293+
endif
269294

270295
################################################################################
271296
# compiler-rt

0 commit comments

Comments
 (0)