aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-02-15 18:14:46 -0500
committerAlon Zakai <alonzakai@gmail.com>2012-02-15 18:14:46 -0500
commit7d756357d7dec0009a9f0c603da0b95cf5a211f4 (patch)
tree9c0b67d35d04abd9773306bec2303151728f3cee
parentd8e25261b69dd4cd5acaacf6c76d7c658c25e9bd (diff)
handle singleton .a files
-rwxr-xr-xemcc11
-rwxr-xr-xtests/runner.py10
2 files changed, 18 insertions, 3 deletions
diff --git a/emcc b/emcc
index 1ec8bdad..d7b7396f 100755
--- a/emcc
+++ b/emcc
@@ -243,6 +243,9 @@ BITCODE_SUFFIXES = ('.bc', '.o')
SHAREDLIB_SUFFIXES = ('.dylib', '.so', '.dll')
ASSEMBLY_SUFFIXES = ('.ll',)
+def suffix(name):
+ return name.split('.')[:-1]
+
def unsuffixed(name):
return '.'.join(name.split('.')[:-1])
@@ -552,9 +555,11 @@ try:
if fix:
fix()
- # First, combine the bitcode files if there are several
- if len(input_files) + len(extra_files_to_link) > 1:
- linker_inputs = map(lambda input_file: in_temp(unsuffixed_basename(input_file) + '.o'), input_files) + extra_files_to_link
+ # First, combine the bitcode files if there are several. We must also link if we have a singleton .a
+ suff = suffix(temp_files[0])
+ if len(input_files) + len(extra_files_to_link) > 1 or \
+ (not (suff in BITCODE_SUFFIXES or suff in SHAREDLIB_SUFFIXES) and shared.Building.is_ar(temp_files[0])):
+ linker_inputs = temp_files + extra_files_to_link
if DEBUG: print >> sys.stderr, 'emcc: linking: ', linker_inputs
shared.Building.link(linker_inputs,
in_temp(target_basename + '.bc'))
diff --git a/tests/runner.py b/tests/runner.py
index a99a8320..13679871 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -5671,6 +5671,16 @@ Options that are modified or new in %s include:
assert os.path.exists(target + '.js'), 'Expected %s to exist since args are %s : %s' % (target + '.js', str(args), '\n'.join(output))
self.assertContained('hello, world!', run_js(target + '.js'))
+ # handle singleton archives
+ clear()
+ Popen([compiler, path_from_root('tests', 'hello_world' + suffix), '-o', 'a.bc'], stdout=PIPE, stderr=PIPE).communicate()
+ Popen([LLVM_AR, 'r', 'a.a', 'a.bc'], stdout=PIPE, stderr=PIPE).communicate()
+ assert os.path.exists('a.a')
+ shutil.copyfile('a.a', '/home/alon/a.a')
+ output = Popen([compiler, 'a.a']).communicate()
+ assert os.path.exists('a.out.js'), output
+ self.assertContained('hello, world!', run_js('a.out.js'))
+
# emcc src.ll ==> generates .js
clear()
output = Popen([compiler, path_from_root('tests', 'hello_world.ll')], stdout=PIPE, stderr=PIPE).communicate()