197a14e60SZachary Turner //===-- HostInfoBase.cpp ----------------------------------------*- C++ -*-===//
297a14e60SZachary Turner //
397a14e60SZachary Turner //                     The LLVM Compiler Infrastructure
497a14e60SZachary Turner //
597a14e60SZachary Turner // This file is distributed under the University of Illinois Open Source
697a14e60SZachary Turner // License. See LICENSE.TXT for details.
797a14e60SZachary Turner //
897a14e60SZachary Turner //===----------------------------------------------------------------------===//
997a14e60SZachary Turner 
1097a14e60SZachary Turner #include "lldb/Host/Config.h"
1197a14e60SZachary Turner 
1297a14e60SZachary Turner #include "lldb/Core/ArchSpec.h"
1342ff0ad8SZachary Turner #include "lldb/Core/Log.h"
1442ff0ad8SZachary Turner #include "lldb/Core/StreamString.h"
1542ff0ad8SZachary Turner #include "lldb/Host/FileSystem.h"
1697a14e60SZachary Turner #include "lldb/Host/Host.h"
1713b18261SZachary Turner #include "lldb/Host/HostInfo.h"
1813b18261SZachary Turner #include "lldb/Host/HostInfoBase.h"
1913b18261SZachary Turner 
2013b18261SZachary Turner #include "llvm/ADT/Triple.h"
21270e99abSZachary Turner #include "llvm/ADT/StringExtras.h"
2213b18261SZachary Turner #include "llvm/Support/Host.h"
23270e99abSZachary Turner #include "llvm/Support/raw_ostream.h"
2497a14e60SZachary Turner 
2597a14e60SZachary Turner #include <thread>
26ff48e4beSGreg Clayton #include <mutex> // std::once
2797a14e60SZachary Turner 
2897a14e60SZachary Turner using namespace lldb;
2997a14e60SZachary Turner using namespace lldb_private;
3097a14e60SZachary Turner 
3142ff0ad8SZachary Turner namespace
3242ff0ad8SZachary Turner {
3342ff0ad8SZachary Turner     void
3442ff0ad8SZachary Turner     CleanupProcessSpecificLLDBTempDir()
3542ff0ad8SZachary Turner     {
3642ff0ad8SZachary Turner         // Get the process specific LLDB temporary directory and delete it.
3742ff0ad8SZachary Turner         FileSpec tmpdir_file_spec;
3842ff0ad8SZachary Turner         if (!HostInfo::GetLLDBPath(ePathTypeLLDBTempSystemDir, tmpdir_file_spec))
3942ff0ad8SZachary Turner             return;
4042ff0ad8SZachary Turner 
4142ff0ad8SZachary Turner         // Remove the LLDB temporary directory if we have one. Set "recurse" to
4242ff0ad8SZachary Turner         // true to all files that were created for the LLDB process can be cleaned up.
4342ff0ad8SZachary Turner         FileSystem::DeleteDirectory(tmpdir_file_spec.GetDirectory().GetCString(), true);
4442ff0ad8SZachary Turner     }
45673b6e4fSZachary Turner 
46ff48e4beSGreg Clayton     //----------------------------------------------------------------------
47ff48e4beSGreg Clayton     // The HostInfoBaseFields is a work around for windows not supporting
48ff48e4beSGreg Clayton     // static variables correctly in a thread safe way. Really each of the
49ff48e4beSGreg Clayton     // variables in HostInfoBaseFields should live in the functions in which
50ff48e4beSGreg Clayton     // they are used and each one should be static, but the work around is
51ff48e4beSGreg Clayton     // in place to avoid this restriction. Ick.
52ff48e4beSGreg Clayton     //----------------------------------------------------------------------
53ff48e4beSGreg Clayton 
54673b6e4fSZachary Turner     struct HostInfoBaseFields
55673b6e4fSZachary Turner     {
56673b6e4fSZachary Turner         uint32_t m_number_cpus;
57673b6e4fSZachary Turner         std::string m_vendor_string;
58673b6e4fSZachary Turner         std::string m_os_string;
59673b6e4fSZachary Turner         std::string m_host_triple;
60673b6e4fSZachary Turner 
61673b6e4fSZachary Turner         ArchSpec m_host_arch_32;
62673b6e4fSZachary Turner         ArchSpec m_host_arch_64;
63673b6e4fSZachary Turner 
64673b6e4fSZachary Turner         FileSpec m_lldb_so_dir;
65673b6e4fSZachary Turner         FileSpec m_lldb_support_exe_dir;
66673b6e4fSZachary Turner         FileSpec m_lldb_headers_dir;
67673b6e4fSZachary Turner         FileSpec m_lldb_python_dir;
68b1e1c62fSSean Callanan         FileSpec m_lldb_clang_resource_dir;
69673b6e4fSZachary Turner         FileSpec m_lldb_system_plugin_dir;
70673b6e4fSZachary Turner         FileSpec m_lldb_user_plugin_dir;
71673b6e4fSZachary Turner         FileSpec m_lldb_tmp_dir;
72673b6e4fSZachary Turner     };
73673b6e4fSZachary Turner 
74673b6e4fSZachary Turner     HostInfoBaseFields *g_fields = nullptr;
7542ff0ad8SZachary Turner }
7642ff0ad8SZachary Turner 
77673b6e4fSZachary Turner void
78673b6e4fSZachary Turner HostInfoBase::Initialize()
79673b6e4fSZachary Turner {
80673b6e4fSZachary Turner     g_fields = new HostInfoBaseFields();
81673b6e4fSZachary Turner }
8242ff0ad8SZachary Turner 
8397a14e60SZachary Turner uint32_t
8497a14e60SZachary Turner HostInfoBase::GetNumberCPUS()
8597a14e60SZachary Turner {
86ff48e4beSGreg Clayton     static std::once_flag g_once_flag;
87ff48e4beSGreg Clayton     std::call_once(g_once_flag,  []() {
88673b6e4fSZachary Turner         g_fields->m_number_cpus = std::thread::hardware_concurrency();
89ff48e4beSGreg Clayton     });
90673b6e4fSZachary Turner     return g_fields->m_number_cpus;
9197a14e60SZachary Turner }
9297a14e60SZachary Turner 
9339de3110SZachary Turner uint32_t
9439de3110SZachary Turner HostInfoBase::GetMaxThreadNameLength()
9539de3110SZachary Turner {
9639de3110SZachary Turner     return 0;
9739de3110SZachary Turner }
9839de3110SZachary Turner 
9997a14e60SZachary Turner llvm::StringRef
10097a14e60SZachary Turner HostInfoBase::GetVendorString()
10197a14e60SZachary Turner {
102ff48e4beSGreg Clayton     static std::once_flag g_once_flag;
103ff48e4beSGreg Clayton     std::call_once(g_once_flag,  []() {
104ff48e4beSGreg Clayton         g_fields->m_vendor_string = std::move(HostInfo::GetArchitecture().GetTriple().getVendorName().str());
105ff48e4beSGreg Clayton     });
106673b6e4fSZachary Turner     return g_fields->m_vendor_string;
10797a14e60SZachary Turner }
10897a14e60SZachary Turner 
10997a14e60SZachary Turner llvm::StringRef
11097a14e60SZachary Turner HostInfoBase::GetOSString()
11197a14e60SZachary Turner {
112ff48e4beSGreg Clayton     static std::once_flag g_once_flag;
113ff48e4beSGreg Clayton     std::call_once(g_once_flag,  []() {
114ff48e4beSGreg Clayton         g_fields->m_os_string = std::move(HostInfo::GetArchitecture().GetTriple().getOSName());
115ff48e4beSGreg Clayton     });
116673b6e4fSZachary Turner     return g_fields->m_os_string;
11797a14e60SZachary Turner }
11897a14e60SZachary Turner 
11997a14e60SZachary Turner llvm::StringRef
12097a14e60SZachary Turner HostInfoBase::GetTargetTriple()
12197a14e60SZachary Turner {
122ff48e4beSGreg Clayton     static std::once_flag g_once_flag;
123ff48e4beSGreg Clayton     std::call_once(g_once_flag,  []() {
124ff48e4beSGreg Clayton         g_fields->m_host_triple = HostInfo::GetArchitecture().GetTriple().getTriple();
125ff48e4beSGreg Clayton     });
126673b6e4fSZachary Turner     return g_fields->m_host_triple;
12797a14e60SZachary Turner }
12813b18261SZachary Turner 
12913b18261SZachary Turner const ArchSpec &
13013b18261SZachary Turner HostInfoBase::GetArchitecture(ArchitectureKind arch_kind)
13113b18261SZachary Turner {
132ff48e4beSGreg Clayton     static std::once_flag g_once_flag;
133ff48e4beSGreg Clayton     std::call_once(g_once_flag,  []() {
134673b6e4fSZachary Turner         HostInfo::ComputeHostArchitectureSupport(g_fields->m_host_arch_32, g_fields->m_host_arch_64);
135ff48e4beSGreg Clayton     });
13613b18261SZachary Turner 
13713b18261SZachary Turner     // If an explicit 32 or 64-bit architecture was requested, return that.
13813b18261SZachary Turner     if (arch_kind == eArchKind32)
139673b6e4fSZachary Turner         return g_fields->m_host_arch_32;
14013b18261SZachary Turner     if (arch_kind == eArchKind64)
141673b6e4fSZachary Turner         return g_fields->m_host_arch_64;
14213b18261SZachary Turner 
14313b18261SZachary Turner     // Otherwise prefer the 64-bit architecture if it is valid.
144673b6e4fSZachary Turner     return (g_fields->m_host_arch_64.IsValid()) ? g_fields->m_host_arch_64 : g_fields->m_host_arch_32;
14513b18261SZachary Turner }
14613b18261SZachary Turner 
14742ff0ad8SZachary Turner bool
14842ff0ad8SZachary Turner HostInfoBase::GetLLDBPath(lldb::PathType type, FileSpec &file_spec)
14942ff0ad8SZachary Turner {
15042ff0ad8SZachary Turner     file_spec.Clear();
15142ff0ad8SZachary Turner 
15242ff0ad8SZachary Turner #if defined(LLDB_DISABLE_PYTHON)
15342ff0ad8SZachary Turner     if (type == lldb::ePathTypePythonDir)
15442ff0ad8SZachary Turner         return false;
15542ff0ad8SZachary Turner #endif
15642ff0ad8SZachary Turner 
15742ff0ad8SZachary Turner     FileSpec *result = nullptr;
15842ff0ad8SZachary Turner     switch (type)
15942ff0ad8SZachary Turner     {
16042ff0ad8SZachary Turner         case lldb::ePathTypeLLDBShlibDir:
161ff48e4beSGreg Clayton             {
162ff48e4beSGreg Clayton                 static std::once_flag g_once_flag;
163ff48e4beSGreg Clayton                 static bool success = false;
164ff48e4beSGreg Clayton                 std::call_once(g_once_flag,  []() {
165ff48e4beSGreg Clayton                     success = HostInfo::ComputeSharedLibraryDirectory (g_fields->m_lldb_so_dir);
166ff48e4beSGreg Clayton                     Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
16742ff0ad8SZachary Turner                     if (log)
168673b6e4fSZachary Turner                         log->Printf("HostInfoBase::GetLLDBPath(ePathTypeLLDBShlibDir) => '%s'", g_fields->m_lldb_so_dir.GetPath().c_str());
169ff48e4beSGreg Clayton                 });
170ff48e4beSGreg Clayton                 if (success)
171ff48e4beSGreg Clayton                     result = &g_fields->m_lldb_so_dir;
172ff48e4beSGreg Clayton             }
17342ff0ad8SZachary Turner             break;
17442ff0ad8SZachary Turner         case lldb::ePathTypeSupportExecutableDir:
175ff48e4beSGreg Clayton             {
176ff48e4beSGreg Clayton                 static std::once_flag g_once_flag;
177ff48e4beSGreg Clayton                 static bool success = false;
178ff48e4beSGreg Clayton                 std::call_once(g_once_flag,  []() {
179ff48e4beSGreg Clayton                     success = HostInfo::ComputeSupportExeDirectory (g_fields->m_lldb_support_exe_dir);
180ff48e4beSGreg Clayton                     Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
18142ff0ad8SZachary Turner                     if (log)
182673b6e4fSZachary Turner                         log->Printf("HostInfoBase::GetLLDBPath(ePathTypeSupportExecutableDir) => '%s'",
183673b6e4fSZachary Turner                                     g_fields->m_lldb_support_exe_dir.GetPath().c_str());
184ff48e4beSGreg Clayton                 });
185ff48e4beSGreg Clayton                 if (success)
186ff48e4beSGreg Clayton                     result = &g_fields->m_lldb_support_exe_dir;
187ff48e4beSGreg Clayton             }
18842ff0ad8SZachary Turner             break;
18942ff0ad8SZachary Turner         case lldb::ePathTypeHeaderDir:
190ff48e4beSGreg Clayton             {
191ff48e4beSGreg Clayton                 static std::once_flag g_once_flag;
192ff48e4beSGreg Clayton                 static bool success = false;
193ff48e4beSGreg Clayton                 std::call_once(g_once_flag,  []() {
194ff48e4beSGreg Clayton                     success = HostInfo::ComputeHeaderDirectory (g_fields->m_lldb_headers_dir);
195ff48e4beSGreg Clayton                     Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
19642ff0ad8SZachary Turner                     if (log)
197673b6e4fSZachary Turner                         log->Printf("HostInfoBase::GetLLDBPath(ePathTypeHeaderDir) => '%s'", g_fields->m_lldb_headers_dir.GetPath().c_str());
198ff48e4beSGreg Clayton                 });
199ff48e4beSGreg Clayton                 if (success)
200ff48e4beSGreg Clayton                     result = &g_fields->m_lldb_headers_dir;
201ff48e4beSGreg Clayton             }
20242ff0ad8SZachary Turner             break;
20342ff0ad8SZachary Turner         case lldb::ePathTypePythonDir:
204ff48e4beSGreg Clayton             {
205ff48e4beSGreg Clayton                 static std::once_flag g_once_flag;
206ff48e4beSGreg Clayton                 static bool success = false;
207ff48e4beSGreg Clayton                 std::call_once(g_once_flag,  []() {
208ff48e4beSGreg Clayton                     success = HostInfo::ComputePythonDirectory (g_fields->m_lldb_python_dir);
209ff48e4beSGreg Clayton                     Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
21042ff0ad8SZachary Turner                     if (log)
211673b6e4fSZachary Turner                         log->Printf("HostInfoBase::GetLLDBPath(ePathTypePythonDir) => '%s'", g_fields->m_lldb_python_dir.GetPath().c_str());
212ff48e4beSGreg Clayton                 });
213ff48e4beSGreg Clayton                 if (success)
214ff48e4beSGreg Clayton                     result = &g_fields->m_lldb_python_dir;
215ff48e4beSGreg Clayton             }
21642ff0ad8SZachary Turner             break;
217b1e1c62fSSean Callanan         case lldb::ePathTypeClangDir:
218ff48e4beSGreg Clayton             {
219ff48e4beSGreg Clayton                 static std::once_flag g_once_flag;
220ff48e4beSGreg Clayton                 static bool success = false;
221ff48e4beSGreg Clayton                 std::call_once(g_once_flag,  []() {
222ff48e4beSGreg Clayton                     success = HostInfo::ComputeClangDirectory (g_fields->m_lldb_clang_resource_dir);
223ff48e4beSGreg Clayton                     Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
224b1e1c62fSSean Callanan                     if (log)
225b1e1c62fSSean Callanan                         log->Printf("HostInfoBase::GetLLDBPath(ePathTypeClangResourceDir) => '%s'", g_fields->m_lldb_clang_resource_dir.GetPath().c_str());
226ff48e4beSGreg Clayton                 });
227ff48e4beSGreg Clayton                 if (success)
228ff48e4beSGreg Clayton                     result = &g_fields->m_lldb_clang_resource_dir;
229ff48e4beSGreg Clayton             }
230b1e1c62fSSean Callanan             break;
23142ff0ad8SZachary Turner         case lldb::ePathTypeLLDBSystemPlugins:
232ff48e4beSGreg Clayton             {
233ff48e4beSGreg Clayton                 static std::once_flag g_once_flag;
234ff48e4beSGreg Clayton                 static bool success = false;
235ff48e4beSGreg Clayton                 std::call_once(g_once_flag,  []() {
236ff48e4beSGreg Clayton                     success = HostInfo::ComputeSystemPluginsDirectory (g_fields->m_lldb_system_plugin_dir);
237ff48e4beSGreg Clayton                     Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
23842ff0ad8SZachary Turner                     if (log)
239673b6e4fSZachary Turner                         log->Printf("HostInfoBase::GetLLDBPath(ePathTypeLLDBSystemPlugins) => '%s'",
240673b6e4fSZachary Turner                                     g_fields->m_lldb_system_plugin_dir.GetPath().c_str());
241ff48e4beSGreg Clayton                 });
242ff48e4beSGreg Clayton                 if (success)
243ff48e4beSGreg Clayton                     result = &g_fields->m_lldb_system_plugin_dir;
244ff48e4beSGreg Clayton             }
24542ff0ad8SZachary Turner             break;
24642ff0ad8SZachary Turner         case lldb::ePathTypeLLDBUserPlugins:
247ff48e4beSGreg Clayton             {
248ff48e4beSGreg Clayton                 static std::once_flag g_once_flag;
249ff48e4beSGreg Clayton                 static bool success = false;
250ff48e4beSGreg Clayton                 std::call_once(g_once_flag,  []() {
251ff48e4beSGreg Clayton                     success = HostInfo::ComputeUserPluginsDirectory (g_fields->m_lldb_user_plugin_dir);
252ff48e4beSGreg Clayton                     Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
25342ff0ad8SZachary Turner                     if (log)
254673b6e4fSZachary Turner                         log->Printf("HostInfoBase::GetLLDBPath(ePathTypeLLDBUserPlugins) => '%s'",
255673b6e4fSZachary Turner                                     g_fields->m_lldb_user_plugin_dir.GetPath().c_str());
256ff48e4beSGreg Clayton                 });
257ff48e4beSGreg Clayton                 if (success)
258ff48e4beSGreg Clayton                     result = &g_fields->m_lldb_user_plugin_dir;
259ff48e4beSGreg Clayton             }
26042ff0ad8SZachary Turner             break;
26142ff0ad8SZachary Turner         case lldb::ePathTypeLLDBTempSystemDir:
262ff48e4beSGreg Clayton             {
263ff48e4beSGreg Clayton                 static std::once_flag g_once_flag;
264ff48e4beSGreg Clayton                 static bool success = false;
265ff48e4beSGreg Clayton                 std::call_once(g_once_flag,  []() {
266ff48e4beSGreg Clayton                     success = HostInfo::ComputeTempFileDirectory (g_fields->m_lldb_tmp_dir);
267ff48e4beSGreg Clayton                     Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
26842ff0ad8SZachary Turner                     if (log)
269673b6e4fSZachary Turner                         log->Printf("HostInfoBase::GetLLDBPath(ePathTypeLLDBTempSystemDir) => '%s'", g_fields->m_lldb_tmp_dir.GetPath().c_str());
270ff48e4beSGreg Clayton                 });
271ff48e4beSGreg Clayton                 if (success)
272ff48e4beSGreg Clayton                     result = &g_fields->m_lldb_tmp_dir;
273ff48e4beSGreg Clayton             }
27442ff0ad8SZachary Turner             break;
27542ff0ad8SZachary Turner     }
27642ff0ad8SZachary Turner 
27742ff0ad8SZachary Turner     if (!result)
27842ff0ad8SZachary Turner         return false;
27942ff0ad8SZachary Turner     file_spec = *result;
28042ff0ad8SZachary Turner     return true;
28142ff0ad8SZachary Turner }
28242ff0ad8SZachary Turner 
28342ff0ad8SZachary Turner bool
28442ff0ad8SZachary Turner HostInfoBase::ComputeSharedLibraryDirectory(FileSpec &file_spec)
28542ff0ad8SZachary Turner {
28642ff0ad8SZachary Turner     // To get paths related to LLDB we get the path to the executable that
28742ff0ad8SZachary Turner     // contains this function. On MacOSX this will be "LLDB.framework/.../LLDB",
28842ff0ad8SZachary Turner     // on linux this is assumed to be the "lldb" main executable. If LLDB on
28942ff0ad8SZachary Turner     // linux is actually in a shared library (liblldb.so) then this function will
29042ff0ad8SZachary Turner     // need to be modified to "do the right thing".
29142ff0ad8SZachary Turner 
29242ff0ad8SZachary Turner     FileSpec lldb_file_spec(
29342ff0ad8SZachary Turner         Host::GetModuleFileSpecForHostAddress(reinterpret_cast<void *>(reinterpret_cast<intptr_t>(HostInfoBase::GetLLDBPath))));
29442ff0ad8SZachary Turner 
29542ff0ad8SZachary Turner     // Remove the filename so that this FileSpec only represents the directory.
2960d8400c8SGreg Clayton     file_spec.GetDirectory() = lldb_file_spec.GetDirectory();
29742ff0ad8SZachary Turner 
29842ff0ad8SZachary Turner     return (bool)file_spec.GetDirectory();
29942ff0ad8SZachary Turner }
30042ff0ad8SZachary Turner 
30142ff0ad8SZachary Turner bool
30242ff0ad8SZachary Turner HostInfoBase::ComputeSupportExeDirectory(FileSpec &file_spec)
30342ff0ad8SZachary Turner {
30442ff0ad8SZachary Turner     return GetLLDBPath(lldb::ePathTypeLLDBShlibDir, file_spec);
30542ff0ad8SZachary Turner }
30642ff0ad8SZachary Turner 
30742ff0ad8SZachary Turner bool
30842ff0ad8SZachary Turner HostInfoBase::ComputeTempFileDirectory(FileSpec &file_spec)
30942ff0ad8SZachary Turner {
31042ff0ad8SZachary Turner     const char *tmpdir_cstr = getenv("TMPDIR");
31142ff0ad8SZachary Turner     if (tmpdir_cstr == NULL)
31242ff0ad8SZachary Turner     {
31342ff0ad8SZachary Turner         tmpdir_cstr = getenv("TMP");
31442ff0ad8SZachary Turner         if (tmpdir_cstr == NULL)
31542ff0ad8SZachary Turner             tmpdir_cstr = getenv("TEMP");
31642ff0ad8SZachary Turner     }
31742ff0ad8SZachary Turner     if (!tmpdir_cstr)
31842ff0ad8SZachary Turner         return false;
31942ff0ad8SZachary Turner 
320270e99abSZachary Turner     FileSpec temp_file_spec(tmpdir_cstr, false);
321270e99abSZachary Turner     temp_file_spec.AppendPathComponent("lldb");
322270e99abSZachary Turner     if (!FileSystem::MakeDirectory(temp_file_spec.GetPath().c_str(), eFilePermissionsDirectoryDefault).Success())
32342ff0ad8SZachary Turner         return false;
32442ff0ad8SZachary Turner 
325270e99abSZachary Turner     std::string pid_str;
326270e99abSZachary Turner     llvm::raw_string_ostream pid_stream(pid_str);
327270e99abSZachary Turner     pid_stream << Host::GetCurrentProcessID();
328270e99abSZachary Turner     temp_file_spec.AppendPathComponent(pid_stream.str().c_str());
329270e99abSZachary Turner     std::string final_path = temp_file_spec.GetPath();
330270e99abSZachary Turner     if (!FileSystem::MakeDirectory(final_path.c_str(), eFilePermissionsDirectoryDefault).Success())
33142ff0ad8SZachary Turner         return false;
33242ff0ad8SZachary Turner 
33342ff0ad8SZachary Turner     // Make an atexit handler to clean up the process specify LLDB temp dir
33442ff0ad8SZachary Turner     // and all of its contents.
33542ff0ad8SZachary Turner     ::atexit(CleanupProcessSpecificLLDBTempDir);
336270e99abSZachary Turner     file_spec.GetDirectory().SetCStringWithLength(final_path.c_str(), final_path.size());
33742ff0ad8SZachary Turner     return true;
33842ff0ad8SZachary Turner }
33942ff0ad8SZachary Turner 
34042ff0ad8SZachary Turner bool
34142ff0ad8SZachary Turner HostInfoBase::ComputeHeaderDirectory(FileSpec &file_spec)
34242ff0ad8SZachary Turner {
34342ff0ad8SZachary Turner     // TODO(zturner): Figure out how to compute the header directory for all platforms.
34442ff0ad8SZachary Turner     return false;
34542ff0ad8SZachary Turner }
34642ff0ad8SZachary Turner 
34742ff0ad8SZachary Turner bool
34842ff0ad8SZachary Turner HostInfoBase::ComputeSystemPluginsDirectory(FileSpec &file_spec)
34942ff0ad8SZachary Turner {
35042ff0ad8SZachary Turner     // TODO(zturner): Figure out how to compute the system plugins directory for all platforms.
35142ff0ad8SZachary Turner     return false;
35242ff0ad8SZachary Turner }
35342ff0ad8SZachary Turner 
35442ff0ad8SZachary Turner bool
355b1e1c62fSSean Callanan HostInfoBase::ComputeClangDirectory(FileSpec &file_spec)
356b1e1c62fSSean Callanan {
357b1e1c62fSSean Callanan     return false;
358b1e1c62fSSean Callanan }
359b1e1c62fSSean Callanan 
360b1e1c62fSSean Callanan bool
36142ff0ad8SZachary Turner HostInfoBase::ComputeUserPluginsDirectory(FileSpec &file_spec)
36242ff0ad8SZachary Turner {
36342ff0ad8SZachary Turner     // TODO(zturner): Figure out how to compute the user plugins directory for all platforms.
36442ff0ad8SZachary Turner     return false;
36542ff0ad8SZachary Turner }
36642ff0ad8SZachary Turner 
36713b18261SZachary Turner void
36813b18261SZachary Turner HostInfoBase::ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64)
36913b18261SZachary Turner {
37013b18261SZachary Turner     llvm::Triple triple(llvm::sys::getDefaultTargetTriple());
37113b18261SZachary Turner 
37213b18261SZachary Turner     arch_32.Clear();
37313b18261SZachary Turner     arch_64.Clear();
37413b18261SZachary Turner 
37513b18261SZachary Turner     switch (triple.getArch())
37613b18261SZachary Turner     {
37713b18261SZachary Turner         default:
37813b18261SZachary Turner             arch_32.SetTriple(triple);
37913b18261SZachary Turner             break;
38013b18261SZachary Turner 
3812559abdaSJustin Hibbits         case llvm::Triple::ppc64:
382*f9ee7e4cSJustin Hibbits         case llvm::Triple::x86_64:
38313b18261SZachary Turner             arch_64.SetTriple(triple);
38413b18261SZachary Turner             arch_32.SetTriple(triple.get32BitArchVariant());
38513b18261SZachary Turner             break;
38613b18261SZachary Turner 
387e4d6922cSTodd Fiala         case llvm::Triple::aarch64:
38813b18261SZachary Turner         case llvm::Triple::mips64:
38913b18261SZachary Turner         case llvm::Triple::sparcv9:
39013b18261SZachary Turner             arch_64.SetTriple(triple);
39113b18261SZachary Turner             break;
39213b18261SZachary Turner     }
39313b18261SZachary Turner }
394