13

I cannot, for the life of me, successfully run "gem install thrift", the thing fails when building the gem's native extensions; this is the output:

(acib708) ~ -> gem install thrift
Building native extensions.  This could take a while...
ERROR:  Error installing thrift:
    ERROR: Failed to build gem native extension.

    /Users/acib708/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
extconf.rb:25:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
extconf.rb:25:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
checking for strlcpy() in string.h... yes
creating Makefile

make "DESTDIR="
compiling binary_protocol_accelerated.c
compiling bytes.c
compiling compact_protocol.c
compiling memory_buffer.c
compiling protocol.c
compiling strlcpy.c
                                           ^

(...)

In file included from strlcpy.c:20:
./strlcpy.h:28:15: error: conflicting types for '__builtin___strlcpy_chk'
/usr/include/secure/_string.h:105:3: note: expanded from macro 'strlcpy'
  __builtin___strlcpy_chk (dest, src, len, __darwin_obsz (dest))
  ^
./strlcpy.h:28:15: note: '__builtin___strlcpy_chk' is a builtin with type 'unsigned long (char *, const char *, unsigned long, unsigned long)'
/usr/include/secure/_string.h:105:3: note: expanded from macro 'strlcpy'
  __builtin___strlcpy_chk (dest, src, len, __darwin_obsz (dest))
  ^
4 errors generated.
make: *** [strlcpy.o] Error 1


Gem files will remain installed in /Users/acib708/.rvm/gems/ruby-2.0.0-p247/gems/thrift-0.9.1 for inspection.
Results logged to /Users/acib708/.rvm/gems/ruby-2.0.0-p247/gems/thrift-0.9.1/ext/gem_make.out

I've seen lots of similar errors around the web, but I haven't found the solution. I'm running OS X 10.9, with a fresh rvm/ruby-2.0.0-p247 install. Any ideas? Thanks.

acib708
  • 1,533
  • 1
  • 13
  • 24
  • 2
    @AlejandroCárdenas Please accept one of the answers. These hard-working folks put in time to help you, a click on the check-mark icon is all it takes, thanks – nhed Jan 26 '14 at 02:22
  • 1
    @nhed Sorry about that, didn't realize I hadn't! Done now. – acib708 Apr 17 '15 at 20:21

4 Answers4

61

the issue for the moment can be found at https://issues.apache.org/jira/browse/THRIFT-2219

As a temporary fix for folks using gems, you can try setting the #define'ing the _FORTIFY_SOURCE macro to 0 to make strlcpy a function rather than a macro:

gem install thrift -- --with-cppflags='-D_FORTIFY_SOURCE=0'

or if you're using bundler, you can set the cflags for thrift locally via:

bundle config build.thrift --with-cppflags='-D_FORTIFY_SOURCE=0'
Gregoire Mulliez
  • 1,072
  • 11
  • 18
  • 3
    Also worked for me! I ran the `bundle config` command and then ran `bundle install` again and it worked great. – Gary Haran Jun 16 '14 at 15:25
7

On OS 10.9.4 the command below worked for me

bundle config build.thrift "--with-cppflags=-D_FORTIFY_SOURCE=0"
deet
  • 71
  • 1
  • 2
3

rather than use a workaround with cppflags I committed a fix which checks for __has_builtin(strlcpy) and if builtins are not available on the system but strlcpy is defined then it uses externs as it previously did. works on os x 10.8, 10.9, centos, ubuntu, ...

jfarrell
  • 4,092
  • 3
  • 19
  • 14
0

Please edit the ~/.bundle/config file then it looks like this:

---
BUNDLE_BUILD__THRIFT: "--with-cppflags=\"-D_FORTIFY_SOURCE=0 -Wno-shift-negative-value\""

It works for me, thanks.

digembok
  • 568
  • 6
  • 18