aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-10-08 11:47:14 -0400
committerAlon Zakai <alonzakai@gmail.com>2013-10-08 11:47:14 -0400
commit0a229cf5a240a1ebf4ff5d0ebb501a286bc96202 (patch)
tree2797d054788e88863d77f9826dde94fb4c276c69
parent05b6aa32a5f1633797f7eae390b3a8048b29ca69 (diff)
parentae5ef852920ce67449af7693f05a767a87aed976 (diff)
Merge branch 'incoming'
-rw-r--r--AUTHORS4
-rw-r--r--cmake/Platform/Emscripten.cmake4
-rwxr-xr-xemcc132
-rwxr-xr-xemscripten.py123
-rw-r--r--src/analyzer.js34
-rw-r--r--src/compiler.js15
-rw-r--r--src/compiler_phase.html33
-rw-r--r--src/fastLong.js12
-rw-r--r--src/intertyper.js168
-rw-r--r--src/jsifier.js216
-rw-r--r--src/library.js845
-rw-r--r--src/library_fs.js83
-rw-r--r--src/library_gl.js168
-rw-r--r--src/library_idbfs.js216
-rw-r--r--src/library_memfs.js23
-rw-r--r--src/library_nodefs.js234
-rw-r--r--src/library_sdl.js465
-rw-r--r--src/library_sockfs.js12
-rw-r--r--src/modules.js28
-rw-r--r--src/parseTools.js314
-rw-r--r--src/preamble.js31
-rw-r--r--src/runtime.js19
-rw-r--r--src/settings.js444
-rw-r--r--src/struct_info.json1045
-rw-r--r--src/utility.js11
-rw-r--r--system/include/emscripten/emscripten.h10
-rw-r--r--system/lib/libc/musl/src/internal/locale_impl.h5
-rw-r--r--system/lib/libc/musl/src/internal/stdio_impl.h92
-rw-r--r--system/lib/libc/musl/src/locale/big5.h1085
-rw-r--r--system/lib/libc/musl/src/locale/codepages.h238
-rw-r--r--system/lib/libc/musl/src/locale/gb18030.h1836
-rw-r--r--system/lib/libc/musl/src/locale/hkscs.h390
-rw-r--r--system/lib/libc/musl/src/locale/iconv.c454
-rw-r--r--system/lib/libc/musl/src/locale/iswalnum_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/iswalpha_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/iswblank_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/iswcntrl_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/iswctype_l.c9
-rw-r--r--system/lib/libc/musl/src/locale/iswdigit_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/iswgraph_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/iswlower_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/iswprint_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/iswpunct_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/iswspace_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/iswupper_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/iswxdigit_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/jis0208.h550
-rw-r--r--system/lib/libc/musl/src/locale/ksc.h640
-rw-r--r--system/lib/libc/musl/src/locale/legacychars.h39
-rw-r--r--system/lib/libc/musl/src/locale/strfmon.c101
-rw-r--r--system/lib/libc/musl/src/locale/strxfrm.c18
-rw-r--r--system/lib/libc/musl/src/locale/towctrans_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/towlower_l.c9
-rw-r--r--system/lib/libc/musl/src/locale/towupper_l.c9
-rw-r--r--system/lib/libc/musl/src/locale/wcscoll.c16
-rw-r--r--system/lib/libc/musl/src/locale/wcscoll_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/wcsxfrm.c21
-rw-r--r--system/lib/libc/musl/src/locale/wcsxfrm_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/wctrans_l.c6
-rw-r--r--system/lib/libc/musl/src/locale/wctype_l.c9
-rw-r--r--system/lib/libc/musl/src/stdio/fwprintf.c13
-rw-r--r--system/lib/libc/musl/src/stdio/swprintf.c14
-rw-r--r--system/lib/libc/musl/src/stdio/vfwprintf.c361
-rw-r--r--system/lib/libc/musl/src/stdio/vswprintf.c53
-rw-r--r--system/lib/libc/musl/src/stdio/vwprintf.c7
-rw-r--r--system/lib/libc/musl/src/stdio/wprintf.c13
-rw-r--r--system/lib/libcextra.symbols44
-rw-r--r--tests/cases/fp80_ta2.ll21
-rw-r--r--tests/fs/test_idbfs_sync.c48
-rw-r--r--tests/fs/test_nodefs_rw.c49
-rw-r--r--tests/printf/output.txt11
-rw-r--r--tests/printf/output_i64_1.txt11
-rw-r--r--tests/printf/test.c11
-rwxr-xr-xtests/runner.py9
-rw-r--r--tests/sdl_audio_beep.cpp246
-rw-r--r--tests/sdl_canvas_alpha.c46
-rw-r--r--tests/sdl_canvas_alpha.pngbin0 -> 169826 bytes
-rw-r--r--tests/test_browser.py16
-rw-r--r--tests/test_core.py144
-rw-r--r--tests/test_other.py10
-rw-r--r--tests/test_sanity.py1
-rw-r--r--tests/unistd/access.c17
-rw-r--r--tests/unistd/access.out40
-rw-r--r--tests/unistd/io.c13
-rw-r--r--tests/unistd/links.c21
-rw-r--r--tests/unistd/links.out6
-rw-r--r--tests/unistd/misc.c24
-rw-r--r--tests/unistd/truncate.c23
-rw-r--r--tests/unistd/unlink.c12
-rw-r--r--tools/asm_module.py2
-rw-r--r--tools/eliminator/asm-eliminator-test-output.js4835
-rw-r--r--tools/eliminator/asm-eliminator-test.js6495
-rw-r--r--tools/gen_struct_info.py509
-rw-r--r--tools/js-optimizer.js35
-rw-r--r--tools/jsrun.py18
-rw-r--r--tools/shared.py33
-rw-r--r--tools/tempfiles.py1
-rw-r--r--tools/test-js-optimizer-asm-pre-output.js20
-rw-r--r--tools/test-js-optimizer-asm-pre.js21
-rw-r--r--tools/test-js-optimizer-asm-regs.js4
100 files changed, 10541 insertions, 13022 deletions
diff --git a/AUTHORS b/AUTHORS
index 604bd6bd..d8f9da02 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,4 +1,4 @@
-The following authors have all licensed their contributions to Emscripten
+The following authors have all licensed their contributions to Emscripten
under the licensing terms detailed in LICENSE.
(Authors keep copyright of their contributions, of course; they just grant
@@ -97,4 +97,6 @@ a license to everyone to use it as detailed in LICENSE.)
* Charlie Birks <admin@daftgames.net>
* Ranger Harke <ranger.harke@autodesk.com> (copyright owned by Autodesk, Inc.)
* Tobias Vrinssen <tobias@vrinssen.de>
+* Patrick R. Martin <patrick.martin.r@gmail.com>
+* Richard Quirk <richard.quirk@gmail.com>
diff --git a/cmake/Platform/Emscripten.cmake b/cmake/Platform/Emscripten.cmake
index 73f2c8ad..7c8e83fa 100644
--- a/cmake/Platform/Emscripten.cmake
+++ b/cmake/Platform/Emscripten.cmake
@@ -104,8 +104,8 @@ set(CMAKE_C_RESPONSE_FILE_LINK_FLAG "@")
set(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG "@")
# Specify the program to use when building static libraries. Force Emscripten-related command line options to clang.
-set(CMAKE_CXX_ARCHIVE_CREATE "${CMAKE_CXX_COMPILER} ${CMAKE_START_TEMP_FILE} -o <TARGET> -emit-llvm <LINK_FLAGS> <OBJECTS>${CMAKE_END_TEMP_FILE}")
-set(CMAKE_C_ARCHIVE_CREATE "${CMAKE_C_COMPILER} ${CMAKE_START_TEMP_FILE} -o <TARGET> -emit-llvm <LINK_FLAGS> <OBJECTS>${CMAKE_END_TEMP_FILE}")
+set(CMAKE_CXX_ARCHIVE_CREATE "${CMAKE_AR} rc <TARGET> ${CMAKE_START_TEMP_FILE} <LINK_FLAGS> <OBJECTS>${CMAKE_END_TEMP_FILE}")
+set(CMAKE_C_ARCHIVE_CREATE "${CMAKE_AR} rc <TARGET> ${CMAKE_START_TEMP_FILE} <LINK_FLAGS> <OBJECTS>${CMAKE_END_TEMP_FILE}")
# Set a global EMSCRIPTEN variable that can be used in client CMakeLists.txt to detect when building using Emscripten.
# There seems to be some kind of bug with CMake, so you might need to define this manually on the command line with "-DEMSCRIPTEN=1".
diff --git a/emcc b/emcc
index cd42d49a..ff81e424 100755
--- a/emcc
+++ b/emcc
@@ -720,6 +720,13 @@ else:
def in_temp(name):
return os.path.join(temp_dir, os.path.basename(name))
+# Parses the essential suffix of a filename, discarding Unix-style version numbers in the name. For example for 'libz.so.1.2.8' returns '.so'
+def filename_type_suffix(filename):
+ for i in reversed(filename.split('.')[1:]):
+ if not i.isdigit():
+ return '.' + i
+ return ''
+
try:
call = CXX if use_cxx else CC
@@ -926,7 +933,7 @@ try:
if default_cxx_std:
newargs = newargs + [default_cxx_std]
- if js_opts is None: js_opts = True
+ if js_opts is None: js_opts = opt_level >= 1
if llvm_opts is None: llvm_opts = LLVM_OPT_LEVEL[opt_level]
if llvm_lto is None and opt_level >= 3: llvm_lto = 3
if opt_level == 0: debug_level = 4
@@ -974,35 +981,45 @@ try:
if i > 0:
prev = newargs[i-1]
- if prev in ['-MT', '-MF', '-MQ', '-D', '-U', '-o', '-x', '-Xpreprocessor', '-include', '-imacros', '-idirafter', '-iprefix', '-iwithprefix', '-iwithprefixbefore', '-isysroot', '-imultilib', '-A', '-isystem', '-iquote', '-install_name', '-I', '-L']: continue # ignore this gcc-style argument
+ if prev in ['-MT', '-MF', '-MQ', '-D', '-U', '-o', '-x', '-Xpreprocessor', '-include', '-imacros', '-idirafter', '-iprefix', '-iwithprefix', '-iwithprefixbefore', '-isysroot', '-imultilib', '-A', '-isystem', '-iquote', '-install_name', '-compatibility_version', '-current_version', '-I', '-L']: continue # ignore this gcc-style argument
if (os.path.islink(arg) and os.path.realpath(arg).endswith(SOURCE_SUFFIXES + BITCODE_SUFFIXES + DYNAMICLIB_SUFFIXES + ASSEMBLY_SUFFIXES)):
arg = os.path.realpath(arg)
- if not arg.startswith('-') and (arg.endswith(SOURCE_SUFFIXES + BITCODE_SUFFIXES + DYNAMICLIB_SUFFIXES + ASSEMBLY_SUFFIXES) or shared.Building.is_ar(arg)): # we already removed -o <target>, so all these should be inputs
- newargs[i] = ''
- if os.path.exists(arg):
- if arg.endswith(SOURCE_SUFFIXES):
+ if not arg.startswith('-'):
+ if not os.path.exists(arg):
+ logging.error(arg + ': No such file or directory')
+ exit(1)
+
+ arg_suffix = filename_type_suffix(arg)
+ if arg_suffix.endswith(SOURCE_SUFFIXES + BITCODE_SUFFIXES + DYNAMICLIB_SUFFIXES + ASSEMBLY_SUFFIXES) or shared.Building.is_ar(arg): # we already removed -o <target>, so all these should be inputs
+ newargs[i] = ''
+ if arg_suffix.endswith(SOURCE_SUFFIXES):
input_files.append(arg)
has_source_inputs = True
+ elif arg_suffix.endswith(ASSEMBLY_SUFFIXES) or shared.Building.is_bitcode(arg): # this should be bitcode, make sure it is valid
+ input_files.append(arg)
+ elif arg_suffix.endswith(STATICLIB_SUFFIXES + DYNAMICLIB_SUFFIXES):
+ # if it's not, and it's a library, just add it to libs to find later
+ l = unsuffixed_basename(arg)
+ for prefix in LIB_PREFIXES:
+ if not prefix: continue
+ if l.startswith(prefix):
+ l = l[len(prefix):]
+ break
+ libs.append(l)
+ newargs[i] = ''
else:
- # this should be bitcode, make sure it is valid
- if arg.endswith(ASSEMBLY_SUFFIXES) or shared.Building.is_bitcode(arg):
- input_files.append(arg)
- elif arg.endswith(STATICLIB_SUFFIXES + DYNAMICLIB_SUFFIXES):
- # if it's not, and it's a library, just add it to libs to find later
- l = unsuffixed_basename(arg)
- for prefix in LIB_PREFIXES:
- if not prefix: continue
- if l.startswith(prefix):
- l = l[len(prefix):]
- break
- libs.append(l)
- newargs[i] = ''
+ logging.warning(arg + ' is not valid LLVM bitcode')
+ elif arg_suffix.endswith(STATICLIB_SUFFIXES):
+ if not shared.Building.is_ar(arg):
+ if shared.Building.is_bitcode(arg):
+ logging.error(arg + ': File has a suffix of a static library ' + str(STATICLIB_SUFFIXES) + ', but instead is an LLVM bitcode file! When linking LLVM bitcode files, use one of the suffixes ' + str(BITCODE_SUFFIXES))
else:
- logging.warning(arg + ' is not valid LLVM bitcode')
+ logging.error(arg + ': Unknown format, not a static library!')
+ exit(1)
else:
- logging.error(arg + ': No such file or directory')
+ logging.error(arg + ": Input file has an unknown suffix, don't know what to do with it!")
exit(1)
elif arg.startswith('-L'):
lib_dirs.append(arg[2:])
@@ -1119,6 +1136,7 @@ try:
if shared.Settings.MAIN_MODULE or shared.Settings.SIDE_MODULE:
assert not memory_init_file, 'memory init file is not supported with module linking'
+ assert shared.Settings.ASM_JS, 'module linking requires asm.js output (-s ASM_JS=1)'
shared.Settings.LINKABLE = 1 # TODO: add FORCE_DCE option for the brave people that do want to dce here and in side modules
debug_level = max(debug_level, 2)
@@ -1143,6 +1161,9 @@ try:
if proxy_to_worker:
shared.Settings.PROXY_TO_WORKER = 1
+ if js_opts:
+ shared.Settings.RUNNING_JS_OPTS = 1
+
## Compile source code to bitcode
logging.debug('compiling to bitcode')
@@ -1151,13 +1172,14 @@ try:
# First, generate LLVM bitcode. For each input file, we get base.o with bitcode
for input_file in input_files:
- if input_file.endswith(SOURCE_SUFFIXES):
+ file_suffix = filename_type_suffix(input_file)
+ if file_suffix.endswith(SOURCE_SUFFIXES):
logging.debug('compiling source file: ' + input_file)
input_file = shared.Building.preprocess(input_file, in_temp(uniquename(input_file)))
output_file = in_temp(unsuffixed(uniquename(input_file)) + '.o')
temp_files.append(output_file)
args = newargs + ['-emit-llvm', '-c', input_file, '-o', output_file]
- if input_file.endswith(CXX_SUFFIXES):
+ if file_suffix.endswith(CXX_SUFFIXES):
args += shared.EMSDK_CXX_OPTS
logging.debug("running: " + call + ' ' + ' '.join(args))
execute([call] + args) # let compiler frontend print directly, so colors are saved (PIPE kills that)
@@ -1165,17 +1187,17 @@ try:
logging.error('compiler frontend failed to generate LLVM bitcode, halting')
sys.exit(1)
else: # bitcode
- if input_file.endswith(BITCODE_SUFFIXES):
+ if file_suffix.endswith(BITCODE_SUFFIXES):
logging.debug('copying bitcode file: ' + input_file)
temp_file = in_temp(unsuffixed(uniquename(input_file)) + '.o')
shutil.copyfile(input_file, temp_file)
temp_files.append(temp_file)
- elif input_file.endswith(DYNAMICLIB_SUFFIXES) or shared.Building.is_ar(input_file):
+ elif file_suffix.endswith(DYNAMICLIB_SUFFIXES) or shared.Building.is_ar(input_file):
logging.debug('copying library file: ' + input_file)
temp_file = in_temp(uniquename(input_file))
shutil.copyfile(input_file, temp_file)
temp_files.append(temp_file)
- else: #.ll
+ elif file_suffix.endswith(ASSEMBLY_SUFFIXES):
if not LEAVE_INPUTS_RAW:
# Note that by assembling the .ll file, then disassembling it later, we will
# remove annotations which is a good thing for compilation time
@@ -1183,6 +1205,9 @@ try:
temp_file = in_temp(unsuffixed(uniquename(input_file)) + '.o')
shared.Building.llvm_as(input_file, temp_file)
temp_files.append(temp_file)
+ else:
+ logging.error(input_file + ': Unknown file suffix when compiling to LLVM bitcode!')
+ sys.exit(1)
if not LEAVE_INPUTS_RAW:
assert len(temp_files) == len(input_files)
@@ -1190,7 +1215,8 @@ try:
# Optimize source files
if llvm_opts > 0:
for i, input_file in enumerate(input_files):
- if input_file.endswith(SOURCE_SUFFIXES):
+ file_suffix = filename_type_suffix(input_file)
+ if file_suffix.endswith(SOURCE_SUFFIXES):
temp_file = temp_files[i]
logging.debug('optimizing %s with -O%d' % (input_file, llvm_opts))
shared.Building.llvm_opt(temp_file, llvm_opts)
@@ -1217,7 +1243,7 @@ try