diff options
| author | Adrian McCarthy <amccarth@google.com> | 2015-10-26 21:38:41 +0000 |
|---|---|---|
| committer | Adrian McCarthy <amccarth@google.com> | 2015-10-26 21:38:41 +0000 |
| commit | 3f989d4e6e088d1630f716e279ea91c627a6de05 (patch) | |
| tree | 7cfd673ef08a2f654f9582f00ae5a70d8675dcab | |
| parent | 298639a5fd6b8a7ce2360eb82e34bc1dc4c0ad82 (diff) | |
| download | bcm5719-llvm-3f989d4e6e088d1630f716e279ea91c627a6de05.tar.gz bcm5719-llvm-3f989d4e6e088d1630f716e279ea91c627a6de05.zip | |
Revert "Clang module compilation options need to be per-platform."
This reverts commit r251340.
Breaks the Windows build because Windows doesn't have getuid. The fix is not obvious.
llvm-svn: 251354
5 files changed, 14 insertions, 97 deletions
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp index 083efdc8c89..05d8a320a5a 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp @@ -641,7 +641,18 @@ ClangModulesDeclVendor::Create(Target &target) compiler_invocation_arguments.push_back(ModuleImportBufferName); // Add additional search paths with { "-I", path } or { "-F", path } here. - + + { + llvm::SmallString<128> DefaultModuleCache; + const bool erased_on_reboot = false; + llvm::sys::path::system_temp_directory(erased_on_reboot, DefaultModuleCache); + llvm::sys::path::append(DefaultModuleCache, "org.llvm.clang"); + llvm::sys::path::append(DefaultModuleCache, "ModuleCache"); + std::string module_cache_argument("-fmodules-cache-path="); + module_cache_argument.append(DefaultModuleCache.str().str()); + compiler_invocation_arguments.push_back(module_cache_argument); + } + FileSpecList &module_search_paths = target.GetClangModuleSearchPaths(); for (size_t spi = 0, spe = module_search_paths.GetSize(); spi < spe; ++spi) diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index e50e76d567c..f75ca1b12dc 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -35,10 +35,6 @@ #include "lldb/Target/Target.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/SmallString.h" -#include "llvm/Support/Path.h" - using namespace lldb; using namespace lldb_private; @@ -1480,17 +1476,6 @@ PlatformDarwin::AddClangModuleCompilationOptionsForSDKType (Target *target, std: apple_arguments.begin(), apple_arguments.end()); - { - llvm::SmallString<128> DefaultModuleCache; - const bool erased_on_reboot = false; - llvm::sys::path::system_temp_directory(erased_on_reboot, DefaultModuleCache); - llvm::sys::path::append(DefaultModuleCache, "org.llvm.clang"); - llvm::sys::path::append(DefaultModuleCache, "ModuleCache"); - std::string module_cache_argument("-fmodules-cache-path="); - module_cache_argument.append(DefaultModuleCache.str().str()); - options.push_back(module_cache_argument); - } - StreamString minimum_version_option; uint32_t versions[3] = { 0, 0, 0 }; bool use_current_os_version = false; diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp index a94de8f5475..cb285c27821 100644 --- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -27,10 +27,6 @@ #include "lldb/Target/Process.h" #include "lldb/Target/ProcessLaunchInfo.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/SmallString.h" -#include "llvm/Support/Path.h" - using namespace lldb; using namespace lldb_private; @@ -852,64 +848,4 @@ void PlatformPOSIX::CalculateTrapHandlerSymbolNames () { m_trap_handlers.push_back (ConstString ("_sigtramp")); -} - -static bool isAlphanumeric(const char c) -{ - return ((c >= '0' && c <= '9') || - (c >= 'a' && c <= 'z') || - (c >= 'A' && c <= 'Z')); -} - -static void appendUserToPath(llvm::SmallVectorImpl<char> &Result) -{ - const char *username = getenv("LOGNAME"); - - if (username) - { - // Validate that LoginName can be used in a path, and get its length. - size_t Len = 0; - for (const char *P = username; *P; ++P, ++Len) { - if (!isAlphanumeric(*P) && *P != '_') { - username = nullptr; - break; - } - } - - if (username && Len > 0) { - Result.append(username, username + Len); - return; - } - } - - // Fallback to user id. - std::string UID = llvm::utostr(getuid()); - - Result.append(UID.begin(), UID.end()); -} - -void -PlatformPOSIX::AddClangModuleCompilationOptions (Target *target, std::vector<std::string> &options) -{ - std::vector<std::string> default_compilation_options = - { - "-x", "c++", "-Xclang", "-nostdsysteminc", "-Xclang", "-nostdsysteminc" - }; - - options.insert(options.end(), - default_compilation_options.begin(), - default_compilation_options.end()); - - { - llvm::SmallString<128> DefaultModuleCache; - const bool erased_on_reboot = false; - llvm::sys::path::system_temp_directory(erased_on_reboot, DefaultModuleCache); - llvm::sys::path::append(DefaultModuleCache, "org.llvm.clang."); - appendUserToPath(DefaultModuleCache); - llvm::sys::path::append(DefaultModuleCache, "ModuleCache"); - std::string module_cache_argument("-fmodules-cache-path="); - module_cache_argument.append(DefaultModuleCache.str().str()); - options.push_back(module_cache_argument); - } -} - +} diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h index 835c1e09096..82686dcef6b 100644 --- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h +++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h @@ -176,9 +176,6 @@ public: lldb_private::Error DisconnectRemote () override; - void - AddClangModuleCompilationOptions (lldb_private::Target *target, std::vector<std::string> &options) override; - protected: std::unique_ptr<lldb_private::OptionGroupOptions> m_options; diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index 0a1ee784d55..33446a9fb3a 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -38,13 +38,12 @@ #include "lldb/Target/Target.h" #include "lldb/Target/UnixSignals.h" #include "lldb/Utility/Utils.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/SmallString.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "Utility/ModuleCache.h" + // Define these constants from POSIX mman.h rather than include the file // so that they will be correct even when compiled on Linux. #define MAP_PRIVATE 2 @@ -622,17 +621,6 @@ Platform::AddClangModuleCompilationOptions (Target *target, std::vector<std::str options.insert(options.end(), default_compilation_options.begin(), default_compilation_options.end()); - - { - llvm::SmallString<128> DefaultModuleCache; - const bool erased_on_reboot = false; - llvm::sys::path::system_temp_directory(erased_on_reboot, DefaultModuleCache); - llvm::sys::path::append(DefaultModuleCache, "org.llvm.clang"); - llvm::sys::path::append(DefaultModuleCache, "ModuleCache"); - std::string module_cache_argument("-fmodules-cache-path="); - module_cache_argument.append(DefaultModuleCache.str().str()); - options.push_back(module_cache_argument); - } } |

