aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-06-13 21:32:28 -0400
committerAlon Zakai <alonzakai@gmail.com>2013-06-13 21:32:28 -0400
commit1a3cb10ca12c7fdfbea1fa3bd253ed46cf7a02ce (patch)
tree1ffa9cc90b4056772dff1fdcd69f298413433c5e
parent886e3158cf5d95a2c2721e5eb9a1c3ac4461f805 (diff)
do not eliminate dead code in EXPORT_ALL
-rw-r--r--src/jsifier.js2
-rwxr-xr-xtests/runner.py18
-rw-r--r--tools/shared.py2
3 files changed, 20 insertions, 2 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 156fd65d..faef88d5 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -328,7 +328,7 @@ function JSify(data, functionsOnly, givenFunctions) {
var js = (index !== null ? '' : item.ident + '=') + constant;
if (js) js += ';';
- if (!ASM_JS && (EXPORT_ALL || (item.ident in EXPORTED_GLOBALS))) {
+ if (!ASM_JS && NAMED_GLOBALS && (EXPORT_ALL || (item.ident in EXPORTED_GLOBALS))) {
js += '\nModule["' + item.ident + '"] = ' + item.ident + ';';
}
if (BUILD_AS_SHARED_LIB == 2 && !item.private_) {
diff --git a/tests/runner.py b/tests/runner.py
index 5e101024..73dbab13 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -10496,6 +10496,24 @@ f.close()
self.assertContained('result: 1', run_js(os.path.join(self.get_dir(), 'a.out.js')))
+ def test_export_all(self):
+ lib = r'''
+ #include <stdio.h>
+ void libf1() { printf("libf1\n"); }
+ void libf2() { printf("libf2\n"); }
+ '''
+ lib_name = os.path.join(self.get_dir(), 'lib.c')
+ open(lib_name, 'w').write(lib)
+
+ open('main.js', 'w').write('''
+ _libf1();
+ _libf2();
+ ''')
+
+ Building.emcc(lib_name, ['-s', 'EXPORT_ALL=1', '--post-js', 'main.js'], output_filename='a.out.js')
+
+ self.assertContained('libf1\nlibf2\n', run_js(os.path.join(self.get_dir(), 'a.out.js')))
+
def test_abspaths(self):
# Includes with absolute paths are generally dangerous, things like -I/usr/.. will get to system local headers, not our portable ones.
diff --git a/tools/shared.py b/tools/shared.py
index 8a172d9c..0d1cfffd 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -1091,7 +1091,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
@staticmethod
def can_build_standalone():
- return not Settings.BUILD_AS_SHARED_LIB and not Settings.LINKABLE
+ return not Settings.BUILD_AS_SHARED_LIB and not Settings.LINKABLE and not Settings.EXPORT_ALL
@staticmethod
def can_use_unsafe_opts():