[libcxx-commits] [libcxx] cfec0a3 - [libcxx] [test] Fix testing on windows with c++experimental enabled
Martin Storsjö via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Apr 22 00:26:18 PDT 2021
Author: Martin Storsjö
Date: 2021-04-22T10:26:00+03:00
New Revision: cfec0a3e9e70e9a7ce5ca6a0888ba71e2d978767
URL: https://github.com/llvm/llvm-project/commit/cfec0a3e9e70e9a7ce5ca6a0888ba71e2d978767
DIFF: https://github.com/llvm/llvm-project/commit/cfec0a3e9e70e9a7ce5ca6a0888ba71e2d978767.diff
LOG: [libcxx] [test] Fix testing on windows with c++experimental enabled
The straightforward `AddLinkFlag('-lc++experimental')` approach doesn't
work on e.g. MSVC. For linking to libc++ itself, a more convoluted logic
is used (see configure_link_flags_cxx_library).
Differential Revision: https://reviews.llvm.org/D99177
Added:
Modified:
libcxx/utils/libcxx/test/features.py
libcxx/utils/libcxx/test/params.py
Removed:
################################################################################
diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index e54cecef0ab8..2fb7e003ce03 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -14,6 +14,8 @@
_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)
+_msvcVersion = lambda cfg: (int(compilerMacros(cfg)['_MSC_VER']) // 100, int(compilerMacros(cfg)['_MSC_VER']) % 100)
DEFAULT_FEATURES = [
Feature(name='fcoroutines-ts',
@@ -81,6 +83,10 @@
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),
+ Feature(name=lambda cfg: 'msvc-{}'.format(*_msvcVersion(cfg)), when=_isMSVC),
+ Feature(name=lambda cfg: 'msvc-{}.{}'.format(*_msvcVersion(cfg)), when=_isMSVC),
]
# Deduce and add the test features that that are implied by the #defines in
diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index 9d1d83a7b9c7..ddf277dea246 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -7,6 +7,7 @@
#===----------------------------------------------------------------------===##
from libcxx.test.dsl import *
+from libcxx.test.features import _isMSVC
_warningFlags = [
'-Werror',
@@ -111,7 +112,12 @@ def getStdFlag(cfg, std):
help="Whether to enable tests for experimental C++ libraries (typically Library Fundamentals TSes).",
actions=lambda experimental: [] if not experimental else [
AddFeature('c++experimental'),
- PrependLinkFlag('-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.
+ PrependLinkFlag(lambda config: '-llibc++experimental' if _isMSVC(config) else '-lc++experimental')
]),
Parameter(name='long_tests', choices=[True, False], type=bool, default=True,
More information about the libcxx-commits
mailing list