have_header from mkmf fails saying I should install development tools first #4409

Open
abnud1 opened this Issue Dec 23, 2016 · 3 comments

Projects

None yet

2 participants

@abnud1
abnud1 commented Dec 23, 2016 edited

Environment

  • JRuby version : jruby 9.1.6.0 (2.3.1) 2016-11-09 0150a76 OpenJDK 64-Bit Server VM 25.112-b15 on 1.8.0_112-b15 +jit [linux-x86_64]

  • Operating system and platform : Linux abd 4.8.13-1-ARCH #1 SMP PREEMPT Fri Dec 9 07:24:34 CET 2016 x86_64 GNU/Linux

  • Environment variables

PATH: "/home/abd/.rvm/gems/jruby-9.1.6.0/bin:/home/abd/.rvm/gems/jruby-9.1.6.0@global/bin:/home/abd/.rvm/rubies/jruby-9.1.6.0/bin:/home/abd/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/opt/mpich/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/abd/.cabal/bin"
GEM_HOME: "/home/abd/.rvm/gems/jruby-9.1.6.0"
GEM_PATH: "/home/abd/.rvm/gems/jruby-9.1.6.0:/home/abd/.rvm/gems/jruby-9.1.6.0@global"
MY_RUBY_HOME: "/home/abd/.rvm/rubies/jruby-9.1.6.0"
IRBRC: "/home/abd/.rvm/rubies/jruby-9.1.6.0/.irbrc"
JAVA_HOME: "/usr/lib/jvm/java-8-openjdk"

I also have to state that I have the jdk installed, not just the jre, I even have openjdk8-src package installed.

Expected Behavior

for this code :

require 'mkmf'
puts have_header("gmp.h")

On a platform where gmp is installed, MRI prints "checking for gmp.h ... yes\ntrue", where it's not installed it will print "no\nfalse", that's what jruby should do.

This code is just a minimal example of what a gem would do for its native extensions

Actual Behavior

it errors with this :

checking for gmp.h... RuntimeError: The compiler failed to generate an executable file.
You have to install development tools first.

try_do at /home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:456
try_cpp at /home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:587
block in have_header at /home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:1091
block in checking_for at /home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:942
block in postpone at /home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:350
open at /home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:320
block in postpone at /home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:350
open at /home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:320
postpone at /home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:346
checking_for at /home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:941
have_header at /home/abd/.rvm/rubies/jruby-9.1.6.0/lib/ruby/stdlib/mkmf.rb:1090

at test.rb:3

I see this same error when installing mongoid even though they state that they support Jruby 9.1(tests are failing under 9.1.6 though but I can't even install it)

@headius
Member
headius commented Dec 23, 2016

First off, I do need to point out that JRuby does not support Ruby C extensions right now, so if you need that it's not going to work. However, if you're just using this to do makefile-like things...

I can confirm this error on my Linux machine. Unsure if it fails on OS X but I wouldn't be surprised. I assume the problem is that we don't have enough configuration info available for it to find a C compiler, and whatever it guesses is wrong.

Can you dig into the code a bit and see how it determines the C compiler settings to use? I'd like to see mkmf work for non-ext uses, but it has not been a priority for us to fix it up.

See also #4118 (and possibly others) for attempts to get mkmf working for non-ext builds.

@abnud1
abnud1 commented Dec 24, 2016 edited

It's probably in try_link0 function, I can't dig farther because neither puts nor debugger works.

I do know that Jruby doesn't support C extensions and as I said I can't install mongoid because of this issue, what don't install are the native Java extensions that come with bson :) .

I will try the pull request and see if it works.

@headius
Member
headius commented Jan 5, 2017

Are you saying that the bson Java exts are trying to do this? I'm confused what fails...perhaps you can provide a Ruby or Shell script or an example repository?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment