[Lldb-commits] [PATCH] D54601: Makefile.rules: Use a shared clang module cache directory.

Adrian Prantl via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 15 17:23:14 PST 2018


aprantl updated this revision to Diff 174311.
aprantl added a comment.

Small bugfix + an error message that would have caught it.


https://reviews.llvm.org/D54601

Files:
  lit/lit.cfg.py
  packages/Python/lldbsuite/test/make/Makefile.rules


Index: packages/Python/lldbsuite/test/make/Makefile.rules
===================================================================
--- packages/Python/lldbsuite/test/make/Makefile.rules
+++ packages/Python/lldbsuite/test/make/Makefile.rules
@@ -33,7 +33,6 @@
 THIS_FILE_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST)))/
 LLDB_BASE_DIR := $(THIS_FILE_DIR)../../../../../
 
-
 #----------------------------------------------------------------------
 # If OS is not defined, use 'uname -s' to determine the OS name.
 #
@@ -242,7 +241,16 @@
 	CFLAGS += -gsplit-dwarf
 endif
 
+# Use a shared module cache when building in the default test build directory.
+ifeq "$(findstring lldb-test-build.noindex, $(BUILDDIR))" ""
 CLANG_MODULE_CACHE_DIR := $(BUILDDIR)/module-cache
+else
+CLANG_MODULE_CACHE_DIR := $(shell echo "$(BUILDDIR)" | sed 's/lldb-test-build.noindex.*/lldb-test-build.noindex\/module-cache-clang/')
+endif
+
+ifeq "$(CLANG_MODULE_CACHE_DIR)" ""
+$(error failed to set the shared clang module cache dir)
+endif
 
 MANDATORY_MODULE_BUILD_CFLAGS := -fmodules -gmodules -fmodules-cache-path=$(CLANG_MODULE_CACHE_DIR)
 
Index: lit/lit.cfg.py
===================================================================
--- lit/lit.cfg.py
+++ lit/lit.cfg.py
@@ -4,9 +4,9 @@
 import sys
 import re
 import platform
+import shutil
 import subprocess
 
-
 import lit.util
 import lit.formats
 from lit.llvm import llvm_config
@@ -124,3 +124,12 @@
      ('--build-mode', {'DEBUG': 'debug'}),
      ('--targets-built', calculate_arch_features)
      ])
+
+# Clean the module caches in the test build directory.  This is
+# necessary in an incremental build whenever clang changes underneath,
+# so doing it once per lit.py invocation is close enough.
+for i in ['module-cache-clang']:
+    cachedir = os.path.join(config.llvm_obj_root, 'lldb-test-build.noindex', i)
+    if os.path.isdir(cachedir):
+        print("Deleting module cache at %s."%cachedir)
+        shutil.rmtree(cachedir)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54601.174311.patch
Type: text/x-patch
Size: 1976 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20181116/687c8e0f/attachment.bin>


More information about the lldb-commits mailing list