aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-04-08 12:27:26 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-04-08 12:27:26 -0700
commit99dd381e078c7dc50e252c79c9631291955fb6d8 (patch)
treeb364807f6c0d5d1e9694ae394411856d5768c2f0
parent39e8885634d8087751703942918b5b8b6e13ed27 (diff)
clean up linker a.out|exe stubs
-rwxr-xr-xtests/runner.py5
-rw-r--r--tools/shared.py3
2 files changed, 6 insertions, 2 deletions
diff --git a/tests/runner.py b/tests/runner.py
index d13815f3..38b9052e 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -6332,10 +6332,11 @@ f.close()
}
''')
- Popen(['python', EMCC, os.path.join(self.get_dir(), 'libdir', 'libfile.cpp'), '-c'], stdout=PIPE, stderr=STDOUT).communicate()
+ Popen(['python', EMCC, os.path.join(self.get_dir(), 'libdir', 'libfile.cpp'), '-c']).communicate()
shutil.move(os.path.join(self.get_dir(), 'libfile.o'), os.path.join(self.get_dir(), 'libdir', 'libfile.so'))
- Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '-L' + os.path.join(self.get_dir(), 'libdir'), '-lfile'], stdout=PIPE, stderr=STDOUT).communicate()
+ Popen(['python', EMCC, os.path.join(self.get_dir(), 'main.cpp'), '-L' + os.path.join(self.get_dir(), 'libdir'), '-lfile']).communicate()
self.assertContained('hello from lib', run_js(os.path.join(self.get_dir(), 'a.out.js')))
+ assert not os.path.exists('a.out') and not os.path.exists('a.exe'), 'Must not leave unneeded linker stubs'
def test_local_link(self):
# Linking a local library directly, like /usr/lib/libsomething.so, cannot work of course since it
diff --git a/tools/shared.py b/tools/shared.py
index e11dc95a..73e2a9a7 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -473,7 +473,10 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
@staticmethod
def link(files, target):
try_delete(target)
+ stub = 'a.out' if not WINDOWS else 'a.exe'
+ need_cleanup = not os.path.exists(stub)
output = Popen([LLVM_LD, '-disable-opt'] + files + ['-b', target], stdout=PIPE).communicate()[0]
+ if need_cleanup: try_delete(stub) # clean up stub left by the linker
assert os.path.exists(target) and (output is None or 'Could not open input file' not in output), 'Linking error: ' + output
# Emscripten optimizations that we run on the .ll file