@@ -50,47 +50,6 @@ bool Popen(const std::string &Cmd, llvm::SmallVectorImpl<char> &Buf, bool RdE) {
50
50
}
51
51
#endif
52
52
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
-
94
53
std::string NormalizePath (const std::string &Path) {
95
54
96
55
llvm::SmallString<256 > Buffer;
@@ -241,5 +200,46 @@ bool SplitPaths(StringRef PathStr, SmallVectorImpl<StringRef> &Paths,
241
200
#undef DEBUG_TYPE
242
201
}
243
202
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
+
244
244
} // namespace orc
245
245
} // namespace llvm
0 commit comments