FrozenGene commented on a change in pull request #4657: [CodeGen] Generate blob
use LLVM directly
URL: https://github.com/apache/incubator-tvm/pull/4657#discussion_r365060564
##########
File path: python/tvm/contrib/cc.py
##########
@@ -51,9 +51,32 @@ def create_shared(output,
else:
raise ValueError("Unsupported platform")
+def get_target_triple():
+ """ Get the target triple using compiler.
+
+ Returns
+ -------
+ out: str (Linux / Mac) or None (Win32)
+ """
+ if sys.platform == "darwin" or sys.platform.startswith("linux"):
+ cmd = ["g++", "-dumpmachine"]
+ proc = subprocess.Popen(
+ cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ (out, _) = proc.communicate()
+ if proc.returncode != 0:
+ msg = "dumpmachine error:\n"
+ msg += py_str(out)
+ raise RuntimeError(msg)
+ return py_str(out)
+ elif sys.platform == "win32":
+ return None
+ else:
+ raise ValueError("Unsupported platform")
+
# assign so as default output format
create_shared.output_format = "so" if sys.platform != "win32" else "dll"
+create_shared.get_target_triple = get_target_triple()
Review comment:
> please also add support for cross_compiler in this file
In my mind, I think get_target_triple should be used for host running TVM or
we call ndk (we could know the compiler according to TVM_NDK_CC). Like we use
cross_compiler (currently be used by MicroDev) to generate C file, we don't
know the compiler. If I don't understand correctly of cross_compiler's effect,
please correct me. Thanks!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services