oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.28k stars 1.63k forks source link

R install on macOS appears to be broken #2034

Closed mobileink closed 4 years ago

mobileink commented 4 years ago

R doesn't work with graalvm-ce-java11-19.3.0.2.

For example, $GRAAL_HOME/bin/R: ... FastR unexpected failure: error loading libR from: /Library/Java/JavaVirtualMachines/graalvm-ce-java11-19.3.0.2/Contents/Home/languages/R/lib/libR.dylib. Message: dlopen(/Library/Java/JavaVirtualMachines/graalvm-ce-java11-19.3.0.2/Contents/Home/languages/R/lib/libR.dylib, 9): Library not loaded: /cm/shared/apps/gcc/4.9.2/lib/libgfortran.3.dylib Referenced from: /Library/Java/JavaVirtualMachines/graalvm-ce-java11-19.3.0.2/Contents/Home/languages/R/lib/libRlapack.dylib Reason: image not found

Both libRblas.dylib and libRlapack.dylib are incorrectly linked to libgfortran and libquadmath:

$ otool -L /Library/Java/JavaVirtualMachines/graalvm-ce-java11-19.3.0.2/Contents/Home/languages/R/lib/libRlapack.dylib /Library/Java/JavaVirtualMachines/graalvm-ce-java11-19.3.0.2/Contents/Home/languages/R/lib/libRlapack.dylib: @rpath/libRlapack.dylib (compatibility version 3.6.0, current version 3.6.1) @rpath/libRblas.dylib (compatibility version 0.0.0, current version 0.0.0) /cm/shared/apps/gcc/4.9.2/lib/libgfortran.3.dylib (compatibility version 4.0.0, current version 4.0.0) /cm/shared/apps/gcc/4.9.2/lib/libquadmath.0.dylib (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)

Workaround: do this for each.

sudo install_name_tool -change /cm/shared/apps/gcc/4.9.2/lib/libquadmath.0.dylib /usr/local/Cellar/gcc\@4.9/4.9.4_1/lib/gcc/4.9/libquadmath.0.dylib /Library/Java/JavaVirtualMachines/graalvm-ce-java11-19.3.0.2/Contents/Home/languages/R/lib/libRlapack.dylib

mobileink commented 4 years ago

Similar issues crop up when running install.packages: the absolute path "/cm/shared/apps/blah blah" is hard-coded in various places in the build stuff, which doesn't look right to me, anyway. Got lots of this kind of thing:

g++ -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/cm/shared/apps/bzip2/1.0.6/lib -L/cm/shared/apps/xz/5.2.2/lib -L/cm/shared/apps/pcre/8.43/lib -L/cm/shared/apps/curl/7.50.1/lib -L/cm/shared/apps/gcc/4.9.2/lib -L/usr/lib -o reticulate.so RcppExports.o event_loop.o libpython.o output.o python.o readline.o ld: warning: directory not found for option '-L/cm/shared/apps/bzip2/1.0.6/lib' ld: warning: directory not found for option '-L/cm/shared/apps/xz/5.2.2/lib' ld: warning: directory not found for option '-L/cm/shared/apps/pcre/8.43/lib' ld: warning: directory not found for option '-L/cm/shared/apps/curl/7.50.1/lib' ld: warning: directory not found for option '-L/cm/shared/apps/gcc/4.9.2/lib'

I managed to get stuff built anyway, but had to use the native toolchain: $ R -e 'fastr.setToolchain("native")', and those link warnings look ominous. Sometimes a build would fail because a component was missing; installing the component separately seemed to fix that problem. An example is 'nlme'.

HTH

steve-s commented 4 years ago

Hello Gregg,

thank you for reporting this!

Have you tried running the configure_fastr(*) script? It's main purpose in this FastR version (19.3.0) is to fix-up the linking with libgfortran3 and libquadmath, which we do not distribute in that FastR version (unlike with the previous versions). We plan to distribute these libraries again in the next version (20.0.0), in which case, libRlapack and other libs linking to them can already be linked to the correct relative location of libgfortran and libquadmath.

For the ld: warning messages: you are right that these paths got into the release unintentionally, we'll get that fixed. However, I believe that otherwise these warnings (or more precisely the fact that those directories do not exists on your system) are mostly harmless.

Sometimes a build would fail because a component was missing; installing the component separately seemed to fix that problem.

What do you mean by a "component" here? An R package or system library like bzip2? Would calling just install.packages("nlme") reproduce the issue?

(*) full path: $GRAALVM_HOME/languages/R/bin/configure_fastr

mobileink commented 4 years ago

I'm pretty sure I ran configure_fastr. I'm on 19.3.0.2, fwiw.

Regarding the package installation, I ran install.packages on:

shiny haven plotly ggplot2 plyr dplyr srvyr tidyverse jsonlite reticulate

I don't recall which ones had the problem, but occurred several times (nlme is just an example). The install would fail, complaining of a missing dependency (e.g. nlme). I found that running install.packages on the missing dependency would succeed, and then rerunning install on the original package would succeed.

Thanks,

G

steve-s commented 4 years ago

Hello Gregg,

in the latest release (20.0.0) the hard-coded absolute paths starting with "/cm/shared/apps" should be gone. We are still investigating the issue with packages installation.

mobileink commented 4 years ago

Just saw this, thanks.

didekin commented 4 years ago

I have just got this, with graalvm 20.1.0 and FastR 20.1.0:

FastR unexpected failure: error loading libR from: /Users/pedro/.sdkman/candidates/java/20.1.0.r11-grl/languages/R/lib/libR.dylib. Message: dlopen(/Users/pedro/.sdkman/candidates/java/20.1.0.r11-grl/languages/R/lib/libR.dylib, 9): Library not loaded: /cm/shared/apps/gcc/8.3.0/lib/libgomp.1.dylib Referenced from: /Users/pedro/.sdkman/candidates/java/20.1.0.r11-grl/languages/R/lib/libRblas.dylib Reason: image not found

FastR unexpected failure: error loading libR from: /Users/pedro/.sdkman/candidates/java/20.1.0.r11-grl/languages/R/lib/libR.dylib. Message: dlopen(/Users/pedro/.sdkman/candidates/java/20.1.0.r11-grl/languages/R/lib/libR.dylib, 9): Library not loaded: /cm/shared/apps/gcc/8.3.0/lib/libgomp.1.dylib Referenced from: /Users/pedro/.sdkman/candidates/java/20.1.0.r11-grl/languages/R/lib/libRlapack.dylib Reason: image not found

I've worked around as suggested above by mobileink.

marthenlt commented 4 years ago

This issue is existed in GraalVM EE 20.1.0 (build 25.251-b08-jvmci-20.1-b02, mixed mode).

I am running MacOs 10.15.5 BuildVersion: 19F101

The error message is

FastR unexpected failure: error loading libR from: /Library/Java/JavaVirtualMachines/graalvm-ee-java8-20.1.0/Contents/Home/jre/languages/R/lib/libR.dylib.
Message: dlopen(/Library/Java/JavaVirtualMachines/graalvm-ee-java8-20.1.0/Contents/Home/jre/languages/R/lib/libR.dylib, 9): Library not loaded: /cm/shared/apps/gcc/8.3.0/lib/libgomp.1.dylib
  Referenced from: /Library/Java/JavaVirtualMachines/graalvm-ee-java8-20.1.0/Contents/Home/jre/languages/R/lib/libRlapack.dylib
  Reason: image not found

I did the workaround suggested by @mobileink , by running : sudo install_name_tool -change /cm/shared/apps/gcc/8.3.0/lib/libgomp.1.dylib /usr/local/Cellar/gcc@4.9/4.9.4_2/lib/gcc/4.9/libgomp.1.dylib /Library/Java/JavaVirtualMachines/graalvm-ee-java8-20.1.0/Contents/Home/jre/languages/R/lib/libRlapack.dylib

wilbyang commented 4 years ago

GraalVM CE 20.1.0 MacOs 10.14.6 (18G5033) I have the same problem. Even I have run sudo install_name_tool -change /cm/shared/apps/gcc/8.3.0/lib/libgomp.1.dylib /usr/local/Cellar/gcc/9.3.0_1/lib/gcc/9/libgomp.1.dylib /Users/boya/.sdkman/candidates/java/20.1.0.r11-grl/languages/R/lib/libRlapack.dylib

didekin commented 4 years ago

This is what I've done:

sudo install_name_tool -change /cm/shared/apps/gcc/8.3.0/lib/libgomp.1.dylib \
             /usr/local/Cellar/gcc@4.9/4.9.4_2/lib/gcc/4.9/libgomp.1.dylib \
             /Users/pedro/.sdkman/candidates/java/20.1.0.r11-grl/languages/R/lib/libRblas.dylib
sudo install_name_tool -change /cm/shared/apps/gcc/8.3.0/lib/libgomp.1.dylib \
              /usr/local/Cellar/gcc@4.9/4.9.4_2/lib/gcc/4.9/libgomp.1.dylib \
              /Users/pedro/.sdkman/candidates/java/20.1.0.r11-grl/languages/R/lib/libRlapack.dylib