aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtests/runner.py31
-rw-r--r--tools/shared.py7
2 files changed, 35 insertions, 3 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 451ecdaf..7a6cbc26 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -7402,6 +7402,37 @@ f.close()
self.assertContained('result: 12346.', run_js(os.path.join(self.get_dir(), 'a.out.js')))
+ def test_dup_o_in_a(self):
+ open('common.c', 'w').write(r'''
+ #include <stdio.h>
+ void a(void) {
+ printf("a\n");
+ }
+ ''')
+ Popen(['python', EMCC, 'common.c', '-c', '-o', 'common.o']).communicate()
+ Popen(['python', EMAR, 'rc', 'liba.a', 'common.o']).communicate()
+
+ open('common.c', 'w').write(r'''
+ #include <stdio.h>
+ void b(void) {
+ printf("b\n");
+ }
+ ''')
+ Popen(['python', EMCC, 'common.c', '-c', '-o', 'common.o']).communicate()
+ Popen(['python', EMAR, 'rc', 'libb.a', 'common.o']).communicate()
+
+ open('main.c', 'w').write(r'''
+ void a(void);
+ void b(void);
+ int main() {
+ a();
+ b();
+ }
+ ''')
+ Popen(['python', EMCC, 'main.c', '-L.', '-la', '-lb']).communicate()
+
+ self.assertContained('a\nb\n', run_js(os.path.join(self.get_dir(), 'a.out.js')))
+
def test_embed_file(self):
open(os.path.join(self.get_dir(), 'somefile.txt'), 'w').write('''hello from a file with lots of data and stuff in it thank you very much''')
open(os.path.join(self.get_dir(), 'main.cpp'), 'w').write(r'''
diff --git a/tools/shared.py b/tools/shared.py
index bdfec8ed..80605b67 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -617,7 +617,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
actual_files = []
unresolved_symbols = set(['main']) # tracking unresolveds is necessary for .a linking, see below. (and main is always a necessary symbol)
resolved_symbols = set()
- temp_dir = None
+ temp_dirs = []
files = map(os.path.abspath, files)
for f in files:
if not Building.is_ar(f):
@@ -631,7 +631,8 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
# (link in an entire .o from the archive if it supplies symbols still unresolved)
cwd = os.getcwd()
try:
- temp_dir = os.path.join(EMSCRIPTEN_TEMP_DIR, 'ar_output_' + str(os.getpid()))
+ temp_dir = os.path.join(EMSCRIPTEN_TEMP_DIR, 'ar_output_' + str(os.getpid()) + '_' + str(len(temp_dirs)))
+ temp_dirs.append(temp_dir)
if not os.path.exists(temp_dir):
os.makedirs(temp_dir)
os.chdir(temp_dir)
@@ -684,7 +685,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
# Finish link
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'
- if temp_dir:
+ for temp_dir in temp_dirs:
try_delete(temp_dir)
# Emscripten optimizations that we run on the .ll file