Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc++][test] Workaround for atomic tests linker errors on Linux systems without libatomic.so #73398

Merged
merged 1 commit into from
Nov 30, 2023

Conversation

huixie90
Copy link
Contributor

  • [libc++][test] fix atomic float test CI failure
  • format
  • [libc++][test] atomic tests add latomic workaround

@huixie90 huixie90 changed the title fix ci2 [libc++][test] Workaround for atomic tests linker errors on Linux systems without libatomic.so Nov 25, 2023
@huixie90 huixie90 marked this pull request as ready for review November 26, 2023 12:58
@huixie90 huixie90 requested a review from a team as a code owner November 26, 2023 12:58
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Nov 26, 2023
@llvmbot
Copy link
Member

llvmbot commented Nov 26, 2023

@llvm/pr-subscribers-libcxx

Author: Hui (huixie90)

Changes
  • [libc++][test] fix atomic float test CI failure
  • format
  • [libc++][test] atomic tests add latomic workaround

Patch is 28.50 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/73398.diff

34 Files Affected:

  • (modified) libcxx/test/libcxx/atomics/atomics.types.generic/atomics.types.float/lockfree.pass.cpp (+1-2)
  • (modified) libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/assign.pass.cpp (+1-2)
  • (modified) libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/compare_exchange_strong.pass.cpp (+1-1)
  • (modified) libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/compare_exchange_weak.pass.cpp (+1-1)
  • (modified) libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/ctor.pass.cpp (+1-2)
  • (modified) libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/exchange.pass.cpp (+2-3)
  • (modified) libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/fetch_add.pass.cpp (+3-4)
  • (modified) libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/fetch_sub.pass.cpp (+3-4)
  • (modified) libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/load.pass.cpp (+2-3)
  • (modified) libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/lockfree.pass.cpp (+1-2)
  • (modified) libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/notify_all.pass.cpp (+1-1)
  • (modified) libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/notify_one.pass.cpp (+1-1)
  • (modified) libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/operator.float.pass.cpp (+1-2)
  • (modified) libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/operator.minus_equals.pass.cpp (+2-3)
  • (modified) libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/operator.plus_equals.pass.cpp (+2-3)
  • (modified) libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/store.pass.cpp (+2-2)
  • (modified) libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/wait.pass.cpp (+2-2)
  • (modified) libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpp (+1-1)
  • (modified) libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp (+1-1)
  • (modified) libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp (+1-1)
  • (modified) libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp (+1-1)
  • (modified) libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp (+1-1)
  • (modified) libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp (+1-1)
  • (modified) libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_init.pass.cpp (+1-1)
  • (modified) libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_is_lock_free.pass.cpp (+1-1)
  • (modified) libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load.pass.cpp (+1-1)
  • (modified) libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load_explicit.pass.cpp (+1-1)
  • (modified) libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store.pass.cpp (+1-1)
  • (modified) libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store_explicit.pass.cpp (+1-1)
  • (modified) libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_notify_all.pass.cpp (+9-5)
  • (modified) libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_notify_one.pass.cpp (+1-1)
  • (modified) libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_wait.pass.cpp (+1-1)
  • (modified) libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.wait/atomic_wait_explicit.pass.cpp (+1-1)
  • (modified) libcxx/utils/libcxx/test/features.py (+3-6)
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 46511530c7c7582..51aff116b63a1cd 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,8 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 // UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: target={{.+}}-windows-gnu
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 
 //   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 8efb556cb5d99a5..a1eb235055eec85 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,8 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 // UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: target={{.+}}-windows-gnu
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 
 //  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 839d79d3a411052..e06dc821976efb1 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,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 // UNSUPPORTED: c++03, c++11, c++14, c++17
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 
 // 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 097210cc4a9db26..aa64af78ad574f1 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,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 // UNSUPPORTED: c++03, c++11, c++14, c++17
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 
 // 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 febabb4f2678261..53041e0b0b36301 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,8 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 // UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: target={{.+}}-windows-gnu
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 
 // 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 a8306304280c545..e2f6cbb2d06a3c4 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,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
+// XFAIL: target={{x86_64-.*}} && tsan
 // XFAIL: target={{x86_64-.*}} && msan
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 
 //  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 0c59b50eb807051..d6509ec30a708c2 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,13 +6,12 @@
 //
 //===----------------------------------------------------------------------===//
 // 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
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 
 // 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 4435e3fc19b4e90..97eae8b120c2599 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,13 +6,12 @@
 //
 //===----------------------------------------------------------------------===//
 // 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
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 
 // 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 fa085275de2995b..70f41c4e06abdf2 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,10 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 // 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: target={{x86_64-.*}} && tsan
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 
 //  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 447e0f86500272b..0918fc40db520e2 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,8 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 // UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: target={{.+}}-windows-gnu
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 
 //   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 e2320ed0b70ed13..f93ddb480b37f20 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,7 +8,7 @@
 // UNSUPPORTED: no-threads
 // XFAIL: availability-synchronization_library-missing
 // UNSUPPORTED: c++03, c++11, c++14, c++17
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 
 //  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 058424f5cee0593..6d94133a0950344 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,7 +8,7 @@
 // UNSUPPORTED: no-threads
 // XFAIL: availability-synchronization_library-missing
 // UNSUPPORTED: c++03, c++11, c++14, c++17
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 
 //  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 54c62ba8d091810..81bbfc0ca8d86b2 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,8 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 // UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: target={{.+}}-windows-gnu
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 
 //  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 23ad0c5c819dc8e..a345cc4eaf10dab 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,9 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 // UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: target={{.+}}-windows-gnu
-// XFAIL: LIBCXX-AIX-FIXME
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
+// UNSUPPORTED: LIBCXX-AIX-FIXME
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 // 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 0676645fcfa1518..af0536abf651204 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,9 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 // UNSUPPORTED: c++03, c++11, c++14, c++17
-// UNSUPPORTED: target={{.+}}-windows-gnu
-// XFAIL: LIBCXX-AIX-FIXME
-// ADDITIONAL_COMPILE_FLAGS(has-latomic): -latomic
+// UNSUPPORTED: LIBCXX-AIX-FIXME
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 // 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 0bb1f00840a890f..a521bbdccc58518 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,8 +7,8 @@
 //===----------------------------------------------------------------------===//
 // 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: target={{x86_64-.*}} && tsan
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 
 // 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 15f3613245a836e..5ffcb9fd5c99dc8 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,9 +8,9 @@
 // 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
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 
 // 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.req/atomic_compare_exchange_strong.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpp
index e5cf6aa12dc14d3..2eaac2b5ad4f5e6 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: !non-lockfree-atomics
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 
 // <atomic>
 
diff --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp
index f039069b49e942a..d05777b3ef4fb27 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: !non-lockfree-atomics
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 
 // <atomic>
 
diff --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp
index 93b7ea525f84315..c981f11a911a600 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: !non-lockfree-atomics
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 
 // <atomic>
 
diff --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp
index 41967bd3f564655..0dd8fb6caaa4201 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: !non-lockfree-atomics
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 
 // <atomic>
 
diff --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp
index 14d159a498ae7ef..cf4745c3dad22dc 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: !non-lockfree-atomics
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 
 // <atomic>
 
diff --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp
index 976327975f9d6cc..81c50384fbdc6cc 100644
--- a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp
+++ b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: !non-lockfree-atomics
+// UNSUPPORTED: !non-lockfree-atomics && !add-latomic-workaround
 
 // <atomic>
 
diff --git a/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_init.pass.cpp b/libcxx/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_init.pass.cpp
index 4dbf8fb928b8af1..2df9e720d8252ad 10...
[truncated]

Copy link

github-actions bot commented Nov 28, 2023

✅ With the latest revision this PR passed the Python code formatter.

Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this in https://buildkite.com/llvm-project/libcxx-ci/builds/31901#018c15d9-3491-4b6f-b2d5-92ce78d2c7a9

Unexpectedly Passed Tests (17):
  libcxx/atomics/atomics.types.generic/atomics.types.float/lockfree.pass.cpp
  std/atomics/atomics.types.generic/atomics.types.float/assign.pass.cpp
  std/atomics/atomics.types.generic/atomics.types.float/compare_exchange_strong.pass.cpp
  std/atomics/atomics.types.generic/atomics.types.float/compare_exchange_weak.pass.cpp
  std/atomics/atomics.types.generic/atomics.types.float/ctor.pass.cpp
  std/atomics/atomics.types.generic/atomics.types.float/exchange.pass.cpp
  std/atomics/atomics.types.generic/atomics.types.float/fetch_add.pass.cpp
  std/atomics/atomics.types.generic/atomics.types.float/fetch_sub.pass.cpp
  std/atomics/atomics.types.generic/atomics.types.float/load.pass.cpp
  std/atomics/atomics.types.generic/atomics.types.float/lockfree.pass.cpp
  std/atomics/atomics.types.generic/atomics.types.float/notify_all.pass.cpp
  std/atomics/atomics.types.generic/atomics.types.float/notify_one.pass.cpp
  std/atomics/atomics.types.generic/atomics.types.float/operator.float.pass.cpp
  std/atomics/atomics.types.generic/atomics.types.float/operator.minus_equals.pass.cpp
  std/atomics/atomics.types.generic/atomics.types.float/operator.plus_equals.pass.cpp
  std/atomics/atomics.types.generic/atomics.types.float/store.pass.cpp
  std/atomics/atomics.types.generic/atomics.types.float/wait.pass.cpp

I think it means that we're failing to detect non-lockfree-atomics on Windows, yet the code apparently seems to work. To unblock this patch and restore some CI stability, we could mark these tests as UNSUPPORTED: !non-lockfree-atomics and investigate the Windows problems separately. I suspect it would be really easy for @mstorsjo to help us out here.

libcxx/utils/libcxx/test/features.py Outdated Show resolved Hide resolved
Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM assuming this passes CI (and I think it should).

format

[libc++][test] atomic tests add latomic workaround

more tests

try again

undo format

next try

revert one change

next try
@zeroomega
Copy link
Contributor

Is this patch ready to land? I run through tests on our bots and can confirm it clears the atomic test failures. It would be great to land this patch timely.

@mstorsjo
Copy link
Member

I think it means that we're failing to detect non-lockfree-atomics on Windows, yet the code apparently seems to work. To unblock this patch and restore some CI stability, we could mark these tests as UNSUPPORTED: !non-lockfree-atomics and investigate the Windows problems separately. I suspect it would be really easy for @mstorsjo to help us out here.

I think the reason for these cases is pretty simple; when compiling a piece of code that uses atomics, there's nothing that says that the compiler MUST generate a call to __atomic_load or similar. The compiler is free to decide whether it is better to generate such code inline or generate a function call to a helper function.

So for such environments where the atomics helper functions are unavailable, some tests may succeed and some may fail, depending on what code generation decisions the compiler makes - thus, one can't really mark them XFAIL.

@ldionne
Copy link
Member

ldionne commented Nov 30, 2023

So for such environments where the atomics helper functions are unavailable, some tests may succeed and some may fail, depending on what code generation decisions the compiler makes - thus, one can't really mark them XFAIL.

We are pretty seriously starting to need compiler-rt on Windows though. This means that atomics on Windows will either work or fail to link depending on how much the compiler decides to inline. And this is also blocking us from refactoring our implementation of std::complex to use vastly superior builtins. What would be the path for this to happen?

Is this patch ready to land? I run through tests on our bots and can confirm it clears the atomic test failures. It would be great to land this patch timely.

Yes, I am merging it now. We were just waiting for the CI to complete over night.

@ldionne ldionne merged commit 6677f02 into llvm:main Nov 30, 2023
36 of 39 checks passed
@mstorsjo
Copy link
Member

So for such environments where the atomics helper functions are unavailable, some tests may succeed and some may fail, depending on what code generation decisions the compiler makes - thus, one can't really mark them XFAIL.

We are pretty seriously starting to need compiler-rt on Windows though.

This is a more nuanced and complex matter than that, though.

The issue that has been discussed multiple times before, is that MSVC style environments don't link in compiler-rt at all - but it should, ideally. There are plans on how to fix that, there was some progress on it earlier, but there still are a couple steps missing for that. (I'm not personally actively working on that, but I do comment on the plans for how they intend to do it.)

For MinGW environments, which we also test, we already do have compiler-rt builtins. However, by default, the compiler-rt builtins library doesn't include atomics: https://github.com/llvm/llvm-project/blob/llvmorg-17.0.6/compiler-rt/lib/builtins/CMakeLists.txt#L221-L223

skip the atomic builtin (these should normally be provided by a shared library)

When on a platform where there's a separate shared atomic library, that is supposed to be used, but here, I guess one should either enable this (i.e. disable COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN), or enable a different option COMPILER_RT_BUILD_STANDALONE_LIBATOMIC, https://github.com/llvm/llvm-project/blob/llvmorg-17.0.6/compiler-rt/lib/builtins/CMakeLists.txt#L857-L859, which builds a separate libclang_rt.atomic. I'm not sure if Clang links that one in automatically if it exists or what the story around it is.

For the MinGW builds, I could try to look into whether we should do either of these, until the LLVM 18 releases (we're past all planned 17.x releases for now), so we could have this in libcxx once 18 is out.

@ldionne
Copy link
Member

ldionne commented Nov 30, 2023

That would be amazing. Basically, my point of view (and I know it's shared by @huixie90) is that any platform where the compiler allows you to write something like __atomic_load(...) and fails to link that -- is a broken platform. That's why we filed #73361, for example.

Basically, the compiler should ensure that it links against the right system and/or toolchain libraries to make your code work. It does it for the C library, for the C++ library, for the unwinder library, but I have no idea why it doesn't do it for some obscure atomic builtins it provides. IMO, that's just a bug that has been around for so long that people think it's "designed like that". So if you have the ability to fix this on at least one platform (MinGW), you have my full support.

zeroomega referenced this pull request Dec 1, 2023
We really shouldn't be depending on far away configuration options like
LLVM_HAVE_LINK_VERSION_SCRIPT here. This patch simplifies the enablement
of the linker scripts and as a result gets rid of an undesirable
dependency on HandleLLVMOptions.cmake.

As a drive-by, the patch also stops taking into account whether Python3
is available. This should have no bearing on whether we generate a
linker script or not, which is required for correctness. If someone
tries to build libc++ and generate a linker script but Python3 is not
available, they should get an error instead of silently getting an
incorrect installation of the library.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants