Skip to content

Commit 527d39f

Browse files
committed
Add platform support check in sanitizeOopArguments
1 parent 7fa02cc commit 527d39f

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

clang/tools/clang-repl/ClangRepl.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ static llvm::Error sanitizeOopArguments(const char *ArgV0) {
8787
OOPExecutorConnect.ArgStr + " can be specified",
8888
llvm::inconvertibleErrorCode());
8989

90+
llvm::Triple SystemTriple(llvm::sys::getProcessTriple());
91+
// TODO: Remove once out-of-process execution support is implemented for
92+
// non-Unix platforms.
93+
if ((!SystemTriple.isOSBinFormatELF() &&
94+
!SystemTriple.isOSBinFormatMachO()) &&
95+
(OOPExecutor.getNumOccurrences() ||
96+
OOPExecutorConnect.getNumOccurrences()))
97+
return llvm::make_error<llvm::StringError>(
98+
"Out-of-process execution is only supported on Unix platforms",
99+
llvm::inconvertibleErrorCode());
100+
90101
// If -slab-allocate is passed, check that we're not trying to use it in
91102
// -oop-executor or -oop-executor-connect mode.
92103
//
@@ -100,22 +111,26 @@ static llvm::Error sanitizeOopArguments(const char *ArgV0) {
100111
llvm::inconvertibleErrorCode());
101112
}
102113

114+
103115
// Out-of-process executors require the ORC runtime.
104116
if (OrcRuntimePath.empty() && (OOPExecutor.getNumOccurrences() ||
105117
OOPExecutorConnect.getNumOccurrences())) {
106118
llvm::SmallString<256> BasePath(llvm::sys::fs::getMainExecutable(
107119
ArgV0, reinterpret_cast<void *>(&sanitizeOopArguments)));
108120
llvm::sys::path::remove_filename(BasePath); // Remove clang-repl filename.
109121
llvm::sys::path::remove_filename(BasePath); // Remove ./bin directory.
110-
llvm::Triple SystemTriple(llvm::sys::getProcessTriple());
111122
llvm::sys::path::append(BasePath, CLANG_INSTALL_LIBDIR_BASENAME, "clang",
112123
CLANG_VERSION_MAJOR_STRING);
113124
if (SystemTriple.isOSBinFormatELF())
114125
OrcRuntimePath =
115126
BasePath.str().str() + "lib/x86_64-unknown-linux-gnu/liborc_rt.a";
116127
else if (SystemTriple.isOSBinFormatMachO())
117128
OrcRuntimePath = BasePath.str().str() + "/lib/darwin/liborc_rt_osx.a";
118-
}
129+
else
130+
return llvm::make_error<llvm::StringError>(
131+
"Out-of-process execution is not supported on non-unix platforms",
132+
llvm::inconvertibleErrorCode());
133+
}
119134

120135
// If -oop-executor was used but no value was specified then use a sensible
121136
// default.

0 commit comments

Comments
 (0)