float icon indicating copy to clipboard operation
float copied to clipboard

Issue linking in CRAN M1 server

Open david-cortes opened this issue 4 years ago • 3 comments

I'm having issues with the CRAN checks on apple M1 for a package that links to float: https://www.stats.ox.ac.uk/pub/bdr/M1mac/recometrics.log https://www.stats.ox.ac.uk/pub/bdr/M1mac/recometrics.out

Seems the linking is not working:

* installing *source* package ‘recometrics’ ...
** package ‘recometrics’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
clang++ -std=gnu++11 -I"/Users/ripley/R/R-devel/include" -DNDEBUG -D_FOR_R -I'/Users/ripley/R/Library/Rcpp/include' -I'/Users/ripley/R/Library/float/include' -I/opt/R/arm64/include   -fPIC  -g -O2  -c RcppExports.cpp -o RcppExports.o
clang++ -std=gnu++11 -I"/Users/ripley/R/R-devel/include" -DNDEBUG -D_FOR_R -I'/Users/ripley/R/Library/Rcpp/include' -I'/Users/ripley/R/Library/float/include' -I/opt/R/arm64/include   -fPIC  -g -O2  -c Rwrapper.cpp -o Rwrapper.o
clang++ -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Users/ripley/R/R-devel/lib -L/opt/R/arm64/lib -o recometrics.so RcppExports.o Rwrapper.o -L/Users/ripley/R/R-devel/lib -lRblas -L/opt/R/arm64/gfortran/lib/gcc/aarch64-apple-darwin20.2.0/11.0.0 -L/opt/R/arm64/gfortran/lib -lgfortran -lemutls_w -lm -L/Users/ripley/R/Library/float/libs /Users/ripley/R/Library/float/libs/float.so -Wl,-rpath /Users/ripley/R/Library/float/libs -L/Users/ripley/R/R-devel/lib -lR -Wl,-framework -Wl,CoreFoundation
installing to /Users/ripley/R/packages/tests-devel/recometrics.Rcheck/00LOCK-recometrics/00new/recometrics/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘recometrics’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Users/ripley/R/packages/tests-devel/recometrics.Rcheck/00LOCK-recometrics/00new/recometrics/libs/recometrics.so':
  dlopen(/Users/ripley/R/packages/tests-devel/recometrics.Rcheck/00LOCK-recometrics/00new/recometrics/libs/recometrics.so, 6): Library not loaded: float.so
  Referenced from: /Users/ripley/R/packages/tests-devel/recometrics.Rcheck/00LOCK-recometrics/00new/recometrics/libs/recometrics.so
  Reason: image not found
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Users/ripley/R/packages/tests-devel/recometrics.Rcheck/recometrics’
* using log directory ‘/Users/ripley/R/packages/tests-devel/recometrics.Rcheck’
* using R Under development (unstable) (2021-07-15 r80623)
* using platform: aarch64-apple-darwin20.5.0 (64-bit)
* using session charset: UTF-8
* using option ‘--no-stop-on-test-error’
* checking for file ‘recometrics/DESCRIPTION’ ... OK
* checking extension type ... Package
* this is package ‘recometrics’ version ‘0.1.2’
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking for hidden files and directories ... OK
* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking whether package ‘recometrics’ can be installed ... ERROR
Installation failed.
See ‘/Users/ripley/R/packages/tests-devel/recometrics.Rcheck/00install.out’ for details.
* DONE

Status: 1 ERROR
See
  ‘/Users/ripley/R/packages/tests-devel/recometrics.Rcheck/00check.log’
for details.

       12.06 real        10.47 user         1.09 sys

Works fine in other platforms though.

david-cortes avatar Jul 15 '21 16:07 david-cortes

From Prof. Ripley: "At least two issues need to be addressed:

  • float.so is not in general a library.
  • -Wl,-rpath is not portable and may well not do what it does on Linux.

See 'Writing R Extensions' §5.8 for fairly portable solutions."

In 'Writing R Extensions' it mentions that shared objects in mac should end in .dylib and that .so objects are not linkeable there.

It also mentions that rpath is specific to the GNU linker - should packages that link to float perhaps also have a requirement for GNU linker specified? Not sure if adding a variable LD in Makevars + SystemRequires in DESCRIPTION would do though.

david-cortes avatar Jul 16 '21 15:07 david-cortes

Try the static library on mac. See rsparse for example.

The mac needs special treatment such as here as LinkingTo may be for simple usage.

snoweye avatar Jul 19 '21 02:07 snoweye

@snoweye Thanks for the reply. I see nevertheless that the code in that PR is no longer used in the current master branch.Does that mean it is now enough to just use float:::ldflags(static=TRUE) for macOS?

david-cortes avatar Jul 19 '21 15:07 david-cortes