oracle / fastr

A high-performance implementation of the R programming language, built on GraalVM.
Other
626 stars 64 forks source link

Problems with Fortran libraries #26

Closed kenahoo closed 6 years ago

kenahoo commented 6 years ago

For various R packages that I try to install, I'm getting errors when it tries to load Fortran libraries:

> install.packages('mgcv')
...
** byte-compile and prepare package for lazy loading
com.oracle.truffle.r.runtime.ffi.DLL$DLLException: unable to load shared object '/Users/kwilliams/Downloads/graalvm-ce-1.0.0-rc8/Contents/Home/jre/languages/R/library/nlme/libs/nlme.so'
  dlopen(/Users/kwilliams/Downloads/graalvm-ce-1.0.0-rc8/Contents/Home/jre/languages/R/library/nlme/libs/nlme.so, 6): Library not loaded: @rpath/libgfortran.3.dylib
  Referenced from: /Users/kwilliams/Downloads/graalvm-ce-1.0.0-rc8/Contents/Home/jre/languages/R/library/nlme/libs/nlme.so
  Reason: image not found

I wondered whether I could solve it by re-installing nlme, but that hits a different Fortran error:

> install.packages('nlme')
...
* installing *source* package ‘nlme’ ...
** package ‘nlme’ successfully unpacked and MD5 sums checked
** libs
/usr/local/bin/gfortran-4.9   -fPIC  -O2  -c chol.f -o chol.o
make: /usr/local/bin/gfortran-4.9: No such file or directory
make: *** [chol.o] Error 1
ERROR: compilation failed for package ‘nlme’

Is this an expected problem, or is there something wrong with my setup? I'm using:

% ./bin/gu info R
Downloading: Component catalog
Filename: https://github.com/oracle/fastr/releases/download/vm-1.0.0-rc8/r-installable-ce-1.0.0-rc8-macos-amd64.jar
Name    : FastR
ID      : R
Version : 1.0.0-rc8
GraalVM : 1.0.0-rc8
Component bundle R cannot be installed
    - The same component FastR (R) is already installed in version 1.0.0-rc8

> R.version
               _                               
platform       x86_64-apple-darwin17.7.0       
arch           x86_64                          
os             darwin17.7.0                    
system         x86_64, darwin17.7.0            
major          3                               
minor          4.0                             
year           2017                            
month          04                              
day            21                              
svn rev                                        
language       R                               
engine         FastR                           
version.string FastR version 3.4.0 (2017-04-21)

(That seems like kind of an old year/month combination, but that's what I got with bin/gu install R.)

kenahoo commented 6 years ago

I get a similar error when trying to load the Matrix library:

> library(Matrix)
com.oracle.truffle.r.runtime.ffi.DLL$DLLException: unable to load shared object '/Users/kwilliams/Downloads/graalvm-ce-1.0.0-rc8/Contents/Home/jre/languages/R/library/Matrix/libs/Matrix.so'
  dlopen(/Users/kwilliams/Downloads/graalvm-ce-1.0.0-rc8/Contents/Home/jre/languages/R/library/Matrix/libs/Matrix.so, 6): Library not loaded: @rpath/libgfortran.3.dylib
  Referenced from: /Users/kwilliams/Downloads/graalvm-ce-1.0.0-rc8/Contents/Home/jre/languages/R/library/Matrix/libs/Matrix.so
  Reason: image not found

FWIW, I do have libgfortran.3.dylib in my installation:

% ls /Users/kwilliams/Downloads/graalvm-ce-1.0.0-rc8/Contents/Home/jre/languages/R/lib
libR.dylib*     libgcc_s.1.dylib    libgfortran.dylib@  libquadmath.0.dylib libz.dylib@
libRblas.dylib*     libgcc_s.dylib@     libpcre.1.dylib     libquadmath.dylib@
libRlapack.dylib*   libgfortran.3.dylib libpcre.dylib@      libz.1.dylib
kenahoo commented 6 years ago

I did a couple of things:

  1. There were two gfortran executables in my path, in /Users/kwilliams/miniconda3/bin and /usr/local/bin. I removed /Users/kwilliams/miniconda3/bin from my $PATH variable.

  2. I ran the jre/languages/R/bin/configure_fastr script, which rewrote my jre/languages/R/etc/Makeconf file. It was necessary to eliminate miniconda from my $PATH before configure_fastr would run successfully.

  3. I ran Graal's R, then did install.packages("Matrix"), which succeeded. I don't know whether both 1. and 2. were necessary to get it to work.

Now I can do library(Matrix) successfully. I also installed nlme and mgcv successfully, hopefully paving the way to installing other packages that depend on them.

steve-s commented 6 years ago

Hi Ken,

thank you for reporting this. @zslajchrt fixed that in the last commit 3ae14b8bafe26c38fc361efab2d87789f1f9d83d. However, this change will only be available in the next public release.

kenahoo commented 6 years ago

Thanks!