aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-03-28 16:52:28 -0700
committerAlon Zakai <alonzakai@gmail.com>2014-03-28 16:52:28 -0700
commitcde38c81c2330c139fa5d7d12a9e3688c5059f9c (patch)
tree1c31a885a9fe73364436b480f9db886d5c90a548
parent20bfe6cf840a29d9dad7d7fda5a3001ebe71a3a5 (diff)
fix the case where emcc's input and output is a bitcode file
-rwxr-xr-xemcc8
-rw-r--r--tests/test_other.py11
2 files changed, 13 insertions, 6 deletions
diff --git a/emcc b/emcc
index 20898043..fa51e57f 100755
--- a/emcc
+++ b/emcc
@@ -1394,8 +1394,6 @@ try:
temp_files.append(temp_file)
elif file_ending.endswith(ASSEMBLY_ENDINGS):
if not LEAVE_INPUTS_RAW:
- # Note that by assembling the .ll file, then disassembling it later, we will
- # remove annotations which is a good thing for compilation time
logging.debug('assembling assembly file: ' + input_file)
temp_file = in_temp(unsuffixed(uniquename(input_file)) + '.o')
shared.Building.llvm_as(input_file, temp_file)
@@ -1426,15 +1424,13 @@ try:
safe_move(get_bitcode_file(input_file), unsuffixed_basename(input_file) + final_ending)
else:
if len(input_files) == 1:
- temp_output_base = unsuffixed(get_bitcode_file(input_files[0]))
- if not specified_target:
- safe_move(get_bitcode_file(input_file), unsuffixed_basename(input_file) + final_ending)
+ safe_move(temp_files[0], specified_target if specified_target else unsuffixed_basename(input_file) + final_ending)
+ temp_output_base = unsuffixed(temp_files[0])
if os.path.exists(temp_output_base + '.d'):
# There was a .d file generated, from -MD or -MMD and friends, save a copy of it to where the output resides,
# adjusting the target name away from the temporary file name to the specified target.
# It will be deleted with the rest of the temporary directory.
deps = open(temp_output_base + '.d').read()
-
deps = deps.replace(temp_output_base + default_object_extension, specified_target)
with open(os.path.join(os.path.dirname(specified_target), os.path.basename(unsuffixed(input_files[0]) + '.d')), "w") as out_dep:
out_dep.write(deps)
diff --git a/tests/test_other.py b/tests/test_other.py
index 8c6a199c..0f5a4191 100644
--- a/tests/test_other.py
+++ b/tests/test_other.py
@@ -2682,3 +2682,14 @@ int main()
symbols = open('a.out.js.symbols').read()
assert ':_main' in symbols
+ def test_bc_to_bc(self):
+ # emcc should 'process' bitcode to bitcode. build systems can request this if
+ # e.g. they assume our 'executable' extension is bc, and compile an .o to a .bc
+ # (the user would then need to build bc to js of course, but we need to actually
+ # emit the bc)
+ cmd = Popen([PYTHON, EMCC, '-c', path_from_root('tests', 'hello_world.c')]).communicate()
+ assert os.path.exists('hello_world.o')
+ cmd = Popen([PYTHON, EMCC, 'hello_world.o', '-o', 'hello_world.bc']).communicate()
+ assert os.path.exists('hello_world.o')
+ assert os.path.exists('hello_world.bc')
+