Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proper way to compile Ruby 2.2 with jemalloc and rbenv?

Downloaded and installed jemalloc 4.0.0 using their recommended steps(from the root directory):

./autogen.sh
make dist
make
make install

Verified install was in my path:

    $ls /usr/local/bin | grep je
    jemalloc-config
    jemalloc.sh
    jeprof

Using rbenv 0.4.0, attempted to build ruby 2.2.3 and pass flags to ruby build as specified here to use the --with-jemalloc option. Build fails :( If I just pass the compiler, it succeeds. Any ideas how to get rbenv/ruby-build to find my jemalloc installation?

$CC="/usr/local/Cellar/gcc5/5.2.0/bin/gcc-5" CONFIGURE_OPTS="--with-jemalloc" rbenv install 2.2.3
Downloading ruby-2.2.3.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/df795f2f99860745a416092a4004b016ccf77e8b82dec956b120f18bdc71edce
Installing ruby-2.2.3...

BUILD FAILED (OS X 10.10.4 using ruby-build 20150818)

Inspect or clean up the working tree at /var/folders/xw/15_55jhn0hb309d6zvh5k9mc0000gn/T/ruby-build.20150913102001.819
Results logged to /var/folders/xw/15_55jhn0hb309d6zvh5k9mc0000gn/T/ruby-build.20150913102001.819.log

Last 10 log lines:
checking gmp.h usability... no
checking gmp.h presence... no
checking for gmp.h... no
checking for malloc_conf in -ljemalloc... no
checking jemalloc/jemalloc.h usability... no
checking jemalloc/jemalloc.h presence... no
checking for jemalloc/jemalloc.h... no
checking for jemalloc with JEMALLOC_MANGLE... no
configure: error: jemalloc requested but not found
make: *** No targets specified and no makefile found.  Stop.
like image 539
Wishful_Widget Avatar asked Sep 13 '15 15:09

Wishful_Widget


1 Answers

Figured it out. Cleaned up my first attempt then on OS X Yosemite, downloaded jemalloc-4.0.0.tar.bz2 instead. Unpacked it and ran ./configure --with-jemalloc-prefix="" from the root directory based on Nobu's note in https://bugs.ruby-lang.org/issues/9113#note-39. Then just make and make install.

Once I verified jemalloc was installed correctly, I was able to pass in the option to rbenv with CONFIGURE_OPTS="--with-jemalloc" rbenv install 2.2.3.

Bonus: Another thing that was helpful in targeting the break point was to download and unpack the ruby source tarball directly and then run ./configure --with-jemalloc inside of the root directory. It will spit out an output of all the build checks, including one for jemalloc.

like image 147
Wishful_Widget Avatar answered Dec 01 '22 12:12

Wishful_Widget