<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Jupyter Blog - Isabel Paredes</title><link href="https://jasongrout.github.io/medium-archive/pelican/" rel="alternate"/><link href="https://jasongrout.github.io/medium-archive/pelican/feeds/author-isabel-paredes.atom.xml" rel="self"/><id>https://jasongrout.github.io/medium-archive/pelican/</id><updated>2025-10-16T15:04:00+00:00</updated><subtitle>The Project Jupyter blog: news, releases, and community stories, archived from blog.jupyter.org.</subtitle><entry><title>GNU Octave Meets JupyterLite: Compute Anywhere, Anytime!</title><link href="https://jasongrout.github.io/medium-archive/pelican/posts/2025/gnu-octave-meets-jupyterlite-compute-anywhere-anytime/" rel="alternate"/><published>2025-10-16T15:04:00+00:00</published><updated>2025-10-16T15:04:00+00:00</updated><author><name>Isabel Paredes</name></author><id>tag:jasongrout.github.io,2025-10-16:/medium-archive/pelican/posts/2025/gnu-octave-meets-jupyterlite-compute-anywhere-anytime/</id><summary type="html">&lt;p&gt;We are thrilled to announce the newest member of our JupyterLite kernel ecosystem: Xeus-Octave. Xeus-Octave allows you to run GNU Octave…&lt;/p&gt;
</summary><content type="html">&lt;p&gt;&lt;img src="https://jasongrout.github.io/medium-archive/pelican/posts/2025/gnu-octave-meets-jupyterlite-compute-anywhere-anytime/images/001-1__Ha5vHmLH66mSH3WFg1fxg.jpg" alt="Octave-lite logo" loading="lazy" data-body-image=""&gt;&lt;/p&gt;
&lt;p&gt;We are thrilled to announce the newest member of our JupyterLite kernel ecosystem: &lt;strong&gt;Xeus-Octave&lt;/strong&gt;. Xeus-Octave allows you to run GNU Octave code directly on your browser. GNU Octave is a free and open-source Scientific Programming Language that can be used to run Matlab scripts. In this article, we present the challenges encountered when targeting WebAssembly, the current state of the Xeus-Octave kernel, and the future plans for expanding the GNU Octave ecosystem.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;Earlier this year, we introduced the JupyterLite kernel for R, &lt;a href="/posts/2025/r-in-the-browser-announcing-our-webassembly/"&gt;&lt;strong&gt;Xeus-R-Lite&lt;/strong&gt;&lt;/a&gt;. Much like R, cross-compiling GNU Octave to WebAssembly required the same custom toolchain to enable the compilation of Fortran code, combining LLVM Flang and Emscripten.&lt;/p&gt;
&lt;p&gt;Similar to many other mathematically oriented language packages, GNU Octave requires a BLAS/LAPACK implementation. Fortunately, OpenBLAS and the Netlib implementations of BLAS/LAPACK had already been added to the emscripten-forge WebAssembly distribution. Initially, OpenBLAS was the preferred implementation, but for the successful compilation of Octave, Netlib LAPACK was selected as it presented fewer hurdles during the build process.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="cross-compilation-of-gnu-octave"&gt;Cross-Compilation of GNU Octave&lt;/h2&gt;
&lt;p&gt;One of the complications of cross-compiling Octave to WebAssembly, which had not been encountered with the R source code, was the extensive use of Fortran common symbols blocks in the internal libraries of Octave such as odepack.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;liboctave&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;external&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;odepack&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;slsode&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;
&lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="o"&gt;-----------------------------------------------------------------------&lt;/span&gt;
&lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;The&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;following&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;internal&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Common&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;block&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;contains&lt;/span&gt;
&lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;variables&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;which&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;are&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;local&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;any&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;subroutine&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;but&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;whose&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;must&lt;/span&gt;
&lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="n"&gt;be&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;preserved&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;between&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;calls&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;routine&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;own&amp;quot;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;variables&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;and&lt;/span&gt;
&lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;variables&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;which&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;are&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;communicated&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;between&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;subroutines&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;The&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;block&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;SLS001&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;is&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;declared&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;subroutines&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;SLSODE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;SINTDY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;SSTODE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;SPREPJ&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;and&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;SSOLSY&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Groups&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;variables&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;are&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;replaced&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;by&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;dummy&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;arrays&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Common&lt;/span&gt;
&lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;declarations&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;routines&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;where&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;those&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;variables&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;are&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;not&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;used&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="o"&gt;-----------------------------------------------------------------------&lt;/span&gt;
&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="n"&gt;COMMON&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;SLS001&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;CONIT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;CRATE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;EL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ELCO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="n"&gt;HOLD&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;RMAX&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;TESCO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="n"&gt;CCMAX&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;EL0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;H&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;HMIN&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;HMXI&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;HU&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;RC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;TN&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;UROUND&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="n"&gt;INIT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MXSTEP&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MXHNIL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;NHNIL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;NSLAST&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;NYH&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="n"&gt;IALTH&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;IPUP&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LMAX&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MEO&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;NQNYH&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;NSLP&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="n"&gt;ICF&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;IERPJ&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;IERSL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;JCUR&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;JSTART&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;KFLAG&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;L&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="n"&gt;LYH&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LEWT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LACOR&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LSAVF&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LWM&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;LIWM&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;METH&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MITER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="n"&gt;MAXORD&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MAXCOR&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MSBP&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;MXNCF&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;NQ&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;NST&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;NFE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;NJE&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;NQU&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Initially, it was not possible to cross-compile these common blocks to WebAssembly because the latest version of LLVM (v20 at the time of testing) did not support common symbol linkage.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="c1"&gt;// Source: llvm/lib/MC/MCWasmStreamer.cpp&lt;/span&gt;
&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;MCWasmStreamer::emitCommonSymbol&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MCSymbol&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;S&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;uint64_t&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Size&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="w"&gt;                                      &lt;/span&gt;&lt;span class="n"&gt;Align&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ByteAlignment&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="n"&gt;llvm_unreachable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;Common symbols are not yet implemented for Wasm&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;As a temporary solution, LLVM was patched with the help of &lt;a href="https://github.com/serge-sans-paille"&gt;Serge Guelton&lt;/a&gt; to simulate common symbols as weak symbols.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;void MCWasmStreamer::emitCommonSymbol(MCSymbol *S, uint64_t Size,
&lt;span class="w"&gt; &lt;/span&gt;                                     Align ByteAlignment) {
&lt;span class="gd"&gt;-  llvm_unreachable(&amp;quot;Common symbols are not yet implemented for Wasm&amp;quot;);&lt;/span&gt;
&lt;span class="gi"&gt;+  auto *Symbol = cast&amp;lt;mcsymbolwasm&amp;gt;(S);&lt;/span&gt;
&lt;span class="gi"&gt;+  getAssembler().registerSymbol(*Symbol);&lt;/span&gt;
&lt;span class="gi"&gt;+  Symbol-&amp;gt;setWeak(true);&lt;/span&gt;
&lt;span class="gi"&gt;+  Symbol-&amp;gt;setExternal(true);&lt;/span&gt;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;A proper solution to enable support of common symbols is currently in progress and will likely be included in the next release of LLVM v22 (see &lt;a href="https://github.com/llvm/llvm-project/pull/151478"&gt;llvm-project/pull/151478&lt;/a&gt;). For curious readers, the patched version of LLVM can be found &lt;a href="https://github.com/IsabelParedes/llvm-project/releases/download/v20.1.7_emscripten-wasm32/llvm_emscripten-wasm32-20.1.7-h2e33cc4_5.tar.bz2"&gt;here&lt;/a&gt; (linux only).&lt;/p&gt;
&lt;p&gt;In addition to the patches for LLVM, GNU Octave required a few minor modifications to target WebAssembly; mainly this entailed disabling the GUI functionalities and consolidating the Fortran function signatures and calling conventions. A full list of patches can be found in the &lt;a href="https://github.com/emscripten-forge/recipes/tree/main/recipes/recipes_emscripten/octave/patches"&gt;recipe directory&lt;/a&gt; on emscripten-forge.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="xeus-octave"&gt;Xeus-Octave&lt;/h2&gt;
&lt;p&gt;Once GNU Octave had been successfully packaged for WebAssembly, bringing &lt;a href="https://github.com/jupyter-xeus/xeus-octave"&gt;Xeus-Octave&lt;/a&gt; to JupyterLite was a simple matter of adding a recipe to &lt;a href="https://github.com/emscripten-forge/recipes/"&gt;emscripten-forge&lt;/a&gt;!&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="A JupyterLite notebook demonstrating plots with Xeus-Octave" src="https://jasongrout.github.io/medium-archive/pelican/posts/2025/gnu-octave-meets-jupyterlite-compute-anywhere-anytime/images/002-1_lKsfXJGc7_tM1ONU5Ej0Ng.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;&lt;a href="https://jupyter-xeus.github.io/xeus-octave/lab/?path=xeus-octave-wasm.ipynb"&gt;&lt;strong&gt;Try Xeus-Octave in JupyterLite!&lt;/strong&gt;&lt;/a&gt;&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;hr&gt;
&lt;h2 id="future-work"&gt;Future Work&lt;/h2&gt;
&lt;p&gt;For our next steps, the team is planning on expanding the Octave ecosystem by adding Octave packages to both conda-forge and emscripten-forge. The packaging work will require defining a process where Octave packages can be installed in predetermined conda environments, perhaps with some minor modifications to the existing pkg utility.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="about-the-author"&gt;About the Author&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Isabel Paredes&lt;/strong&gt;, who led the charge on bringing GNU Octave to emscripten-forge, is a senior scientific software developer at QuantStack. Prior to working on this project, she focused on porting the R programming language and the Robot Operating System (ROS) framework to WebAssembly.&lt;/p&gt;
&lt;h2 id="acknowledgments"&gt;Acknowledgments&lt;/h2&gt;
&lt;p&gt;This project synthesizes work from many open-source contributors.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/emscripten-forge/recipes/"&gt;&lt;strong&gt;Emscripten-forge&lt;/strong&gt;&lt;/a&gt;, the distribution of conda packages for WebAssembly, was created by Thorsten Beier, who continues to lead the project. Many recipes were contributed by Isabel Paredes, Anutosh Bhat, Martin Renou, Ian Thomas, Wolf Vollprecht, and Johan Mabille.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://jupyterlite.readthedocs.io/en/stable/?badge=latest"&gt;&lt;strong&gt;JupyterLite&lt;/strong&gt;&lt;/a&gt;, the Jupyter distribution that runs entirely in the web browser, was created by Jeremy Tuloup.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/jupyter-xeus/xeus"&gt;&lt;strong&gt;Xeus&lt;/strong&gt;&lt;/a&gt;, the C++ library implementing the Jupyter kernel protocol, enabling a custom communication layer, and is foundational to kernels like xeus-r, xeus-python, running in JupyterLite, was created by Johan Mabille and is maintained by a broader team including Martin Renou, Sylvain Corlay, and Thorsten Beier, who worked on the first integration with JupyterLite.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/jupyter-xeus/xeus-octave"&gt;&lt;strong&gt;Xeus-Octave&lt;/strong&gt;&lt;/a&gt;, the Xeus-based Jupyter kernel for GNU Octave, was created by Giulio Girardi and Antoine Prouvost.&lt;/li&gt;
&lt;/ul&gt;
</content><category term="JupyterLite"/><category term="kernels"/><category term="WebAssembly"/><category term="xeus"/></entry><entry><title>R in the Browser: Announcing Our WebAssembly Distribution</title><link href="https://jasongrout.github.io/medium-archive/pelican/posts/2025/r-in-the-browser-announcing-our-webassembly/" rel="alternate"/><published>2025-02-28T08:31:00+00:00</published><updated>2025-04-25T07:39:00+00:00</updated><author><name>Isabel Paredes</name></author><id>tag:jasongrout.github.io,2025-02-28:/medium-archive/pelican/posts/2025/r-in-the-browser-announcing-our-webassembly/</id><summary type="html">&lt;p&gt;R is now available in emscripten-forge, enabling the Xeus-R kernel in JupyterLite&lt;/p&gt;
</summary><content type="html">&lt;p&gt;&lt;img src="https://jasongrout.github.io/medium-archive/pelican/posts/2025/r-in-the-browser-announcing-our-webassembly/images/001-1_y4YmV8C0L1CkE1Q5JRJLkg.webp" alt="Banner with gradient background and R-lite logo" loading="lazy" data-body-image=""&gt;&lt;/p&gt;
&lt;p&gt;In the past few months, &lt;a href="https://quantstack.net/"&gt;QuantStack&lt;/a&gt; has received funding from the &lt;a href="https://www.gatesfoundation.org/"&gt;&lt;strong&gt;Bill &amp;amp; Melinda Gates Foundation&lt;/strong&gt;&lt;/a&gt; through a grant to &lt;a href="https://coursekata.org/"&gt;CourseKata&lt;/a&gt; to develop support for the R programming language in &lt;a href="https://jupyterlite.readthedocs.io/en/stable/"&gt;JupyterLite&lt;/a&gt; and the &lt;a href="https://emscripten-forge.org/"&gt;Emscripten-forge&lt;/a&gt; distribution for WebAssembly.&lt;/p&gt;
&lt;p&gt;Today, we are thrilled to announce the availability of the R programming language in the Emscripten-Forge distribution for WebAssembly, which enables R workflows in JupyterLite through the Xeus-R Jupyter kernel.&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="Screenshot of JupyterLite with an R Jupyter notebook in use" src="https://jasongrout.github.io/medium-archive/pelican/posts/2025/r-in-the-browser-announcing-our-webassembly/images/002-0_9D50aOr7jhxFnjzo.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;JupyterLite with an R Jupyter notebook in use&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;To experience R in JupyterLite, simply click on the link below:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://isabelparedes.github.io/xeus-r-demo/lab/?path=demo.ipynb"&gt;&lt;img src="https://jasongrout.github.io/medium-archive/pelican/posts/2025/r-in-the-browser-announcing-our-webassembly/images/003-0_qOr5KTmon-fiZ37l.webp" alt="Button to access JupyterLite" loading="lazy" data-body-image=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In this article, we present the details of our efforts to enable R workflows in JupyterLite. We cover the challenges encountered in packaging R and its dependencies for this platform, the solutions we implemented, and the process of handling R mamba packages on the frontend.&lt;/p&gt;
&lt;h2 id="why-webassembly-scaling-scientific-computing-workflows-in-jupyter-to-millions-of-users"&gt;&lt;strong&gt;Why WebAssembly? Scaling scientific computing workflows in Jupyter to millions of users&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;The main challenge in scaling Jupyter deployments lies in providing a live computing environment on the server side for each user session.&lt;/p&gt;
&lt;p&gt;While Kubernetes-based JupyterHub deployments have been successfully implemented at a university scale (such as the UC Berkeley Data 8 class, or the JupyterHub deployment of Université Paris Saclay), they demand substantial computing resources and a skilled DevOps team to achieve and maintain this level of scalability.&lt;/p&gt;
&lt;p&gt;In contrast, &lt;a href="https://jupyterlite.readthedocs.io/"&gt;&lt;strong&gt;JupyterLite&lt;/strong&gt;&lt;/a&gt; represents a fundamentally different paradigm. As a browser-based distribution of Jupyter, it runs language kernels directly in the browser, enabling significantly greater scalability and ease of deployment. Notable JupyterLite-based applications include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A JupyterLite console integrated into &lt;a href="http://numpy.org"&gt;&lt;strong&gt;NumPy&lt;/strong&gt;&lt;/a&gt;’s front page, providing immediate access to NumPy functionality without requiring installation.&lt;/li&gt;
&lt;li&gt;A similar console application on &lt;a href="https://live.sympy.org/"&gt;&lt;strong&gt;SymPy&lt;/strong&gt;&lt;/a&gt;’s project page, fully hosted statically.&lt;/li&gt;
&lt;li&gt;The official &lt;a href="https://jupyter.org/try"&gt;&lt;strong&gt;Jupyter&lt;/strong&gt;&lt;/a&gt; website¹.&lt;/li&gt;
&lt;li&gt;The examples in &lt;a href="https://scikit-learn.org/stable/lite/lab/index.html"&gt;&lt;strong&gt;Scikit-Learn&lt;/strong&gt;&lt;/a&gt;’s documentation.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These examples illustrate how WebAssembly can be transformative by providing ready-to-use computing environments for scientific workflows, in documentation, blog posts, and scientific communications. The WebAssembly environments are made available to the hundreds of thousands of monthly visitors of these websites without requiring any computing resources on the backend.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://NumPy.org"&gt;&lt;img src="https://jasongrout.github.io/medium-archive/pelican/posts/2025/r-in-the-browser-announcing-our-webassembly/images/004-0_-531naCHla3pK14Q.jpg" alt="" loading="lazy" data-body-image=""&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://live.sympy.org/"&gt;&lt;img src="https://jasongrout.github.io/medium-archive/pelican/posts/2025/r-in-the-browser-announcing-our-webassembly/images/005-0_vk6bu54D0C7y4k9b.jpg" alt="" loading="lazy" data-body-image=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;figure&gt;
&lt;a href="https://jupyter.org/try"&gt;&lt;img alt="JupyterLite deployments displayed on the NumPy, SymPy, and Jupyter websites" src="https://jasongrout.github.io/medium-archive/pelican/posts/2025/r-in-the-browser-announcing-our-webassembly/images/006-0_SKvqpunHcz3i2mBG.webp" loading="lazy" data-body-image=""&gt;&lt;/a&gt;
&lt;figcaption&gt;JupyterLite deployments displayed on the NumPy, SymPy, and Jupyter websites&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;[1] Even though it powers the deployment of Jupyter on the main Jupyter website, JupyterLite is not an officially sanctioned Jupyter project.&lt;/p&gt;
&lt;h2 id="beyond-python-enabling-r-in-the-browser-and-more"&gt;&lt;strong&gt;Beyond Python, enabling R in the browser, and more&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;While the initial focus of the JupyterLite team has been on the Python programming language, the JupyterLite infrastructure was designed to be language-agnostic from the outset. The same principle applies to the package management stack we have been contributing to over the past few years, namely, &lt;a href="https://github.com/mamba-org/mamba"&gt;mamba&lt;/a&gt; and &lt;a href="https://conda-forge.org/"&gt;conda-forge&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;When we began targeting the WebAssembly platform, we chose to build our efforts on the mamba and conda-forge ecosystem. This decision allowed us to provide customizable environments for WebAssembly and expand beyond Python. This enabled applications such as the &lt;a href="https://github.com/jupyterlite/terminal"&gt;&lt;strong&gt;JupyterLite terminal&lt;/strong&gt;&lt;/a&gt;, created by Ian Thomas, which comprises a bash-like shell written in TypeScript called &lt;a href="https://github.com/jupyterlite/cockle"&gt;Cockle&lt;/a&gt;, and WebAssembly builds of native shell commands such as cat, grep, ls, and vim. You can read the &lt;a href="/posts/2024/jupyterlite-terminal/"&gt;&lt;strong&gt;earlier&lt;/strong&gt; &lt;strong&gt;announcement&lt;/strong&gt;&lt;/a&gt; introducing the JupyterLite terminal.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Today, we are excited to reveal the availability of R in emscripten-forge, enabling Jupyter kernels such as Xeus-R to be used in JupyterLite.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;With the addition of R, emscripten-forge now provides a unified packaging solution for Python, R, and terminal applications for WebAssembly. This covers the scopes of &lt;a href="https://pyodide.org/"&gt;&lt;strong&gt;Pyodide&lt;/strong&gt;&lt;/a&gt; (a Python distribution for WebAssembly), &lt;a href="https://docs.r-wasm.org/"&gt;&lt;strong&gt;WebR&lt;/strong&gt;&lt;/a&gt; (an R distribution for WebAssembly), and &lt;a href="https://sandbox.bio/"&gt;&lt;strong&gt;Sandbox.bio&lt;/strong&gt;&lt;/a&gt; (a shell emulator with WebAssembly commands).&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="building-r-for-emscripten-forge"&gt;&lt;strong&gt;Building R for Emscripten-forge&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Emscripten-forge is a GitHub organization containing recipes to build &lt;strong&gt;conda packages&lt;/strong&gt; for the emscripten-wasm32 platform; it is also the first distribution of conda packages targeting this platform. It is built upon a modernized stack, leveraging &lt;strong&gt;rattler-build&lt;/strong&gt; (the successor to the conda-build package builder) and &lt;strong&gt;mamba&lt;/strong&gt;. The emscripten-forge project, which was created and is still led by Thorsten Beier, is now a team effort covering a broad range of packages.&lt;/p&gt;
&lt;p&gt;In order to build R with emscripten-forge, we first required a toolchain capable of converting Fortran and C/C++ code into WebAssembly. Since R relies on BLAS and LAPACK (which are written in Fortran) and many essential R packages wrap native libraries that use Fortran, this conversion capability was crucial.&lt;/p&gt;
&lt;h2 id="fortran"&gt;&lt;strong&gt;Fortran&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;By default, the emscripten-forge toolchain can cross-compile any C/C++ packages into WebAssembly; however, the first challenge in building the R stack was expanding the toolchain to also compile Fortran code. The two compilers that we considered for this task are LFortran and Flang.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://lfortran.org/"&gt;&lt;strong&gt;LFortran&lt;/strong&gt;&lt;/a&gt; is a compiler built on top of LLVM and designed from the ground up as a cross-compiler. Despite its potential, LFortran is still in its early stages compared to Flang and does not yet fully support all Fortran features.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://flang.llvm.org/"&gt;&lt;strong&gt;LLVM Flang&lt;/strong&gt;&lt;/a&gt; is the Fortran compiler of the LLVM project. Unfortunately, it does not support cross-compilation.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Working with Serge Guelton and Kerim Birgi, we initially experimented with the LFortran compiler and contributed to addressing issues encountered when building Netlib &lt;a href="https://github.com/Reference-LAPACK/lapack"&gt;LAPACK&lt;/a&gt;. The BLAS implementation from this package served as a valuable testing ground since BLAS is one of the core dependencies for R.&lt;/p&gt;
&lt;p&gt;After careful consideration, we found that Flang, with its ability to compile a wider variety of Fortran projects, brought us closer to building the Fortran components of R to WebAssembly. George Stagg, the main developer of the WebR project, has written a detailed &lt;a href="https://gws.phd/posts/fortran_wasm/"&gt;article&lt;/a&gt; on using Flang to produce WebAssembly, which was adapted to the (then) latest version of LLVM (&lt;a href="https://github.com/r-wasm/llvm-project/blob/wasm/llvm/CMakeLists.txt"&gt;v18&lt;/a&gt;). Inspired by George Stagg’s endeavors, Serge posted upstream contributions to the Flang project (&lt;a href="https://github.com/llvm/llvm-project/pull/99465"&gt;#99465&lt;/a&gt;, &lt;a href="https://github.com/llvm/llvm-project/pull/99822"&gt;#99822&lt;/a&gt;, &lt;a href="https://github.com/llvm/llvm-project/pull/101242"&gt;#101242&lt;/a&gt;, &lt;a href="https://github.com/llvm/llvm-project/pull/105589"&gt;#105589&lt;/a&gt;), resolving issues with 32-bit platforms that were impacting our effort to support WebAssembly. All of these changes will be included in LLVM/Flang 20.0.&lt;/p&gt;
&lt;p&gt;The remaining patches which cannot be merged upstream at this point involve:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;(1) enabling code generation that targets WebAssembly (&lt;a href="https://github.com/llvm/llvm-project/commit/198c0e1e23a52abb3e274ee44223551247f2c38f"&gt;198c0e1&lt;/a&gt;),&lt;/li&gt;
&lt;li&gt;(2) encoding target-specific size definitions for various data types given that the host and target platforms have different architectures (&lt;a href="https://github.com/llvm/llvm-project/commit/1da66cda3652da369f5d1be871c27368a12b55e9"&gt;1da66cd&lt;/a&gt;), and&lt;/li&gt;
&lt;li&gt;(3) disabling support for 128-bit floating-point types (&lt;a href="https://github.com/llvm/llvm-project/commit/f20c7c05db0ed9afb50c0092dad7bc991d933481"&gt;f20c7c0&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A version of (2) that could be contributed upstream is in the works, which would be one step closer to making WebAssembly an official target for Flang. Additionally, (3) will no longer be needed starting with Flang v20.&lt;/p&gt;
&lt;p&gt;These patches were integrated by Axel Obermeier into the Flang build recipe for the conda-forge distribution, making the modified build accessible to everyone. It can be installed on Linux with mamba or micromamba by executing:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;micromamba&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;conda-forge/label/emscripten::flang&lt;span class="w"&gt; &lt;/span&gt;libllvm19&lt;span class="w"&gt; &lt;/span&gt;--no-channel-priority
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The final ingredient for our toolchain involved creating a compatible Fortran runtime library. Since Flang implements its runtime library in C/C++, compiling this library with Emscripten proved to be straightforward. We added a &lt;a href="https://github.com/emscripten-forge/recipes/blob/9b08a19a531bb5e03c7d5147367f6de2acb57e40/recipes/recipes_emscripten/libflang/recipe.yaml"&gt;recipe for libflang&lt;/a&gt; to emscripten-forge, which packages the runtime library and includes all the aforementioned patches.&lt;/p&gt;
&lt;p&gt;In the following example, we invoke Flang on a simple Fortran script, and execute the resulting JavaScript and WebAssembly with NodeJS.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;ls
hello.f90&lt;span class="w"&gt;  &lt;/span&gt;libFortranRuntime.a
&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;cat&lt;span class="w"&gt; &lt;/span&gt;hello.f90
File:&lt;span class="w"&gt; &lt;/span&gt;hello.f90
program&lt;span class="w"&gt; &lt;/span&gt;hello
&lt;span class="w"&gt; &lt;/span&gt;print&lt;span class="w"&gt; &lt;/span&gt;*,&lt;span class="w"&gt; &lt;/span&gt;“Hello,&lt;span class="w"&gt; &lt;/span&gt;Fortran!”
end&lt;span class="w"&gt; &lt;/span&gt;program&lt;span class="w"&gt; &lt;/span&gt;hello
&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;source&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;~/emsdk/emsdk_env.sh
&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;flang-new&lt;span class="w"&gt; &lt;/span&gt;--target&lt;span class="o"&gt;=&lt;/span&gt;wasm32-unknown-emscripten&lt;span class="w"&gt; &lt;/span&gt;-c&lt;span class="w"&gt; &lt;/span&gt;hello.f90&lt;span class="w"&gt; &lt;/span&gt;-o&lt;span class="w"&gt; &lt;/span&gt;hello.o
&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;emcc&lt;span class="w"&gt; &lt;/span&gt;hello.o&lt;span class="w"&gt; &lt;/span&gt;libFortranRuntime.a&lt;span class="w"&gt; &lt;/span&gt;-o&lt;span class="w"&gt; &lt;/span&gt;hello.js
&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;ls
hello.f90&lt;span class="w"&gt;  &lt;/span&gt;hello.js&lt;span class="w"&gt;  &lt;/span&gt;hello.o&lt;span class="w"&gt;  &lt;/span&gt;hello.wasm&lt;span class="w"&gt;  &lt;/span&gt;libFortranRuntime.a
&amp;gt;&lt;span class="w"&gt; &lt;/span&gt;node&lt;span class="w"&gt; &lt;/span&gt;hello.js
Hello,&lt;span class="w"&gt; &lt;/span&gt;Fortran!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;With a working Fortran-to-WebAssembly toolchain, we managed to compile BLAS and LAPACK (See the &lt;a href="https://github.com/emscripten-forge/recipes/blob/main/recipes/recipes_emscripten/lapack/recipe.yaml"&gt;LAPACK recipe&lt;/a&gt;). But before we could get started with building R, we needed to tackle the remaining R dependencies.&lt;/p&gt;
&lt;h2 id="walking-up-the-stack"&gt;&lt;strong&gt;Walking up the stack&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;In R (v4.4), there are a handful of dependencies that are required to provide basic functionality; these are: libiconv, zlib, bzip2, xz, pcre2, and libcurl. Thanks to the packaging efforts led by Thorsten Beier and Wolf Vollprecht, these dependencies are available on emscripten-forge with the exception of libcurl. Because of its socket-based networking architecture and reliance on system-level resource access, libcurl faces fundamental incompatibilities with WebAssembly’s sandboxed environment constraints. Therefore, libcurl had to be disabled in the R source code. As a consequence, downstream R packages which depend on libcurl cannot be ported to WebAssembly until a suitable libcurl replacement is available.&lt;/p&gt;
&lt;p&gt;Apart from the core dependencies, R also requires a BLAS implementation. Although external BLAS libraries can be used with R, the R code base contains linear algebra routines from Netlib BLAS and a subset of LAPACK where both libraries are written in C and Fortran. To simplify configuration, we opted for these internal implementations instead of using external BLAS and LAPACK libraries.&lt;/p&gt;
&lt;p&gt;Furthermore, several key optional dependencies were cross-compiled to WebAssembly to enhance R’s graphical capabilities; these include libpng, libtiff, cairo, and pango, along with their respective subdependencies. One particularly challenging aspect of packaging these libraries was the cross-compilation of glib, which both cairo and pango depend on. Compiling glib was only possible thanks to the efforts of &lt;a href="https://gist.github.com/kleisauke/acfa1c09522705efa5eb0541d2d00887"&gt;Kleis Auke Wolthuizen&lt;/a&gt; whose patches made glib compatible with Emscripten, and Johan Mabille who disabled multi-threading.&lt;/p&gt;
&lt;p&gt;The R dependencies are summarized in the following table:&lt;/p&gt;
&lt;figure&gt;
&lt;img alt="A table summarizing the R dependencies." src="https://jasongrout.github.io/medium-archive/pelican/posts/2025/r-in-the-browser-announcing-our-webassembly/images/007-1_9VQSZHRow-lBASg0wxfklg.webp" loading="lazy" data-body-image=""&gt;
&lt;figcaption&gt;Table of R dependencies&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;h2 id="cross-compilation-of-r"&gt;&lt;strong&gt;Cross-compilation of R&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Although R typically configures and builds seamlessly on most unix platforms, cross-compiling is not straightforward because R uses a bootstrap approach; first it creates a minimal version of R which is then used to run several R scripts to complete the build process. Bootstrapping is a challenge because the built binaries for the target platform (WebAssembly) are not executable (at least not directly) from the host platform. Therefore, the r-base package necessitates two build phases. First, we compile R for the host platform (Linux) with GCC and Flang; this generates the R and Rscript executables needed for the second phase. And then, we cross-compile to WebAssembly with Emscripten and Flang.&lt;/p&gt;
&lt;p&gt;One of the major challenges of this setup was generating the R Data Base (.rdb) and R Data Index (.rdx) files for the internal packages of r-base (base, compiler, grDevices, graphics, grid, methods, parallel, splines, stats, stats4, tools, and utils). To accomplish this, it was necessary to dynamically load some of the internal shared libraries (tools, grDevices, graphics, utils, stats, and methods) which provide essential functionality to generate the data and index files. However, the R executables we created during the first phase of the build are incompatible with the WebAssembly shared libraries. In order to work around this, we temporarily replaced the WebAssembly libraries of the internal packages with the linux shared libraries we built during the first phase (See &lt;a href="https://github.com/emscripten-forge/recipes/blob/9b08a19a531bb5e03c7d5147367f6de2acb57e40/recipes/recipes_emscripten/r-base/cross_libraries.sh"&gt;cross_libraries.sh&lt;/a&gt;). This makeshift solution is also used to cross-compile all other R packages; the setup is carried out by the activation script of the cross-r-base package (See &lt;a href="https://github.com/conda-forge/r-base-feedstock/blob/54c15117f86693d54d69aacdd2fb76f622e31e5a/recipe/activate-cross-r-base.sh#L18"&gt;activate-cross-r-base.sh&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Additionally, the R source code required a few modifications to enable cross-compilation to WebAssembly.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The Emscripten platform was added to select the correct configuration for the platform.&lt;/li&gt;
&lt;li&gt;The dependency on libcurl was removed (as mentioned in the previous section) and as a consequence, the internet package which relies on libcurl was disabled.&lt;/li&gt;
&lt;li&gt;System calls which are not compatible with our WebAssembly environment were disabled.&lt;/li&gt;
&lt;li&gt;Cairo replaced Xlib as the default bitmap type to enable graphics.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The complete list of patches applied to R is available here: &lt;a href="https://github.com/emscripten-forge/recipes/tree/main/recipes/recipes_emscripten/r-base/patches"&gt;r-base patches&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="the-r-package-ecosystem"&gt;&lt;strong&gt;The R package ecosystem&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Building R itself was just the beginning. The next challenge was to provide a wide array of R packages to create a robust development environment. Fortunately, many packages are written in pure R and are available as “noarch” packages on conda-forge, making them directly compatible with emscripten-forge environments. However, for the R packages that require compilation, a package recipe needs to be created and added to emscripten-forge. Thanks to the help of Anutosh Bhat, the following packages have been compiled and are available to use.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;r-askpass     r-digest    r-haven      r-magrittr  r-purrr    r-tidyr
r-base64enc   r-dplyr     r-hexbin     r-mass      r-rcpp     r-tzdb
r-bit         r-ellipsis  r-htmltools  r-matrix    r-readr    r-utf8
r-bit64       r-fansi     r-isoband    r-mgcv      r-rlang    r-vctrs
r-cachem      r-farver    r-jsonlite   r-mime      r-sp       r-vroom
r-cli         r-fastmap   r-later      r-nlme      r-stringi  r-xfun
r-colorspace  r-ggrepel   r-lattice    r-plyr      r-sys      r-yaml
r-data.table  r-glue      r-lazyeval   r-promises  r-tibble
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Most of the time, cross-compiling an R package is very simple because the bulk of the work is handled by r-base. Building a package typically boils down to a single line:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nv"&gt;$R&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;CMD&lt;span class="w"&gt; &lt;/span&gt;INSTALL&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$R_ARGS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Occasionally, minor patches are applied to the package source code to enable the WebAssembly target platform or to simplify cross-compilation. Some R packages, such as r-nlme, contain Fortran code; for such packages, the custom flang compiler needs to be installed before the package can be cross-compiled. Should any package be needed for your use case, feel free to contribute them to emscripten-forge!&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="xeus-r"&gt;&lt;strong&gt;Xeus-R&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Once a sufficient set of packages is available for the platform, the next step is to provide a development environment for end users. Our chosen tool for this purpose is Jupyter.&lt;/p&gt;
&lt;p&gt;The most popular Jupyter kernel for R is &lt;a href="https://github.com/IRkernel/IRkernel"&gt;IRkernel&lt;/a&gt;, which has been developed over several years. It includes complete ZeroMQ bindings for the R language and comprehensive coverage of the Jupyter protocol. However, since IRkernel is tied to ZeroMQ, we opted to work with the &lt;a href="https://github.com/jupyter-xeus/xeus-r"&gt;Xeus-R&lt;/a&gt; project instead, which was &lt;a href="/posts/2024/meet-xeus-r-a-future-proof-jupyter-kernel-for-r/"&gt;announced last year.&lt;/a&gt; Xeus-R was developed by Romain François in collaboration with our team and with JupyterLite in mind. It is built upon the Xeus library, which provides a native implementation of the Jupyter protocol and is adapted to work with the JupyterLite frontend.&lt;/p&gt;
&lt;p&gt;Fortunately, the components of IRkernel responsible for the rich representation of R objects and rich display in Jupyter frontends were split into two separate R packages: &lt;strong&gt;IRdisplay&lt;/strong&gt; and &lt;strong&gt;repr&lt;/strong&gt;. These packages can be reused in Xeus-R. As a result, Xeus-R and IRkernel offer the same rich display functionality, ensuring that Jupyter notebooks created with one kernel will work with the other. However, Xeus-R provides a different implementation of the communication layer through &lt;a href="https://github.com/jupyterlite/xeus"&gt;jupyterlite-xeus&lt;/a&gt;, which enables integration with the JupyterLite stack. This integration was previously implemented for Xeus-Python and Xeus-Lua.&lt;/p&gt;
&lt;p&gt;One key aspect of this integration is the populating of the in-memory file system used by JupyterLite kernels with the required runtime dependencies, particularly shared libraries. This process is done upon bootstrapping the kernel. For this purpose, Anastiasiia Sliusar and Martin Renou developed &lt;a href="https://github.com/emscripten-forge/mambajs"&gt;mambajs&lt;/a&gt;, which, in combination with jupyterlite-xeus, processes conda packages in the frontend and installs them in the kernel filesystem at startup. In WebAssembly, shared libraries need to be handled with special care in order to function as expected. Drawing inspiration from the Python community, we adapted the pioneering work of Pyodide to properly load shared libraries into the filesystem.&lt;/p&gt;
&lt;h2 id="how-to-make-a-deployment-with-custom-packages"&gt;&lt;strong&gt;How to make a deployment with custom packages&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;The GitHub repository &lt;a href="https://github.com/jupyterlite/xeus-lite-demo"&gt;https://github.com/jupyterlite/xeus-lite-demo&lt;/a&gt; is a template for creating a JupyterLite deployment on GitHub pages that includes the packages specified in a conda environment.&lt;/p&gt;
&lt;p&gt;The process is as follows:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a new repository from the GitHub template.&lt;/li&gt;
&lt;li&gt;Enable the deployment on GitHub pages from a GitHub action, as shown in the README.&lt;/li&gt;
&lt;li&gt;Edit the environment file to include the desired packages.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For example, to deploy an R kernel with coursekata installed, the environment.yml file would contain the following:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="nt"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;xeus-r&lt;/span&gt;
&lt;span class="nt"&gt;channels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;https://repo.mamba.pm/emscripten-forge&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;conda-forge&lt;/span&gt;
&lt;span class="nt"&gt;dependencies&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;xeus-r&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;r-coursekata&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The deployment linked at the beginning of this article was created with this template.&lt;/p&gt;
&lt;h2 id="how-to-contribute"&gt;&lt;strong&gt;How to contribute&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Contributors are always welcome! New R packages can be requested by opening an issue on emscripten-forge, or added directly by opening a pull request with the desired package recipe. For instructions on how to contribute, please visit &lt;a href="https://emscripten-forge.org/"&gt;https://emscripten-forge.org/&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="what-is-in-the-works"&gt;&lt;strong&gt;What is in the works&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;Currently, we are developing the infrastructure to dynamically install emscripten-forge and conda-forge noarch packages in JupyterLite kernel environments. This will apply to all Xeus kernels that make use of these packages, such as Xeus-Python, Xeus-R, and Xeus-Lua. In the case of R, this may be directly bound to install.packages.&lt;/p&gt;
&lt;p&gt;Additionally, we are working on more advanced features for the R kernel, including support for Jupyter interactive widgets and the split of the pure R parts of xeus-r into a separate package, which would facilitate a possible convergence with IRkernel.&lt;/p&gt;
&lt;p&gt;Finally, other language kernels based on the same package management stack are also in the works. Stay tuned for future announcements!&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="about-the-author"&gt;&lt;strong&gt;About the Author&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Isabel Paredes&lt;/strong&gt;, who led the charge on bringing R to emscripten-forge, is a senior scientific software developer at QuantStack. Prior to working on this project, she focused on porting the Robot Operating System (ROS) framework to WebAssembly.&lt;/p&gt;
&lt;h2 id="acknowledgments"&gt;&lt;strong&gt;Acknowledgments&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;This effort brought together several endeavors from many open-source developers.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;JupyterLite&lt;/strong&gt;, the Jupyter distribution that runs entirely in the web browser, was created by Jeremy Tuloup.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Xeus&lt;/strong&gt;, the C++ library implementing the Jupyter kernel protocol, enabling a custom communication layer, and is foundational to kernels like xeus-r, xeus-python, running in JupyterLite, was created by Johan Mabille and is maintained by a broader team including Martin Renou, Sylvain Corlay, and Thorsten Beier, who worked on the first integration with JupyterLite.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Emscripten-forge&lt;/strong&gt;, the distribution of conda packages for WebAssembly, was created by Thorsten Beier, who continues to lead the project. Many recipes were contributed by Isabel Paredes (for the R ecosystem), but also Kerim Birgi, Anutosh Bhat, Martin Renou, Wolf Vollprecht, and Johan Mabille.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Xeus-R&lt;/strong&gt;, the Xeus-based Jupyter kernel for R, was created by Romain François.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;IRDisplay&lt;/strong&gt; and &lt;strong&gt;repr&lt;/strong&gt; are pure R packages providing rich display and rich mime type rendering of many core R types, which are used in xeus-r. These two packages stem from the IRkernel project, a Jupyter kernel for R written in R, which was started by Thomas Kluyver, and has been maintained over the years by Philipp Angerer and Jan Katins.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MambaJS&lt;/strong&gt;, the library enabling the processing of conda packages in the frontend, was developed by Anastasiia Sliusar and Martin Renou.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Conda-forge&lt;/strong&gt;, the main distribution of conda packages, includes a large number of “noarch” recipes, including for R packages, and is developed by a broad community of contributors worldwide.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;WebR&lt;/strong&gt;, an R distribution for WebAssembly, was created by George Stagg. Although not directly used in this project, it documented numerous patches and changes to the Flang compiler that were adapted for this effort.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="funding"&gt;&lt;strong&gt;Funding&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;The work by &lt;strong&gt;Isabel Paredes&lt;/strong&gt; and other &lt;strong&gt;QuantStack&lt;/strong&gt; team members on bringing R and Xeus-R to Emscripten-Forge was supported by the &lt;a href="https://www.gatesfoundation.org/"&gt;&lt;strong&gt;Bill &amp;amp; Melinda Gates Foundation&lt;/strong&gt;&lt;/a&gt; through a grant to &lt;strong&gt;CourseKata&lt;/strong&gt;. CourseKata is a nonprofit project dedicated to improving statistics and data science education through interactive, research-backed curricula that integrate professional tools like R and Jupyter notebooks. This grant was part of CourseKata’s broader mission to scale its innovative curriculum, equipping students with the skills and confidence to engage with statistics, data science, and coding in meaningful ways.&lt;/p&gt;
</content><category term="JupyterLite"/><category term="kernels"/><category term="WebAssembly"/><category term="xeus"/></entry></feed>