aboutsummaryrefslogtreecommitdiff
path: root/tools/shared.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-02-26 16:08:29 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-02-26 16:08:29 -0800
commit58af9770c7e38daedfd8f088995a4657f835fd68 (patch)
tree490a057a37db9c5e303e472f83dd5cb372969897 /tools/shared.py
parent2f5e6f993e1b1a446331520b4dc2d5b19d597371 (diff)
parent7c8e4eb469dac56b6bc3bbd979ed2245e0cecfbe (diff)
Merge pull request #877 from vvuk/response-files
Add response file support to emscripten
Diffstat (limited to 'tools/shared.py')
-rw-r--r--tools/shared.py20
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)