[libcxx-commits] [libcxx] 6677f02 - [libc++] Workaround linker errors in floating-point atomic tests (#73398)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Nov 30 06:18:37 PST 2023
Author: Hui
Date: 2023-11-30T09:18:30-05:00
New Revision: 6677f029b2d177aaeea94df0f8ba67e760e43d4b
URL: https://github.com/llvm/llvm-project/commit/6677f029b2d177aaeea94df0f8ba67e760e43d4b
DIFF: https://github.com/llvm/llvm-project/commit/6677f029b2d177aaeea94df0f8ba67e760e43d4b.diff
LOG: [libc++] Workaround linker errors in floating-point atomic tests (#73398)
We now add -latomic whenever we detect that it's supported on the platform,
and we mark the tests as UNSUPPORTED on platforms where non-lockfree
atomics are not supported.
Added:
Modified:
libcxx/test/libcxx/atomics/atomics.types.generic/atomics.types.float/lockfree.pass.cpp
libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/assign.pass.cpp
libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/compare_exchange_strong.pass.cpp
libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/compare_exchange_weak.pass.cpp
libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/ctor.pass.cpp
libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/exchange.pass.cpp
libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/fetch_add.pass.cpp
libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/fetch_sub.pass.cpp
libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/load.pass.cpp
libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/lockfree.pass.cpp
libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/notify_all.pass.cpp
libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/notify_one.pass.cpp
libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/operator.float.pass.cpp
libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/operator.minus_equals.pass.cpp
libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/operator.plus_equals.pass.cpp
libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/store.pass.cpp
libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/wait.pass.cpp
libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_notify_all.pass.cpp
libcxx/utils/libcxx/test/features.py
Removed:
################################################################################
diff --git a/libcxx/test/libcxx/atomics/atomics.types.generic/atomics.types.float/lockfree.pass.cpp b/libcxx/test/libcxx/atomics/atomics.types.generic/atomics.types.float/lockfree.pass.cpp
index 222c6d026fc0f1d..42a7c08fa75ba26 100644
--- a/libcxx/test/libcxx/atomics/atomics.types.generic/atomics.types.float/lockfree.pass.cpp
+++ b/libcxx/test/libcxx/atomics/atomics.types.generic/atomics.types.float/lockfree.pass.cpp
@@ -6,9 +6,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: target={{.+}}-windows-gnu
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
// XFAIL: !has-64-bit-atomics
+// UNSUPPORTED: !non-lockfree-atomics
// static constexpr bool is_always_lock_free = implementation-defined;
// bool is_lock_free() const volatile noexcept;
diff --git a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/assign.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/assign.pass.cpp
index 3bdd8ae792cf7db..3daf3aba71fc9f2 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/assign.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/assign.pass.cpp
@@ -6,9 +6,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: target={{.+}}-windows-gnu
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
// XFAIL: !has-64-bit-atomics
+// UNSUPPORTED: !non-lockfree-atomics
// floating-point-type operator=(floating-point-type) volatile noexcept;
// floating-point-type operator=(floating-point-type) noexcept;
diff --git a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/compare_exchange_strong.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/compare_exchange_strong.pass.cpp
index b9e2fe40f955f74..b010e7c7a4d79d9 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/compare_exchange_strong.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/compare_exchange_strong.pass.cpp
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
// XFAIL: !has-64-bit-atomics
+// UNSUPPORTED: !non-lockfree-atomics
// bool compare_exchange_strong(T& expected, T desired,
// memory_order success, memory_order failure) volatile noexcept;
diff --git a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/compare_exchange_weak.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/compare_exchange_weak.pass.cpp
index f3ac52ff28cfee2..27853ef08c7482c 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/compare_exchange_weak.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/compare_exchange_weak.pass.cpp
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
// XFAIL: !has-64-bit-atomics
+// UNSUPPORTED: !non-lockfree-atomics
// bool compare_exchange_weak(T& expected, T desired,
// memory_order success, memory_order failure) volatile noexcept;
diff --git a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/ctor.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/ctor.pass.cpp
index d2f4a2bd64dc038..aad63540847618f 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/ctor.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/ctor.pass.cpp
@@ -6,9 +6,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: target={{.+}}-windows-gnu
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
// XFAIL: !has-64-bit-atomics
+// UNSUPPORTED: !non-lockfree-atomics
// constexpr atomic() noexcept;
// constexpr atomic(floating-point-type) noexcept;
diff --git a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/exchange.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/exchange.pass.cpp
index 1807e48f7befbfe..9c67d7e671cfa71 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/exchange.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/exchange.pass.cpp
@@ -6,12 +6,11 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: target={{.+}}-windows-gnu
// Clang's support for atomic operations on long double is broken. See https://github.com/llvm/llvm-project/issues/72893
-// XFAIL: tsan
+// XFAIL: target={{x86_64-.*}} && tsan
// XFAIL: target={{x86_64-.*}} && msan
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
// XFAIL: !has-64-bit-atomics
+// UNSUPPORTED: !non-lockfree-atomics
// T exchange(T, memory_order = memory_order::seq_cst) volatile noexcept;
// T exchange(T, memory_order = memory_order::seq_cst) noexcept;
diff --git a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/fetch_add.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/fetch_add.pass.cpp
index a73c5f26b71f64f..664185fc243f9a2 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/fetch_add.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/fetch_add.pass.cpp
@@ -6,14 +6,13 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: target={{.+}}-windows-gnu
-// XFAIL: LIBCXX-AIX-FIXME
+// UNSUPPORTED: LIBCXX-AIX-FIXME
// Clang's support for atomic operations on long double is broken. See https://github.com/llvm/llvm-project/issues/72893
-// XFAIL: tsan
+// XFAIL: target={{x86_64-.*}} && tsan
// Hangs with msan.
// UNSUPPORTED: msan
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
// XFAIL: !has-64-bit-atomics
+// UNSUPPORTED: !non-lockfree-atomics
// floating-point-type fetch_add(floating-point-type,
// memory_order = memory_order::seq_cst) volatile noexcept;
diff --git a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/fetch_sub.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/fetch_sub.pass.cpp
index d21a42e53a5469e..c4e33538de74178 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/fetch_sub.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/fetch_sub.pass.cpp
@@ -6,14 +6,13 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: target={{.+}}-windows-gnu
-// XFAIL: LIBCXX-AIX-FIXME
+// UNSUPPORTED: LIBCXX-AIX-FIXME
// Clang's support for atomic operations on long double is broken. See https://github.com/llvm/llvm-project/issues/72893
-// XFAIL: tsan
+// XFAIL: target={{x86_64-.*}} && tsan
// Hangs with msan.
// UNSUPPORTED: msan
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
// XFAIL: !has-64-bit-atomics
+// UNSUPPORTED: !non-lockfree-atomics
// floating-point-type fetch_sub(floating-point-type,
// memory_order = memory_order::seq_cst) volatile noexcept;
diff --git a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/load.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/load.pass.cpp
index 2901af0a7f39d83..b495d04989e2007 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/load.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/load.pass.cpp
@@ -6,11 +6,10 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: target={{.+}}-windows-gnu
// Clang's support for atomic operations on long double is broken. See https://github.com/llvm/llvm-project/issues/72893
-// XFAIL: tsan
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
// XFAIL: !has-64-bit-atomics
+// XFAIL: target={{x86_64-.*}} && tsan
+// UNSUPPORTED: !non-lockfree-atomics
// floating-point-type load(memory_order = memory_order::seq_cst) volatile noexcept;
// floating-point-type load(memory_order = memory_order::seq_cst) noexcept;
diff --git a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/lockfree.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/lockfree.pass.cpp
index 7619d113a3408a6..b5422c0362dc130 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/lockfree.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/lockfree.pass.cpp
@@ -6,9 +6,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: target={{.+}}-windows-gnu
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
// XFAIL: !has-64-bit-atomics
+// UNSUPPORTED: !non-lockfree-atomics
// static constexpr bool is_always_lock_free = implementation-defined;
// bool is_lock_free() const volatile noexcept;
diff --git a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/notify_all.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/notify_all.pass.cpp
index 143a034c55b7ffc..eca7a19e5c57da0 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/notify_all.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/notify_all.pass.cpp
@@ -8,8 +8,8 @@
// UNSUPPORTED: no-threads
// XFAIL: availability-synchronization_library-missing
// UNSUPPORTED: c++03, c++11, c++14, c++17
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
// XFAIL: !has-64-bit-atomics
+// UNSUPPORTED: !non-lockfree-atomics
// void notify_all() volatile noexcept;
// void notify_all() noexcept;
diff --git a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/notify_one.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/notify_one.pass.cpp
index debc9ddcdd32817..183cf18b820e746 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/notify_one.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/notify_one.pass.cpp
@@ -8,8 +8,8 @@
// UNSUPPORTED: no-threads
// XFAIL: availability-synchronization_library-missing
// UNSUPPORTED: c++03, c++11, c++14, c++17
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
// XFAIL: !has-64-bit-atomics
+// UNSUPPORTED: !non-lockfree-atomics
// void notify_one() volatile noexcept;
// void notify_one() noexcept;
diff --git a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/operator.float.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/operator.float.pass.cpp
index e0da122c3059b26..58c8da6c1042b26 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/operator.float.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/operator.float.pass.cpp
@@ -6,9 +6,8 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: target={{.+}}-windows-gnu
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
// XFAIL: !has-64-bit-atomics
+// UNSUPPORTED: !non-lockfree-atomics
// operator floating-point-type() volatile noexcept;
// operator floating-point-type() noexcept;
diff --git a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/operator.minus_equals.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/operator.minus_equals.pass.cpp
index 0ee0232718afa86..b1ef276d870cf50 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/operator.minus_equals.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/operator.minus_equals.pass.cpp
@@ -6,10 +6,9 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: target={{.+}}-windows-gnu
-// XFAIL: LIBCXX-AIX-FIXME
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
// XFAIL: !has-64-bit-atomics
+// UNSUPPORTED: LIBCXX-AIX-FIXME
+// UNSUPPORTED: !non-lockfree-atomics
// Hangs with msan.
// UNSUPPORTED: msan
diff --git a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/operator.plus_equals.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/operator.plus_equals.pass.cpp
index 1cdafaa4b5ab898..0b1781bf8e571b9 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/operator.plus_equals.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/operator.plus_equals.pass.cpp
@@ -6,10 +6,9 @@
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: target={{.+}}-windows-gnu
-// XFAIL: LIBCXX-AIX-FIXME
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
// XFAIL: !has-64-bit-atomics
+// UNSUPPORTED: LIBCXX-AIX-FIXME
+// UNSUPPORTED: !non-lockfree-atomics
// Hangs with msan.
// UNSUPPORTED: msan
diff --git a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/store.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/store.pass.cpp
index 957dbbe0d876e33..81d17cd32a6c502 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/store.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/store.pass.cpp
@@ -7,9 +7,9 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// Clang's support for atomic operations on long double is broken. See https://github.com/llvm/llvm-project/issues/72893
-// XFAIL: tsan
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
// XFAIL: !has-64-bit-atomics
+// XFAIL: target={{x86_64-.*}} && tsan
+// UNSUPPORTED: !non-lockfree-atomics
// void store(floating-point-type, memory_order = memory_order::seq_cst) volatile noexcept;
// void store(floating-point-type, memory_order = memory_order::seq_cst) noexcept;
diff --git a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/wait.pass.cpp b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/wait.pass.cpp
index 6c4f65d3bc38630..d95801e25d35e03 100644
--- a/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/wait.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/wait.pass.cpp
@@ -8,10 +8,10 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17
// XFAIL: availability-synchronization_library-missing
// Clang's support for atomic operations on long double is broken. See https://github.com/llvm/llvm-project/issues/72893
-// XFAIL: tsan
+// XFAIL: target={{x86_64-.*}} && tsan
// XFAIL: target={{x86_64-.*}} && msan
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
// XFAIL: !has-64-bit-atomics
+// UNSUPPORTED: !non-lockfree-atomics
// void wait(T old, memory_order order = memory_order::seq_cst) const volatile noexcept;
// void wait(T old, memory_order order = memory_order::seq_cst) const noexcept;
diff --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_notify_all.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_notify_all.pass.cpp
index e446bcf5cfc976b..2c8ce3453030269 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_notify_all.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_notify_all.pass.cpp
@@ -40,8 +40,10 @@ struct TestFn {
A a(T(1));
static_assert(noexcept(std::atomic_notify_all(&a)), "");
- std::atomic<bool> is_ready[2] = {false, false};
- auto f = [&](int index) {
+ std::atomic<bool> is_ready[2];
+ is_ready[0] = false;
+ is_ready[1] = false;
+ auto f = [&](int index) {
assert(std::atomic_load(&a) == T(1));
is_ready[index].store(true);
@@ -63,8 +65,10 @@ struct TestFn {
volatile A a(T(2));
static_assert(noexcept(std::atomic_notify_all(&a)), "");
- std::atomic<bool> is_ready[2] = {false, false};
- auto f = [&](int index) {
+ std::atomic<bool> is_ready[2];
+ is_ready[0] = false;
+ is_ready[1] = false;
+ auto f = [&](int index) {
assert(std::atomic_load(&a) == T(2));
is_ready[index].store(true);
diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index ab5a24dadb605b8..ccabb48833f10de 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -169,14 +169,11 @@ def _getAndroidDeviceApi(cfg):
when=lambda cfg: hasCompileFlag(cfg, "-Xclang -verify-ignore-unexpected"),
),
Feature(
- name="has-latomic",
+ name="add-latomic-workaround", # https://github.com/llvm/llvm-project/issues/73361
when=lambda cfg: sourceBuilds(
- cfg,
- """
- int main(int, char**) { return 0; }
- """,
- ["-latomic"],
+ cfg, "int main(int, char**) { return 0; }", ["-latomic"]
),
+ actions=[AddLinkFlag("-latomic")],
),
Feature(
name="non-lockfree-atomics",
More information about the libcxx-commits
mailing list