ARROW-2168: [C++] Build toolchain on CI with jemalloc

Author: Uwe L. Korn <uwelk@xhochy.com>

Closes #1621 from xhochy/ARROW-2168 and squashes the following commits:

30a9b979 [Uwe L. Korn] [ARROW-2168] [C++] Build toolchain on CI with jemalloc [skip appveyor]
diff --git a/ci/travis_before_script_cpp.sh b/ci/travis_before_script_cpp.sh
index 4ffe97f67..17b5deb 100755
--- a/ci/travis_before_script_cpp.sh
+++ b/ci/travis_before_script_cpp.sh
@@ -29,14 +29,6 @@
   source $TRAVIS_BUILD_DIR/ci/travis_install_conda.sh
 fi
 
-if [ "$ARROW_TRAVIS_USE_TOOLCHAIN" == "1" ]; then
-  # Set up C++ toolchain from conda-forge packages for faster builds
-  source $TRAVIS_BUILD_DIR/ci/travis_install_toolchain.sh
-fi
-
-mkdir -p $ARROW_CPP_BUILD_DIR
-pushd $ARROW_CPP_BUILD_DIR
-
 CMAKE_COMMON_FLAGS="\
 -DARROW_BUILD_BENCHMARKS=ON \
 -DCMAKE_INSTALL_PREFIX=$ARROW_CPP_INSTALL \
@@ -45,6 +37,15 @@
 CMAKE_LINUX_FLAGS=""
 CMAKE_OSX_FLAGS=""
 
+if [ "$ARROW_TRAVIS_USE_TOOLCHAIN" == "1" ]; then
+  # Set up C++ toolchain from conda-forge packages for faster builds
+  source $TRAVIS_BUILD_DIR/ci/travis_install_toolchain.sh
+  CMAKE_COMMON_FLAGS="${CMAKE_COMMON_FLAGS} -DARROW_JEMALLOC=ON"
+fi
+
+mkdir -p $ARROW_CPP_BUILD_DIR
+pushd $ARROW_CPP_BUILD_DIR
+
 if [ $only_library_mode == "yes" ]; then
   CMAKE_COMMON_FLAGS="\
 $CMAKE_COMMON_FLAGS \
diff --git a/ci/travis_install_toolchain.sh b/ci/travis_install_toolchain.sh
index e01a084..60cdc36 100755
--- a/ci/travis_install_toolchain.sh
+++ b/ci/travis_install_toolchain.sh
@@ -24,7 +24,7 @@
 if [ ! -e $CPP_TOOLCHAIN ]; then
     # Set up C++ toolchain from conda-forge packages for faster builds
     conda create -y -q -p $CPP_TOOLCHAIN python=2.7 \
-        jemalloc=4.4.0 \
+        jemalloc=4.5.0.post \
         nomkl \
         boost-cpp \
         rapidjson \