dmurdoch/rgl

rgl fails to load after being built with Abort trap

barracuda156 opened this issue · 13 comments

:info:destroot /opt/local/bin/g++-mp-12 -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/opt/local/Library/Frameworks/R.framework/Resources/lib -Wl,-headerpad_max_install_names -Wl,-rpath,/opt/local/lib/libgcc -L/opt/local/lib -lMacportsLegacySupport -arch ppc -o useNULL.so ABCLineSet.o BBoxDeco.o Background.o ClipPlane.o Color.o Disposable.o Light.o LineSet.o LineStripSet.o Material.o NULLgui.o PlaneSet.o PointSet.o PrimitiveSet.o RenderContext.o Shape.o SphereMesh.o SphereSet.o SpriteSet.o String.o Surface.o TextSet.o Texture.o Viewpoint.o api.o assert.o callbacks.o device.o devicemanager.o fps.o ftgl.o geom.o glErrors.o glgui.o gui.o init.o par3d.o pixmap.o platform.o render.o rglmath.o rglview.o scene.o select.o subscene.o win32gui.o win32lib.o x11gui.o x11lib.o gl2ps.o pretty.o -L/opt/local/lib -lpng16 -F/opt/local/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
:info:destroot installing to /opt/local/var/macports/build/_opt_PPCRosettaPorts_R_R-rgl/R-rgl/work/destroot/opt/local/Library/Frameworks/R.framework/Versions/4.2/Resources/library/00LOCK-rgl-1.0.1/00new/rgl/libs
:info:destroot ** R
:info:destroot ** demo
:info:destroot ** inst
:info:destroot ** byte-compile and prepare package for lazy loading
:info:destroot ** help
:info:destroot *** installing help indices
:info:destroot *** copying figures
:info:destroot ** building package indices
:info:destroot ** installing vignettes
:info:destroot ** testing if installed package can be loaded from temporary location
:info:destroot sh: line 1: 18769 Abort trap              R_TESTS= '/opt/local/Library/Frameworks/R.framework/Resources/bin/R' --no-save --no-restore --no-echo 2>&1 < '/opt/local/var/macports/build/_opt_PPCRosettaPorts_R_R-rgl/R-rgl/work/.tmp/RtmpmASUgg/file446023036b39'
:info:destroot ERROR: loading failed
:info:destroot * removing ‘/opt/local/var/macports/build/_opt_PPCRosettaPorts_R_R-rgl/R-rgl/work/destroot/opt/local/Library/Frameworks/R.framework/Versions/4.2/Resources/library/rgl’
:info:destroot Command failed:  cd "/opt/local/var/macports/build/_opt_PPCRosettaPorts_R_R-rgl/R-rgl/work/rgl-1.0.1" && /opt/local/bin/R CMD INSTALL . --library=/opt/local/var/macports/build/_opt_PPCRosettaPorts_R_R-rgl/R-rgl/work/destroot/opt/local/Library/Frameworks/R.framework/Versions/4.2/Resources/library 
:info:destroot Exit code: 1
:error:destroot Failed to destroot R-rgl: command execution failed
:debug:destroot Error code: CHILDSTATUS 17500 1
:debug:destroot Backtrace: command execution failed
:debug:destroot     while executing
:debug:destroot "system {*}$notty {*}$callback {*}$nice $fullcmdstring"
:debug:destroot     invoked from within
:debug:destroot "command_exec -callback portprogress::target_progress_callback destroot"
:debug:destroot     (procedure "portdestroot::destroot_main" line 2)
:debug:destroot     invoked from within
:debug:destroot "$procedure $targetname"

macOS 10.6.8 Rosetta, gcc 12.2.0, R 4.2.2, rgl 1.0.1

EDIT: Oops, it still cannot load even after fixing paths to X11.

What it links to:

svacchanda$ otool -L /opt/local/var/macports/build/_opt_PPCRosettaPorts_R_R-rgl/R-rgl/work/destroot/opt/local/Library/Frameworks/R.framework/Versions/4.2/Resources/library/rgl/libs/rgl.so 
/opt/local/var/macports/build/_opt_PPCRosettaPorts_R_R-rgl/R-rgl/work/destroot/opt/local/Library/Frameworks/R.framework/Versions/4.2/Resources/library/rgl/libs/rgl.so:
	rgl.so (compatibility version 0.0.0, current version 0.0.0)
	/opt/local/lib/libMacportsLegacySupport.dylib (compatibility version 1.0.0, current version 1.0.7)
	/opt/local/lib/libGLU.1.dylib (compatibility version 5.0.0, current version 5.1.0)
	/opt/local/lib/libGL.1.dylib (compatibility version 4.0.0, current version 4.0.0)
	/opt/local/lib/libpng16.16.dylib (compatibility version 56.0.0, current version 56.0.0)
	/opt/local/lib/libX11.6.dylib (compatibility version 11.0.0, current version 11.0.0)
	/opt/local/lib/libfreetype.6.dylib (compatibility version 25.0.0, current version 25.3.0)
	/opt/local/lib/libbz2.1.0.dylib (compatibility version 1.0.0, current version 1.0.8)
	/opt/local/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.13)
	/opt/local/lib/libbrotlidec.1.dylib (compatibility version 1.0.0, current version 1.0.9)
	/opt/local/lib/libbrotlicommon.1.dylib (compatibility version 1.0.0, current version 1.0.9)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 550.44.0)
	/opt/local/lib/libgcc/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.30.0)
	/opt/local/Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libR.dylib (compatibility version 4.2.0, current version 4.2.2)
	/opt/local/lib/libgcc/libgcc_s.1.1.dylib (compatibility version 1.0.0, current version 1.1.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)

Okay, perhaps it should not use quartz on <10.7:

Error: package or namespace load failed for ‘rgl’:
 .onLoad failed in loadNamespace() for 'rgl', details:
  call: grDevices::quartz()
  error: unable to create quartz() device target, given type may not be supported
In addition: Warning message:
In grDevices::quartz() :
  Requested on-screen area is too large (4503601774854144.0 by 7.0 inches).

@dmurdoch Could you advise me how to switch to Mesa/X11 implementation instead of broken Apple XQuarts? --disable-cocoa is not recognized, --with-x does not switch to X11.

After spending quite a while now on tweaking the build I was able to get a loading lib, however without OpenGL altogether, as it seems:

> library(rgl)
This build of rgl does not include OpenGL functions.  Use
 rglwidget() to display results, e.g. via options(rgl.printRglwidget = TRUE).

I would like to have OpenGL, but use a generic Unix fallback.

I don't know if that's possible. You would need to modify the configure.ac autoconf script so it didn't try to find the libs from XQuartz.

@dmurdoch Thank you. That is an obvious, but suboptimal solution (as I hoped, expecting a config switch). Will do manually then.

I've just committed some big changes to the low level parts of rgl. Along the way, I noticed that on MacOS, it has been using Mesa all along. It uses the X11 code from Xquartz; to override that you should only need to set --x-includes=DIR and --x-libraries=DIR when you build.

@dmurdoch As I understand, the problem was in grDevices::quartz(); obviously, Quartz is not supported on 10.6, and R is built with X11 backend instead: https://github.com/macports/macports-ports/blob/0c1ff00a3965b76820031b80ac78c5e0281497ab/math/R/Portfile#L234-L244

grDevices is an appendix to R itself, so presumably it won’t have Quartz, and therefore the call above fails.

I did try using --x-includes= and --x-libraries=: https://github.com/macports/macports-ports/blob/0c1ff00a3965b76820031b80ac78c5e0281497ab/R/R-rgl/Portfile#L32-L37
The problem was I either got a load failure or otherwise no GL support. (For now, I explicitly disabled GL in the portfile, to keep code simpler; but it is not awesome, obviously.)

rgl and grDevices have very little to do with each other.

I don't know what the issue is, but I'd guess you'll get different results after today's update. (Maybe just different errors.)

But even if you don't get rgl displaying within R, you can still display in a browser using rglwidget().

@dmurdoch What happened to the update btw? CRAN is still at 1.0.1 after three weeks.

I made submissions on March 13. I got a rejection on March 17, which I believe was unrelated to rgl, and I reported that to them. Nothing more since then.

If you can build rgl yourself, I think the head of the master branch is currently stable. You could also use SHA 492f253, which is what was submitted to CRAN and has undergone much more testing.

If you can't get the build to work, let me know your R version and your OS, and I might be able to build a binary package for you.

@dmurdoch CRAN published 1.1.3 now, but apparently nothing changed in discussed context: either rgl fails to load:

** testing if installed package can be loaded from temporary location
sh: line 1: 23777 Abort trap              R_TESTS= '/opt/local/Library/Frameworks/R.framework/Resources/bin/R' --no-save --no-restore --no-echo 2>&1 < '/opt/local/var/macports/build/_opt_PPCRosettaPorts_R_R-rgl/R-rgl/work/.tmp/RtmprMZ6Dt/file5807388420cc'
ERROR: loading failed
* removing ‘/opt/local/var/macports/build/_opt_PPCRosettaPorts_R_R-rgl/R-rgl/work/destroot/opt/local/Library/Frameworks/R.framework/Versions/4.2/Resources/library/rgl’
Command failed:  cd "/opt/local/var/macports/build/_opt_PPCRosettaPorts_R_R-rgl/R-rgl/work/rgl-1.1.3" && /opt/local/bin/R CMD INSTALL . --configure-args=' --with-x --x-includes=/opt/local/include/X11 --x-libraries=/opt/local/lib ' --library=/opt/local/var/macports/build/_opt_PPCRosettaPorts_R_R-rgl/R-rgl/work/destroot/opt/local/Library/Frameworks/R.framework/Versions/4.2/Resources/library 
Exit code: 1

Or it builds fine, but with --disable-opengl being passed.

10:~ svacchanda$ r

R version 4.2.3 (2023-03-15) -- "Shortstop Beagle"
Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: powerpc-apple-darwin10.8.0 (32-bit)

> library("rgl")
This build of rgl does not include OpenGL functions.  Use
 rglwidget() to display results, e.g. via options(rgl.printRglwidget = TRUE).

That's too bad. I really can't offer any advice -- I don't use Macports, and I don't use MacOS 10.6. If you can put together a small PR that fixes this I'd consider it, but generally speaking I only target the build chain that CRAN uses.