-
-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure igraph can be installed in webR #1284
Comments
Also reported at r-wasm/webr#341. I had another look at it this today. The main blocker is the Fortran library The If you aren't actually using the debugging functionality in I just tried it for myself, commenting out the blocks: rigraph/src/vendor/arpack/debug.h Lines 12 to 16 in 4f4fce5
and rigraph/src/vendor/arpack/stat.h Lines 16 to 21 in 4f4fce5
by prepending a With this change, the R package is able to be compiled for WebAssembly. Next, once compiled the package still does not load, with error:
This is a WebAssembly issue occurring when loading a Lapack symbol. Unlike most systems, function signatures must be declared consistently for WebAssembly symbols. R's built-in Lapack implementation declares Fortran subroutines as returning rigraph/src/vendor/cigraph/src/linalg/lapack_internal.h Lines 147 to 153 in 4f4fce5
In addition, extra so-called "hidden" Fortran character length arguments are missing from some of the function signatures in that file. Normally, these differences do not matter much, but under WebAssembly it does. I continued to experiment, switching After these further changes, the package loads under webR. I am not very familiar with how to use igraph, but basic functionality seems to work: I have updated the igraph package on the webR binary Wasm package repository, so you can try this version out for yourself at https://webr.r-wasm.org/latest/ now using And, a summary of the changes I've made is here: main...r-wasm:rigraph:webr. While these workarounds seem to get things up and running for Wasm, I don't really know how safe they are for the more traditional R systems. Applying them as-is means editing vendored source code, and might even break the package for normal Linux, Windows and macOS users. Nevertheless, this should give you an idea of what the path looks like in the long term for webR compatibility. For formal changes to the C source code, it's possible to make specific changes for Wasm gated behind Another option might be to simply wait until our version of the LLVM Flang compiler better supports In the meantime, I am happy to maintain the fork at https://github.com/r-wasm/rigraph/tree/webr, we already do so for some other R packages that require patches for Wasm. That might be the simplest solution in the short term. |
With the C core we bundle an older version of ARPACK that was translated to C with f2c. This would probably trigger compiler warnings on CRAN, so it's not option there, but could it be used with webR? |
Perhaps, can you please send me a link to one of the However, note that the rigraph/src/vendor/cigraph/vendor/lapack/dgeev.c Lines 209 to 212 in 4f4fce5
So, we'd still have to deal with the |
I'm sorry, you are correct. The The lack of a standard interface between C and Fortran (with older Fortran) tends to be an issue ... |
Should we use the f2c translation also for the R package? Any downsides? |
Many downsides. Worse performance, compiler warnings are likely, manual fix for warnings is not realistic, outdated ARPACK version. Upside: No need for a Fortran compiler, no issues with calling conventions (as discussed here), anyone can compile the igraph C core with minimal technical experience (which is important given our userbase) The upsides don't all apply for the R interface ... |
@georgestagg: Is there anything we can do to help? I'd like to create a webR demo for igraph and dm.
The text was updated successfully, but these errors were encountered: