diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-12-19 13:54:43 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-12-19 13:54:43 -0800 |
commit | fca29f7958688e613801f4f13c784796f1270bad (patch) | |
tree | dcdc2461d3ec76ad5c74e0752896b1746b88ae0f | |
parent | 1327ff5cbb6f0c433b64f713dd95acb0f09a669f (diff) |
tolerate people issuing link commands with duplicates in them
-rwxr-xr-x | tests/runner.py | 21 | ||||
-rw-r--r-- | tools/shared.py | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py index 775225c6..9982d0ef 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -8139,6 +8139,27 @@ f.close() self.assertContained('result: 62', run_js(os.path.join(self.get_dir(), 'a.out.js'))) + def test_redundant_link(self): + lib = "int mult() { return 1; }" + lib_name = os.path.join(self.get_dir(), 'libA.c') + open(lib_name, 'w').write(lib) + main = r''' + #include <stdio.h> + int mult(); + int main() { + printf("result: %d\n", mult()); + return 0; + } + ''' + main_name = os.path.join(self.get_dir(), 'main.c') + open(main_name, 'w').write(main) + + Building.emcc(lib_name, output_filename='libA.so') + + Building.emcc(main_name, ['libA.so']*2, output_filename='a.out.js') + + self.assertContained('result: 1', run_js(os.path.join(self.get_dir(), 'a.out.js'))) + def test_abspaths(self): # Includes with absolute paths are generally dangerous, things like -I/usr/.. will get to system local headers, not our portable ones. diff --git a/tools/shared.py b/tools/shared.py index fdcdbbda..0a041669 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -790,6 +790,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e seen_symbols = seen_symbols.union(symbols.defs) # Finish link + actual_files = list(set(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] assert os.path.exists(target) and (output is None or 'Could not open input file' not in output), 'Linking error: ' + output + '\nemcc: If you get duplicate symbol errors, try --remove-duplicates' |