diff options
author | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2012-02-07 19:54:24 -0500 |
---|---|---|
committer | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2012-02-08 18:46:22 -0500 |
commit | 06048b0e62197e0aa00b504e9de5d774e38ac8da (patch) | |
tree | c971d466f2cadfeeffc83f7e82e7ddbe501c123c | |
parent | f0fe97c44891b20962d4c3f7122d205cdfc479aa (diff) |
Use ld for linking multiple files passed to emcc
-rwxr-xr-x | emcc | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -425,11 +425,14 @@ try: if DEBUG: print >> sys.stderr, 'emcc: compiling to bitcode' + temp_files = [] + # First, generate LLVM bitcode. For each input file, we get base.o with bitcode 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') + 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) Popen([call] + args).communicate() # let compiler frontend print directly, so colors are saved (PIPE kills that) @@ -439,16 +442,22 @@ try: else: # bitcode if input_file.endswith(BITCODE_SUFFIXES): if DEBUG: print >> sys.stderr, 'emcc: copying bitcode file: ', input_file - shutil.copyfile(input_file, in_temp(unsuffixed_basename(input_file) + '.o')) + temp_file = in_temp(unsuffixed_basename(input_file) + '.o') + shutil.copyfile(input_file, temp_file) + temp_files.append(temp_file) elif shared.Building.is_ar(input_file): if DEBUG: print >> sys.stderr, 'emcc: copying ar file: ', input_file - shutil.copyfile(input_file, in_temp(os.path.basename(input_file))) + temp_file = in_temp(os.path.basename(input_file)) + shutil.copyfile(input_file, temp_file) + temp_files.append(temp_file) else: #.ll 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 if DEBUG: print >> sys.stderr, 'emcc: assembling assembly file: ', input_file + temp_file = in_temp(os.path.basename(input_file)) shared.Building.llvm_as(input_file, in_temp(unsuffixed_basename(input_file) + '.o')) + temp_files.append(temp_file) # If we were just asked to generate bitcode, stop there if final_suffix not in ['js', 'html']: @@ -464,11 +473,10 @@ try: 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 # we have multiple files: Link them TODO: llvm link-time opts? - ld_args = map(lambda input_file: in_temp(unsuffixed_basename(input_file) + '.o'), input_files) + \ - ['-o', specified_target] + ld_args = temp_files + ['-b', specified_target] #[arg.split('-Wl,')[1] for arg in filter(lambda arg: arg.startswith('-Wl,'), sys.argv)] if DEBUG: print >> sys.stderr, 'emcc: link: ' + str(ld_args) - Popen([shared.LLVM_LINK] + ld_args).communicate() + Popen([shared.LLVM_LD, '-disable-opt'] + ld_args).communicate() exit(0) ## Continue on to create JavaScript |