diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-12-04 11:54:07 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-12-04 11:54:07 -0800 |
commit | 2817d5ac5526f61b748827f0fae9ecdbc16fcef6 (patch) | |
tree | 13eddcc4dd31203e8889fa28f348e5e2173b82ba /tests | |
parent | c735bb6469370c0a6be212a630c9a73698ebdfbc (diff) |
only add in .o inside .a that are needed
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/runner.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py index f024198e..3dfef3e9 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -7880,6 +7880,40 @@ f.close() self.assertContained('result: 1', run_js(os.path.join(self.get_dir(), 'a.out.js'))) + def test_multiply_defined_libsymbols_2(self): + a = "int x() { return 55; }" + a_name = os.path.join(self.get_dir(), 'a.c') + open(a_name, 'w').write(a) + b = "int y() { return 2; }" + b_name = os.path.join(self.get_dir(), 'b.c') + open(b_name, 'w').write(b) + c = "int z() { return 5; }" + c_name = os.path.join(self.get_dir(), 'c.c') + open(c_name, 'w').write(c) + main = r''' + #include <stdio.h> + int x(); + int y(); + int z(); + int main() { + printf("result: %d\n", x() + y() + z()); + return 0; + } + ''' + main_name = os.path.join(self.get_dir(), 'main.c') + open(main_name, 'w').write(main) + + Building.emcc(a_name) # a.c.o + Building.emcc(b_name) # b.c.o + Building.emcc(c_name) # c.c.o + lib_name = os.path.join(self.get_dir(), 'libLIB.a') + Building.emar('cr', lib_name, [a_name + '.o', b_name + '.o']) # libLIB.a with a and b + + # a is in the lib AND in an .o, so should be ignored in the lib. We do still need b from the lib though + Building.emcc(main_name, ['-L.', '-lLIB', a_name+'.o', c_name + '.o'], output_filename='a.out.js') + + self.assertContained('result: 62', 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. |