8

OSX/Monterey/M1/Arm/Homebrew: can't for the life of me get this to work:

./configure --with-jemalloc

It dies with

checking jemalloc/jemalloc.h presence... no
configure: error: jemalloc requested but not found

even though it's right there in: /opt/homebrew/Cellar/jemalloc/5.2.1_1/include/jemalloc/jemalloc.js.

brew --prefix jemalloc and jemalloc-config --includedir all looks correct.

I've tried various versions of:

export RUBY_CONFIGURE_OPTS="--with-jemalloc-include=$(brew --prefix jemalloc)/include

and/or

./configure --with-jemalloc-include=$(brew --prefix jemalloc)/include

but no dice. Not even sure those env vars/flags are respected by ruby or if they're some rvm/rbenv/ruby-build thing.

I'm down to doing all my testing directly with ruby's configure and not a rvm/build tool.

Holger Just
  • 52,918
  • 14
  • 115
  • 123
jsharpe
  • 2,546
  • 3
  • 26
  • 42

2 Answers2

0

Try the following:

❯ export HOMEBREW_PREFIX=$(brew --prefix)
❯ export CPPFLAGS="$CPPFLAGS -I $HOMEBREW_PREFIX/include"
❯ export LDFLAGS="$LDFLAGS -L $HOMEBREW_PREFIX/lib"
❯ cd ruby-2.7.6 && ./configure --with-jemalloc
❯ make && make install
0

This worked using RVM:

# Install jemalloc first
brew install jemalloc

# Install using RVM:
rvm install 3.2.1 --with-jemalloc --with-cppflags="-I$(brew --prefix)/include" -E "LDFLAGS=-L$(brew --prefix)/lib"

It seems that --with-cppflags works as expected, but it's being overwritten by the internal RVM flags passed in, so --with-ldflags does nothing. That's why we pass in the -E flag (as an enviroment variable) instead.

Erik Rothoff
  • 4,826
  • 9
  • 41
  • 59