[libcxx-commits] [PATCH] D140675: [AIX][libc++] Always opt in to _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION

Michael Francis via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Feb 16 07:34:26 PST 2023


francii updated this revision to Diff 498017.
francii added a comment.

Update test case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140675/new/

https://reviews.llvm.org/D140675

Files:
  libcxx/include/__config
  libcxx/test/libcxx/vendor/ibm/bad_function_call.pass.cpp


Index: libcxx/test/libcxx/vendor/ibm/bad_function_call.pass.cpp
===================================================================
--- /dev/null
+++ libcxx/test/libcxx/vendor/ibm/bad_function_call.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: target={{powerpc.*-ibm-aix.*}}
+// ADDITIONAL_COMPILE_FLAGS: -fvisibility-inlines-hidden
+
+// When there is a weak hidden symbol in user code and a strong definition
+// in the library, we test that the linker relies on the library version,
+// as the default weak resolution semantics don't favour weak local definitions
+// for XCOFF. This creates a conflict on std::bad_function_call, which is used
+// by the std::function template instantiated in main.
+#include <functional>
+#include "test_macros.h"
+#include "assert.h"
+
+void foo() {}
+
+void test_call() {
+  std::function<void()> r(foo);
+  r();
+}
+
+void test_throw() {
+#ifndef TEST_HAS_NO_EXCEPTIONS
+  std::function<int()> f;
+  try {
+    f();
+    assert(false);
+  } catch (const std::bad_function_call&) {
+    return;
+  }
+  assert(false);
+#endif // TEST_HAS_NO_EXCEPTIONS
+}
+
+int main() {
+  test_call();
+  test_throw();
+  return 0;
+}
Index: libcxx/include/__config
===================================================================
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -164,6 +164,12 @@
 #    if defined(__FreeBSD__)
 #      define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
 #    endif
+// For XCOFF linkers, we have problems if we see a weak hidden version of a symbol
+// in user code (like you get with -fvisibility-inlines-hidden) and then a strong def
+// in the library, so we need to always rely on the library version.
+#    if defined(_AIX)
+#      define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
+#    endif
 #  endif
 
 #  if defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_ABI_VERSION >= 2


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140675.498017.patch
Type: text/x-patch
Size: 2234 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230216/421041c9/attachment.bin>


More information about the libcxx-commits mailing list