Skip to content

Setup online lpython #2328

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

Merged
merged 11 commits into from
Sep 17, 2023
Merged

Setup online lpython #2328

merged 11 commits into from
Sep 17, 2023

Conversation

ubaidsk
Copy link
Collaborator

@ubaidsk ubaidsk commented Sep 17, 2023

@ubaidsk ubaidsk force-pushed the setup_online_lpython branch from 5538e84 to bd4f333 Compare September 17, 2023 03:01

# Notes:
# STANDALONE_WASM is disabling support for exceptions, so it is currently omitted
# In build_to_wasm.sh, we need CMAKE_CXX_FLAGS_DEBUG="-Wall -Wextra -fexceptions" flags for exception support
set(WASM_COMPILE_FLAGS "-g0 -fexceptions")
set(WASM_COMPILE_FLAGS "-g0 -fexceptions -fsanitize=undefined")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LPython's parser segfaults in many cases when LPython is build to wasm. It seems LPython uses a different parser as compared to LFortran. I think LPython uses LR(1) parser where as LFortran uses GLR parser.

The above -fsanitize flag is actually a debugging flag, but it seems to make LPython's parser to work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, LPython uses LALR(1), which should be an easier parser.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a previous version of emscripten, the LPython parser would abort with error in the lines of "large memory ~3.5Gbs requested which is more than the available ~2.4Gbs". With the latest version of emscripten, it says "aborted, runtime error". (I updated my installed emscripten to be sure the errors are not due to some old version. )

@ubaidsk ubaidsk force-pushed the setup_online_lpython branch from bd4f333 to 1b52a44 Compare September 17, 2023 03:25
@ubaidsk ubaidsk marked this pull request as ready for review September 17, 2023 03:25
@@ -164,6 +168,7 @@ abi -- External ABI
| GFortranModule -- Yes GFortran
| BindC -- Yes C
| BindPython -- Yes Python
| BindJS -- Yes Javascript
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a new decorator for calls to Javascript functions. We previously used the (BindC + implementation=interface) for recognizing the functions to be imported. But it seems some functions from the numpy intrinsic module use these exact parameters (BindC + interface) and thus we are unable to distinguish between these numpy intrinsic functions and the functions that call into Javascript.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's fine. The same should be done in LFortran.

--> tests/../integration_tests/elemental_01.py:10:24
|
10 | assert abs(sin(sin(array[i])) - result[i]) <= eps
| ^^^^^^^^^^^^^
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These few files got removed. I think these were left over from some previous PR.

@ubaidsk
Copy link
Collaborator Author

ubaidsk commented Sep 17, 2023

After we merge this, we need to update the commit version at https://dev.lpython.org/ (and also the browser window tab name).

@ubaidsk ubaidsk requested a review from certik September 17, 2023 03:45
Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this is fine, thanks!

@ubaidsk ubaidsk merged commit 0a5d89b into lcompilers:main Sep 17, 2023
@ubaidsk ubaidsk deleted the setup_online_lpython branch September 17, 2023 04:44
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