Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
frenkel opened this issue Jul 21, 2017 · 8 comments
Closed

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

frenkel opened this issue Jul 21, 2017 · 8 comments

Comments

@frenkel
Copy link

frenkel commented Jul 21, 2017

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
Copy link
Owner

mudge commented Jul 21, 2017

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
Copy link
Owner

mudge commented Jul 21, 2017

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 added a commit that referenced this issue Jul 21, 2017
GitHub: #33

Follow the lead from Nokogiri and the sqlite3 gem by using the CC (and
CXX) environments to configure the Makefile during installation if
present.

See:

* https://github.com/sparklemotion/sqlite3-ruby/blob/master/ext/sqlite3/extconf.rb#L7
* https://github.com/sparklemotion/nokogiri/blob/master/ext/nokogiri/extconf.rb#L395-L402
mudge added a commit that referenced this issue Jul 21, 2017
GitHub: #33

Follow the lead from Nokogiri and the sqlite3 gem by using the CC (and
CXX) environments to configure the Makefile during installation if
present.

See:

* https://github.com/sparklemotion/sqlite3-ruby/blob/master/ext/sqlite3/extconf.rb#L7
* https://github.com/sparklemotion/nokogiri/blob/master/ext/nokogiri/extconf.rb#L395-L402
mudge added a commit that referenced this issue Jul 21, 2017
GitHub: #33

Follow the lead from Nokogiri and the sqlite3 gem by using the CC (and
CXX) environments to configure the Makefile during installation if
present.

See:

* https://github.com/sparklemotion/sqlite3-ruby/blob/master/ext/sqlite3/extconf.rb#L7
* https://github.com/sparklemotion/nokogiri/blob/master/ext/nokogiri/extconf.rb#L395-L402
mudge added a commit that referenced this issue Jul 21, 2017
GitHub: #33

Follow the lead from Nokogiri and the sqlite3 gem by using the CC (and
CXX) environments to configure the Makefile during installation if
present.

See:

* https://github.com/sparklemotion/sqlite3-ruby/blob/master/ext/sqlite3/extconf.rb#L7
* https://github.com/sparklemotion/nokogiri/blob/master/ext/nokogiri/extconf.rb#L395-L402
mudge added a commit that referenced this issue Jul 22, 2017
GitHub: #33

Follow the lead from Nokogiri and the sqlite3 gem by using the CC (and
CXX) environments to configure the Makefile during installation if
present.

See:

* https://github.com/sparklemotion/sqlite3-ruby/blob/master/ext/sqlite3/extconf.rb#L7
* https://github.com/sparklemotion/nokogiri/blob/master/ext/nokogiri/extconf.rb#L395-L402
@mudge
Copy link
Owner

mudge commented Jul 23, 2017

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
Copy link
Author

frenkel commented Jul 24, 2017

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
Copy link
Owner

mudge commented Jul 24, 2017

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
Copy link
Author

frenkel commented Jul 24, 2017

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 added a commit that referenced this issue Jul 24, 2017
GitHub: #33

When compiling the gem with a compiler specified through the CC and CXX
environment variables, we need to update both the Makefile configuration
and standard Ruby configuration so that the various pre-compilation
checks and final Makefile use the right compiler toolchain.

This should hopefully allow compilation on OpenBSD using egcc and eg++
(tested in VirtualBox).
@mudge
Copy link
Owner

mudge commented Jul 24, 2017

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
Copy link
Author

frenkel commented Jul 25, 2017

Great, thank you so much!

@frenkel frenkel closed this as completed Jul 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants