forked from M-Labs/artiq
Use try..finally in compiler.targets.Target.link.
This commit is contained in:
parent
b0185f3917
commit
1e3911ed39
|
@ -8,7 +8,7 @@ llvm.initialize_all_asmprinters()
|
|||
class Target:
|
||||
"""
|
||||
A description of the target environment where the binaries
|
||||
generaed by the ARTIQ compiler will be deployed.
|
||||
generated by the ARTIQ compiler will be deployed.
|
||||
|
||||
:var triple: (string)
|
||||
LLVM target triple, e.g. ``"or1k"``
|
||||
|
@ -36,6 +36,7 @@ class Target:
|
|||
f.flush()
|
||||
return f
|
||||
|
||||
try:
|
||||
output_file = make_tempfile()
|
||||
cmdline = [self.triple + "-ld", "-shared", "--eh-frame-hdr", "-init", init_fn] + \
|
||||
[make_tempfile(obj).name for obj in objects] + \
|
||||
|
@ -45,13 +46,11 @@ class Target:
|
|||
if linker.returncode != 0:
|
||||
raise Exception("Linker invocation failed: " + stderr.decode('utf-8'))
|
||||
|
||||
output = output_file.read()
|
||||
|
||||
return output_file.read()
|
||||
finally:
|
||||
for f in files:
|
||||
f.close()
|
||||
|
||||
return output
|
||||
|
||||
def compile(self, module):
|
||||
"""Compile the module to a relocatable object for this target."""
|
||||
llmod = module.build_llvm_ir(self)
|
||||
|
|
Loading…
Reference in New Issue