Skip to content

Commit 72265a4

Browse files
committed
Update build script to compile rt lib to wasm
Also, define macro in lfortran_intrinsics.h to export functions
1 parent d9f1049 commit 72265a4

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

build1.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ cmake \
1515
-DCMAKE_INSTALL_PREFIX=`pwd`/inst \
1616
.
1717
cmake --build . -j16 --target install
18+
19+
emcc -DWASM_RT_LIB src/libasr/runtime/lfortran_intrinsics.c -o src/libasr/runtime/rt_lib.wasm -s WASM=1 --no-entry

src/libasr/runtime/lfortran_intrinsics.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
#include <inttypes.h>
77
#include <stdbool.h>
88

9+
#ifdef WASM_RT_LIB
10+
#include <emscripten.h>
11+
#endif
12+
913
#ifdef __cplusplus
1014
extern "C" {
1115
#endif
@@ -34,6 +38,11 @@ typedef double _Complex double_complex_t;
3438
#define LFORTRAN_API /* Nothing */
3539
#endif
3640

41+
#ifdef WASM_RT_LIB
42+
#undef LFORTRAN_API
43+
#define LFORTRAN_API EMSCRIPTEN_KEEPALIVE
44+
#endif
45+
3746
LFORTRAN_API double _lfortran_sum(int n, double *v);
3847
LFORTRAN_API void _lfortran_random_number(int n, double *v);
3948
LFORTRAN_API double _lfortran_random();

0 commit comments

Comments
 (0)