wrappers: Handle tools named [<target>-]llvm-<tool>

Normally, we'd split the string at the last dash. However if the
tool name is "llvm-<tool>", make sure to include "llvm-" in the
tool name part when splitting the executable name.

In llvm-wrapper, don't add a duplicate "llvm-" prefix for the tool
name in these cases.
This commit is contained in:
Martin Storsjö committed 2022-10-01 13:28:41 +03:00
1 parent 2f8b90b583
commit 087255e28a
2 files changed
+20 -2

No files matched your search

+15
View File
@@ -154,6 +154,21 @@ static inline void split_argv(const TCHAR *argv0, const TCHAR **dir_ptr, const T
if (dash) {
*dash = '\0';
exe = dash + 1;
// Handle [<target>-]llvm-<tool> as exe=llvm-<tool>
TCHAR *dash2 = _tcsrchr(target, '-');
if (dash2 && !_tcscmp(dash2, _T("-llvm"))) {
// Found <target>-llvm-<tool>; move the llvm- prefix to
// exe. Convert the original dash which we overwrite with '\0'
// back into a dash and split the string at the preceding dash.
*dash = '-';
*dash2 = '\0';
exe = dash2 + 1;
} else if (!_tcscmp(target, _T("llvm"))) {
// Found llvm-<tool>; don't treat "llvm" as target but move
// it to the exe part.
exe = basename;
target = NULL;
}
} else {
target = NULL;
}