jruby-launcher icon indicating copy to clipboard operation
jruby-launcher copied to clipboard

Does not compile with GCC 6

Open preetpalS opened this issue 7 years ago • 7 comments

GCC 6 changed the default C++ standard from C++98 to C++14 (https://gcc.gnu.org/gcc-6/changes.html) and this prevents jruby-launcher from building. The reason why this repository is affected due to the change in C++ standard is because NULL is defined differently since C++11 (http://en.cppreference.com/w/cpp/types/NULL).

I encountered this on FreeBSD 11.1.with GCC 6 installed. I was mainly affected because I was trying to install JRuby using Rbenv which attempts to compile jruby-launcher during the installation of JRuby 9.1.15.0. This issue probably isn't confined to FreeBSD.

Relevant terminal session:

$ rbenv install jruby-9.1.15.0   
Downloading jruby-dist-9.1.15.0-bin.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/4a0d9305867ed327a8cf4f7ff8a65c7ff62094a495ec85463d0792656762469e
Installing jruby-9.1.15.0...

BUILD FAILED (FreeBSD 11.1-RELEASE-p4 using ruby-build 20171226)

Inspect or clean up the working tree at /tmp/ruby-build.20180222135747.13771
Results logged to /tmp/ruby-build.20180222135747.13771.log

Last 10 log lines:
gmake[2]: *** [inc/Makefile-rules.mk:19: build/unix/FreeBSD/argparser.o] Error 1
gmake[2]: Leaving directory '/usr/home/ps/.rbenv/versions/jruby-9.1.15.0/lib/ruby/gems/shared/gems/jruby-launcher-1.1.4-java'
gmake[1]: *** [inc/Makefile-rules.mk:5: .build-conf] Error 2
gmake[1]: Leaving directory '/usr/home/ps/.rbenv/versions/jruby-9.1.15.0/lib/ruby/gems/shared/gems/jruby-launcher-1.1.4-java'
gmake: *** [inc/Makefile-impl.mk:28: .build-impl] Error 2

make failed, exit code 2

Gem files will remain installed in /usr/home/ps/.rbenv/versions/jruby-9.1.15.0/lib/ruby/gems/shared/gems/jruby-launcher-1.1.4-java for inspection.
Results logged to /usr/home/ps/.rbenv/versions/jruby-9.1.15.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.3.0/jruby-launcher-1.1.4-java/gem_make.out

$ cat /tmp/ruby-build.20180222135747.13771.log | tail -n 30
gmake[1]: Leaving directory '/usr/home/ps/.rbenv/versions/jruby-9.1.15.0/lib/ruby/gems/shared/gems/jruby-launcher-1.1.4-java'
rm -f *.exe *.res

current directory: /usr/home/ps/.rbenv/versions/jruby-9.1.15.0/lib/ruby/gems/shared/gems/jruby-launcher-1.1.4-java
gmake "DESTDIR="
gmake -f inc/Makefile-rules.mk CONF=unix SUBPROJECTS= .build-conf
gmake[1]: Entering directory '/usr/home/ps/.rbenv/versions/jruby-9.1.15.0/lib/ruby/gems/shared/gems/jruby-launcher-1.1.4-java'
gmake -f inc/Makefile-rules.mk jruby
gmake[2]: Entering directory '/usr/home/ps/.rbenv/versions/jruby-9.1.15.0/lib/ruby/gems/shared/gems/jruby-launcher-1.1.4-java'
mkdir -p build/unix/FreeBSD
rm -f build/unix/FreeBSD/argparser.o.d
g++ -O2 -Wall "-I/usr/local/openjdk8/include" -I/home/ps/.rbenv/versions/jruby-9.1.15.0/include   -c argparser.cpp -MMD -MP -MF build/unix/FreeBSD/argparser.o.d -o build/unix/FreeBSD/argparser.o
argparser.cpp: In member function 'bool ArgParser::initPlatformDir()':
argparser.cpp:136:40: error: cannot convert 'std::nullptr_t' to 'char' in initialization
         char sep[2] = { FILE_SEP, NULL };
                                        ^
argparser.cpp: In member function 'bool ArgParser::parseArgs(int, char**)':
argparser.cpp:250:17: warning: unused variable 'buffer' [-Wunused-variable]
     struct stat buffer;
                 ^~~~~~
gmake[2]: *** [inc/Makefile-rules.mk:19: build/unix/FreeBSD/argparser.o] Error 1
gmake[2]: Leaving directory '/usr/home/ps/.rbenv/versions/jruby-9.1.15.0/lib/ruby/gems/shared/gems/jruby-launcher-1.1.4-java'
gmake[1]: *** [inc/Makefile-rules.mk:5: .build-conf] Error 2
gmake[1]: Leaving directory '/usr/home/ps/.rbenv/versions/jruby-9.1.15.0/lib/ruby/gems/shared/gems/jruby-launcher-1.1.4-java'
gmake: *** [inc/Makefile-impl.mk:28: .build-impl] Error 2

make failed, exit code 2

Gem files will remain installed in /usr/home/ps/.rbenv/versions/jruby-9.1.15.0/lib/ruby/gems/shared/gems/jruby-launcher-1.1.4-java for inspection.
Results logged to /usr/home/ps/.rbenv/versions/jruby-9.1.15.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.3.0/jruby-launcher-1.1.4-java/gem_make.out

preetpalS avatar Feb 22 '18 22:02 preetpalS

In the meanwhile, I am working around this issue (as it makes jruby unusable with rbenv for me) with a local change to ruby-build (in case anyone is also running to this issue):

install_jruby_launcher() {
  cd "${PREFIX_PATH}/bin"
  ./ruby gem install specific_install
  { ./ruby gem specific_install -l https://github.com/preetpalS/jruby-launcher.git
  } >&4 2>&1
}

preetpalS avatar Mar 02 '18 01:03 preetpalS

Can confirm both FreeBSD and OpenBSD are effected by this, but it seems to work fine in Ubuntu 16.04.

@preetpalS thanks for the fix for the time being!

desnudopenguino avatar Mar 25 '18 07:03 desnudopenguino

@desnudopenguino Glad that fix works for you. Ubuntu 18.04 will probably be affected by this since it most likely will have an updated GCC version.

UPDATE (2018-Nov-25):

JRuby 9.1.15.0 and 9.2.0.0 install cleanly on Ubuntu 18.04 using GCC 7.3.0. Have not re-tested with FreeBSD 11 yet.

preetpalS avatar Mar 25 '18 10:03 preetpalS

@preetpalS thanks for that, that seemed to send me in the right direction as well.

Any chance you ran into this?

ERROR:  While executing gem ... (Gem::Ext::BuildError)
    ERROR: Failed to build gem native extension.

    current directory: /home/slackz/.rbenv/versions/jruby-9.2.4.0/lib/ruby/gems/shared/gem
s/jruby-launcher-1.1.5.pre-java
/home/slackz/.rbenv/versions/jruby-9.2.4.0/bin/jruby -r ./siteconf20181125-27297-mot9sw.rb extconf.rb
NameError: uninitialized constant Config
Did you mean?  RbConfig
  const_missing at org/jruby/RubyModule.java:3534
         <main> at extconf.rb:4

This is on OpenBSD 6.4, trying to install jruby 9.2.4, jre / jdk 1.8 from OpenBSD packages. I also had to tweak the version check for existing jdk environment; the OpenBSD version of grep wasn't succeeded with that regex, small tweak, will file separate issue / PR

ghost avatar Nov 25 '18 22:11 ghost

@ckuttruff I do not believe that I have seen that error before.

preetpalS avatar Nov 25 '18 22:11 preetpalS

@preetpalS lol, sorry, my bad, tunnel vision. Of course you didn't see that error cause it's for jruby / concerning a separate version. Also why you didn't hit this: https://github.com/rbenv/ruby-build/pull/1259

I actually didn't encounter your original error when installing 2.5.3 MRI (on OpenBSD 6.4). Thanks for your time reporting; would love to see (and help contribute to) stronger BSD support with rbenv (currently using the system version, since I still have some hangups with jruby).

Your tweak was def. still relevant for me since it involved build stuff before the java / C compilation divergence for our cases.

ghost avatar Nov 25 '18 23:11 ghost

@ckuttruff I am not familiar with the differences between grep on different platforms (I am not sure why I did not encounter the issue on FreeBSD, but if you are curious, try it on FreeBSD yourself, I believe I was using rbenv from the pkg package manager).

This issue is only for this project (jruby-launcher) which is not used by MRI. It would not make any sense to see this issue when installing MRI 2.5.3 on OpenBSD 6.4.

Also, the error that you encountered was a ruby error, so you actually are not encountering the problem described in this issue. I am unable to help you with that unfortunately.

preetpalS avatar Nov 26 '18 00:11 preetpalS

Out of date

preetpalS avatar Jun 03 '24 23:06 preetpalS