Skip to content

Add and test Emscripten/WASM compilation#23

Merged
ilayn merged 10 commits into
ilayn:mainfrom
agriyakhetarpal:emscripten
Jul 8, 2026
Merged

Add and test Emscripten/WASM compilation#23
ilayn merged 10 commits into
ilayn:mainfrom
agriyakhetarpal:emscripten

Conversation

@agriyakhetarpal

@agriyakhetarpal agriyakhetarpal commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

See #19 (comment)

This PR sets up BLIS compiled to WASM (using my patches in Pyodide) and CMocka compiled to WASM, then runs the test suite by compiling semicolon-lapack to WASM.

I see that you merge PRs with a merge commit instead of squashing/rebasing, so I will rebase my commits accordingly so as to have a cleaner commit history (this is mostly rough work with unclean commit history, which I committed after testing stuff out over the weekend).

xref pyodide/pyodide-recipes#604, pyodide/pyodide-recipes#609 and pyodide/pyodide-recipes#610, and flame/blis#491.

@agriyakhetarpal

Copy link
Copy Markdown
Contributor Author

The 480 tests (and thousands of subtests) are all green! See https://github.com/agriyakhetarpal/semicolon-lapack/actions/runs/28874908379/job/85647289889?pr=1 🎉

@ilayn

ilayn commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Ah very cool, thanks a lot for this. Finally all pieces are coming together.

I see that you merge PRs with a merge commit instead of squashing/rebasing, so I will rebase my commits accordingly so as to have a cleaner commit history

That's my bad, whatever that button is set up for, I just click it without thinking too much. I really don't have any preferences so please use whichever style you prefer. If you want to squash it for a single functionality that would be indeed better. But in general as long as it is kinda sorta clean I don't think I would care either way.

I also saw that during build process emscripten has an extension that leads to warnings, which is probably why it is busy printing tons of stuff like

 [980/3580] Compiling C object src/libsemilapack.a.p/s_strtrs.c.o
[981/3580] Compiling C object src/libsemilapack.a.p/s_strttp.c.o
[982/3580] Compiling C object src/libsemilapack.a.p/s_strttf.c.o
[983/3580] Compiling C object src/libsemilapack.a.p/z_dzsum1.c.o
[984/3580] Compiling C object src/libsemilapack.a.p/z_izmax1.c.o
[985/3580] Compiling C object src/libsemilapack.a.p/z_ilazlr.c.o
../src/z/ilazlr.c:33:23: warning: complex initialization specifying real and imaginary components is an extension [-Wcomplex-component-init]
   33 |     const c128 zero = CMPLX(0.0, 0.0);
      |                       ^~~~~~~~~~~~~~~
/home/runner/work/_temp/fd95dd82-078c-4694-be0f-9cba4b7fadf0/emsdk-main/upstream/emscripten/cache/sysroot/include/complex.h:125:21: note: expanded from macro 'CMPLX'
  125 | #define CMPLX(x, y) __CMPLX(x, y, double)
      |                     ^~~~~~~~~~~~~~~~~~~~~
/home/runner/work/_temp/fd95dd82-078c-4694-be0f-9cba4b7fadf0/emsdk-main/upstream/emscripten/cache/sysroot/include/complex.h:121:40: note: expanded from macro '__CMPLX'
  121 | #define __CMPLX(x, y, t) (+(_Complex t){ (t)(x), (t)(y) })
      |                                        ^~~~~~~~~~~~~~~~~~
1 warning generated.
[986/3580] Compiling C object src/libsemilapack.a.p/s_stzrzf.c.o
[987/3580] Compiling C object src/libsemilapack.a.p/z_ilazlc.c.o
../src/z/ilazlc.c:33:23: warning: complex initialization specifying real and imaginary components is an extension [-Wcomplex-component-init]
   33 |     const c128 zero = CMPLX(0.0, 0.0);
      |                       ^~~~~~~~~~~~~~~
/home/runner/work/_temp/fd95dd82-078c-4694-be0f-9cba4b7fadf0/emsdk-main/upstream/emscripten/cache/sysroot/include/complex.h:125:21: note: expanded from macro 'CMPLX'
  125 | #define CMPLX(x, y) __CMPLX(x, y, double)
      |                     ^~~~~~~~~~~~~~~~~~~~~
/home/runner/work/_temp/fd95dd82-078c-4694-be0f-9cba4b7fadf0/emsdk-main/upstream/emscripten/cache/sysroot/include/complex.h:121:40: note: expanded from macro '__CMPLX'
  121 | #define __CMPLX(x, y, t) (+(_Complex t){ (t)(x), (t)(y) })
      |                                        ^~~~~~~~~~~~~~~~~~
1 warning generated.
[988/3580] Compiling C object src/libsemilapack.a.p/z_zcposv.c.o
../src/z/zcposv.c:113:25: warning: complex initialization specifying real and imaginary components is an extension [-Wcomplex-component-init]
  113 |     const c128 NEGONE = CMPLX(-1.0, + 0.0);
      |                         ^~~~~~~~~~~~~~~~~~
/home/runner/work/_temp/fd95dd82-078c-4694-be0f-9cba4b7fadf0/emsdk-main/upstream/emscripten/cache/sysroot/include/complex.h:125:21: note: expanded from macro 'CMPLX'
  125 | #define CMPLX(x, y) __CMPLX(x, y, double)
      |                     ^~~~~~~~~~~~~~~~~~~~~
/home/runner/work/_temp/fd95dd82-078c-4694-be0f-9cba4b7fadf0/emsdk-main/upstream/emscripten/cache/sysroot/include/complex.h:

I did not check but is it possible to use a silencer for that like -Wno-complex-component-init or something?

@ilayn

ilayn commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Looks good @agriyakhetarpal thanks again. There is one more flag that is lighting up but I can do it with the next PR anyways. So in it goes.

@ilayn
ilayn merged commit 90c9315 into ilayn:main Jul 8, 2026
5 checks passed
@agriyakhetarpal

Copy link
Copy Markdown
Contributor Author

Thank you!

While looking at this locally, I also had a bit of a TIL. Leaving it here since it might be interesting (but I assume you already know all this)!

What I found is more about the Apple SDK than Emscripten. Since Emscripten is based on LLVM-Clang, I kind of expected Clang in a native build on my macOS machine to show these warnings as well. However, even with -Wcomplex-component-init and -Weverything, AppleClang did not emit anything. I did some digging about this, and found that the reason is more about the libc and not about the compiler :D

This is what macOS's libc does for the CMPLX definition – and quite cheekily too at the macro expansion site itself, in my opinion:

#define CMPLX(__real,__imag) \
  _Pragma("clang diagnostic push") \
  _Pragma("clang diagnostic ignored \"-Wcomplex-component-init\"") \
  (double _Complex){(__real),(__imag)} \
  _Pragma("clang diagnostic pop")

Emscripten uses MUSL, whose <complex.h> defines __CMPLX(x, y, t) (+(_Complex t){ (t)(x), (t)(y) }) with no such pragma guard.

So I thought it made sense not to limit this to Emscripten specifically, since theoretically a Linux/non-Apple Clang build could show these warnings against a more standard glibc/MUSL.

I can take a look at adding more flags (you merged as I was writing this comment, so thanks for raising that!).

@ilayn

ilayn commented Jul 8, 2026

Copy link
Copy Markdown
Owner

I should have guessed. In the early versions of this library I had so many issues with it that I was about to give up on MacOSX. So many "liberal" changes done over the years that is making things seriously difficult. But glad that it is not detrimental.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants