aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/jsifier.js3
-rw-r--r--src/settings.js8
-rwxr-xr-xtests/runner.py19
3 files changed, 30 insertions, 0 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 6cbe8b88..b3c2af1d 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -453,6 +453,9 @@ function JSify(data, functionsOnly, givenFunctions) {
item.JS = addFromLibrary(shortident);
} else {
item.JS = 'var ' + item.ident + '; // stub for ' + item.ident;
+ if (WARN_ON_UNDEFINED_SYMBOLS) {
+ warn('Unresolved symbol: ' + item.ident);
+ }
}
return ret;
}
diff --git a/src/settings.js b/src/settings.js
index 1910e943..e0286213 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -218,6 +218,14 @@ var FAKE_X86_FP80 = 1; // Replaces x86_fp80 with double. This loses precision. I
var GC_SUPPORT = 1; // Enables GC, see gc.h (this does not add overhead, so it is on by default)
+var WARN_ON_UNDEFINED_SYMBOLS = 0; // If set to 1, we will warn on any undefined symbols that
+ // are not resolved by the library_*.js files. We by default
+ // do not warn because (1) it is normal in large projects to
+ // not implement everything, when you know what is not
+ // going to actually be called (and don't want to mess with
+ // the existing buildsystem), and (2) functions might be
+ // implemented later on, say in --pre-js
+
// Compiler debugging options
var DEBUG_TAGS_SHOWING = [];
// Some useful items:
diff --git a/tests/runner.py b/tests/runner.py
index c17b1a0a..6991735e 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -6786,6 +6786,25 @@ f.close()
Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp')]).communicate()
self.assertContained('1234, 1234, 4321\n', run_js(os.path.join(self.get_dir(), 'a.out.js')))
+ def test_warn_undefined(self):
+ open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(r'''
+ #include <stdio.h>
+
+ extern "C" {
+ void something();
+ }
+
+ int main() {
+ something();
+ return 0;
+ }
+ ''')
+ output = Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '-s', 'WARN_ON_UNDEFINED_SYMBOLS=1'], stderr=PIPE).communicate()
+ self.assertContained('Unresolved symbol: _something\n', output[1])
+
+ output = Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp')], stderr=PIPE).communicate()
+ self.assertNotContained('Unresolved symbol: _something\n', output[1])
+
def test_prepost(self):
open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write('''
#include <stdio.h>