Skip to content

Commit 7501bdb

Browse files
committed
Fix compiler error
1 parent faeb524 commit 7501bdb

File tree

3 files changed

+50
-46
lines changed

3 files changed

+50
-46
lines changed

interpreter/llvm-project/llvm/include/llvm/ExecutionEngine/Orc/Shared/AutoLoadDylibUtils.h

+7-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ constexpr uint32_t log2u(std::uint32_t n) {
3030
return (n > 1) ? 1 + log2u(n >> 1) : 0;
3131
}
3232

33-
// namespace platform {
3433
/// Platform specific delimiter for splitting environment variables.
3534
/// ':' on Unix, and ';' on Windows
3635
extern const char *const kEnvDelim;
@@ -41,10 +40,14 @@ enum class SplitMode {
4140
AllowNonExistant ///< Add all paths whether they exist or not
4241
};
4342

44-
bool SplitPaths(StringRef PathStr, SmallVectorImpl<StringRef> &Paths,
45-
SplitMode Mode, StringRef Delim, bool Verbose = false);
43+
/// Collect the constituant paths from a PATH string.
44+
/// /bin:/usr/bin:/usr/local/bin -> {/bin, /usr/bin, /usr/local/bin}
45+
bool SplitPaths(llvm::StringRef PathStr,
46+
llvm::SmallVectorImpl<llvm::StringRef> &Paths,
47+
SplitMode Mode = SplitMode::PruneNonExistant,
48+
llvm::StringRef Delim = kEnvDelim,
49+
bool Verbose = false);
4650

47-
///
4851
bool GetSystemLibraryPaths(llvm::SmallVectorImpl<std::string> &Paths);
4952

5053
/// Returns a normalized version of the given Path
@@ -58,7 +61,6 @@ void *DLSym(const std::string &Name, std::string *Err = nullptr);
5861

5962
/// Close a handle to a shared library.
6063
void DLClose(void *Lib, std::string *Err = nullptr);
61-
// } // namespace platform
6264

6365
class BloomFilter {
6466
private:

interpreter/llvm-project/llvm/lib/ExecutionEngine/Orc/Shared/AutoLoadDylibUtils.cpp

+41-41
Original file line numberDiff line numberDiff line change
@@ -50,47 +50,6 @@ bool Popen(const std::string &Cmd, llvm::SmallVectorImpl<char> &Buf, bool RdE) {
5050
}
5151
#endif
5252

53-
bool GetSystemLibraryPaths(llvm::SmallVectorImpl<std::string> &Paths) {
54-
#if defined(__APPLE__) || defined(__CYGWIN__)
55-
Paths.push_back("/usr/local/lib/");
56-
Paths.push_back("/usr/X11R6/lib/");
57-
Paths.push_back("/usr/lib/");
58-
Paths.push_back("/lib/");
59-
60-
#ifndef __APPLE__
61-
Paths.push_back("/lib/x86_64-linux-gnu/");
62-
Paths.push_back("/usr/local/lib64/");
63-
Paths.push_back("/usr/lib64/");
64-
Paths.push_back("/lib64/");
65-
#endif
66-
#elif defined(LLVM_ON_UNIX)
67-
llvm::SmallString<1024> Buf;
68-
platform::Popen("LD_DEBUG=libs LD_PRELOAD=DOESNOTEXIST ls", Buf, true);
69-
const llvm::StringRef Result = Buf.str();
70-
71-
const std::size_t NPos = std::string::npos;
72-
const std::size_t LD = Result.find("(LD_LIBRARY_PATH)");
73-
std::size_t From = Result.find("search path=", LD == NPos ? 0 : LD);
74-
if (From != NPos) {
75-
std::size_t To = Result.find("(system search path)", From);
76-
if (To != NPos) {
77-
From += 12;
78-
while (To > From && isspace(Result[To - 1]))
79-
--To;
80-
std::string SysPath = Result.substr(From, To - From).str();
81-
SysPath.erase(std::remove_if(SysPath.begin(), SysPath.end(), ::isspace),
82-
SysPath.end());
83-
84-
llvm::SmallVector<llvm::StringRef, 10> CurPaths;
85-
SplitPaths(SysPath, CurPaths);
86-
for (const auto &Path : CurPaths)
87-
Paths.push_back(Path.str());
88-
}
89-
}
90-
#endif
91-
return true;
92-
}
93-
9453
std::string NormalizePath(const std::string &Path) {
9554

9655
llvm::SmallString<256> Buffer;
@@ -241,5 +200,46 @@ bool SplitPaths(StringRef PathStr, SmallVectorImpl<StringRef> &Paths,
241200
#undef DEBUG_TYPE
242201
}
243202

203+
bool GetSystemLibraryPaths(llvm::SmallVectorImpl<std::string> &Paths) {
204+
#if defined(__APPLE__) || defined(__CYGWIN__)
205+
Paths.push_back("/usr/local/lib/");
206+
Paths.push_back("/usr/X11R6/lib/");
207+
Paths.push_back("/usr/lib/");
208+
Paths.push_back("/lib/");
209+
210+
#ifndef __APPLE__
211+
Paths.push_back("/lib/x86_64-linux-gnu/");
212+
Paths.push_back("/usr/local/lib64/");
213+
Paths.push_back("/usr/lib64/");
214+
Paths.push_back("/lib64/");
215+
#endif
216+
#elif defined(LLVM_ON_UNIX)
217+
llvm::SmallString<1024> Buf;
218+
Popen("LD_DEBUG=libs LD_PRELOAD=DOESNOTEXIST ls", Buf, true);
219+
const llvm::StringRef Result = Buf.str();
220+
221+
const std::size_t NPos = std::string::npos;
222+
const std::size_t LD = Result.find("(LD_LIBRARY_PATH)");
223+
std::size_t From = Result.find("search path=", LD == NPos ? 0 : LD);
224+
if (From != NPos) {
225+
std::size_t To = Result.find("(system search path)", From);
226+
if (To != NPos) {
227+
From += 12;
228+
while (To > From && isspace(Result[To - 1]))
229+
--To;
230+
std::string SysPath = Result.substr(From, To - From).str();
231+
SysPath.erase(std::remove_if(SysPath.begin(), SysPath.end(), ::isspace),
232+
SysPath.end());
233+
234+
llvm::SmallVector<llvm::StringRef, 10> CurPaths;
235+
SplitPaths(SysPath, CurPaths);
236+
for (const auto &Path : CurPaths)
237+
Paths.push_back(Path.str());
238+
}
239+
}
240+
#endif
241+
return true;
242+
}
243+
244244
} // namespace orc
245245
} // namespace llvm

interpreter/llvm-project/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleExecutorDylibManager.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
#include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h"
1212
#include "llvm/Support/FormatVariadic.h"
1313

14+
#if defined(LLVM_ON_UNIX)
1415
#include <dlfcn.h>
16+
#endif
1517

1618
#define DEBUG_TYPE "orc"
1719

0 commit comments

Comments
 (0)