Skip to content

Commit 6677f02

Browse files
authored
[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.
1 parent 78237b7 commit 6677f02

File tree

19 files changed

+38
-48
lines changed

19 files changed

+38
-48
lines changed

libcxx/test/libcxx/atomics/atomics.types.generic/atomics.types.float/lockfree.pass.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88
// UNSUPPORTED: c++03, c++11, c++14, c++17
9-
// UNSUPPORTED: target={{.+}}-windows-gnu
10-
// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
119
// XFAIL: !has-64-bit-atomics
10+
// UNSUPPORTED: !non-lockfree-atomics
1211

1312
// static constexpr bool is_always_lock_free = implementation-defined;
1413
// bool is_lock_free() const volatile noexcept;

libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/assign.pass.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88
// UNSUPPORTED: c++03, c++11, c++14, c++17
9-
// UNSUPPORTED: target={{.+}}-windows-gnu
10-
// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
119
// XFAIL: !has-64-bit-atomics
10+
// UNSUPPORTED: !non-lockfree-atomics
1211

1312
// floating-point-type operator=(floating-point-type) volatile noexcept;
1413
// floating-point-type operator=(floating-point-type) noexcept;

libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/compare_exchange_strong.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88
// UNSUPPORTED: c++03, c++11, c++14, c++17
9-
// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
109
// XFAIL: !has-64-bit-atomics
10+
// UNSUPPORTED: !non-lockfree-atomics
1111

1212
// bool compare_exchange_strong(T& expected, T desired,
1313
// memory_order success, memory_order failure) volatile noexcept;

libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/compare_exchange_weak.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88
// UNSUPPORTED: c++03, c++11, c++14, c++17
9-
// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
109
// XFAIL: !has-64-bit-atomics
10+
// UNSUPPORTED: !non-lockfree-atomics
1111

1212
// bool compare_exchange_weak(T& expected, T desired,
1313
// memory_order success, memory_order failure) volatile noexcept;

libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/ctor.pass.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88
// UNSUPPORTED: c++03, c++11, c++14, c++17
9-
// UNSUPPORTED: target={{.+}}-windows-gnu
10-
// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
119
// XFAIL: !has-64-bit-atomics
10+
// UNSUPPORTED: !non-lockfree-atomics
1211

1312
// constexpr atomic() noexcept;
1413
// constexpr atomic(floating-point-type) noexcept;

libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/exchange.pass.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
//
77
//===----------------------------------------------------------------------===//
88
// UNSUPPORTED: c++03, c++11, c++14, c++17
9-
// UNSUPPORTED: target={{.+}}-windows-gnu
109
// Clang's support for atomic operations on long double is broken. See https://github.com/llvm/llvm-project/issues/72893
11-
// XFAIL: tsan
10+
// XFAIL: target={{x86_64-.*}} && tsan
1211
// XFAIL: target={{x86_64-.*}} && msan
13-
// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
1412
// XFAIL: !has-64-bit-atomics
13+
// UNSUPPORTED: !non-lockfree-atomics
1514

1615
// T exchange(T, memory_order = memory_order::seq_cst) volatile noexcept;
1716
// T exchange(T, memory_order = memory_order::seq_cst) noexcept;

libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/fetch_add.pass.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
//
77
//===----------------------------------------------------------------------===//
88
// UNSUPPORTED: c++03, c++11, c++14, c++17
9-
// UNSUPPORTED: target={{.+}}-windows-gnu
10-
// XFAIL: LIBCXX-AIX-FIXME
9+
// UNSUPPORTED: LIBCXX-AIX-FIXME
1110
// Clang's support for atomic operations on long double is broken. See https://github.com/llvm/llvm-project/issues/72893
12-
// XFAIL: tsan
11+
// XFAIL: target={{x86_64-.*}} && tsan
1312
// Hangs with msan.
1413
// UNSUPPORTED: msan
15-
// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
1614
// XFAIL: !has-64-bit-atomics
15+
// UNSUPPORTED: !non-lockfree-atomics
1716

1817
// floating-point-type fetch_add(floating-point-type,
1918
// memory_order = memory_order::seq_cst) volatile noexcept;

libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/fetch_sub.pass.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
//
77
//===----------------------------------------------------------------------===//
88
// UNSUPPORTED: c++03, c++11, c++14, c++17
9-
// UNSUPPORTED: target={{.+}}-windows-gnu
10-
// XFAIL: LIBCXX-AIX-FIXME
9+
// UNSUPPORTED: LIBCXX-AIX-FIXME
1110
// Clang's support for atomic operations on long double is broken. See https://github.com/llvm/llvm-project/issues/72893
12-
// XFAIL: tsan
11+
// XFAIL: target={{x86_64-.*}} && tsan
1312
// Hangs with msan.
1413
// UNSUPPORTED: msan
15-
// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
1614
// XFAIL: !has-64-bit-atomics
15+
// UNSUPPORTED: !non-lockfree-atomics
1716

1817
// floating-point-type fetch_sub(floating-point-type,
1918
// memory_order = memory_order::seq_cst) volatile noexcept;

libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/load.pass.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
//
77
//===----------------------------------------------------------------------===//
88
// UNSUPPORTED: c++03, c++11, c++14, c++17
9-
// UNSUPPORTED: target={{.+}}-windows-gnu
109
// Clang's support for atomic operations on long double is broken. See https://github.com/llvm/llvm-project/issues/72893
11-
// XFAIL: tsan
12-
// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
1310
// XFAIL: !has-64-bit-atomics
11+
// XFAIL: target={{x86_64-.*}} && tsan
12+
// UNSUPPORTED: !non-lockfree-atomics
1413

1514
// floating-point-type load(memory_order = memory_order::seq_cst) volatile noexcept;
1615
// floating-point-type load(memory_order = memory_order::seq_cst) noexcept;

libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/lockfree.pass.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88
// UNSUPPORTED: c++03, c++11, c++14, c++17
9-
// UNSUPPORTED: target={{.+}}-windows-gnu
10-
// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
119
// XFAIL: !has-64-bit-atomics
10+
// UNSUPPORTED: !non-lockfree-atomics
1211

1312
// static constexpr bool is_always_lock_free = implementation-defined;
1413
// bool is_lock_free() const volatile noexcept;

libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/notify_all.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// UNSUPPORTED: no-threads
99
// XFAIL: availability-synchronization_library-missing
1010
// UNSUPPORTED: c++03, c++11, c++14, c++17
11-
// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
1211
// XFAIL: !has-64-bit-atomics
12+
// UNSUPPORTED: !non-lockfree-atomics
1313

1414
// void notify_all() volatile noexcept;
1515
// void notify_all() noexcept;

libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/notify_one.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// UNSUPPORTED: no-threads
99
// XFAIL: availability-synchronization_library-missing
1010
// UNSUPPORTED: c++03, c++11, c++14, c++17
11-
// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
1211
// XFAIL: !has-64-bit-atomics
12+
// UNSUPPORTED: !non-lockfree-atomics
1313

1414
// void notify_one() volatile noexcept;
1515
// void notify_one() noexcept;

libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/operator.float.pass.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88
// UNSUPPORTED: c++03, c++11, c++14, c++17
9-
// UNSUPPORTED: target={{.+}}-windows-gnu
10-
// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
119
// XFAIL: !has-64-bit-atomics
10+
// UNSUPPORTED: !non-lockfree-atomics
1211

1312
// operator floating-point-type() volatile noexcept;
1413
// operator floating-point-type() noexcept;

libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/operator.minus_equals.pass.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
//
77
//===----------------------------------------------------------------------===//
88
// UNSUPPORTED: c++03, c++11, c++14, c++17
9-
// UNSUPPORTED: target={{.+}}-windows-gnu
10-
// XFAIL: LIBCXX-AIX-FIXME
11-
// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
129
// XFAIL: !has-64-bit-atomics
10+
// UNSUPPORTED: LIBCXX-AIX-FIXME
11+
// UNSUPPORTED: !non-lockfree-atomics
1312
// Hangs with msan.
1413
// UNSUPPORTED: msan
1514

libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/operator.plus_equals.pass.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
//
77
//===----------------------------------------------------------------------===//
88
// UNSUPPORTED: c++03, c++11, c++14, c++17
9-
// UNSUPPORTED: target={{.+}}-windows-gnu
10-
// XFAIL: LIBCXX-AIX-FIXME
11-
// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
129
// XFAIL: !has-64-bit-atomics
10+
// UNSUPPORTED: LIBCXX-AIX-FIXME
11+
// UNSUPPORTED: !non-lockfree-atomics
1312
// Hangs with msan.
1413
// UNSUPPORTED: msan
1514

libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/store.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
//===----------------------------------------------------------------------===//
88
// UNSUPPORTED: c++03, c++11, c++14, c++17
99
// Clang's support for atomic operations on long double is broken. See https://github.com/llvm/llvm-project/issues/72893
10-
// XFAIL: tsan
11-
// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
1210
// XFAIL: !has-64-bit-atomics
11+
// XFAIL: target={{x86_64-.*}} && tsan
12+
// UNSUPPORTED: !non-lockfree-atomics
1313

1414
// void store(floating-point-type, memory_order = memory_order::seq_cst) volatile noexcept;
1515
// void store(floating-point-type, memory_order = memory_order::seq_cst) noexcept;

libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/wait.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
// UNSUPPORTED: c++03, c++11, c++14, c++17
99
// XFAIL: availability-synchronization_library-missing
1010
// Clang's support for atomic operations on long double is broken. See https://github.com/llvm/llvm-project/issues/72893
11-
// XFAIL: tsan
11+
// XFAIL: target={{x86_64-.*}} && tsan
1212
// XFAIL: target={{x86_64-.*}} && msan
13-
// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
1413
// XFAIL: !has-64-bit-atomics
14+
// UNSUPPORTED: !non-lockfree-atomics
1515

1616
// void wait(T old, memory_order order = memory_order::seq_cst) const volatile noexcept;
1717
// void wait(T old, memory_order order = memory_order::seq_cst) const noexcept;

libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_notify_all.pass.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ struct TestFn {
4040
A a(T(1));
4141
static_assert(noexcept(std::atomic_notify_all(&a)), "");
4242

43-
std::atomic<bool> is_ready[2] = {false, false};
44-
auto f = [&](int index) {
43+
std::atomic<bool> is_ready[2];
44+
is_ready[0] = false;
45+
is_ready[1] = false;
46+
auto f = [&](int index) {
4547
assert(std::atomic_load(&a) == T(1));
4648
is_ready[index].store(true);
4749

@@ -63,8 +65,10 @@ struct TestFn {
6365
volatile A a(T(2));
6466
static_assert(noexcept(std::atomic_notify_all(&a)), "");
6567

66-
std::atomic<bool> is_ready[2] = {false, false};
67-
auto f = [&](int index) {
68+
std::atomic<bool> is_ready[2];
69+
is_ready[0] = false;
70+
is_ready[1] = false;
71+
auto f = [&](int index) {
6872
assert(std::atomic_load(&a) == T(2));
6973
is_ready[index].store(true);
7074

libcxx/utils/libcxx/test/features.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,11 @@ def _getAndroidDeviceApi(cfg):
169169
when=lambda cfg: hasCompileFlag(cfg, "-Xclang -verify-ignore-unexpected"),
170170
),
171171
Feature(
172-
name="has-latomic",
172+
name="add-latomic-workaround", # https://github.com/llvm/llvm-project/issues/73361
173173
when=lambda cfg: sourceBuilds(
174-
cfg,
175-
"""
176-
int main(int, char**) { return 0; }
177-
""",
178-
["-latomic"],
174+
cfg, "int main(int, char**) { return 0; }", ["-latomic"]
179175
),
176+
actions=[AddLinkFlag("-latomic")],
180177
),
181178
Feature(
182179
name="non-lockfree-atomics",

0 commit comments

Comments
 (0)