Thrift Ruby gem - ruby

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.

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'

On OS 10.9.4 the command below worked for me
bundle config build.thrift "--with-cppflags=-D_FORTIFY_SOURCE=0"

The following should install the gem.
gem install thrift -- --with-cppflags=\"-Wno-compound-token-split-by-macro\"
In bundler, you'll need to do the following until a new ruby release goes out with the fix linked to in the issue above.
bundle config build.thrift --with-cppflags=\"-Wno-compound-token-split-by-macro\"

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, ...

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.

Related

How can I compile ruby 3.1.2 on powerpc64le-linux without disabling the jit features?

I think this is a bug I should report but will ask here first to see if I am missing something simple.
Firstly I need to build from source for various reasons including the fact that I don't have sudo access to the system I am trying to install on.
The system I am trying to compile on is a ppc64el system running RedHat 7 (3.10.0-1160.62.1.el7.ppc64le). I can successfully compile on a x86_64 system running the same version RedHat 7 (3.10.0-1160.62.1.el7.x86_64)
When I configure with the following, make completes fine, but if I remove the --disable-jit-support it fails with the following error.
Am I missing a setting on ./configure that can fix this?
./configure --enable-shared --enable-load-relative --disable-install-doc --prefix=$RUBY_PREFIX --exec-prefix=$RUBY_PREFIX/rh_ppc --disable-jit-support
building rb_mjit_header.h
rb_mjit_header.h updated
building .ext/include/powerpc64le-linux/rb_mjit_min_header-3.1.2.h
error in final header file:
In file included from /tmp/20220525-12786-q2ndz2.c:1:0:
/tmp/20220525-12786-vf3xbh.h:16627:1: error: multiple storage classes in declaration specifiers
__attribute__ ((__visibility__("default"))) extern
^
compilation terminated due to -Wfatal-errors.
make: *** [.ext/include/powerpc64le-linux/rb_mjit_min_header-3.1.2.h] Error 1

Install xdebug failing on Mac

I am running MacOS Big Sur (ver 11.4) w/ PHP 7.4.19. I am trying to install xdebug w/ homebrew:
pecl install xdebug
but it fails with:
5 warnings and 4 errors generated.
make: *** [xdebug.lo] Error 1
ERROR: `make' failed
I tried downloading source and running make but I get the same error:
In file included from /usr/local/Cellar/php#7.4/7.4.19_1/include/php/Zend/zend.h:356:
/usr/local/Cellar/php#7.4/7.4.19_1/include/php/Zend/zend_operators.h:523:10: error:
'asm goto' constructs are not supported yet
__asm__ goto(
I have Googled to no avail. Has anyone else encountered this?
This is because of a mismatch between compilers. You didn't enough include information about which part was compiled by which compiler, but one of them was compiled by LLVM, and the other with GCC. This causes a mismatch.
You need to make sure that you're using the same compiler for both.

weird error when installing mechainze gem on mac os

I'm trying to install the mechainze gem on my mac os, however when I typed gem install mechanize, after a few seconds, it poped out:
Building native extensions. This could take a while...
ERROR: Error installing mechanize:
ERROR: Failed to build gem native extension.
/Users/Tim/.rvm/rubies/ruby-1.9.3-p545/bin/ruby extconf.rb
checking for main() in -lstdc++... yes
checking for ruby/encoding.h... yes
creating Makefile
make clean
make
compiling unf.cc
g++: error: unrecognized command line option '-Wshorten-64-to-32'
make: *** [unf.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/Tim/.rvm/gems/ruby-1.9.3-p545#global/gems/unf_ext-0.0.6 for inspection.
Results logged to /Users/Tim/.rvm/gems/ruby-1.9.3-p545#global/extensions/x86_64-darwin-12/1.9.1/unf_ext-0.0.6/gem_make.out
I have no idea why this happened and is there anyone willing to help?
Thanks!
PS: I found out that actually a long time ago I set the default compiler to g++ instead of clang. Does this matter?
Actually this is indeed caused by my switching the default compiler to gcc4.7. After I switched back(command: sudo port select --set gcc llvm-gcc42), it went well smoothly.

Ruby gem version_sorter on OS X 10.9

I've tried to make update for Gitlab Installation guide for OS X (https://github.com/CiTroNaK/Installation-guide-for-GitLab-on-OS-X) for the newest version of Gitlab 6.7.
I use OS X 10.9 with xcode command lines tools and I ended with this error for version_sorter gem:
Building native extensions. This could take a while...
ERROR: Error installing version_sorter:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for pcre_compile() in -lpcre... yes
creating Makefile
make "DESTDIR="
compiling rb_version_sorter.c
compiling version_sorter.c
version_sorter.c:49:16: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
while (cur = vsi->head) {
~~~~^~~~~~~~~~~
version_sorter.c:49:16: note: place parentheses around the assignment to silence this warning
while (cur = vsi->head) {
^
( )
version_sorter.c:49:16: note: use '==' to turn this assignment into an equality comparison
while (cur = vsi->head) {
^
==
1 warning generated.
linking shared-object version_sorter.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [version_sorter.bundle] Error 1
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/version_sorter-1.1.0 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/version_sorter-1.1.0/ext/version_sorter/gem_make.out
Unfortunately I do not have enough knowledge to fix it. Could someone help me please?
A recent XCode update broke quite a bit of native code compilation, try this:
Add ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future to whatever you were running above. It looks like the Gitlab instructions are installing it using the system Ruby, so try this:
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install version_sorter

Compile Ruby Enterprise Edition on Mac OS X

Hi
when trying to compile Ruby Enterprise Edition 2010.02
readline.c: In function ‘username_completion_proc_call’:
readline.c:734: error: ‘username_completion_function’ undeclared (first use in this function)
readline.c:734: error: (Each undeclared identifier is reported only once
readline.c:734: error: for each function it appears in.)
make[1]: *** [readline.o] Error 1
make: *** [all] Error 1
I tried also specifying the option -c '--with-readline-path=/usr/local' (where I installed the readline libs), but I have the same issue.
I tried to install readline with port and delete my manual compile, but the problem still there.
I never had troubles under Linux (the system I'm used to), having ldconfig, etc...
HELP! :)
Thanks
Have you tried using RVM (Ruby Version Manager)?
Ok, I resolved in this way:
I compiled readline 5.2 following this guide
http://techdebug.com/blog/2009/01/03/compiling-readline-on-an-osx-105-intel-x86_64/
readline 6.1 does not work with ree.
Doing the installation with the following:
./installer -c '--with-readline-dir=PATH'
works fine

Resources