diff options
author | Vladimir Vukicevic <vladimirv@dugeo.com> | 2013-02-26 18:43:00 -0500 |
---|---|---|
committer | Vladimir Vukicevic <vladimirv@dugeo.com> | 2013-02-26 18:43:00 -0500 |
commit | f1f101ee44d7ddcee996594c2f9a265ca3a43036 (patch) | |
tree | cf4a1fb1e0164dc9ab4a60cb7af65a59f3cd981d /tools/shared.py | |
parent | b2496c286d3ea0a5d5365f10bc1ebc67f66e5cc3 (diff) |
Generate response file for llvm-link
Diffstat (limited to 'tools/shared.py')
-rw-r--r-- | tools/shared.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tools/shared.py b/tools/shared.py index c8c09617..6cd28401 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -812,7 +812,25 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e # Finish link actual_files = unique_ordered(actual_files) # tolerate people trying to link a.so a.so etc. if DEBUG: print >>sys.stderr, 'emcc: llvm-linking:', actual_files - output = Popen([LLVM_LINK] + actual_files + ['-o', target], stdout=PIPE).communicate()[0] + + # check for too-long command line + linkcmd = [LLVM_LINK] + actual_files + ['-o', target] + # 8k is a bit of an arbitrary limit, but a reasonable one + # for max command line size before we use a respose file + responseFile = None + if len(" ".join(linkcmd)) > 8192: + [responseFD, responseFile] = mkstemp(suffix='.response', dir=TEMP_DIR) + responseFH = os.fdopen(responseFD, 'w') + for arg in actual_files: + responseFH.write(arg + "\n") + responseFH.close() + linkcmd = [LLVM_LINK, "@" + responseFile, '-o', target] + + output = Popen(linkcmd, stdout=PIPE).communicate()[0] + + if responseFile: + os.unlink(responseFile) + assert os.path.exists(target) and (output is None or 'Could not open input file' not in output), 'Linking error: ' + output for temp_dir in temp_dirs: try_delete(temp_dir) |