Skip to content

Commit

Permalink
[µTVM] Remove binutils module, no longer needed after microTVM refact…
Browse files Browse the repository at this point in the history
…or. (apache#6947)
  • Loading branch information
areusch authored and Trevor Morris committed Dec 4, 2020
1 parent 5a32985 commit b302b76
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 492 deletions.
320 changes: 0 additions & 320 deletions python/tvm/contrib/binutils.py

This file was deleted.

32 changes: 27 additions & 5 deletions python/tvm/micro/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,37 @@
import glob
import os
import re
import subprocess

from tvm.contrib import binutils
import tvm.target
from . import build
from . import class_factory
from . import debugger
from . import transport


def run_cmd(cmd):
"""Runs `cmd` in a subprocess and awaits its completion.
Parameters
----------
cmd : List[str]
list of command-line arguments
Returns
-------
output : str
resulting stdout capture from the subprocess
"""
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
(output, _) = proc.communicate()
output = output.decode("utf-8")
if proc.returncode != 0:
cmd_str = " ".join(cmd)
msg = f'error while running command "{cmd_str}":\n{output}'
raise RuntimeError(msg)


class DetectTargetError(Exception):
"""Raised when no target comment was detected in the sources given."""

Expand Down Expand Up @@ -232,13 +254,13 @@ def library(self, output, sources, options=None):

output_filename = f"{src_base}.o"
output_abspath = os.path.join(output, output_filename)
binutils.run_cmd(args + ["-c", "-o", output_abspath, src])
run_cmd(args + ["-c", "-o", output_abspath, src])
outputs.append(output_abspath)

output_filename = f"{os.path.basename(output)}.a"
output_abspath = os.path.join(output, output_filename)
binutils.run_cmd([prefix + "ar", "-r", output_abspath] + outputs)
binutils.run_cmd([prefix + "ranlib", output_abspath])
run_cmd([prefix + "ar", "-r", output_abspath] + outputs)
run_cmd([prefix + "ranlib", output_abspath])

return tvm.micro.MicroLibrary(output, [output_filename])

Expand Down Expand Up @@ -273,7 +295,7 @@ def binary(self, output, objects, options=None, link_main=True, main_options=Non
for lib_name in obj.library_files:
args.append(obj.abspath(lib_name))

binutils.run_cmd(args)
run_cmd(args)
return tvm.micro.MicroBinary(output, output_filename, [])

@property
Expand Down
Loading

0 comments on commit b302b76

Please sign in to comment.