diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/autodebugger_c.py | 10 | ||||
-rw-r--r-- | tools/js_optimizer.py | 4 | ||||
-rw-r--r-- | tools/shared.py | 40 |
3 files changed, 40 insertions, 14 deletions
diff --git a/tools/autodebugger_c.py b/tools/autodebugger_c.py index 5d41faf0..54a4d691 100644 --- a/tools/autodebugger_c.py +++ b/tools/autodebugger_c.py @@ -21,9 +21,13 @@ for filename in filenames: if m and (' if ' not in lines[i-1] or '{' in lines[i-1]) and \ (' if ' not in lines[i+1] or '{' in lines[i+1]) and \ (' else' not in lines[i-1] or '{' in lines[i-1]) and \ - (' else' not in lines[i+1] or '{' in lines[i+1]): - var = m.groups(1)[0].rstrip().split(' ')[-1] - lines[i] += ''' printf("%s:%d:%s=%%d\\n", %s);''' % (filename, i+1, var, var) + (' else' not in lines[i+1] or '{' in lines[i+1]) and \ + (' for' not in lines[i-1]) and \ + ('struct' not in lines[i]): + raw = m.groups(1)[0].rstrip() + var = raw.split(' ')[-1] + if ' ' in raw and '[' in var: continue + lines[i] += ''' printf("%s:%d:%s=%%d\\n", (int)%s);''' % (filename, i+1, var, var) f = open(filename, 'w') f.write('\n'.join(lines)) diff --git a/tools/js_optimizer.py b/tools/js_optimizer.py index 52cae6e5..231c6257 100644 --- a/tools/js_optimizer.py +++ b/tools/js_optimizer.py @@ -11,7 +11,7 @@ def path_from_root(*pathelems): JS_OPTIMIZER = path_from_root('tools', 'js-optimizer.js') NUM_CHUNKS_PER_CORE = 1.5 -MIN_CHUNK_SIZE = 1024*1024 +MIN_CHUNK_SIZE = int(os.environ.get('EMCC_JSOPT_MIN_CHUNK_SIZE') or 1024*1024) # configuring this is just for debugging purposes MAX_CHUNK_SIZE = 20*1024*1024 WINDOWS = sys.platform.startswith('win') @@ -139,7 +139,7 @@ def run_on_js(filename, passes, js_engine, jcache): if len(filenames) > 0: # XXX Use '--nocrankshaft' to disable crankshaft to work around v8 bug 1895, needed for older v8/node (node 0.6.8+ should be ok) - commands = map(lambda filename: [js_engine, JS_OPTIMIZER, filename, 'noPrintMetadata'] + passes, filenames) + commands = map(lambda filename: js_engine + [JS_OPTIMIZER, filename, 'noPrintMetadata'] + passes, filenames) #print [' '.join(command) for command in commands] cores = min(cores, filenames) diff --git a/tools/shared.py b/tools/shared.py index 6f97737e..aca0677d 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -2,6 +2,10 @@ import shutil, time, os, sys, json, tempfile, copy, shlex, atexit, subprocess, h from subprocess import Popen, PIPE, STDOUT from tempfile import mkstemp +def listify(x): + if type(x) is not list: return [x] + return x + # On Windows python suffers from a particularly nasty bug if python is spawning new processes while python itself is spawned from some other non-console process. # Use a custom replacement for Popen on Windows to avoid the "WindowsError: [Error 6] The handle is invalid" errors when emcc is driven through cmake or mingw32-make. # See http://bugs.python.org/issue3905 @@ -28,7 +32,10 @@ class WindowsPopen: self.stderr_ = PIPE # Call the process with fixed streams. - self.process = subprocess.Popen(args, bufsize, executable, self.stdin_, self.stdout_, self.stderr_, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags) + try: + self.process = subprocess.Popen(args, bufsize, executable, self.stdin_, self.stdout_, self.stderr_, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags) + except Exception, e: + print >> sys.stderr, 'subprocess.Popen(args=%s) failed! Exception %s' % (' '.join(args), str(e)) def communicate(self, input=None): output = self.process.communicate(input) @@ -155,7 +162,8 @@ EXPECTED_NODE_VERSION = (0,6,8) def check_node_version(): try: - actual = Popen([NODE_JS, '--version'], stdout=PIPE).communicate()[0].strip() + node = listify(NODE_JS) + actual = Popen(node + ['--version'], stdout=PIPE).communicate()[0].strip() version = tuple(map(int, actual.replace('v', '').split('.'))) if version >= EXPECTED_NODE_VERSION: return True @@ -380,6 +388,9 @@ if USE_EMSDK: else: EMSDK_OPTS = [] +#print >> sys.stderr, 'SDK opts', ' '.join(EMSDK_OPTS) +#print >> sys.stderr, 'Compiler opts', ' '.join(COMPILER_OPTS) + # Engine tweaks try: @@ -465,7 +476,8 @@ def timeout_run(proc, timeout, note='unnamed process', full_output=False): def run_js(filename, engine=None, args=[], check_timeout=False, stdout=PIPE, stderr=None, cwd=None, full_output=False): if engine is None: engine = JS_ENGINES[0] - if type(engine) is not list: engine = [engine] + engine = listify(engine) + #if not WINDOWS: 'd8' in engine[0] or 'node' in engine[0]: engine += ['--stack_size=8192'] # needed for some big projects command = engine + [filename] + (['--'] if 'd8' in engine[0] else []) + args return timeout_run(Popen(command, stdout=stdout, stderr=stderr, cwd=cwd), 15*60 if check_timeout else None, 'Execution', full_output=full_output) @@ -571,8 +583,7 @@ class Settings: if opt_level >= 2: Settings.RELOOP = 1 if opt_level >= 3: - # Aside from these, -O3 also runs closure compiler - Settings.INLINING_LIMIT = 0 + # Aside from these, -O3 also runs closure compiler and llvm lto Settings.DOUBLE_MODE = 0 Settings.PRECISE_I64_MATH = 0 if noisy: print >> sys.stderr, 'Warning: Applying some potentially unsafe optimizations! (Use -O2 if this fails.)' @@ -822,14 +833,25 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e # 8k is a bit of an arbitrary limit, but a reasonable one # for max command line size before we use a respose file response_file = None - if len(' '.join(link_cmd)) > 8192: + if WINDOWS and len(' '.join(link_cmd)) > 8192: if DEBUG: print >>sys.stderr, 'using response file for llvm-link' [response_fd, response_file] = mkstemp(suffix='.response', dir=TEMP_DIR) + + link_cmd = [LLVM_LINK, "@" + response_file] + response_fh = os.fdopen(response_fd, 'w') for arg in actual_files: - response_fh.write(arg + "\n") + # we can't put things with spaces in the response file + if " " in arg: + link_cmd.append(arg) + else: + response_fh.write(arg + "\n") response_fh.close() - link_cmd = [LLVM_LINK, "@" + response_file, '-o', target] + link_cmd.append("-o") + link_cmd.append(target) + + if len(' '.join(link_cmd)) > 8192: + print >>sys.stderr, 'emcc: warning: link command line is very long, even with response file -- use paths with no spaces' output = Popen(link_cmd, stdout=PIPE).communicate()[0] @@ -1078,7 +1100,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e @staticmethod def js_optimizer(filename, passes, jcache): - return js_optimizer.run(filename, passes, NODE_JS, jcache) + return js_optimizer.run(filename, passes, listify(NODE_JS), jcache) @staticmethod def closure_compiler(filename): |