15 July 2011

Building ruby 1.8.7 with glibc 2.14

It seems that there's a bug which means that ruby 1.8.7 and ruby enterprise edition 1.8.7 don't build with glibc 2.14:

/bin/sh ./libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I. -I./src  -I./src   -DNO_TCMALLOC_SAMPLES -pthread -DNDEBUG -Wall -Wwrit
e-strings -Woverloaded-virtual -Wno-sign-compare -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc -fno-builtin-calloc -fno-builtin-c
free -fno-builtin-memalign -fno-builtin-posix_memalign -fno-builtin-valloc -fno-builtin-pvalloc  -DNO_FRAME_POINTER -g -O2 -c -o libtcmalloc_m
inimal_la-tcmalloc.lo `test -f 'src/tcmalloc.cc' || echo './'`src/tcmalloc.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I. -I./src -I./src -DNO_TCMALLOC_SAMPLES -pthread -DNDEBUG -Wall -Wwrite-strings -Woverloaded-virt
ual -Wno-sign-compare -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 -DNO_FRAME_POINTER -g -O2 -c src/tcmalloc.cc  -fPIC -DPIC -o .libs/libtcm
src/tcmalloc.cc:1672:54: error: conflicting declaration ‘void* (* __memalign_hook)(size_t, size_t, const void*)’
/usr/include/malloc.h:183:39: error: ‘__memalign_hook’ has a previous declaration as ‘void* (* volatile __memalign_hook)(size_t, size_t, const
make: *** [libtcmalloc_minimal_la-tcmalloc.lo] Error 1

While those that understand this sort of thing sort it out, there's a workaround posted on github. Here are the instructions (for ree):

  1. Run rvm install ree-1.8.7
  2. Wait for it to fail.
  3. Fix the broken files with:

    % cd ~/.rvm/src/ree-1.8.7-2011.03/source/ext/dl

    % rm callback.func

    % touch callback.func

    % ruby mkcallback.rb >> callback.func

    % rm cbtable.func

    % touch cbtable.func

    % ruby mkcbtable.rb >> cbtable.func

  4. Re-run rvm install ree and the ruby files will not be re-extracted, so your changes to callback.func and cbtable.func will persist.

Categories: All articles Ruby