RcppCore / RcppEigen

Rcpp integration for the Eigen templated linear algebra library
Other
110 stars 40 forks source link

Fails to compile on PowerPC Mac with R 4.2.1 #104

Closed barracuda156 closed 2 years ago

barracuda156 commented 2 years ago

install.packages("RcppEigen", type="source") Installing package into ‘/Users/svacchanda/Library/R/powerpc/4.1/library’ (as ‘lib’ is unspecified) trying URL 'https://cran.csie.ntu.edu.tw/src/contrib/RcppEigen_0.3.3.9.1.tar.gz' Content type 'application/octet-stream' length 1633360 bytes (1.6 MB)

downloaded 1.6 MB

Warning in file(con, "r") : cannot open file '/var/db/timezone/zoneinfo/+VERSION': No such file or directory

The downloaded source packages are in ‘/private/var/folders/rD/rDeCM6SDHv8daLCecrRmrU+++TI/-Tmp-/RtmpYWTu3s/downloaded_packages’ Warning message: In install.packages("RcppEigen", type = "source") : installation of package ‘RcppEigen’ had non-zero exit status

eddelbuettel commented 2 years ago

Is that possibly the same issue as the one Kevin explained to you in RcppParallel ?

In any event we do not set linker options, so if you have 'framework' issues that may be with R itself. Maybe you can find other users on this somewhat exotic platforms, the package tends to build everywhere else....

kevinushey commented 2 years ago

ld: library not found for -lRlapack

Where is libRlapack.dylib located in your R installation? You might have to modify R's etc/Makeconf file to add that library path in the link step.

You can run something like this from the terminal to find it:

find $(R RHOME) -name 'libRlapack.dylib'

I see, on my macOS machine with Homebrew:

$ find $(R RHOME) -name 'libRlapack.dylib'
/opt/homebrew/Cellar/r/4.1.2/lib/R/lib/libRlapack.dylib

So you'd need to add this library path to LDFLAGS in $(R RHOME)/etc/Makeconf.

FWIW my R installation has:

LDFLAGS = -L/opt/homebrew/opt/gettext/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/xz/lib -L/opt/homebrew/lib

and Homebrew puts libRlapack.dylib in /opt/homebrew/lib, hence why it's discovered here.

barracuda156 commented 2 years ago

I have installed R with MacPorts, so the path to it is /opt/local/Library/Frameworks. I will try adding a path to libRlapack.dylib as you suggested once I am on that machine, and update here. Thank you.

On Wed, Nov 24, 2021 at 2:25 AM Kevin Ushey @.***> wrote:

ld: library not found for -lRlapack

Where is libRlapack.dylib located in your R installation? You might have to modify R's etc/Makeconf file to add that library path in the link step.

You can run something like this from the terminal to find it:

find $(R RHOME) -name 'libRlapack.dylib'

I see, on my macOS machine with Homebrew:

$ find $(R RHOME) -name 'libRlapack.dylib' /opt/homebrew/Cellar/r/4.1.2/lib/R/lib/libRlapack.dylib

So you'd need to add this library path to LDFLAGS in $(R RHOME)/etc/Makeconf.

FWIW my R installation has:

LDFLAGS = -L/opt/homebrew/opt/gettext/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/xz/lib -L/opt/homebrew/lib

and Homebrew puts libRlapack.dylib in /opt/homebrew/lib, hence why it's discovered here.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/RcppCore/RcppEigen/issues/104#issuecomment-976977032, or unsubscribe https://github.com/notifications/unsubscribe-auth/AV6AXFQAFPBWHHTZ2CM77RTUNPMDFANCNFSM5ITO3ESQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

barracuda156 commented 2 years ago

@kevinushey I have added the path to libRlapack, however I keep getting errors with libppc and lquadmath:

36-137:~ svacchanda$ r

R version 4.1.2 (2021-11-01) -- "Bird Hippie"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: powerpc-apple-darwin10.0.0d2 (32-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> Sys.setenv(arch = "ppc")
> Sys.setenv(compiler = "gcc")
> Sys.setenv(stdlib = "libstdc++")
> install.packages("RcppEigen", type = "source",
+                  dependencies=TRUE,
+                  repos="https://cloud.r-project.org")
Installing package into ‘/Users/svacchanda/Library/R/powerpc/4.1/library’
(as ‘lib’ is unspecified)
also installing the dependency ‘microbenchmark’

trying URL 'https://cloud.r-project.org/src/contrib/microbenchmark_1.4.9.tar.gz'
Content type 'application/x-gzip' length 59607 bytes (58 KB)
==================================================
downloaded 58 KB

trying URL 'https://cloud.r-project.org/src/contrib/RcppEigen_0.3.3.9.1.tar.gz'
Content type 'application/x-gzip' length 1633360 bytes (1.6 MB)
==================================================
downloaded 1.6 MB

Warning in file(con, "r") :
  cannot open file '/var/db/timezone/zoneinfo/+VERSION': No such file or directory
* installing *source* package ‘microbenchmark’ ...
** package ‘microbenchmark’ successfully unpacked and MD5 sums checked
** using staged installation
checking for gcc... /opt/local/bin/gcc-mp-7
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /opt/local/bin/gcc-mp-7 accepts -g... yes
checking for /opt/local/bin/gcc-mp-7 option to accept ISO C89... none needed
checking how to run the C preprocessor... /opt/local/bin/gcc-mp-7 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdint.h... (cached) yes
checking for stdlib.h... (cached) yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for uint64_t... yes
checking for error_at_line... no
checking for mach_absolute_time... yes
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating src/config.h
** libs
/opt/local/bin/gcc-mp-7 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -D_POSIX_C_SOURCE=200112L -DHAVE_CONFIG_H  -I/opt/local/include   -fPIC  -pipe -Os -arch ppc -m32  -c do_nothing.c -o do_nothing.o
/opt/local/bin/gcc-mp-7 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -D_POSIX_C_SOURCE=200112L -DHAVE_CONFIG_H  -I/opt/local/include   -fPIC  -pipe -Os -arch ppc -m32  -c init.c -o init.o
/opt/local/bin/gcc-mp-7 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -D_POSIX_C_SOURCE=200112L -DHAVE_CONFIG_H  -I/opt/local/include   -fPIC  -pipe -Os -arch ppc -m32  -c nanotimer.c -o nanotimer.o
/opt/local/bin/gcc-mp-7 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/opt/local/Library/Frameworks/R.framework/Resources/libppc -L/opt/local/Library/Frameworks/R.framework/Versions/4.1/Resources/lib/ -o microbenchmark.so do_nothing.o init.o nanotimer.o -F/opt/local/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-L/opt/local/Library/Frameworks/R.framework/Resources/libppc'
installing to /Users/svacchanda/Library/R/powerpc/4.1/library/00LOCK-microbenchmark/00new/microbenchmark/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (microbenchmark)
Warning in file(con, "r") :
  cannot open file '/var/db/timezone/zoneinfo/+VERSION': No such file or directory
* installing *source* package ‘RcppEigen’ ...
** package ‘RcppEigen’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
/opt/local/bin/g++-mp-7 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Users/svacchanda/Library/R/powerpc/4.1/library/Rcpp/include' -I/opt/local/include  -I../inst/include -fPIC  -pipe -Os -arch ppc -m32  -c RcppEigen.cpp -o RcppEigen.o
In file included from ../inst/include/Eigen/Core:428:0,
                 from ../inst/include/Eigen/Dense:1,
                 from ../inst/include/RcppEigenForward.h:30,
                 from ../inst/include/RcppEigen.h:25,
                 from RcppEigen.cpp:22:
../inst/include/Eigen/src/Core/functors/BinaryFunctors.h: In constructor 'Eigen::internal::scalar_sum_op<bool, bool>::scalar_sum_op()':
../inst/include/Eigen/src/Core/functors/BinaryFunctors.h:66:20: warning: 'Eigen::internal::scalar_sum_op<bool, bool>::scalar_sum_op()' is deprecated [-Wdeprecated-declarations]
   scalar_sum_op() {}
                    ^
../inst/include/Eigen/src/Core/functors/BinaryFunctors.h:66:3: note: declared here
   scalar_sum_op() {}
   ^~~~~~~~~~~~~
../inst/include/Eigen/src/Core/functors/BinaryFunctors.h: In constructor 'Eigen::internal::scalar_sum_op<bool, bool>::scalar_sum_op()':
../inst/include/Eigen/src/Core/functors/BinaryFunctors.h:66:20: warning: 'Eigen::internal::scalar_sum_op<bool, bool>::scalar_sum_op()' is deprecated [-Wdeprecated-declarations]
   scalar_sum_op() {}
                    ^
../inst/include/Eigen/src/Core/functors/BinaryFunctors.h:66:3: note: declared here
   scalar_sum_op() {}
   ^~~~~~~~~~~~~
/opt/local/bin/g++-mp-7 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Users/svacchanda/Library/R/powerpc/4.1/library/Rcpp/include' -I/opt/local/include  -I../inst/include -fPIC  -pipe -Os -arch ppc -m32  -c RcppExports.cpp -o RcppExports.o
In file included from ../inst/include/Eigen/Core:428:0,
                 from ../inst/include/Eigen/Dense:1,
                 from ../inst/include/RcppEigenForward.h:30,
                 from ../inst/include/RcppEigen.h:25,
                 from RcppExports.cpp:4:
../inst/include/Eigen/src/Core/functors/BinaryFunctors.h: In constructor 'Eigen::internal::scalar_sum_op<bool, bool>::scalar_sum_op()':
../inst/include/Eigen/src/Core/functors/BinaryFunctors.h:66:20: warning: 'Eigen::internal::scalar_sum_op<bool, bool>::scalar_sum_op()' is deprecated [-Wdeprecated-declarations]
   scalar_sum_op() {}
                    ^
../inst/include/Eigen/src/Core/functors/BinaryFunctors.h:66:3: note: declared here
   scalar_sum_op() {}
   ^~~~~~~~~~~~~
../inst/include/Eigen/src/Core/functors/BinaryFunctors.h: In constructor 'Eigen::internal::scalar_sum_op<bool, bool>::scalar_sum_op()':
../inst/include/Eigen/src/Core/functors/BinaryFunctors.h:66:20: warning: 'Eigen::internal::scalar_sum_op<bool, bool>::scalar_sum_op()' is deprecated [-Wdeprecated-declarations]
   scalar_sum_op() {}
                    ^
../inst/include/Eigen/src/Core/functors/BinaryFunctors.h:66:3: note: declared here
   scalar_sum_op() {}
   ^~~~~~~~~~~~~
/opt/local/bin/g++-mp-7 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Users/svacchanda/Library/R/powerpc/4.1/library/Rcpp/include' -I/opt/local/include  -I../inst/include -fPIC  -pipe -Os -arch ppc -m32  -c fastLm.cpp -o fastLm.o
In file included from ../inst/include/Eigen/Core:428:0,
                 from ../inst/include/Eigen/Dense:1,
                 from ../inst/include/RcppEigenForward.h:30,
                 from ../inst/include/RcppEigen.h:25,
                 from fastLm.h:25,
                 from fastLm.cpp:23:
../inst/include/Eigen/src/Core/functors/BinaryFunctors.h: In constructor 'Eigen::internal::scalar_sum_op<bool, bool>::scalar_sum_op()':
../inst/include/Eigen/src/Core/functors/BinaryFunctors.h:66:20: warning: 'Eigen::internal::scalar_sum_op<bool, bool>::scalar_sum_op()' is deprecated [-Wdeprecated-declarations]
   scalar_sum_op() {}
                    ^
../inst/include/Eigen/src/Core/functors/BinaryFunctors.h:66:3: note: declared here
   scalar_sum_op() {}
   ^~~~~~~~~~~~~
../inst/include/Eigen/src/Core/functors/BinaryFunctors.h: In constructor 'Eigen::internal::scalar_sum_op<bool, bool>::scalar_sum_op()':
../inst/include/Eigen/src/Core/functors/BinaryFunctors.h:66:20: warning: 'Eigen::internal::scalar_sum_op<bool, bool>::scalar_sum_op()' is deprecated [-Wdeprecated-declarations]
   scalar_sum_op() {}
                    ^
../inst/include/Eigen/src/Core/functors/BinaryFunctors.h:66:3: note: declared here
   scalar_sum_op() {}
   ^~~~~~~~~~~~~
/opt/local/bin/gcc-mp-7 -I"/opt/local/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Users/svacchanda/Library/R/powerpc/4.1/library/Rcpp/include' -I/opt/local/include   -fPIC  -pipe -Os -arch ppc -m32  -c init.c -o init.o
/opt/local/bin/g++-mp-7 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/opt/local/Library/Frameworks/R.framework/Resources/libppc -L/opt/local/Library/Frameworks/R.framework/Versions/4.1/Resources/lib/ -o RcppEigen.so RcppEigen.o RcppExports.o fastLm.o init.o -L/opt/local/Library/Frameworks/R.framework/Resources/libppc -lRlapack -L/opt/local/Library/Frameworks/R.framework/Resources/libppc -lRblas -L/opt/local/lib/gcc7 -lgfortran -lquadmath -lm -F/opt/local/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-L/opt/local/Library/Frameworks/R.framework/Resources/libppc'
ld: warning: directory not found for option '-L/opt/local/Library/Frameworks/R.framework/Resources/libppc'
ld: warning: directory not found for option '-L/opt/local/Library/Frameworks/R.framework/Resources/libppc'
ld: library not found for -lquadmath
collect2: error: ld returned 1 exit status
make: *** [RcppEigen.so] Error 1
ERROR: compilation failed for package ‘RcppEigen’
* removing ‘/Users/svacchanda/Library/R/powerpc/4.1/library/RcppEigen’
* restoring previous ‘/Users/svacchanda/Library/R/powerpc/4.1/library/RcppEigen’

The downloaded source packages are in
        ‘/private/var/folders/rD/rDeCM6SDHv8daLCecrRmrU+++TI/-Tmp-/RtmpCimVo8/downloaded_packages’
Warning message:
In install.packages("RcppEigen", type = "source", dependencies = TRUE,  :
  installation of package ‘RcppEigen’ had non-zero exit status
kevinushey commented 2 years ago

The warning looks pretty clear to me...

ld: warning: directory not found for option '-L/opt/local/Library/Frameworks/R.framework/Resources/libppc'

Are you sure you input the library path correctly?

barracuda156 commented 2 years ago

The warning looks pretty clear to me...

ld: warning: directory not found for option '-L/opt/local/Library/Frameworks/R.framework/Resources/libppc'

Are you sure you input the library path correctly?

@kevinushey Yes, but there is no such library or directory inside R.framework.

I have specified the path to libRlapack.dylib, as you advised, and that error is gone. I cannot locate libquadmath and libppc though.

barracuda156 commented 2 years ago

Is that possibly the same issue as the one Kevin explained to you in RcppParallel ?

@eddelbuettel Those errors were corrected according to @kevinushey suggestion, and RcppParallel has built successfully. This time the issue is different.

barracuda156 commented 2 years ago

I have found a [temporary] solution here: https://githubmemory.com/repo/fxcoudert/gfortran-for-macOS/issues/24 Specifically, editing the Makeconf of R and removing -lquadmath from the variable FLIBS worked, RcppEigen built.

There might be a way to build libquadmath on PowerPC, but it will require rebuilding gcc: https://patchwork.ozlabs.org/project/gcc/patch/20170816030601.GA18844@ibm-tiger.the-meissners.org (leaving this here for future reference).

eddelbuettel commented 2 years ago

If you don't mind, I am going to close this here as the issue does not really pertain to RcppEigen but more to compilation of R package on a (apparently not exactly widely-used platform of macOS on powerpc). If you do find issues where the package needs adjusting by all means please reopen, or file a new ticket, ideally with something we can reproduce.