aboutsummaryrefslogtreecommitdiff
path: root/libcxx/utils
diff options
context:
space:
mode:
authorLouis Dionne <ldionne.2@gmail.com>2024-06-21 10:31:22 -0400
committerGitHub <noreply@github.com>2024-06-21 10:31:22 -0400
commitdb8c7e004a8acf74f40e0f7bc60066f26d43ccd9 (patch)
treedc67234e18ba55f538c729d08f3eb110c0b7f12b /libcxx/utils
parent60bdcc02ad19045ebb71ce8e48a316882c9b4e7e (diff)
downloadllvm-db8c7e004a8acf74f40e0f7bc60066f26d43ccd9.zip
llvm-db8c7e004a8acf74f40e0f7bc60066f26d43ccd9.tar.gz
llvm-db8c7e004a8acf74f40e0f7bc60066f26d43ccd9.tar.bz2
[libc++] Fix deployment target Lit features (#94791)
We were not making any distinction between e.g. the "Apple-flavored" libc++ built from trunk and the system-provided standard library on Apple platforms. For example, any test that would be XFAILed on a back-deployment target would unexpectedly pass when run on that deployment target against the tip of trunk Apple-flavored libc++. In reality, that test would be expected to pass because we're running against the latest libc++, even if it is Apple-flavored. To solve this issue, we introduce a new feature that describes whether the Standard Library in use is the one provided by the system by default, and that notion is different from the underlying standard library flavor. We also refactor the existing Lit features to make a distinction between availability markup and the library we're running against at runtime, which otherwise limit the flexibility of what we can express in the test suite. Finally, we refactor some of the back-deployment versions that were incorrect (such as thinking that LLVM 10 was introduced in macOS 11, when in reality macOS 11 was synced with LLVM 11). Fixes #82107
Diffstat (limited to 'libcxx/utils')
-rw-r--r--libcxx/utils/ci/buildkite-pipeline.yml4
-rwxr-xr-xlibcxx/utils/ci/run-buildbot2
-rw-r--r--libcxx/utils/libcxx/test/features.py166
-rw-r--r--libcxx/utils/libcxx/test/params.py13
4 files changed, 112 insertions, 73 deletions
diff --git a/libcxx/utils/ci/buildkite-pipeline.yml b/libcxx/utils/ci/buildkite-pipeline.yml
index 4bacdec..71d211b 100644
--- a/libcxx/utils/ci/buildkite-pipeline.yml
+++ b/libcxx/utils/ci/buildkite-pipeline.yml
@@ -89,8 +89,8 @@ steps:
<<: *common
# Build with the configuration we use to generate libc++.dylib on Apple platforms
- - label: Apple system
- command: libcxx/utils/ci/run-buildbot apple-system
+ - label: Apple system configuration
+ command: libcxx/utils/ci/run-buildbot apple-configuration
agents:
queue: libcxx-builders
os: macos
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index f96fc85..f1c20b9 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -514,7 +514,7 @@ generic-optimized-speed)
generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-optimized-speed.cmake"
check-runtimes
;;
-apple-system)
+apple-configuration)
clean
arch="$(uname -m)"
diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index 28c9c35..f93d9ef 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -359,6 +359,7 @@ macros = {
"_LIBCPP_HAS_NO_WIDE_CHARACTERS": "no-wide-characters",
"_LIBCPP_HAS_NO_TIME_ZONE_DATABASE": "no-tzdb",
"_LIBCPP_HAS_NO_UNICODE": "libcpp-has-no-unicode",
+ "_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS": "libcpp-has-no-availability-markup",
"_LIBCPP_PSTL_BACKEND_LIBDISPATCH": "libcpp-pstl-backend-libdispatch",
}
for macro, feature in macros.items():
@@ -580,107 +581,140 @@ DEFAULT_FEATURES += [
)
]
-# Define features for back-deployment testing.
-#
-# These features can be used to XFAIL tests that fail when deployed on (or compiled
-# for) an older system. For example, if a test exhibits a bug in the libc on a
-# particular system version, or if it uses a symbol that is not available on an
-# older version of the dylib, it can be marked as XFAIL with these features.
-#
-# It is sometimes useful to check that a test fails specifically when compiled for a
-# given deployment target. For example, this is the case when testing availability
-# markup, where we want to make sure that using the annotated facility on a deployment
-# target that doesn't support it will fail at compile time, not at runtime. This can
-# be achieved by creating a `.verify.cpp` test that checks for the right errors, and
-# mark that test as requiring `stdlib=<vendor>-libc++ && target=<target>`.
-#
-# Since it is not always known which deployment target to pick there are
-# short-hands based on the LLVM version like using-built-library-before-llvm-xx.
-# These short-hands make it easy for libc++ developers to select the proper
-# version the feature will be available in and allows vendors to set the proper
-# target information.
+# Helpers to define correspondances between LLVM versions and vendor system versions.
+# Those are used for backdeployment features below, do not use directly in tests.
DEFAULT_FEATURES += [
- # Backdeployment short-hands
Feature(
- name="using-built-library-before-llvm-11",
+ name="_target-before-llvm-11",
when=lambda cfg: BooleanExpression.evaluate(
- "stdlib=apple-libc++ && target={{.+}}-apple-macosx{{(10.9|10.10|10.11|10.12|10.13|10.14|10.15|11.0)(.0)?}}",
+ "target={{.+}}-apple-macosx{{(10.13|10.14|10.15)(.0)?}}",
cfg.available_features,
),
),
Feature(
- name="using-built-library-before-llvm-12",
+ name="_target-before-llvm-12",
when=lambda cfg: BooleanExpression.evaluate(
- "using-built-library-before-llvm-11 || (stdlib=apple-libc++ && target={{.+}}-apple-macosx12.{{(0|1|2)}}.0)",
+ "_target-before-llvm-11 || target={{.+}}-apple-macosx{{(11(.\d+)?|12.[0-2])(.0)?}}",
cfg.available_features,
),
),
-
Feature(
- name="using-built-library-before-llvm-13",
+ name="_target-before-llvm-13",
when=lambda cfg: BooleanExpression.evaluate(
- "using-built-library-before-llvm-12 || (stdlib=apple-libc++ && target={{.+}}-apple-macosx{{((12.(3|4|5|6|7))|(13.(0|1|2|3)))}}.0)",
+ "_target-before-llvm-12 || target={{.+}}-apple-macosx{{(12.[3-7]|13.[0-3])(.0)?}}",
cfg.available_features,
),
),
-
Feature(
- name="using-built-library-before-llvm-14",
+ name="_target-before-llvm-14",
when=lambda cfg: BooleanExpression.evaluate(
- "using-built-library-before-llvm-13",
+ "_target-before-llvm-13",
cfg.available_features,
),
),
-
Feature(
- name="using-built-library-before-llvm-15",
+ name="_target-before-llvm-15",
when=lambda cfg: BooleanExpression.evaluate(
- "using-built-library-before-llvm-14 || (stdlib=apple-libc++ && target={{.+}}-apple-macosx13.{{(4|5|6)}}.0)",
+ "_target-before-llvm-14 || target={{.+}}-apple-macosx{{13.[4-6](.0)?}}",
cfg.available_features,
),
),
-
Feature(
- name="using-built-library-before-llvm-16",
+ name="_target-before-llvm-16",
when=lambda cfg: BooleanExpression.evaluate(
- "using-built-library-before-llvm-15 || (stdlib=apple-libc++ && target={{.+}}-apple-macosx14.{{(0|1|2|3)}}.0)",
+ "_target-before-llvm-15 || target={{.+}}-apple-macosx{{12.[0-3](.0)?}}",
cfg.available_features,
),
),
-
Feature(
- name="using-built-library-before-llvm-17",
+ name="_target-before-llvm-17",
when=lambda cfg: BooleanExpression.evaluate(
- "using-built-library-before-llvm-16",
+ "_target-before-llvm-16",
cfg.available_features,
),
),
-
+ # For now, no released version of macOS contains LLVM 18
+ # TODO(ldionne) Please provide the correct value.
Feature(
- name="using-built-library-before-llvm-18",
+ name="_target-before-llvm-18",
when=lambda cfg: BooleanExpression.evaluate(
- # For now, no released version of macOS contains LLVM 18
- # TODO(ldionne) Please provide the correct value.
- "using-built-library-before-llvm-17 || stdlib=apple-libc++ && target={{.+}}-apple-macosx{{.+}}",
+ "_target-before-llvm-17 || target={{.+}}-apple-macosx{{.+}}",
cfg.available_features,
),
),
-
+ # For now, no released version of macOS contains LLVM 19
+ # TODO(ldionne) Please provide the correct value.
Feature(
- name="using-built-library-before-llvm-19",
+ name="_target-before-llvm-19",
when=lambda cfg: BooleanExpression.evaluate(
- # For now, no released version of macOS contains LLVM 19
- # TODO(ldionne) Please provide the correct value.
- "using-built-library-before-llvm-18 || stdlib=apple-libc++ && target={{.+}}-apple-macosx{{.+}}",
+ "_target-before-llvm-18 || target={{.+}}-apple-macosx{{.+}}",
cfg.available_features,
),
),
+]
- # Tests that require std::to_chars(floating-point) in the built library
+# Define features for back-deployment testing.
+#
+# These features can be used to XFAIL tests that fail when deployed on (or compiled
+# for) an older system. For example, if a test exhibits a bug in the libc++ on a
+# particular system version, or if it uses a symbol that is not available on an
+# older version of the dylib, it can be marked as XFAIL with these features.
+#
+# We have two families of Lit features:
+#
+# The first one is `using-built-library-before-llvm-XYZ`. These features encode the
+# fact that the test suite is being *run* against a version of the shared/static library
+# that predates LLVM version XYZ. This is useful to represent the use case of compiling
+# a program against the latest libc++ but then deploying it and running it on an older
+# system with an older version of the (usually shared) library.
+#
+# This feature is built up using the target triple passed to the compiler and the
+# `stdlib=system` Lit feature, which encodes that we're running against the same library
+# as described by the target triple.
+#
+# The second set of features is `availability-<FEATURE>-missing`. This family of Lit
+# features encodes the presence of availability markup in the libc++ headers. This is
+# useful to check that a test fails specifically when compiled for a given deployment
+# target, such as when testing availability markup where we want to make sure that
+# using the annotated facility on a deployment target that doesn't support it will fail
+# at compile time. This can be achieved by creating a `.verify.cpp` test that checks for
+# the right errors and marking the test as `REQUIRES: availability-<FEATURE>-missing`.
+#
+# This feature is built up using the presence of availability markup detected inside
+# __config, the flavor of the library being tested and the target triple passed to the
+# compiler.
+#
+# Note that both families of Lit features are similar but different in important ways.
+# For example, tests for availability markup should be expected to produce diagnostics
+# regardless of whether we're running against a system library, as long as we're using
+# a libc++ flavor that enables availability markup. Similarly, a test could fail when
+# run against the system library of an older version of FreeBSD, even though FreeBSD
+# doesn't provide availability markup at the time of writing this.
+for version in ("11", "12", "13", "14", "15", "16", "17", "18", "19"):
+ DEFAULT_FEATURES.append(
+ Feature(
+ name="using-built-library-before-llvm-{}".format(version),
+ when=lambda cfg: BooleanExpression.evaluate(
+ "stdlib=system && _target-before-llvm-{}".format(version),
+ cfg.available_features,
+ ),
+ )
+ )
+
+DEFAULT_FEATURES += [
+ # Tests that require std::filesystem support in the built library
Feature(
- name="availability-fp_to_chars-missing",
+ name="availability-filesystem-missing",
when=lambda cfg: BooleanExpression.evaluate(
- "using-built-library-before-llvm-13",
+ "!libcpp-has-no-availability-markup && (stdlib=apple-libc++ && target={{.+}}-apple-macosx10.{{(13|14)(.0)?}})",
+ cfg.available_features,
+ ),
+ ),
+ # Tests that require the C++20 synchronization library (P1135R6 implemented by https://llvm.org/D68480) in the built library
+ Feature(
+ name="availability-synchronization_library-missing",
+ when=lambda cfg: BooleanExpression.evaluate(
+ "!libcpp-has-no-availability-markup && (stdlib=apple-libc++ && _target-before-llvm-11)",
cfg.available_features,
),
),
@@ -688,7 +722,7 @@ DEFAULT_FEATURES += [
Feature(
name="availability-char8_t_support-missing",
when=lambda cfg: BooleanExpression.evaluate(
- "using-built-library-before-llvm-11",
+ "!libcpp-has-no-availability-markup && (stdlib=apple-libc++ && _target-before-llvm-12)",
cfg.available_features,
),
),
@@ -696,7 +730,7 @@ DEFAULT_FEATURES += [
Feature(
name="availability-verbose_abort-missing",
when=lambda cfg: BooleanExpression.evaluate(
- "using-built-library-before-llvm-13",
+ "!libcpp-has-no-availability-markup && (stdlib=apple-libc++ && _target-before-llvm-13)",
cfg.available_features,
),
),
@@ -704,23 +738,23 @@ DEFAULT_FEATURES += [
Feature(
name="availability-pmr-missing",
when=lambda cfg: BooleanExpression.evaluate(
- "using-built-library-before-llvm-13",
+ "!libcpp-has-no-availability-markup && (stdlib=apple-libc++ && _target-before-llvm-13)",
cfg.available_features,
),
),
- # Tests that require std::filesystem support in the built library
+ # Tests that require std::to_chars(floating-point) in the built library
Feature(
- name="availability-filesystem-missing",
+ name="availability-fp_to_chars-missing",
when=lambda cfg: BooleanExpression.evaluate(
- "stdlib=apple-libc++ && target={{.+}}-apple-macosx10.{{(13|14)(.0)?}}",
+ "!libcpp-has-no-availability-markup && (stdlib=apple-libc++ && _target-before-llvm-14)",
cfg.available_features,
),
),
- # Tests that require the C++20 synchronization library (P1135R6 implemented by https://llvm.org/D68480) in the built library
+ # Tests that require support for <print> and std::print in <ostream> in the built library.
Feature(
- name="availability-synchronization_library-missing",
+ name="availability-print-missing",
when=lambda cfg: BooleanExpression.evaluate(
- "stdlib=apple-libc++ && target={{.+}}-apple-macosx10.{{(13|14|15)(.0)?}}",
+ "!libcpp-has-no-availability-markup && (stdlib=apple-libc++ && _target-before-llvm-18)",
cfg.available_features,
),
),
@@ -728,15 +762,7 @@ DEFAULT_FEATURES += [
Feature(
name="availability-tzdb-missing",
when=lambda cfg: BooleanExpression.evaluate(
- "using-built-library-before-llvm-19",
- cfg.available_features,
- ),
- ),
- # Tests that require support for <print> and std::print in <ostream> in the built library.
- Feature(
- name="availability-print-missing",
- when=lambda cfg: BooleanExpression.evaluate(
- "using-built-library-before-llvm-18",
+ "!libcpp-has-no-availability-markup && (stdlib=apple-libc++ && _target-before-llvm-19)",
cfg.available_features,
),
),
diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py
index 4c8590a..ea841ac 100644
--- a/libcxx/utils/libcxx/test/params.py
+++ b/libcxx/utils/libcxx/test/params.py
@@ -265,6 +265,19 @@ DEFAULT_PARAMETERS = [
),
),
Parameter(
+ name="using_system_stdlib",
+ choices=[True, False],
+ type=bool,
+ default=False,
+ help="""Whether the Standard Library being tested is the one that shipped with the system by default.
+
+ This is different from the 'stdlib' parameter, which describes the flavor of libc++ being
+ tested. 'using_system_stdlib' describes whether the target system passed with 'target_triple'
+ also corresponds to the version of the library being tested.
+ """,
+ actions=lambda is_system: [AddFeature("stdlib=system")] if is_system else [],
+ ),
+ Parameter(
name="enable_warnings",
choices=[True, False],
type=bool,