diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-04-07 20:42:02 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-04-07 20:42:02 -0700 |
commit | ae1cb6d7eca0bffcfae0f923dd2dd6d7ed8037ca (patch) | |
tree | a3ab3df08a53fc41f93d42aac748670c2355067c /emcc | |
parent | 7af9a2d81c1c3fe1711c1d6a9b702aaab44ef67a (diff) |
handle identical basenames in emcc properly; fixes #287
Diffstat (limited to 'emcc')
-rwxr-xr-x | emcc | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -341,6 +341,13 @@ def unsuffixed(name): def unsuffixed_basename(name): return os.path.basename(unsuffixed(name)) +seen_names = {} +def unsuffixed_uniquename(name): + ret = unsuffixed_basename(name) + if name not in seen_names: + seen_names[name] = str(len(seen_names)) + return ret + '_' + seen_names[name] + # ---------------- End configs ------------- if len(sys.argv) == 1 or sys.argv[1] in ['x', 't']: @@ -641,7 +648,7 @@ try: for input_file in input_files: if input_file.endswith(SOURCE_SUFFIXES): if DEBUG: print >> sys.stderr, 'emcc: compiling source file: ', input_file - output_file = in_temp(unsuffixed_basename(input_file) + '.o') + output_file = in_temp(unsuffixed_uniquename(input_file) + '.o') temp_files.append(output_file) args = newargs + ['-emit-llvm', '-c', input_file, '-o', output_file] if DEBUG: print >> sys.stderr, "emcc running:", call, ' '.join(args) @@ -652,7 +659,7 @@ try: else: # bitcode if input_file.endswith(BITCODE_SUFFIXES): if DEBUG: print >> sys.stderr, 'emcc: copying bitcode file: ', input_file - temp_file = in_temp(unsuffixed_basename(input_file) + '.o') + temp_file = in_temp(unsuffixed_uniquename(input_file) + '.o') shutil.copyfile(input_file, temp_file) temp_files.append(temp_file) elif input_file.endswith(DYNAMICLIB_SUFFIXES) or shared.Building.is_ar(input_file): @@ -665,7 +672,7 @@ try: # Note that by assembling the .ll file, then disassembling it later, we will # remove annotations which is a good thing for compilation time if DEBUG: print >> sys.stderr, 'emcc: assembling assembly file: ', input_file - temp_file = in_temp(unsuffixed_basename(input_file) + '.o') + temp_file = in_temp(unsuffixed_uniquename(input_file) + '.o') shared.Building.llvm_as(input_file, temp_file) temp_files.append(temp_file) @@ -677,10 +684,10 @@ try: print >> sys.stderr, 'emcc: warning: -Ox flags ignored, since not generating JavaScript' if not specified_target: for input_file in input_files: - shutil.move(in_temp(unsuffixed_basename(input_file) + '.o'), unsuffixed_basename(input_file) + '.' + final_suffix) + shutil.move(in_temp(unsuffixed_uniquename(input_file) + '.o'), unsuffixed_basename(input_file) + '.' + final_suffix) else: if len(input_files) == 1: - shutil.move(in_temp(unsuffixed_basename(input_files[0]) + '.o'), specified_target) + shutil.move(in_temp(unsuffixed_uniquename(input_files[0]) + '.o'), specified_target) else: assert not has_dash_c, 'fatal error: cannot specify -o with -c with multiple files' + str(sys.argv) # We have a specified target (-o <target>), which is not JavaScript or HTML, and |