[libcxx-commits] [PATCH] D99177: [libcxx] [test] Fix testing on windows with c++experimental enabled

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 23 05:05:26 PDT 2021


mstorsjo created this revision.
Herald added a subscriber: arichardson.
mstorsjo requested review of this revision.
Herald added a project: libc++.
Herald added a reviewer: libc++.

The straightforward `AddLinkFlag('-lc++experimental')` approach doesn't
work on e.g. MSVC; instead use logic similar to how libc++ itself
is linked, but with the exception that libc++experimental always is
linked statically.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99177

Files:
  libcxx/utils/libcxx/test/config.py
  libcxx/utils/libcxx/test/params.py


Index: libcxx/utils/libcxx/test/params.py
===================================================================
--- libcxx/utils/libcxx/test/params.py
+++ libcxx/utils/libcxx/test/params.py
@@ -89,8 +89,7 @@
   Parameter(name='enable_experimental', choices=[True, False], type=bool, default=False,
             help="Whether to enable tests for experimental C++ libraries (typically Library Fundamentals TSes).",
             actions=lambda experimental: [] if not experimental else [
-              AddFeature('c++experimental'),
-              AddLinkFlag('-lc++experimental')
+              AddFeature('c++experimental')
             ]),
 
   Parameter(name='long_tests', choices=[True, False], type=bool, default=True,
Index: libcxx/utils/libcxx/test/config.py
===================================================================
--- libcxx/utils/libcxx/test/config.py
+++ libcxx/utils/libcxx/test/config.py
@@ -110,7 +110,6 @@
     def make_static_lib_name(self, name):
         """Return the full filename for the specified library name"""
         if self.target_info.is_windows() and not self.target_info.is_mingw():
-            assert name == 'c++'  # Only allow libc++ to use this function for now.
             return 'lib' + name + '.lib'
         else:
             return 'lib' + name + '.a'
@@ -144,6 +143,9 @@
             self.lit_config
         )
 
+        if 'c++experimental' in self.config.available_features:
+            self.configure_link_flags_cxx_experimental_library()
+
         self.lit_config.note("All available features: {}".format(self.config.available_features))
 
     def print_config_info(self):
@@ -446,6 +448,17 @@
             else:
                 self.cxx.link_flags += ['-lc++']
 
+    def configure_link_flags_cxx_experimental_library(self):
+        # c++experimental is always linked statically
+        if self.cxx_library_root:
+            libname = self.make_static_lib_name('c++experimental')
+            abs_path = os.path.join(self.cxx_library_root, libname)
+            assert os.path.exists(abs_path) and \
+                   "static libc++ library does not exist"
+            self.cxx.link_flags += [abs_path]
+        else:
+            self.cxx.link_flags += ['-lc++experimental']
+
     def configure_link_flags_abi_library(self):
         cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi')
         if cxx_abi == 'libstdc++':


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99177.332627.patch
Type: text/x-patch
Size: 2393 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210323/06fdb023/attachment.bin>


More information about the libcxx-commits mailing list