================ @@ -96,16 +98,120 @@ def getArchSpec(self, architecture): """ return ["ARCH=" + architecture] if architecture else [] - def getCCSpec(self, compiler): + def getToolchainSpec(self, compiler): """ - Helper function to return the key-value string to specify the compiler + Helper function to return the key-value strings to specify the toolchain used for the make system. """ cc = compiler if compiler else None if not cc and configuration.compiler: cc = configuration.compiler + if cc: - return ['CC="%s"' % cc] + exe_ext = "" + if lldbplatformutil.getHostPlatform() == "windows": + exe_ext = ".exe" + + cc = cc.strip() + cc_path = pathlib.Path(cc) + cc = cc_path.as_posix() + + # We can get CC compiler string in the following formats: + # [<tool>] <compiler> - such as 'xrun clang', 'xrun /usr/bin/clang' & etc + # + # Where <compiler> could contain the following parts: + # <simple-name>[.<exe-ext>] - sucn as 'clang', 'clang.exe' ('clamg-cl.exe'?) + # <target-triple>-<simple-name>[.<exe-ext>] - such as 'armv7-linux-gnueabi-gcc' + # <path>/<simple-name>[.<exe-ext>] - such as '/usr/bin/clang', 'c:\path\to\compiler\clang,exe' + # <path>/<target-triple>-<simple-name>[.<exe-ext>] - such as '/usr/bin/clang', 'c:\path\to\compiler\clang,exe' + + cc_ext = cc_path.suffix + # Compiler name without extension + cc_name = cc_path.stem.split(" ")[-1] + + # A kind of compiler (canonical name): clang, gcc, cc & etc. + cc_type = cc_name + # A triple prefix of compiler name: <armv7-none-linux-gnu->gcc + cc_prefix = "" + if not "clang-cl" in cc_name and not "llvm-gcc" in cc_name: + cc_name_parts = cc_name.split("-") + cc_type = cc_name_parts[-1] + if len(cc_name_parts) > 1: + cc_prefix = "-".join(cc_name_parts[:-1]) + "-" + + # A kind of C++ compiler. + cxx_types = { + "icc": "icpc", + "llvm-gcc": "llvm-g++", + "gcc": "g++", + "cc": "c++", + "clang": "clang++", + } + cxx_type = cxx_types.get(cc_type, cc_type) + + cc_dir = cc_path.parent + + def getLlvmUtil(util_name): + llvm_tools_dir = os.getenv("LLVM_TOOLS_DIR", cc_dir.as_posix()) + return llvm_tools_dir + "/" + util_name + exe_ext ---------------- labath wrote:
```suggestion return os.path.join(llvm_tools_dir, util_name + exe_ext) ``` https://github.com/llvm/llvm-project/pull/102185 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits