webruby 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/lib/webruby/environment.rb +4 -0
  3. data/lib/webruby/rake/files.rake +2 -1
  4. data/lib/webruby/rake/mruby.rake +4 -2
  5. data/modules/emscripten/AUTHORS +1 -0
  6. data/modules/emscripten/cmake/Platform/Emscripten.cmake +2 -0
  7. data/modules/emscripten/emcc +96 -40
  8. data/modules/emscripten/emrun +301 -136
  9. data/modules/emscripten/emscripten.py +5 -45
  10. data/modules/emscripten/src/analyzer.js +11 -1
  11. data/modules/emscripten/src/compiler.js +1 -1
  12. data/modules/emscripten/src/emrun_postjs.js +2 -2
  13. data/modules/emscripten/src/emrun_prejs.js +5 -0
  14. data/modules/emscripten/src/emscripten-source-map.min.js +31 -0
  15. data/modules/emscripten/src/library.js +187 -0
  16. data/modules/emscripten/src/library_egl.js +20 -0
  17. data/modules/emscripten/src/library_sdl.js +1 -0
  18. data/modules/emscripten/src/preamble.js +4 -0
  19. data/modules/emscripten/src/relooper/Relooper.cpp +33 -15
  20. data/modules/emscripten/src/relooper/Relooper.h +20 -14
  21. data/modules/emscripten/src/relooper/fuzzer.py +6 -0
  22. data/modules/emscripten/src/relooper/test.cpp +28 -0
  23. data/modules/emscripten/src/relooper/test.txt +211 -166
  24. data/modules/emscripten/src/relooper/test2.txt +20 -20
  25. data/modules/emscripten/src/relooper/test3.txt +41 -41
  26. data/modules/emscripten/src/relooper/test4.txt +26 -26
  27. data/modules/emscripten/src/relooper/test5.txt +52 -52
  28. data/modules/emscripten/src/relooper/test6.txt +19 -19
  29. data/modules/emscripten/src/relooper/test_dead.txt +1 -1
  30. data/modules/emscripten/src/relooper/test_debug.txt +31 -31
  31. data/modules/emscripten/src/relooper/test_fuzz1.txt +50 -50
  32. data/modules/emscripten/src/relooper/test_fuzz2.txt +21 -21
  33. data/modules/emscripten/src/relooper/test_fuzz3.txt +18 -18
  34. data/modules/emscripten/src/relooper/test_fuzz4.txt +28 -28
  35. data/modules/emscripten/src/relooper/test_fuzz5.txt +61 -61
  36. data/modules/emscripten/src/relooper/test_fuzz6.txt +179 -179
  37. data/modules/emscripten/src/relooper/test_inf.txt +846 -846
  38. data/modules/emscripten/src/relooper/testit.sh +15 -15
  39. data/modules/emscripten/system/include/emscripten/emscripten.h +64 -0
  40. data/modules/emscripten/tools/eliminator/asm-eliminator-test-output.js +8 -2
  41. data/modules/emscripten/tools/eliminator/asm-eliminator-test.js +9 -1
  42. data/modules/emscripten/tools/eliminator/eliminator-test-output.js +11 -0
  43. data/modules/emscripten/tools/eliminator/eliminator-test.js +16 -1
  44. data/modules/emscripten/tools/file_packager.py +59 -49
  45. data/modules/emscripten/tools/js-optimizer.js +47 -8
  46. data/modules/emscripten/tools/shared.py +3 -3
  47. data/modules/emscripten/tools/test-js-optimizer-asm-pre-output.js +5 -3
  48. data/modules/emscripten/tools/test-js-optimizer-asm-pre.js +4 -0
  49. data/modules/mruby/INSTALL +11 -6
  50. data/modules/mruby/include/mrbconf.h +0 -3
  51. data/modules/mruby/include/mruby/khash.h +34 -36
  52. data/modules/mruby/include/mruby/string.h +3 -0
  53. data/modules/mruby/include/mruby.h +3 -3
  54. data/modules/mruby/mrblib/string.rb +3 -0
  55. data/modules/mruby/src/class.c +12 -12
  56. data/modules/mruby/src/codegen.c +18 -11
  57. data/modules/mruby/src/hash.c +12 -12
  58. data/modules/mruby/src/kernel.c +3 -3
  59. data/modules/mruby/src/load.c +29 -14
  60. data/modules/mruby/src/numeric.c +1 -1
  61. data/modules/mruby/src/object.c +14 -2
  62. data/modules/mruby/src/state.c +13 -10
  63. data/modules/mruby/src/string.c +1 -3
  64. data/modules/mruby/src/symbol.c +44 -18
  65. data/modules/mruby/src/variable.c +6 -6
  66. data/modules/mruby/test/t/class.rb +34 -0
  67. data/modules/mruby/test/t/module.rb +1 -1
  68. data/modules/mruby/test/t/syntax.rb +28 -0
  69. metadata +5 -13
  70. data/modules/emscripten/src/relooper.js +0 -11516
  71. data/modules/emscripten/src/relooper.js.raw.js +0 -11511
  72. data/modules/emscripten/tools/__init__.pyc +0 -0
  73. data/modules/emscripten/tools/cache.pyc +0 -0
  74. data/modules/emscripten/tools/gen_struct_info.pyc +0 -0
  75. data/modules/emscripten/tools/js_optimizer.pyc +0 -0
  76. data/modules/emscripten/tools/jsrun.pyc +0 -0
  77. data/modules/emscripten/tools/response_file.pyc +0 -0
  78. data/modules/emscripten/tools/shared.pyc +0 -0
  79. data/modules/emscripten/tools/tempfiles.pyc +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aedc4071e607370d314a952a88efe13293725e20
4
- data.tar.gz: cb178b987350f414363cbe3c2c7ed61ebb15f0d8
3
+ metadata.gz: 8aa9f4f3e59012a040e4f07a5bc66d2d6cb095ec
4
+ data.tar.gz: c0b1bc4d899990bf072b9c73732dc53b0bd0279f
5
5
  SHA512:
6
- metadata.gz: bb8bfa9b37a5400335a4940ea35081e66faf7a95bfe3bb486c6da157224afe455e492334a1f39a2c52b00a049c241c882b3f50c66b2e8e1f34f2585c59a781ae
7
- data.tar.gz: b728f44d40dbbab32a0b1288871739f9e28f6991b5e0653a268603501948fd7eb89c706c892c964da01cb260b191880b39b6bf7d28342ea83222a2acf4972267
6
+ metadata.gz: 963102b0355a11a2412d344525217fdc4cbf34d0e8495b714d7c4922dc96e18ccdeca1748cd6a84a123d17b45ccaf0c2a1ffcafcf0d7652094d5319986785d7d
7
+ data.tar.gz: 9699973d8194cc3ccfadc5ba513ce10cccec9565193236f16dc7558a8ef1c24d9ee6816f957c9d5d8f3ee621b1f719e29d01424963714d1d2d1c4c5a47805e2b
@@ -45,3 +45,7 @@ __EOF__
45
45
 
46
46
  exec(EMCC)
47
47
  end
48
+
49
+ if `uname -a`.downcase.index("cygwin")
50
+ ENV['CYGWIN'] = 'nodosfilewarning'
51
+ end
@@ -13,7 +13,8 @@ file "#{Webruby.build_dir}/rbcode.c" => [Webruby.entrypoint_file,
13
13
  Webruby.build_dir] +
14
14
  Webruby.rb_files do |t|
15
15
  if Webruby::App.config.source_processor == :gen_require
16
- sh "MRBC=#{Webruby.full_build_dir}/#{MRBC} ruby #{SCRIPT_GEN_REQUIRE} #{File.expand_path(Webruby.entrypoint_file)} #{Webruby.full_build_dir}/rbcode.c"
16
+ ENV["MRBC"] = "#{Webruby.full_build_dir}/#{MRBC}"
17
+ sh "ruby #{SCRIPT_GEN_REQUIRE} #{File.expand_path(Webruby.entrypoint_file)} #{Webruby.full_build_dir}/rbcode.c"
17
18
  else
18
19
  sh "ruby #{MRUBYMIX} #{Webruby.entrypoint_file} #{Webruby.build_dir}/rbcode.rb"
19
20
  sh "#{Webruby.build_dir}/#{MRBC} -Bapp_irep -o#{Webruby.build_dir}/rbcode.c #{Webruby.build_dir}/rbcode.rb"
@@ -36,10 +36,12 @@ end
36
36
 
37
37
  desc "build mruby library"
38
38
  task :libmruby => Webruby.build_config do |t|
39
- sh "cd #{MRUBY_DIR} && MRUBY_CONFIG=#{Webruby.full_build_config} ./minirake #{Webruby.full_build_dir}/#{LIBMRUBY}"
39
+ ENV["MRUBY_CONFIG"] = Webruby.full_build_config
40
+ sh "cd #{MRUBY_DIR} && ruby ./minirake #{Webruby.full_build_dir}/#{LIBMRUBY}"
40
41
  end
41
42
 
42
43
  desc "mruby test library"
43
44
  task :libmruby_test => Webruby.build_config do |t|
44
- sh "cd #{MRUBY_DIR} && MRUBY_CONFIG=#{Webruby.full_build_config} ./minirake #{Webruby.full_build_dir}/#{MRBTEST}"
45
+ ENV["MRUBY_CONFIG"] = Webruby.full_build_config
46
+ sh "cd #{MRUBY_DIR} && ruby ./minirake #{Webruby.full_build_dir}/#{MRBTEST}"
45
47
  end
@@ -113,3 +113,4 @@ a license to everyone to use it as detailed in LICENSE.)
113
113
  * Heidi Pan <heidi.pan@intel.com> (copyright owned by Intel)
114
114
  * Vasilis Kalintiris <ehostunreach@gmail.com>
115
115
  * Adam C. Clifton <adam@hulkamaniac.com>
116
+ * Volo Zyko <volo.zyko@gmail.com>
@@ -109,6 +109,8 @@ set(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG "@")
109
109
  # Specify the program to use when building static libraries. Force Emscripten-related command line options to clang.
110
110
  set(CMAKE_CXX_ARCHIVE_CREATE "${CMAKE_AR} rc <TARGET> ${CMAKE_START_TEMP_FILE} <LINK_FLAGS> <OBJECTS>${CMAKE_END_TEMP_FILE}")
111
111
  set(CMAKE_C_ARCHIVE_CREATE "${CMAKE_AR} rc <TARGET> ${CMAKE_START_TEMP_FILE} <LINK_FLAGS> <OBJECTS>${CMAKE_END_TEMP_FILE}")
112
+ set(CMAKE_CXX_ARCHIVE_APPEND "${CMAKE_AR} r <TARGET> ${CMAKE_START_TEMP_FILE} <LINK_FLAGS> <OBJECTS>${CMAKE_END_TEMP_FILE}")
113
+ set(CMAKE_C_ARCHIVE_APPEND "${CMAKE_AR} r <TARGET> ${CMAKE_START_TEMP_FILE} <LINK_FLAGS> <OBJECTS>${CMAKE_END_TEMP_FILE}")
112
114
 
113
115
  # Set a global EMSCRIPTEN variable that can be used in client CMakeLists.txt to detect when building using Emscripten.
114
116
  # 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".
@@ -53,14 +53,17 @@ from tools import shared, jsrun
53
53
  from tools.shared import Compression, execute, suffix, unsuffixed, unsuffixed_basename, WINDOWS
54
54
  from tools.response_file import read_response_file
55
55
 
56
- C_SUFFIXES = ('.c', '.C')
57
- CXX_SUFFIXES = ('.cpp', '.cxx', '.cc', '.CPP', '.CXX', '.CC')
58
- SOURCE_SUFFIXES = C_SUFFIXES + CXX_SUFFIXES + ('.m', '.mm')
59
- BITCODE_SUFFIXES = ('.bc', '.o', '.obj')
60
- DYNAMICLIB_SUFFIXES = ('.dylib', '.so', '.dll')
61
- STATICLIB_SUFFIXES = ('.a',)
62
- ASSEMBLY_SUFFIXES = ('.ll',)
56
+ # endings = dot + a suffix, safe to test by filename.endswith(endings)
57
+ C_ENDINGS = ('.c', '.C')
58
+ CXX_ENDINGS = ('.cpp', '.cxx', '.cc', '.CPP', '.CXX', '.CC')
59
+ SOURCE_ENDINGS = C_ENDINGS + CXX_ENDINGS + ('.m', '.mm')
60
+ BITCODE_ENDINGS = ('.bc', '.o', '.obj')
61
+ DYNAMICLIB_ENDINGS = ('.dylib', '.so', '.dll')
62
+ STATICLIB_ENDINGS = ('.a',)
63
+ ASSEMBLY_ENDINGS = ('.ll',)
64
+
63
65
  LIB_PREFIXES = ('', 'lib')
66
+
64
67
  JS_CONTAINING_SUFFIXES = ('js', 'html')
65
68
 
66
69
  # Mapping of emcc opt levels to llvm opt levels. We use llvm opt level 3 in emcc opt
@@ -341,6 +344,10 @@ Options that are modified or new in %s include:
341
344
  For more docs on the options --preload-file
342
345
  accepts, see https://github.com/kripken/emscripten/wiki/Filesystem-Guide
343
346
 
347
+ --exclude-file <name> Files and directories to be excluded from
348
+ --embed-file and --preload-file
349
+ wildcard is supported
350
+
344
351
  --compression <codec> Compress both the compiled code and embedded/
345
352
  preloaded files. <codec> should be a triple,
346
353
 
@@ -758,9 +765,13 @@ def in_temp(name):
758
765
  def filename_type_suffix(filename):
759
766
  for i in reversed(filename.split('.')[1:]):
760
767
  if not i.isdigit():
761
- return '.' + i
768
+ return i
762
769
  return ''
763
770
 
771
+ def filename_type_ending(filename):
772
+ suffix = filename_type_suffix(filename)
773
+ return '' if not suffix else ('.' + suffix)
774
+
764
775
  try:
765
776
  call = CXX if use_cxx else CC
766
777
 
@@ -780,6 +791,7 @@ try:
780
791
  split_js_file = None
781
792
  preload_files = []
782
793
  embed_files = []
794
+ exclude_files = []
783
795
  compression = None
784
796
  ignore_dynamic_linking = False
785
797
  shell_path = shared.path_from_root('src', 'shell.html')
@@ -896,6 +908,11 @@ try:
896
908
  preload_files.append(newargs[i+1])
897
909
  newargs[i] = ''
898
910
  newargs[i+1] = ''
911
+ elif newargs[i].startswith('--exclude-file'):
912
+ check_bad_eq(newargs[i])
913
+ exclude_files.append(newargs[i+1])
914
+ newargs[i] = ''
915
+ newargs[i+1] = ''
899
916
  elif newargs[i].startswith('--compression'):
900
917
  check_bad_eq(newargs[i])
901
918
  parts = newargs[i+1].split(',')
@@ -990,6 +1007,7 @@ try:
990
1007
  newargs = newargs + [default_cxx_std]
991
1008
 
992
1009
  if emrun:
1010
+ pre_js += open(shared.path_from_root('src', 'emrun_prejs.js')).read() + '\n'
993
1011
  post_js += open(shared.path_from_root('src', 'emrun_postjs.js')).read() + '\n'
994
1012
 
995
1013
  if js_opts is None: js_opts = opt_level >= 2
@@ -1042,23 +1060,23 @@ try:
1042
1060
  prev = newargs[i-1]
1043
1061
  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
1044
1062
 
1045
- if (os.path.islink(arg) and os.path.realpath(arg).endswith(SOURCE_SUFFIXES + BITCODE_SUFFIXES + DYNAMICLIB_SUFFIXES + ASSEMBLY_SUFFIXES)):
1063
+ if (os.path.islink(arg) and os.path.realpath(arg).endswith(SOURCE_ENDINGS + BITCODE_ENDINGS + DYNAMICLIB_ENDINGS + ASSEMBLY_ENDINGS)):
1046
1064
  arg = os.path.realpath(arg)
1047
1065
 
1048
1066
  if not arg.startswith('-'):
1049
1067
  if not os.path.exists(arg):
1050
- logging.error(arg + ': No such file or directory')
1068
+ logging.error('%s: No such file or directory ("%s" was expected to be an input file, based on the commandline arguments provided)' % (arg, arg))
1051
1069
  exit(1)
1052
1070
 
1053
- arg_suffix = filename_type_suffix(arg)
1054
- 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
1071
+ arg_ending = filename_type_ending(arg)
1072
+ if arg_ending.endswith(SOURCE_ENDINGS + BITCODE_ENDINGS + DYNAMICLIB_ENDINGS + ASSEMBLY_ENDINGS) or shared.Building.is_ar(arg): # we already removed -o <target>, so all these should be inputs
1055
1073
  newargs[i] = ''
1056
- if arg_suffix.endswith(SOURCE_SUFFIXES):
1074
+ if arg_ending.endswith(SOURCE_ENDINGS):
1057
1075
  input_files.append(arg)
1058
1076
  has_source_inputs = True
1059
- elif arg_suffix.endswith(ASSEMBLY_SUFFIXES) or shared.Building.is_bitcode(arg): # this should be bitcode, make sure it is valid
1077
+ elif arg_ending.endswith(ASSEMBLY_ENDINGS) or shared.Building.is_bitcode(arg): # this should be bitcode, make sure it is valid
1060
1078
  input_files.append(arg)
1061
- elif arg_suffix.endswith(STATICLIB_SUFFIXES + DYNAMICLIB_SUFFIXES):
1079
+ elif arg_ending.endswith(STATICLIB_ENDINGS + DYNAMICLIB_ENDINGS):
1062
1080
  # if it's not, and it's a library, just add it to libs to find later
1063
1081
  l = unsuffixed_basename(arg)
1064
1082
  for prefix in LIB_PREFIXES:
@@ -1070,10 +1088,10 @@ try:
1070
1088
  newargs[i] = ''
1071
1089
  else:
1072
1090
  logging.warning(arg + ' is not valid LLVM bitcode')
1073
- elif arg_suffix.endswith(STATICLIB_SUFFIXES):
1091
+ elif arg_ending.endswith(STATICLIB_ENDINGS):
1074
1092
  if not shared.Building.is_ar(arg):
1075
1093
  if shared.Building.is_bitcode(arg):
1076
- 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))
1094
+ logging.error(arg + ': File has a suffix of a static library ' + str(STATICLIB_ENDINGS) + ', but instead is an LLVM bitcode file! When linking LLVM bitcode files, use one of the suffixes ' + str(BITCODE_ENDINGS))
1077
1095
  else:
1078
1096
  logging.error(arg + ': Unknown format, not a static library!')
1079
1097
  exit(1)
@@ -1098,17 +1116,12 @@ try:
1098
1116
  target = target_basename + '.o'
1099
1117
  final_suffix = 'o'
1100
1118
 
1101
- # do not link in libs when just generating object code (not an 'executable', i.e. JS, or a library)
1102
- if ('.' + final_suffix) in BITCODE_SUFFIXES and len(libs) > 0:
1103
- logging.warning('not linking against libraries since only compiling to bitcode')
1104
- libs = []
1105
-
1106
1119
  # Find library files
1107
1120
  for lib in libs:
1108
1121
  logging.debug('looking for library "%s"' % lib)
1109
1122
  found = False
1110
1123
  for prefix in LIB_PREFIXES:
1111
- for suff in STATICLIB_SUFFIXES + DYNAMICLIB_SUFFIXES:
1124
+ for suff in STATICLIB_ENDINGS + DYNAMICLIB_ENDINGS:
1112
1125
  name = prefix + lib + suff
1113
1126
  for lib_dir in lib_dirs:
1114
1127
  path = os.path.join(lib_dir, name)
@@ -1119,12 +1132,21 @@ try:
1119
1132
  break
1120
1133
  if found: break
1121
1134
  if found: break
1122
-
1123
- if ignore_dynamic_linking:
1124
- input_files = filter(lambda input_file: not input_file.endswith(DYNAMICLIB_SUFFIXES), input_files)
1135
+ if not found: logging.warning('emcc: cannot find library "%s"' % lib)
1136
+
1137
+ # If not compiling to JS, then we are compiling to an intermediate bitcode objects or library, so
1138
+ # ignore dynamic linking, since multiple dynamic linkings can interfere with each other
1139
+ if not filename_type_suffix(target) in JS_CONTAINING_SUFFIXES or ignore_dynamic_linking:
1140
+ def check(input_file):
1141
+ if filename_type_ending(input_file) in DYNAMICLIB_ENDINGS:
1142
+ if not ignore_dynamic_linking: logging.warning('ignoring dynamic library %s because not compiling to JS or HTML, remember to link it when compiling to JS or HTML at the end' % os.path.basename(input_file))
1143
+ return False
1144
+ else:
1145
+ return True
1146
+ input_files = filter(lambda input_file: check(input_file), input_files)
1125
1147
 
1126
1148
  if len(input_files) == 0:
1127
- logging.error('no input files\nnote that input files without a known suffix are ignored, make sure your input files end with one of: ' + str(SOURCE_SUFFIXES + BITCODE_SUFFIXES + DYNAMICLIB_SUFFIXES + STATICLIB_SUFFIXES + ASSEMBLY_SUFFIXES))
1149
+ logging.error('no input files\nnote that input files without a known suffix are ignored, make sure your input files end with one of: ' + str(SOURCE_ENDINGS + BITCODE_ENDINGS + DYNAMICLIB_ENDINGS + STATICLIB_ENDINGS + ASSEMBLY_ENDINGS))
1128
1150
  exit(0)
1129
1151
 
1130
1152
  newargs = CC_ADDITIONAL_ARGS + newargs
@@ -1151,8 +1173,28 @@ try:
1151
1173
  logging.warning('disabling asm.js since embind is not ready for it yet')
1152
1174
  shared.Settings.ASM_JS = 0
1153
1175
 
1176
+ if os.environ.get('EMCC_FAST_COMPILER'):
1177
+ shared.Settings.ASM_JS = 1
1178
+ if shared.Settings.DISABLE_EXCEPTION_CATCHING == 0:
1179
+ logging.warning('disabling exception catching since not supported in fastcomp yet')
1180
+ shared.Settings.DISABLE_EXCEPTION_CATCHING = 1
1181
+ assert shared.Settings.ALLOW_MEMORY_GROWTH == 0, 'memory growth not supported in fastcomp yet'
1182
+ assert shared.Settings.UNALIGNED_MEMORY == 0, 'forced unaligned memory not supported in fastcomp'
1183
+ assert shared.Settings.SAFE_HEAP == 0, 'safe heap not supported in fastcomp yet'
1184
+ assert shared.Settings.CHECK_HEAP_ALIGN == 0, 'check heap align not supported in fastcomp yet'
1185
+ assert shared.Settings.SAFE_DYNCALLS == 0, 'safe dyncalls not supported in fastcomp'
1186
+ assert shared.Settings.RESERVED_FUNCTION_POINTERS == 0, 'reserved function pointers not supported in fastcomp'
1187
+ assert shared.Settings.ASM_HEAP_LOG == 0, 'asm heap log not supported in fastcomp'
1188
+ assert shared.Settings.LABEL_DEBUG == 0, 'label debug not supported in fastcomp'
1189
+ assert shared.Settings.LEGACY_GL_EMULATION == 0, 'legacy gl emulation not supported in fastcomp'
1190
+ assert shared.Settings.EXECUTION_TIMEOUT == -1, 'execution timeout not supported in fastcomp'
1191
+ assert shared.Settings.NAMED_GLOBALS == 0, 'named globals not supported in fastcomp'
1192
+ assert shared.Settings.PGO == 0, 'pgo not supported in fastcomp'
1193
+ assert shared.Settings.TARGET_LE32 == 1, 'fastcomp requires le32'
1194
+ assert not bind, 'embind not supported in fastcomp yet'
1195
+
1154
1196
  if shared.Settings.ASM_JS:
1155
- assert opt_level >= 1, 'asm.js requires -O1 or above'
1197
+ assert opt_level >= 1 or os.environ.get('EMCC_FAST_COMPILER'), 'asm.js requires -O1 or above'
1156
1198
 
1157
1199
  if bind:
1158
1200
  shared.Settings.RESERVED_FUNCTION_POINTERS = max(shared.Settings.RESERVED_FUNCTION_POINTERS, 10)
@@ -1241,14 +1283,14 @@ try:
1241
1283
 
1242
1284
  # First, generate LLVM bitcode. For each input file, we get base.o with bitcode
1243
1285
  for input_file in input_files:
1244
- file_suffix = filename_type_suffix(input_file)
1245
- if file_suffix.endswith(SOURCE_SUFFIXES):
1286
+ file_ending = filename_type_ending(input_file)
1287
+ if file_ending.endswith(SOURCE_ENDINGS):
1246
1288
  logging.debug('compiling source file: ' + input_file)
1247
1289
  input_file = shared.Building.preprocess(input_file, in_temp(uniquename(input_file)))
1248
1290
  output_file = in_temp(unsuffixed(uniquename(input_file)) + '.o')
1249
1291
  temp_files.append(output_file)
1250
1292
  args = newargs + ['-emit-llvm', '-c', input_file, '-o', output_file]
1251
- if file_suffix.endswith(CXX_SUFFIXES):
1293
+ if file_ending.endswith(CXX_ENDINGS):
1252
1294
  args += shared.EMSDK_CXX_OPTS
1253
1295
  logging.debug("running: " + call + ' ' + ' '.join(args))
1254
1296
  execute([call] + args) # let compiler frontend print directly, so colors are saved (PIPE kills that)
@@ -1256,17 +1298,17 @@ try:
1256
1298
  logging.error('compiler frontend failed to generate LLVM bitcode, halting')
1257
1299
  sys.exit(1)
1258
1300
  else: # bitcode
1259
- if file_suffix.endswith(BITCODE_SUFFIXES):
1301
+ if file_ending.endswith(BITCODE_ENDINGS):
1260
1302
  logging.debug('copying bitcode file: ' + input_file)
1261
1303
  temp_file = in_temp(unsuffixed(uniquename(input_file)) + '.o')
1262
1304
  shutil.copyfile(input_file, temp_file)
1263
1305
  temp_files.append(temp_file)
1264
- elif file_suffix.endswith(DYNAMICLIB_SUFFIXES) or shared.Building.is_ar(input_file):
1306
+ elif file_ending.endswith(DYNAMICLIB_ENDINGS) or shared.Building.is_ar(input_file):
1265
1307
  logging.debug('copying library file: ' + input_file)
1266
1308
  temp_file = in_temp(uniquename(input_file))
1267
1309
  shutil.copyfile(input_file, temp_file)
1268
1310
  temp_files.append(temp_file)
1269
- elif file_suffix.endswith(ASSEMBLY_SUFFIXES):
1311
+ elif file_ending.endswith(ASSEMBLY_ENDINGS):
1270
1312
  if not LEAVE_INPUTS_RAW:
1271
1313
  # Note that by assembling the .ll file, then disassembling it later, we will
1272
1314
  # remove annotations which is a good thing for compilation time
@@ -1284,8 +1326,8 @@ try:
1284
1326
  # Optimize source files
1285
1327
  if llvm_opts > 0:
1286
1328
  for i, input_file in enumerate(input_files):
1287
- file_suffix = filename_type_suffix(input_file)
1288
- if file_suffix.endswith(SOURCE_SUFFIXES):
1329
+ file_ending = filename_type_ending(input_file)
1330
+ if file_ending.endswith(SOURCE_ENDINGS):
1289
1331
  temp_file = temp_files[i]
1290
1332
  logging.debug('optimizing %s with -O%s' % (input_file, llvm_opts))
1291
1333
  shared.Building.llvm_opt(temp_file, llvm_opts)
@@ -1630,11 +1672,11 @@ try:
1630
1672
 
1631
1673
  # First, combine the bitcode files if there are several. We must also link if we have a singleton .a
1632
1674
  if len(input_files) + len(extra_files_to_link) > 1 or \
1633
- (not LEAVE_INPUTS_RAW and not (suffix(temp_files[0]) in BITCODE_SUFFIXES or suffix(temp_files[0]) in DYNAMICLIB_SUFFIXES) and shared.Building.is_ar(temp_files[0])):
1675
+ (not LEAVE_INPUTS_RAW and not (suffix(temp_files[0]) in BITCODE_ENDINGS or suffix(temp_files[0]) in DYNAMICLIB_ENDINGS) and shared.Building.is_ar(temp_files[0])):
1634
1676
  linker_inputs = temp_files + extra_files_to_link
1635
1677
  logging.debug('linking: ' + str(linker_inputs))
1636
1678
  t0 = time.time()
1637
- shared.Building.link(linker_inputs, in_temp(target_basename + '.bc'), force_archive_contents = len(filter(lambda temp: not temp.endswith(STATICLIB_SUFFIXES), temp_files)) == 0)
1679
+ shared.Building.link(linker_inputs, in_temp(target_basename + '.bc'), force_archive_contents = len(filter(lambda temp: not temp.endswith(STATICLIB_ENDINGS), temp_files)) == 0)
1638
1680
  t1 = time.time()
1639
1681
  logging.debug(' linking took %.2f seconds' % (t1 - t0))
1640
1682
  final = in_temp(target_basename + '.bc')
@@ -1679,7 +1721,12 @@ try:
1679
1721
  else:
1680
1722
  # At minimum remove dead functions etc., this potentially saves a lot in the size of the generated code (and the time to compile it)
1681
1723
  link_opts += shared.Building.get_safe_internalize() + ['-globaldce']
1682
- if not save_bc:
1724
+
1725
+ # Simplify LLVM bitcode for fastcomp
1726
+ if os.environ.get('EMCC_FAST_COMPILER') and not AUTODEBUG:
1727
+ link_opts += ['-pnacl-abi-simplify-preopt', '-pnacl-abi-simplify-postopt']
1728
+
1729
+ if (not save_bc and not os.environ.get('EMCC_FAST_COMPILER')) or AUTODEBUG:
1683
1730
  # let llvm opt directly emit ll, to skip writing and reading all the bitcode
1684
1731
  link_opts += ['-S']
1685
1732
  shared.Building.llvm_opt(final, link_opts, final + '.link.ll')
@@ -1706,6 +1753,12 @@ try:
1706
1753
  final += '.ad.ll'
1707
1754
  if DEBUG: save_intermediate('autodebug', 'll')
1708
1755
 
1756
+ # Simplify bitcode after autodebug
1757
+ if os.environ.get('EMCC_FAST_COMPILER') and (AUTODEBUG or LEAVE_INPUTS_RAW):
1758
+ shared.Building.llvm_opt(final, ['-pnacl-abi-simplify-preopt', '-pnacl-abi-simplify-postopt'], final + '.adsimp.bc')
1759
+ final += '.adsimp.bc'
1760
+ if DEBUG: save_intermediate('adsimp', 'bc')
1761
+
1709
1762
  # Emscripten
1710
1763
  logging.debug('LLVM => JS')
1711
1764
  extra_args = [] if not js_libraries else ['--libraries', ','.join(map(os.path.abspath, js_libraries))]
@@ -1716,13 +1769,16 @@ try:
1716
1769
  # Embed and preload files
1717
1770
  if len(preload_files) + len(embed_files) > 0:
1718
1771
  logging.debug('setting up files')
1719
- file_args = ['--pre-run']
1772
+ file_args = []
1720
1773
  if len(preload_files) > 0:
1721
1774
  file_args.append('--preload')
1722
1775
  file_args += preload_files
1723
1776
  if len(embed_files) > 0:
1724
1777
  file_args.append('--embed')
1725
1778
  file_args += embed_files
1779
+ if len(exclude_files) > 0:
1780
+ file_args.append('--exclude')
1781
+ file_args += exclude_files
1726
1782
  if Compression.on:
1727
1783
  file_args += ['--compress', Compression.encoder, Compression.decoder, Compression.js_name]
1728
1784
  if use_preload_cache: