diff options
-rwxr-xr-x | emcc | 11 | ||||
-rwxr-xr-x | tests/runner.py | 10 |
2 files changed, 18 insertions, 3 deletions
@@ -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() |