[libc++] Add a CI configuration for the modular build
authorLouis Dionne <ldionne.2@gmail.com>
Wed, 2 Jun 2021 21:07:57 +0000 (17:07 -0400)
committerLouis Dionne <ldionne.2@gmail.com>
Tue, 8 Jun 2021 17:32:08 +0000 (13:32 -0400)
Differential Revision: https://reviews.llvm.org/D103559

libcxx/cmake/caches/Generic-modules.cmake [new file with mode: 0644]
libcxx/test/libcxx/include_as_c.sh.cpp
libcxx/test/libcxx/utilities/utility/pairs/pairs.pair/non_trivial_copy_move_ABI.pass.cpp
libcxx/utils/ci/buildkite-pipeline.yml
libcxx/utils/ci/run-buildbot
libcxx/utils/libcxx/test/config.py
libcxx/utils/libcxx/test/format.py
libcxx/utils/libcxx/test/params.py

diff --git a/libcxx/cmake/caches/Generic-modules.cmake b/libcxx/cmake/caches/Generic-modules.cmake
new file mode 100644 (file)
index 0000000..29b4d4b
--- /dev/null
@@ -0,0 +1,2 @@
+set(LIBCXX_TEST_PARAMS "enable_modules=True" CACHE STRING "")
+set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "")
index 3fc4f1f..9f5ff98 100644 (file)
@@ -8,7 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 // We're building as C, so this test doesn't work when building with modules.
-// UNSUPPORTED: -fmodules
+// UNSUPPORTED: modules-build
 
 // GCC complains about unrecognized arguments because we're compiling the
 // file as C, but we're passing C++ flags on the command-line.
index 65fe65a..acf557d 100644 (file)
@@ -8,7 +8,7 @@
 
 // The test suite needs to define the ABI macros on the command line when
 // modules are enabled.
-// UNSUPPORTED: -fmodules
+// UNSUPPORTED: modules-build
 
 // <utility>
 
index b27222c..58272b6 100644 (file)
@@ -164,6 +164,17 @@ steps:
         - exit_status: -1  # Agent was lost
           limit: 2
 
+  - label: "Modular build"
+    command: "libcxx/utils/ci/run-buildbot generic-modules"
+    artifact_paths:
+      - "**/test-results.xml"
+    agents:
+      queue: "libcxx-builders"
+    retry:
+      automatic:
+        - exit_status: -1  # Agent was lost
+          limit: 2
+
   - label: "Static libraries"
     command: "libcxx/utils/ci/run-buildbot generic-static"
     artifact_paths:
index 64526c8..a1858c1 100755 (executable)
@@ -248,6 +248,13 @@ generic-noexceptions)
     generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-noexceptions.cmake"
     check-cxx-cxxabi
 ;;
+generic-modules)
+    export CC=clang
+    export CXX=clang++
+    clean
+    generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-modules.cmake"
+    check-cxx-cxxabi
+;;
 generic-static)
     export CC=clang
     export CXX=clang++
index 71880b8..4978482 100644 (file)
@@ -132,7 +132,6 @@ class Configuration(object):
         self.configure_link_flags()
         self.configure_env()
         self.configure_coverage()
-        self.configure_modules()
         self.configure_substitutions()
         self.configure_features()
 
@@ -470,28 +469,6 @@ class Configuration(object):
             self.cxx.flags += ['-g', '--coverage']
             self.cxx.compile_flags += ['-O0']
 
-    def configure_modules(self):
-        modules_flags = ['-fmodules', '-Xclang', '-fmodules-local-submodule-visibility']
-        supports_modules = self.cxx.hasCompileFlag(modules_flags)
-        enable_modules = self.get_lit_bool('enable_modules', default=False,
-                                                             env_var='LIBCXX_ENABLE_MODULES')
-        if enable_modules and not supports_modules:
-            self.lit_config.fatal(
-                '-fmodules is enabled but not supported by the compiler')
-        if not supports_modules:
-            return
-        module_cache = os.path.join(self.config.test_exec_root,
-                                   'modules.cache')
-        module_cache = os.path.realpath(module_cache)
-        if os.path.isdir(module_cache):
-            shutil.rmtree(module_cache)
-        os.makedirs(module_cache)
-        self.cxx.modules_flags += modules_flags + \
-            ['-fmodules-cache-path=' + module_cache]
-        if enable_modules:
-            self.config.available_features.add('-fmodules')
-            self.cxx.useModules()
-
     def quote(self, s):
         if platform.system() == 'Windows':
             return lit.TestRunner.quote_windows_command([s])
index 72f6d36..e4e2937 100644 (file)
@@ -225,7 +225,7 @@ class CxxStandardLibraryTest(lit.formats.TestFormat):
         #                split the part that does a death test outside of the
         #                test, and only disable that part when modules are
         #                enabled.
-        if '-fmodules' in test.config.available_features and self._disableWithModules(test):
+        if 'modules-build' in test.config.available_features and self._disableWithModules(test):
             return lit.Test.Result(lit.Test.UNSUPPORTED, 'Test {} is unsupported when modules are enabled')
 
         if re.search('[.]sh[.][^.]+$', filename):
index d2a7309..5ab8271 100644 (file)
@@ -77,6 +77,14 @@ DEFAULT_PARAMETERS = [
               AddCompileFlag(lambda cfg: getStdFlag(cfg, std)),
             ]),
 
+  Parameter(name='enable_modules', choices=[True, False], type=bool, default=False,
+            help="Whether to build the test suite with Clang modules enabled.",
+            actions=lambda modules: [
+              AddFeature('modules-build'),
+              AddCompileFlag('-fmodules'),
+              AddCompileFlag('-Xclang -fmodules-local-submodule-visibility'),
+            ] if modules else []),
+
   Parameter(name='enable_exceptions', choices=[True, False], type=bool, default=True,
             help="Whether to enable exceptions when compiling the test suite.",
             actions=lambda exceptions: [] if exceptions else [