mudge / re2

Ruby bindings to RE2, a "fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python".
http://mudge.name/re2/
BSD 3-Clause "New" or "Revised" License
129 stars 13 forks source link

Installation of re2 ignore $CC and $CXX variables #33

Closed frenkel closed 7 years ago

frenkel commented 7 years ago

On OpenBSD we need to use egcc and eg++ from ports to compile re2 and therefore also the re2 gem. When I specify them using environment variables (CC=egcc CXX=eg++ bundle), this is completely ignored (snippet from mkmf.log):

"cc -I/usr/local/include/ruby-2.3/x86_64-openbsd -I/usr/local/include/ruby-2.3/ruby/backward -I/usr/local/include/ruby-2.3 -I. -DOPENSSL_NO_STATIC_ENGINE -I/usr/local/include   -O2 -pipe -fPIC -Wall -Wextra -funroll-loops  -x c++ -std=c++0x -c conftest.c"
cc1plus: error: unrecognized command line option "-std=c++0x"

For other gems such as Nokogiri this works without problems.

mudge commented 7 years ago

Hi @frenkel, thanks for reporting this.

It looks like Nokogiri have specific support for OpenBSD in their extconf.rb, let me see if there's a simple way to make mkmf respect the CC and CXX environment variables based on this.

mudge commented 7 years ago

Could you please try adding the following to ext/re2/extconf.rb after require 'mkmf' to see if this remedies your issue?

RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
RbConfig::MAKEFILE_CONFIG['CXX'] = ENV['CXX'] if ENV['CXX']

See the sqlite3-ruby extconf.rb for another example of this.

mudge commented 7 years ago

I've released v1.1.0 which should hopefully fix this problem: please give it a whirl and let me know if it solves your issue.

frenkel commented 7 years ago

Thank you and sorry for the late reply! Unfortunately it doesn't work. The mkmf.log contains the same commands, no mention of what I set in the CC and CXX environment variables.

"cc -I/usr/local/include/ruby-2.3/x86_64-openbsd -I/usr/local/include/ruby-2.3/ruby/backward -I/usr/local/include/ruby-2.3 -I. -DOPENSSL_NO_STATIC_ENGINE -I/usr/local/include   -O2 -pipe -fPIC -Wall -Wextra -funroll-loops  -x c++ -std=c++11 -c conftest.c"
cc1plus: error: unrecognized command line option "-std=c++11"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <re2/re2.h>
4: int main() { return 0; }
/* end */

"cc -I/usr/local/include/ruby-2.3/x86_64-openbsd -I/usr/local/include/ruby-2.3/ruby/backward -I/usr/local/include/ruby-2.3 -I. -DOPENSSL_NO_STATIC_ENGINE -I/usr/local/include   -O2 -pipe -fPIC -Wall -Wextra -funroll-loops  -x c++ -std=c++0x -c conftest.c"
cc1plus: error: unrecognized command line option "-std=c++0x"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <re2/re2.h>
4: int main() { return 0; }
/* end */
mudge commented 7 years ago

So I can reproduce this locally (e.g. in a virtual machine), could you please provide the exact version of OpenBSD, the appropriate commands, etc. and I'll see what I can do?

frenkel commented 7 years ago

Thank you! Just install OpenBSD 6.1 and run the following command as root:

pkg_add -v ruby23 gcc
pkg_add -v -Dunsigned http://packages.ivaldi.nl/pub/OpenBSD/6.1-stable/packages/amd64/re2-20170601.tgz

and then as any normal user:

CC=egcc CXX=eg++ gem23 install --user-install re2 '~> 1.1.0'
mudge commented 7 years ago

Hi @frenkel, I think this should now be fixed in the newly-released 1.1.1.

I've tested it with the following on OpenBSD 6.1 in VirtualBox (with both gcc and g++ installed via pkg_add):

$ CC=egcc CXX=eg++ gem23 install re2

Please feel free to give it a go!

frenkel commented 7 years ago

Great, thank you so much!