diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-10-15 16:40:29 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-10-17 12:43:59 -0700 |
commit | eb466e688fb95efe4bdf32facb99c1b668e6cb4e (patch) | |
tree | 1d95d9f6c63971a92c567b3b1d80cdf25398a163 /src | |
parent | 844faf36ebb89698bb6db042f366ec851b89ddbe (diff) |
improve runtimelink handling of function aliases
Diffstat (limited to 'src')
-rw-r--r-- | src/jsifier.js | 12 | ||||
-rw-r--r-- | src/settings.js | 4 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index b76579cc..02459193 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -358,11 +358,21 @@ function JSify(data, functionsOnly, givenFunctions) { item.JS = 'var ' + item.ident + ';'; // Set the actual value in a postset, since it may be a global variable. We also order by dependencies there var value = Variables.globals[item.ident].resolvedAlias = finalizeLLVMParameter(item.value); + var fix = ''; + if (BUILD_AS_SHARED_LIB == 2 && !item.private_) { + var target = item.ident; + if (isFunctionType(item.type)) { + target = item.value.ident; // the other side does not know this is an alias/function table index. So make it the alias target. + var varData = Variables.globals[target]; + assert(!varData, 'multi-level aliasing does not work yet in shared lib 2 exports'); + } + fix = '\nif (globalScope) { assert(!globalScope["' + item.ident + '"]); globalScope["' + item.ident + '"] = ' + target + ' }' + } ret.push({ intertype: 'GlobalVariablePostSet', ident: item.ident, dependencies: set([value]), - JS: item.ident + ' = ' + value + ';' + JS: item.ident + ' = ' + value + ';' + fix }); return ret; } diff --git a/src/settings.js b/src/settings.js index 9e6f257a..0b58a26f 100644 --- a/src/settings.js +++ b/src/settings.js @@ -198,6 +198,10 @@ var INCLUDE_FULL_LIBRARY = 0; // Whether to include the whole library rather tha // functions used by the generated code. This is needed when // dynamically loading modules that make use of runtime // library functions that are not used in the main module. + // Note that this includes js libraries but *not* C. You will + // need the main file to include all needed C libraries. For + // example, if a library uses malloc or new, you will need + // to use those in the main file too to link in dlmalloc. var SHELL_FILE = 0; // set this to a string to override the shell file used |