aboutsummaryrefslogtreecommitdiff
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
parent2f5e6f993e1b1a446331520b4dc2d5b19d597371 (diff)
parent7c8e4eb469dac56b6bc3bbd979ed2245e0cecfbe (diff)
Merge pull request #877 from vvuk/response-files
Add response file support to emscripten
-rw-r--r--AUTHORS1
-rwxr-xr-xemcc22
-rw-r--r--tools/shared.py20
3 files changed, 42 insertions, 1 deletions
diff --git a/AUTHORS b/AUTHORS
index 3a7ceb32..ef611d55 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -50,4 +50,5 @@ a license to everyone to use it as detailed in LICENSE.)
* Bruce Mitchener, Jr. <bruce.mitchener@gmail.com>
* Michael Bishop <mbtyke@gmail.com>
* Roger Braun <roger@rogerbraun.net>
+* Vladimir Vukicevic <vladimir@pobox.com> (copyright owned by Mozilla Foundation)
diff --git a/emcc b/emcc
index 2f4bad2b..15742d1a 100755
--- a/emcc
+++ b/emcc
@@ -1,4 +1,5 @@
#!/usr/bin/env python2
+# -*- Mode: python -*-
'''
emcc - compiler helper script
@@ -118,6 +119,27 @@ if len(sys.argv) == 1:
print 'emcc: no input files'
exit(1)
+# read response files very early on
+response_file = True
+while response_file:
+ response_file = None
+ for index in range(1, len(sys.argv)):
+ if sys.argv[index][0] == '@':
+ # found one, loop again next time
+ response_file = sys.argv[index][1:]
+ if not os.path.exists(response_file):
+ print >>sys.stderr, 'emcc: error: Response file not found: %s' % response_file
+ exit(1)
+
+ response_fd = open(response_file, 'r')
+ extra_args = shlex.split(response_fd.read())
+ response_fd.close()
+
+ # slice in extra_args in place of the response file arg
+ sys.argv[index:index+1] = extra_args
+ #if DEBUG: print >>sys.stderr, "Expanded response file: " + " | ".join(sys.argv)
+ break
+
if sys.argv[1] == '--version':
revision = '(unknown revision)'
here = os.getcwd()
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)