aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-02-25 18:31:05 -0800
committerAlon Zakai <alonzakai@gmail.com>2014-02-26 09:48:27 -0800
commit01efb0bfc550ed1e4ebd4cfc2c617dea83026029 (patch)
treef301558f011101e8a891c1fec20ca7fa92508b45
parente2d05d569d7848d15ddd956e5c456d81f7bf9292 (diff)
pass NO_EXIT_RUNTIME flag to fastcomp and add test
-rwxr-xr-xemcc5
-rw-r--r--tests/test_other.py37
2 files changed, 41 insertions, 1 deletions
diff --git a/emcc b/emcc
index 8d840074..71e55f44 100755
--- a/emcc
+++ b/emcc
@@ -1180,7 +1180,10 @@ try:
logging.warning('jcache is deprecated and not supported in fastcomp (you should not need it anyhow), disabling')
jcache = False
- fastcomp_opts = ['-pnacl-abi-simplify-preopt', '-pnacl-abi-simplify-postopt']
+ fastcomp_opts = []
+ if shared.Settings.NO_EXIT_RUNTIME:
+ fastcomp_opts += ['-emscripten-no-exit-runtime', '-globaldce']
+ fastcomp_opts += ['-pnacl-abi-simplify-preopt', '-pnacl-abi-simplify-postopt']
if shared.Settings.DISABLE_EXCEPTION_CATCHING != 1:
fastcomp_opts += ['-enable-emscripten-cxx-exceptions']
if len(shared.Settings.EXCEPTION_CATCHING_WHITELIST) > 0:
diff --git a/tests/test_other.py b/tests/test_other.py
index 55cc5635..f5a4ebc9 100644
--- a/tests/test_other.py
+++ b/tests/test_other.py
@@ -2391,3 +2391,40 @@ int main() {
assert 'emcc: warning: unaligned store' in output[1]
assert '@line 9 "src.cpp"' in output[1]
+ def test_no_exit_runtime(self):
+ open('code.cpp', 'w').write(r'''
+#include <stdio.h>
+
+template<int x>
+struct Waste {
+ Waste() {
+ printf("coming around %d\n", x);
+ }
+ ~Waste() {
+ printf("going away %d\n", x);
+ }
+};
+
+Waste<1> w1;
+Waste<2> w2;
+Waste<3> w3;
+Waste<4> w4;
+Waste<5> w5;
+
+int main(int argc, char **argv) {
+ return 0;
+}
+''')
+
+ for no_exit in [0, 1]:
+ for opts in [0, 1]:
+ print no_exit, opts
+ Popen([PYTHON, EMCC, '-O' + str(opts), 'code.cpp', '-s', 'NO_EXIT_RUNTIME=' + str(no_exit)]).communicate()
+ output = run_js(os.path.join(self.get_dir(), 'a.out.js'), stderr=PIPE, full_output=True, engine=NODE_JS)
+ src = open('a.out.js').read()
+ exit = 1-no_exit
+ assert 'coming around' in output
+ assert ('going away' in output) == exit, 'destructors should not run if no exit'
+ assert ('_ZN5WasteILi2EED1Ev' in src) == exit, 'destructors should not appear if no exit'
+ assert ('atexit(' in src) == exit, 'atexit should not appear or be called'
+