aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Gohman <sunfish@google.com>2014-02-20 17:24:22 -0800
committerDan Gohman <sunfish@google.com>2014-02-25 11:58:52 -0800
commit264a5a91c450b510bcee1d257372ee5d9750879b (patch)
tree4f6f79a60d1b20d5f81bdae873b548cc55644a59
parente6f7d1edbe66e4ee676413de57a96222add7a3fd (diff)
Introduce the asmjs-unknown-emscripten target triple.
-rwxr-xr-xemcc14
-rwxr-xr-xemscripten.py8
-rwxr-xr-xscons-tools/emscripten.py2
-rw-r--r--src/intertyper.js4
-rw-r--r--src/jsifier.js4
-rw-r--r--src/library.js10
-rw-r--r--src/parseTools.js6
-rw-r--r--src/runtime.js4
-rw-r--r--src/settings.js4
-rw-r--r--tools/shared.py13
10 files changed, 37 insertions, 32 deletions
diff --git a/emcc b/emcc
index 7157f89c..b8ccbdcf 100755
--- a/emcc
+++ b/emcc
@@ -591,7 +591,7 @@ if CONFIGURE_CONFIG or CMAKE_CONFIG:
idx += 1
cmd = [compiler] + list(filter_emscripten_options(sys.argv[1:]))
- if not use_js: cmd += shared.EMSDK_OPTS + ['-DEMSCRIPTEN']
+ if not use_js: cmd += shared.EMSDK_OPTS + ['-D__EMSCRIPTEN__', '-DEMSCRIPTEN']
if use_js: cmd += ['-s', 'ERROR_ON_UNDEFINED_SYMBOLS=1'] # configure tests should fail when an undefined symbol exists
logging.debug('just configuring: ' + ' '.join(cmd))
@@ -1161,7 +1161,7 @@ try:
assert shared.Settings.EXECUTION_TIMEOUT == -1, 'execution timeout not supported in fastcomp'
assert shared.Settings.NAMED_GLOBALS == 0, 'named globals not supported in fastcomp'
assert shared.Settings.PGO == 0, 'pgo not supported in fastcomp'
- assert shared.Settings.TARGET_LE32 == 1, 'fastcomp requires le32'
+ assert shared.Settings.TARGET_ASMJS_UNKNOWN_EMSCRIPTEN == 1, 'fastcomp requires asmjs-unknown-emscripten'
assert shared.Settings.USE_TYPED_ARRAYS == 2, 'fastcomp assumes ta2'
assert not split_js_file, '--split-js is deprecated and not supported in fastcomp'
assert not bind, 'embind not supported in fastcomp yet'
@@ -1214,10 +1214,12 @@ try:
assert shared.LLVM_TARGET in shared.COMPILER_OPTS
if shared.LLVM_TARGET == 'i386-pc-linux-gnu':
shared.Settings.TARGET_X86 = 1
- shared.Settings.TARGET_LE32 = 0
- assert 'le32-unknown-nacl' not in shared.COMPILER_OPTS
- elif shared.LLVM_TARGET == 'le32-unknown-nacl':
- shared.Settings.TARGET_LE32 = 1
+ shared.Settings.TARGET_ASMJS_UNKNOWN_EMSCRIPTEN = 0
+ assert 'asmjs-unknown-emscripten' not in shared.COMPILER_OPTS
+ elif shared.LLVM_TARGET == 'asmjs-unknown-emscripten' or \
+ shared.LLVM_TARGET == 'le32-unknown-nacl':
+ # For temporary compatibility, treat 'le32-unknown-nacl' as 'asmjs-unknown-emscripten'.
+ shared.Settings.TARGET_ASMJS_UNKNOWN_EMSCRIPTEN = 1
shared.Settings.TARGET_X86 = 0
assert 'i386-pc-linux-gnu' not in shared.COMPILER_OPTS
else:
diff --git a/emscripten.py b/emscripten.py
index 4001a100..cb9eefab 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -538,7 +538,7 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None,
''.join([' var ' + g + '=+env.' + g + ';\n' for g in basic_float_vars])
# In linkable modules, we need to add some explicit globals for global variables that can be linked and used across modules
if settings.get('MAIN_MODULE') or settings.get('SIDE_MODULE'):
- assert settings.get('TARGET_LE32'), 'TODO: support x86 target when linking modules (needs offset of 4 and not 8 here)'
+ assert settings.get('TARGET_ASMJS_UNKNOWN_EMSCRIPTEN'), 'TODO: support x86 target when linking modules (needs offset of 4 and not 8 here)'
for key, value in forwarded_json['Variables']['globals'].iteritems():
if value.get('linkable'):
init = forwarded_json['Variables']['indexedGlobals'][key] + 8 # 8 is Runtime.GLOBAL_BASE / STATIC_BASE
@@ -801,8 +801,8 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
if DEBUG: logging.debug('emscript: js compiler glue')
# Settings changes
- assert settings['TARGET_LE32'] == 1
- settings['TARGET_LE32'] = 2
+ assert settings['TARGET_ASMJS_UNKNOWN_EMSCRIPTEN'] == 1
+ settings['TARGET_ASMJS_UNKNOWN_EMSCRIPTEN'] = 2
i64_funcs = ['i64Add', 'i64Subtract', '__muldi3', '__divdi3', '__udivdi3', '__remdi3', '__uremdi3']
for i64_func in i64_funcs:
if i64_func in metadata['declares']:
@@ -1087,7 +1087,7 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
asm_global_vars = ''.join([' var ' + g + '=env.' + g + '|0;\n' for g in basic_vars + global_vars])
# In linkable modules, we need to add some explicit globals for global variables that can be linked and used across modules
if settings.get('MAIN_MODULE') or settings.get('SIDE_MODULE'):
- assert settings.get('TARGET_LE32'), 'TODO: support x86 target when linking modules (needs offset of 4 and not 8 here)'
+ assert settings.get('TARGET_ASMJS_UNKNOWN_EMSCRIPTEN'), 'TODO: support x86 target when linking modules (needs offset of 4 and not 8 here)'
for key, value in forwarded_json['Variables']['globals'].iteritems():
if value.get('linkable'):
init = forwarded_json['Variables']['indexedGlobals'][key] + 8 # 8 is Runtime.GLOBAL_BASE / STATIC_BASE
diff --git a/scons-tools/emscripten.py b/scons-tools/emscripten.py
index 4c48083e..af85f106 100755
--- a/scons-tools/emscripten.py
+++ b/scons-tools/emscripten.py
@@ -274,7 +274,7 @@ def generate(env):
RANLIBCOM='',
CCFLAGS=[
'-U__STRICT_ANSI__',
- '-target', 'le32-unknown-nacl',
+ '-target', 'asmjs-unknown-emscripten',
'-nostdinc',
'-Wno-#warnings',
'-Wno-error=unused-variable',
diff --git a/src/intertyper.js b/src/intertyper.js
index 4e91261e..7743ce62 100644
--- a/src/intertyper.js
+++ b/src/intertyper.js
@@ -348,7 +348,7 @@ function intertyper(lines, sidePass, baseLineNums) {
if (token1Text == 'triple') {
var triple = item.tokens[3].text;
triple = triple.substr(1, triple.length-2);
- var expected = TARGET_LE32 ? 'le32-unknown-nacl' : 'i386-pc-linux-gnu';
+ var expected = TARGET_ASMJS_UNKNOWN_EMSCRIPTEN ? 'asmjs-unknown-emscripten' : 'i386-pc-linux-gnu';
if (triple !== expected) {
warn('using an unexpected LLVM triple: ' + [triple, ' !== ', expected] + ' (are you using emcc for everything and not clang?)');
}
@@ -688,7 +688,7 @@ function intertyper(lines, sidePass, baseLineNums) {
Types.hasInlineJS = true;
warnOnce('inline JavaScript using asm() will cause the code to no longer fall in the asm.js subset of JavaScript, which can reduce performance - consider using emscripten_run_script');
}
- assert(TARGET_LE32, 'inline js is only supported in le32');
+ assert(TARGET_ASMJS_UNKNOWN_EMSCRIPTEN, 'inline js is only supported in asmjs-unknown-emscripten');
// Inline assembly is just JavaScript that we paste into the code
item.intertype = 'value';
if (tokensLeft[0].text == 'sideeffect') tokensLeft.splice(0, 1);
diff --git a/src/jsifier.js b/src/jsifier.js
index c1ca893b..56dc9d26 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -1413,7 +1413,7 @@ function JSify(data, functionsOnly) {
}
}
function va_argHandler(item) {
- assert(TARGET_LE32);
+ assert(TARGET_ASMJS_UNKNOWN_EMSCRIPTEN);
var ident = item.value.ident;
var move = Runtime.STACK_ALIGN;
@@ -1710,7 +1710,7 @@ function JSify(data, functionsOnly) {
if ((phase == 'pre' || phase == 'glue') && !Variables.generatedGlobalBase && !BUILD_AS_SHARED_LIB) {
Variables.generatedGlobalBase = true;
// Globals are done, here is the rest of static memory
- assert((TARGET_LE32 && Runtime.GLOBAL_BASE == 8) || (TARGET_X86 && Runtime.GLOBAL_BASE == 4)); // this is assumed in e.g. relocations for linkable modules
+ assert((TARGET_ASMJS_UNKNOWN_EMSCRIPTEN && Runtime.GLOBAL_BASE == 8) || (TARGET_X86 && Runtime.GLOBAL_BASE == 4)); // this is assumed in e.g. relocations for linkable modules
if (!SIDE_MODULE) {
print('STATIC_BASE = ' + Runtime.GLOBAL_BASE + ';\n');
print('STATICTOP = STATIC_BASE + ' + Runtime.alignMemory(Variables.nextIndexedOffset) + ';\n');
diff --git a/src/library.js b/src/library.js
index 5df5ff20..18a794fd 100644
--- a/src/library.js
+++ b/src/library.js
@@ -1861,14 +1861,14 @@ LibraryManager.library = {
// int x = 4; printf("%c\n", (char)x);
var ret;
if (type === 'double') {
-#if TARGET_LE32 == 2
+#if TARGET_ASMJS_UNKNOWN_EMSCRIPTEN == 2
ret = {{{ makeGetValue('varargs', 'argIndex', 'double', undefined, undefined, true, 4) }}};
#else
ret = {{{ makeGetValue('varargs', 'argIndex', 'double', undefined, undefined, true) }}};
#endif
#if USE_TYPED_ARRAYS == 2
} else if (type == 'i64') {
-#if TARGET_LE32 == 1
+#if TARGET_ASMJS_UNKNOWN_EMSCRIPTEN == 1
ret = [{{{ makeGetValue('varargs', 'argIndex', 'i32', undefined, undefined, true) }}},
{{{ makeGetValue('varargs', 'argIndex+8', 'i32', undefined, undefined, true) }}}];
argIndex += {{{ STACK_ALIGN }}}; // each 32-bit chunk is in a 64-bit block
@@ -1885,7 +1885,7 @@ LibraryManager.library = {
type = 'i32'; // varargs are always i32, i64, or double
ret = {{{ makeGetValue('varargs', 'argIndex', 'i32', undefined, undefined, true) }}};
}
-#if TARGET_LE32 == 2
+#if TARGET_ASMJS_UNKNOWN_EMSCRIPTEN == 2
argIndex += Runtime.getNativeFieldSize(type);
#else
argIndex += Math.max(Runtime.getNativeFieldSize(type), Runtime.getAlignSize(type, null, true));
@@ -2859,7 +2859,7 @@ LibraryManager.library = {
vsscanf: 'sscanf',
#endif
-#if TARGET_LE32
+#if TARGET_ASMJS_UNKNOWN_EMSCRIPTEN
// convert va_arg into varargs
vfprintf__deps: ['fprintf'],
vfprintf: function(s, f, va_arg) {
@@ -4178,7 +4178,7 @@ LibraryManager.library = {
#if TARGET_X86
return makeSetValue(ptr, 0, 'varrp', 'void*');
#endif
-#if TARGET_LE32
+#if TARGET_ASMJS_UNKNOWN_EMSCRIPTEN
// 2-word structure: struct { void* start; void* currentOffset; }
return makeSetValue(ptr, 0, 'varrp', 'void*') + ';' + makeSetValue(ptr, Runtime.QUANTUM_SIZE, 0, 'void*');
#endif
diff --git a/src/parseTools.js b/src/parseTools.js
index fe56580e..4fb76196 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1161,7 +1161,7 @@ function getHeapOffset(offset, type, forceAsm) {
if (Runtime.getNativeFieldSize(type) > 4) {
if (type == 'i64' || TARGET_X86) {
- type = 'i32'; // XXX we emulate 64-bit values as 32 in x86, and also in le32 but only i64, not double
+ type = 'i32'; // XXX we emulate 64-bit values as 32 in x86, and also in asmjs-unknown-emscripten but only i64, not double
}
}
@@ -1287,7 +1287,7 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSa
return '{ ' + ret.join(', ') + ' }';
}
- // In double mode 1, in x86 we always assume unaligned because we can't trust that; otherwise in le32
+ // In double mode 1, in x86 we always assume unaligned because we can't trust that; otherwise in asmjs-unknown-emscripten
// we need this code path if we are not fully aligned.
if (DOUBLE_MODE == 1 && USE_TYPED_ARRAYS == 2 && type == 'double' && (TARGET_X86 || align < 8)) {
return '(' + makeSetTempDouble(0, 'i32', makeGetValue(ptr, pos, 'i32', noNeedFirst, unsigned, ignore, align, noSafe)) + ',' +
@@ -1826,7 +1826,7 @@ function makeGetSlabs(ptr, type, allowMultiple, unsigned) {
case '<4 x i32>':
case 'i32': case 'i64': return [unsigned ? 'HEAPU32' : 'HEAP32']; break;
case 'double': {
- if (TARGET_LE32) return ['HEAPF64']; // in le32, we do have the ability to assume 64-bit alignment
+ if (TARGET_ASMJS_UNKNOWN_EMSCRIPTEN) return ['HEAPF64']; // in asmjs-unknown-emscripten, we do have the ability to assume 64-bit alignment
// otherwise, fall through to float
}
case '<4 x float>':
diff --git a/src/runtime.js b/src/runtime.js
index fecd3b68..97de7473 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -185,10 +185,10 @@ var Runtime = {
// type can be a native type or a struct (or null, for structs we only look at size here)
getAlignSize: function(type, size, vararg) {
// we align i64s and doubles on 64-bit boundaries, unlike x86
-#if TARGET_LE32 == 1
+#if TARGET_ASMJS_UNKNOWN_EMSCRIPTEN == 1
if (vararg) return 8;
#endif
-#if TARGET_LE32
+#if TARGET_ASMJS_UNKNOWN_EMSCRIPTEN
if (!vararg && (type == 'i64' || type == 'double')) return 8;
if (!type) return Math.min(size, 8); // align structures internally to 64 bits
#endif
diff --git a/src/settings.js b/src/settings.js
index 1c6b998e..7f9fbabf 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -23,8 +23,8 @@ var QUANTUM_SIZE = 4; // This is the size of an individual field in a structure.
// Changing this from the default of 4 is deprecated.
var TARGET_X86 = 0; // For i386-pc-linux-gnu
-var TARGET_LE32 = 1; // For le32-unknown-nacl. 1 is normal, 2 is for the fastcomp llvm
- // backend using pnacl abi simplification
+var TARGET_ASMJS_UNKNOWN_EMSCRIPTEN = 1; // For asmjs-unknown-emscripten. 1 is normal, 2 is for the fastcomp llvm
+ // backend using emscripten-customized abi simplification
var CORRECT_SIGNS = 1; // Whether we make sure to convert unsigned values to signed values.
// Decreases performance with additional runtime checks. Might not be
diff --git a/tools/shared.py b/tools/shared.py
index b170972b..a9a3fa4e 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -618,7 +618,7 @@ except:
# Target choice. Must be synced with src/settings.js (TARGET_*)
def get_llvm_target():
- return os.environ.get('EMCC_LLVM_TARGET') or 'le32-unknown-nacl' # 'i386-pc-linux-gnu'
+ return os.environ.get('EMCC_LLVM_TARGET') or 'asmjs-unknown-emscripten'
LLVM_TARGET = get_llvm_target()
# COMPILER_OPTS: options passed to clang when generating bitcode for us
@@ -631,8 +631,9 @@ COMPILER_OPTS = COMPILER_OPTS + ['-m32', '-DEMSCRIPTEN', '-D__EMSCRIPTEN__',
#'-fno-threadsafe-statics', # disabled due to issue 1289
'-target', LLVM_TARGET]
-if LLVM_TARGET == 'le32-unknown-nacl':
- COMPILER_OPTS = filter(lambda opt: opt != '-m32', COMPILER_OPTS) # le32 target is 32-bit anyhow, no need for -m32
+# For temporary compatibility, treat 'le32-unknown-nacl' as 'asmjs-unknown-emscripten'.
+if LLVM_TARGET == 'asmjs-unknown-emscripten' or LLVM_TARGET == 'le32-unknown-nacl':
+ COMPILER_OPTS = filter(lambda opt: opt != '-m32', COMPILER_OPTS) # asmjs-unknown-emscripten target is 32-bit anyhow, no need for -m32
COMPILER_OPTS += ['-U__native_client__', '-U__pnacl__', '-U__ELF__'] # The nacl target is originally used for Google Native Client. Emscripten is not NaCl, so remove the platform #define, when using their triple.
# Remove various platform specific defines, and set little endian
@@ -658,8 +659,10 @@ if USE_EMSDK:
'-Xclang', '-isystem' + path_from_root('system', 'include', 'SDL'),
]
EMSDK_OPTS += COMPILER_STANDARDIZATION_OPTS
- if LLVM_TARGET != 'le32-unknown-nacl':
- EMSDK_CXX_OPTS = ['-nostdinc++'] # le32 target does not need -nostdinc++
+ # For temporary compatibility, treat 'le32-unknown-nacl' as 'asmjs-unknown-emscripten'.
+ if LLVM_TARGET != 'asmjs-unknown-emscripten' and \
+ LLVM_TARGET != 'le32-unknown-pnacl':
+ EMSDK_CXX_OPTS = ['-nostdinc++'] # asmjs-unknown-emscripten target does not need -nostdinc++
else:
EMSDK_CXX_OPTS = []
COMPILER_OPTS += EMSDK_OPTS