diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-11-12 21:09:38 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-11-12 21:09:38 -0800 |
commit | 4caba7e02ab1e3dcae31114fd119544c7e106e70 (patch) | |
tree | 6f2a83cb8cc7679da85a4e1d564ef11d2eb06b4f /src | |
parent | 634ded6639c0a25b558aedbfc8bb4add0a5feea9 (diff) |
make DEAD_FUNCTIONS work on js library functions too
Diffstat (limited to 'src')
-rw-r--r-- | src/jsifier.js | 7 | ||||
-rw-r--r-- | src/settings.js | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index 97317756..a9505bb8 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -490,10 +490,15 @@ function JSify(data, functionsOnly, givenFunctions) { } else { // If this is not linkable, anything not in the library is definitely missing var cancel = false; + if (item.ident in DEAD_FUNCTIONS) { + LibraryManager.library[shortident] = new Function("Module['printErr']('dead function: " + shortident + "'); abort(-1);"); + delete LibraryManager.library[shortident + '__inline']; + delete LibraryManager.library[shortident + '__deps']; + } if (!LINKABLE && !LibraryManager.library.hasOwnProperty(shortident) && !LibraryManager.library.hasOwnProperty(shortident + '__inline')) { if (ERROR_ON_UNDEFINED_SYMBOLS) error('unresolved symbol: ' + shortident); if (VERBOSE || WARN_ON_UNDEFINED_SYMBOLS) printErr('warning: unresolved symbol: ' + shortident); - if (ASM_JS || item.ident in DEAD_FUNCTIONS) { + if (ASM_JS) { // emit a stub that will fail during runtime. this allows asm validation to succeed. LibraryManager.library[shortident] = new Function("Module['printErr']('missing function: " + shortident + "'); abort(-1);"); } else { diff --git a/src/settings.js b/src/settings.js index 4ffbb415..0d8d3da5 100644 --- a/src/settings.js +++ b/src/settings.js @@ -428,6 +428,8 @@ var DEAD_FUNCTIONS = []; // Functions on this list are not converted to JS, and // reducing code size. // If a dead function is actually called, you will get a runtime // error. + // This can affect both functions in compiled code, and system + // library functions (e.g., you can use this to kill printf). // TODO: options to lazily load such functions var EXPLICIT_ZEXT = 0; // If 1, generate an explicit conversion of zext i1 to i32, using ?: |