-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
dev.lfortran.org: use Release build #1240
Comments
For release build, I am using the following changes: diff --git a/build_to_wasm.sh b/build_to_wasm.sh
index 382663dc3..e2d74f95d 100755
--- a/build_to_wasm.sh
+++ b/build_to_wasm.sh
@@ -3,7 +3,7 @@
set -ex
cmake \
- -DCMAKE_BUILD_TYPE=Debug \
+ -DCMAKE_BUILD_TYPE=Release \
-DWITH_LLVM=yes \
-DLFORTRAN_BUILD_ALL=yes \
-DWITH_STACKTRACE=no \
@@ -17,7 +17,7 @@ cp src/runtime/*.mod src/bin/asset_dir
git clean -dfx -e src/bin/asset_dir
emcmake cmake \
- -DCMAKE_BUILD_TYPE=Debug \
+ -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS_DEBUG="-Wall -Wextra -fexceptions" \
-DWITH_LLVM=no \
-DLFORTRAN_BUILD_ALL=yes \
diff --git a/src/lfortran/parser/parser_stype.h b/src/lfortran/parser/parser_stype.h
index c197c77bf..009557569 100644
--- a/src/lfortran/parser/parser_stype.h
+++ b/src/lfortran/parser/parser_stype.h
@@ -93,7 +93,7 @@ static_assert(std::is_trivial<YYSTYPE>::value);
// Ensure the YYSTYPE size is equal to Vec<AST::ast_t*>, which is a required member, so
// YYSTYPE has to be at least as big, but it should not be bigger, otherwise it
// would reduce performance.
-static_assert(sizeof(YYSTYPE) == sizeof(Vec<AST::ast_t*>));
+// static_assert(sizeof(YYSTYPE) == sizeof(Vec<AST::ast_t*>));
} // namespace LCompilers::LFortran (the With the release build, it throws a (I think it is similar to the one discussed at https://lfortran.zulipchat.com/#narrow/stream/197339-general/topic/Building.20LFortran.20in.20emscripten-forge/near/292549746 and #585) The exact issue comes when we are allocating/reserving space for wasm section streams. It especially fails when reserving space for the last stream lfortran/src/libasr/codegen/asr_to_wasm.cpp Lines 161 to 168 in 36f604c
Surprisingly, the following diff seems to get it working (I am currently unsure why/how it works): diff --git a/src/libasr/alloc.h b/src/libasr/alloc.h
index 76588a288..81902ab0f 100644
--- a/src/libasr/alloc.h
+++ b/src/libasr/alloc.h
@@ -6,6 +6,7 @@
#include <new>
#include <stdexcept>
#include <vector>
+#include <iostream>
#include <libasr/assert.h>
@@ -52,6 +53,7 @@ public:
// force new_chunk() not to get inlined, but there is no standard way of
// doing it. This try/catch approach effectively achieves the same using
// standard C++.
+ std::cout << std::endl;
try {
LCOMPILERS_ASSERT(start != nullptr);
size_t addr = current_pos; (we can also write any string inside the above |
Thanks for debugging it. We'll have to figure out what is causing it. |
Here is how we can fix this: --- a/src/libasr/alloc.h
+++ b/src/libasr/alloc.h
@@ -52,15 +52,25 @@ public:
// force new_chunk() not to get inlined, but there is no standard way of
// doing it. This try/catch approach effectively achieves the same using
// standard C++.
+#ifndef LCOMPILERS_FAST_ALLOC
try {
+#endif
LCOMPILERS_ASSERT(start != nullptr);
size_t addr = current_pos;
current_pos += align(s);
- if (size_current() > size_total()) throw std::bad_alloc();
+ if (size_current() > size_total()) {
+#ifdef LCOMPILERS_FAST_ALLOC
+ throw std::bad_alloc();
+#else
+ return new_chunk(s);
+#endif
+ }
return (void*)addr;
+#ifndef LCOMPILERS_FAST_ALLOC
} catch (const std::bad_alloc &e) {
return new_chunk(s);
}
+#endif
}
void *new_chunk(size_t s) { And have |
This #1240 (comment) seems to work. I am slightly concerned if it is a robust solution. I will see if there are better approaches to it. |
A concern here was that exceptions are not being supported in release mode as shared by you. I found the fix. I will be submitting a PR soon. |
The size for generated PS: I just noticed that the size for |
Yeah, and we might need to start removing backends (via cmake options) and features that we don't need for the WASM application, to keep the size low. |
Currently it is using Debug build.
The text was updated successfully, but these errors were encountered: