[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 13:44:18 PDT 2021


mstorsjo updated this revision to Diff 332777.
mstorsjo added a comment.

Add a _isMSVC helper function in features.py and add a 'msvc' feature via that.
As the features themselves are processed after processing parameters, we can't check for the feature itself, but use the _isMSVC function.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99177/new/

https://reviews.llvm.org/D99177

Files:
  libcxx/utils/libcxx/test/features.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
@@ -7,6 +7,7 @@
 #===----------------------------------------------------------------------===##
 
 from libcxx.test.dsl import *
+from libcxx.test.features import _isMSVC
 
 _allStandards = ['c++03', 'c++11', 'c++14', 'c++17', 'c++2a', 'c++2b']
 _warningFlags = [
@@ -90,7 +91,12 @@
             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')
+              # When linking in MSVC mode via the Clang driver, a -l<foo>
+              # maps to <foo>.lib, so we need to use -llibc++experimental here
+              # to make it link against the static libc++experimental.lib.
+              # We can't check for the feature 'msvc' in available_features
+              # as those features are added after processing parameters.
+              AddLinkFlag(lambda config: '-llibc++experimental' if _isMSVC(config) else '-lc++experimental')
             ]),
 
   Parameter(name='long_tests', choices=[True, False], type=bool, default=True,
Index: libcxx/utils/libcxx/test/features.py
===================================================================
--- libcxx/utils/libcxx/test/features.py
+++ libcxx/utils/libcxx/test/features.py
@@ -14,6 +14,7 @@
 _isClang      = lambda cfg: '__clang__' in compilerMacros(cfg) and '__apple_build_version__' not in compilerMacros(cfg)
 _isAppleClang = lambda cfg: '__apple_build_version__' in compilerMacros(cfg)
 _isGCC        = lambda cfg: '__GNUC__' in compilerMacros(cfg) and '__clang__' not in compilerMacros(cfg)
+_isMSVC       = lambda cfg: '_MSC_VER' in compilerMacros(cfg)
 
 DEFAULT_FEATURES = [
   Feature(name='fcoroutines-ts',
@@ -81,6 +82,8 @@
   Feature(name=lambda cfg: 'gcc-{__GNUC__}'.format(**compilerMacros(cfg)),                                                         when=_isGCC),
   Feature(name=lambda cfg: 'gcc-{__GNUC__}.{__GNUC_MINOR__}'.format(**compilerMacros(cfg)),                                        when=_isGCC),
   Feature(name=lambda cfg: 'gcc-{__GNUC__}.{__GNUC_MINOR__}.{__GNUC_PATCHLEVEL__}'.format(**compilerMacros(cfg)),                  when=_isGCC),
+
+  Feature(name='msvc',                                                                                                             when=_isMSVC),
 ]
 
 # Deduce and add the test features that that are implied by the #defines in


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


More information about the libcxx-commits mailing list