-
Notifications
You must be signed in to change notification settings - Fork 250
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
wasm wheel #560
Comments
It's amazing what you can do in the browser nowadays. I don't have any experience with these tools, but it seems quite sure that you also need to convert the C glue code in this module to Some additional hackery might be required, because |
Did you try this with version 0.9? Would you be able to check whether it works without issues for the 0.10 pre-release as well? Here's a tarball. |
@szhorvat |
No progress from my side yet. I'm collecting a few things:
|
Almost done (I think). I patched setup.py to invoke emcmake and then run
Now, while linking of the C extensions I'm facing the following problems:
|
The issues about As for |
igraph/igraph@c307fc4 changes the diff --git a/vendor/lapack/dneupd.c b/vendor/lapack/dneupd.c
index 4dc419ac6..442d9d0b5 100644
--- a/vendor/lapack/dneupd.c
+++ b/vendor/lapack/dneupd.c
@@ -331,7 +331,7 @@ static doublereal c_b71 = -1.;
/* Builtin functions */
double pow_dd(doublereal *, doublereal *);
integer s_cmp(char *, char *, ftnlen, ftnlen);
- /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
+ /* Subroutine */ void s_copy(char *, char *, ftnlen, ftnlen);
/* Local variables */
integer j, k, ih;
diff --git a/vendor/lapack/dormhr.c b/vendor/lapack/dormhr.c
index 6ff1704d4..d7c170f06 100644
--- a/vendor/lapack/dormhr.c
+++ b/vendor/lapack/dormhr.c
@@ -205,7 +205,7 @@ f">
char ch__1[2];
/* Builtin functions
- Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen);
+ Subroutine */ void s_cat(char *, char **, integer *, integer *, ftnlen);
/* Local variables */
integer i1, i2, nb, mi, nh, ni, nq, nw; |
This is Bison version dependent, we should not change it arbitrarily. |
I don't remember the details but I seemed to recall that we've been here and changed that return type back and forth at least once. This function is generated by Flex. I checked that both the latest released version as well as the ancient version included with macOS use Note that we use these functions with |
Did you provide a custom Or does this method of compiling produce actually runnable executables? @flange-ipb I am asking this to decide how much more testing we need to do on cross-compilation. |
Flex generates |
The attached patch now makes the compilation work with the most recent |
@flange-ipb Do you know why @ntamas If it is truly a hard requirement that the signatures should match, I worry that there will be problems with the code that casts functions to a different signature before calling them. Specifically, the flex destructors that were changed to an int (as a response to this issue) are cast to a void return type in |
Sanitizers did not reveal anything so I'm pretty convinced that it doesn't cause problems. But, just to be on the safe side, we can wrap them in a wrapper that truly returns |
At least in C89, it is legal to call functions with no prototype at all. So this should be fine, no? As for the changes to |
Re the changes to https://github.com/juanjosegarciaripoll/f2c/blob/master/lib/s_cat.c So I dug around a bit more, and it turns out that there's a macro named |
The In C, the default return type is |
P.S. We definitely don't want to activate using the ancient K&R style definitions. |
The second to last paragraph of this Wikipedia article section confirms that the original K&R C did not support the This is almost certainly the reason for this setup in f2c, which means that we should go ahead and just change those |
Committed the prototype changes and updated the Python interface so now both the |
Amazing! So much activity here. 😃 @szhorvat
During build configuration there is a warning:
Nevertheless, the build does not fail.
The following #define IEEE_8087
#define Arith_Kind_ASL 1
#define Double_Align
#define NANCHECK
#define QNaN0 0x0
#define QNaN1 0x7ff80000 I guess it is generated via the following rule in
Do you refer to the executables in |
I also ran the tests with
|
Thank you, this answers my question. Unlike during normal cross-compilation, the system is able to run This means that we still need to test igraph in a more traditional cross-compilation environment before the 0.10 release. |
Tests whose output is verified are executed differently, through We'll get back to this in time, but there may be a pause in activity here for a week or two from now on. |
The key is probably to use CROSSCOMPILING_EMULATOR when using |
Indeed, this is what I also just found. I'm checking Emscripten's documentation ... |
The information necessary for the detection of Emscripten is not available in
|
Alright, I'm able to build the wasm wheel with the current master branch of igraph. 😃
|
@flange-ipb Could you please try to build C/igraph from the latest |
Thanks @flange-ipb ! Now both of those two tests pass. This is quite strange, as all I did was add a final newline to the output. |
@hoodmane Is thread local storage supposed to work with emscripten? |
We don't build with threading enabled because it doesn't work correctly with dynamic linking right now. Thread local storage should work because it should just fall back to global storage. |
@hoodmane |
@hoodmane |
I just wanted to post something similar; it seems like supporting wasm builds is near-zero effort from our side, we just need to have a reliable way of detecting whether we are being invoked from |
Our documentation currently suggests:
https://pyodide.org/en/stable/usage/faq.html#how-to-detect-that-code-is-run-with-pyodide |
I should have kept my eyes open. 🤦 @ntamas Do you want to add it or should I PR it? (to the develop branch or to master?) |
Please send a PR to |
The out of tree build system applies an abi tag based on `PYODIDE_EMSCRIPTEN_VERSION` in `Makefile.envs`. Prior to this PR, it will happily accept the version of emscripten (say 3.1.18) and produce a wheel tagged like it was produced from the expected Emscripten version (say 3.1.14). This causes confusing errors due to ABI mismatch see igraph/python-igraph#560. This error message should help prevent such confusion.
The out of tree build system applies an abi tag based on `PYODIDE_EMSCRIPTEN_VERSION` in `Makefile.envs`. Prior to this PR, it will happily accept the version of emscripten (say 3.1.18) and produce a wheel tagged like it was produced from the expected Emscripten version (say 3.1.14). This causes confusing errors due to ABI mismatch see igraph/python-igraph#560. This error message should help prevent such confusion.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
PR pending so removing stale label. |
i noticed when building wasm wheel with "setup.py bdist_wheel", that C headers are added to the wheel. Would not it be better to SKIP_HEADER_INSTALL (and maybe script too ) when including headers adds probably useless size to the wheel and may cause problems with pypa/installer |
I'm fine with that if you say it's unnecessary (I'm not faimilar with |
@ntamas yes it could but i was talking it in a more generic way, it seems to me that PR 561 is targeted only at pyodide as shown by the Tbh i'm a pyodide contributor but sysconfig should be all that is needed, my cpython-wasm - not pyodide specific and mvp - wheel build seems to work fine with main...pmp-p:python-igraph-wasm:wasm-wheel ( beware i'm not qualified to test the wheel i'm waiting for feedback from an actual python-igraph user ) imho the pyodide check should be reserved to decide if library must be normalized or not ( bigints support expected from all the runtime - pyodide's way - not really wasm mvp 1.0 compliant ) |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions. |
#561 is now merged so this is done; wasm wheels are now generated in CI. |
igraph 0.10.5 was released with a @flange-ipb Do you know anything about whether |
@flange-ipb In what situation, and how, would one use these wasm wheels? I'm not into web technologies, but I'd like to take the opportunity to show off that igraph is prepared for this already. Tips would be appreciated. (Otherwise I just go with an |
This Jupyter demo has python-igraph available by default, but it's a very old version, 0.10.6: https://jupyter.org/try-jupyter/ I wonder who would need to be contacted to have it updated. Pyodide has 0.11.4 now. |
The out of tree build system applies an abi tag based on `PYODIDE_EMSCRIPTEN_VERSION` in `Makefile.envs`. Prior to this PR, it will happily accept the version of emscripten (say 3.1.18) and produce a wheel tagged like it was produced from the expected Emscripten version (say 3.1.14). This causes confusing errors due to ABI mismatch see igraph/python-igraph#560. This error message should help prevent such confusion.
Hi folks!
I'd like to use the igraph library inside the Pyodide environment. With their latest release, they added the possibility to load binary wheels specifically built for WebAssembly. Having such wheels deployed at PyPI would be fantastic.
I already figured out how cross-compile the igraph C library to wasm using Emscripten. Thanks to the existing cmake infrastructure, this is pretty easy.
emcmake cmake .. -DIGRAPH_WARNINGS_AS_ERRORS:BOOL=OFF
(Emscripten seems to be a bit more pedantic than gcc)I'm not sure how to proceed now. I guess the C glue code in this repo also needs to be compiled to wasm.
The text was updated successfully, but these errors were encountered: