fix i64* funcs in side modules when only some are used
This commit is contained in:
Родитель
39c644817c
Коммит
195a162528
|
@ -16,6 +16,8 @@ var INDENTATION = ' ';
|
|||
|
||||
var functionStubSigs = {};
|
||||
|
||||
var ALWAYS_EMITTED_I64_FUNCS = set('i64Add', 'i64Subtract', 'bitshift64Shl', 'bitshift64Lshr', 'bitshift64Ashr'); // even in side modules
|
||||
|
||||
// JSifier
|
||||
function JSify(data, functionsOnly) {
|
||||
//B.start('jsifier');
|
||||
|
@ -137,6 +139,7 @@ function JSify(data, functionsOnly) {
|
|||
LibraryManager.library[shortident] = new Function("Module['printErr']('missing function: " + shortident + "'); abort(-1);");
|
||||
} else {
|
||||
var target = (MAIN_MODULE ? '' : 'parent') + "Module['_" + shortident + "']";
|
||||
if (SIDE_MODULE && (ident in ALWAYS_EMITTED_I64_FUNCS)) return ''; // we emit i64Add etc. even in side modules (small, and should be fast)
|
||||
var assertion = '';
|
||||
if (ASSERTIONS) assertion = 'if (!' + target + ') abort("external function \'' + shortident + '\' is missing. perhaps a side module was not linked in? if this function was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment");';
|
||||
LibraryManager.library[shortident] = new Function(assertion + "return " + target + ".apply(null, arguments);");
|
||||
|
|
|
@ -3934,6 +3934,25 @@ var Module = {
|
|||
}
|
||||
''', 'other says 15724949027125.')
|
||||
|
||||
def test_dylink_i64_b(self):
|
||||
self.dylink_test('''
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
extern int64_t sidey();
|
||||
int main() {
|
||||
printf("other says %lld.", sidey());
|
||||
return 0;
|
||||
}
|
||||
''', '''
|
||||
#include <stdint.h>
|
||||
int64_t sidey() {
|
||||
volatile int64_t x = 0x12345678abcdef12LL;
|
||||
x += x % 17;
|
||||
x = 18 - x;
|
||||
return x;
|
||||
}
|
||||
''', 'other says -1311768467750121224.')
|
||||
|
||||
def test_dylink_class(self):
|
||||
self.dylink_test(header=r'''
|
||||
#include <stdio.h>
|
||||
|
|
Загрузка…
Ссылка в новой задаче