Author: adrian Date: Fri Feb 9 14:08:26 2018 New Revision: 324775 URL: http://llvm.org/viewvc/llvm-project?rev=324775&view=rev Log: Make LLDB's clang module cache path customizable
This patch makes LLDB's clang module cache path customizable via settings set target.clang-modules-cache-path <path> and uses it in the LLDB testsuite to reuse the same location inside the build directory for LLDB and clang. Differential Revision: https://reviews.llvm.org/D43099 Modified: lldb/trunk/include/lldb/Target/Target.h lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py lldb/trunk/packages/Python/lldbsuite/test/macosx/nslog/TestDarwinNSLogOutput.py lldb/trunk/source/Plugins/ExpressionParser/Clang/CMakeLists.txt lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=324775&r1=324774&r2=324775&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Fri Feb 9 14:08:26 2018 @@ -126,6 +126,8 @@ public: FileSpecList &GetDebugFileSearchPaths(); + FileSpec &GetClangModulesCachePath(); + FileSpecList &GetClangModuleSearchPaths(); bool GetEnableAutoImportClangModules() const; Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=324775&r1=324774&r2=324775&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Fri Feb 9 14:08:26 2018 @@ -1914,6 +1914,14 @@ class TestBase(Base): # decorators. Base.setUp(self) + # Set the clang modules cache path. + if self.child: + assert(self.getDebugInfo() == 'default') + mod_cache = os.path.join(self.getBuildDir(), "module-cache") + self.runCmd("settings set target.clang-modules-cache-path " + + mod_cache) + + if "LLDB_MAX_LAUNCH_COUNT" in os.environ: self.maxLaunchCount = int(os.environ["LLDB_MAX_LAUNCH_COUNT"]) Modified: lldb/trunk/packages/Python/lldbsuite/test/macosx/nslog/TestDarwinNSLogOutput.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/macosx/nslog/TestDarwinNSLogOutput.py?rev=324775&r1=324774&r2=324775&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/macosx/nslog/TestDarwinNSLogOutput.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/macosx/nslog/TestDarwinNSLogOutput.py Fri Feb 9 14:08:26 2018 @@ -15,21 +15,20 @@ import re import sys from lldbsuite.test.decorators import * -from lldbsuite.test import lldbtest +from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbtest_config -class DarwinNSLogOutputTestCase(lldbtest.TestBase): +class DarwinNSLogOutputTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True - - mydir = lldbtest.TestBase.compute_mydir(__file__) + mydir = TestBase.compute_mydir(__file__) @skipUnlessDarwin @skipIfRemote # this test is currently written using lldb commands & assumes running on local system def setUp(self): # Call super's setUp(). - super(DarwinNSLogOutputTestCase, self).setUp() + TestBase.setUp(self) self.child = None self.child_prompt = '(lldb) ' self.strict_sources = False @@ -42,7 +41,7 @@ class DarwinNSLogOutputTestCase(lldbtest self.d = {'OBJC_SOURCES': self.source, 'EXE': self.exe_name} # Locate breakpoint. - self.line = lldbtest.line_number(self.source, '// break here') + self.line = line_number(self.source, '// break here') def tearDown(self): # Shut down the process if it's still running. Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/CMakeLists.txt?rev=324775&r1=324774&r2=324775&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ExpressionParser/Clang/CMakeLists.txt (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/CMakeLists.txt Fri Feb 9 14:08:26 2018 @@ -23,6 +23,7 @@ add_lldb_library(lldbPluginExpressionPar LINK_LIBS clangAST clangCodeGen + clangDriver clangEdit clangFrontend clangLex Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp?rev=324775&r1=324774&r2=324775&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp Fri Feb 9 14:08:26 2018 @@ -13,6 +13,7 @@ // Other libraries and framework includes #include "clang/Basic/TargetInfo.h" +#include "clang/Driver/Driver.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/FrontendActions.h" #include "clang/Lex/Preprocessor.h" @@ -590,14 +591,12 @@ ClangModulesDeclVendor::Create(Target &t // 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"); + llvm::SmallString<128> Path; + target.GetClangModulesCachePath().GetPath(Path); + if (Path.empty()) + clang::driver::Driver::getDefaultModuleCachePath(Path); std::string module_cache_argument("-fmodules-cache-path="); - module_cache_argument.append(DefaultModuleCache.str().str()); + module_cache_argument.append(Path.str()); compiler_invocation_arguments.push_back(module_cache_argument); } Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=324775&r1=324774&r2=324775&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Fri Feb 9 14:08:26 2018 @@ -3509,6 +3509,9 @@ static PropertyDefinition g_properties[] OptionValue::eTypeString, nullptr, nullptr, "A list of trap handler function names, e.g. a common Unix user process " "one is _sigtramp."}, + {"clang-modules-cache-path", + OptionValue::eTypeFileSpec, false, 0, nullptr, nullptr, + "The path to the clang modules cache directory (-fmodules-cache-path)."}, {"display-runtime-support-values", OptionValue::eTypeBoolean, false, false, nullptr, nullptr, "If true, LLDB will show variables that are meant to " "support the operation of a language's runtime " @@ -3558,6 +3561,7 @@ enum { ePropertyMemoryModuleLoadLevel, ePropertyDisplayExpressionsInCrashlogs, ePropertyTrapHandlerNames, + ePropertyClangModulesCachePath, ePropertyDisplayRuntimeSupportValues, ePropertyNonStopModeEnabled, ePropertyExperimental @@ -3936,6 +3940,15 @@ FileSpecList &TargetProperties::GetDebug assert(option_value); return option_value->GetCurrentValue(); } + +FileSpec &TargetProperties::GetClangModulesCachePath() { + const uint32_t idx = ePropertyClangModulesCachePath; + OptionValueFileSpec *option_value = + m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpec(nullptr, false, + idx); + assert(option_value); + return option_value->GetCurrentValue(); +} FileSpecList &TargetProperties::GetClangModuleSearchPaths() { const uint32_t idx = ePropertyClangModuleSearchPaths; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits