[libcxx-commits] [libcxx] [libc++] Remove workaround which allows setting _LIBCPP_OVERRIDABLE_FUNC_VIS externally (PR #113139)

Nico Weber via libcxx-commits libcxx-commits at lists.llvm.org
Mon Nov 18 11:58:44 PST 2024


nico wrote:

Heads-up: This broke a bunch of tests for us (chromium) that we're still analyzing.

However, trying `-fvisibility-global-new-delete` on a small demo shows that using it basically doesn't work:

```
% cat test-attrib.cc
#include <new>

int main() {
  int* a = new int;
  return *a;
}

thakis at MacBook-Pro llvm-project % out/gn/bin/clang++ test-attrib.cc -isysroot $(xcrun -show-sdk-path)  -fuse-ld=lld --target=x86_64-unknown-linux --sysroot ~/src/chrome/src/build/linux/debian_bullseye_amd64-sysroot -fvisibility-global-new-delete=force-hidden -stdlib=libc++
In file included from test-attrib.cc:1:
/Users/thakis/src/llvm-project/out/gn/bin/../include/c++/v1/new:212:19: error: visibility does not match previous declaration
  212 | [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC;
      |                   ^
/Users/thakis/src/llvm-project/out/gn/bin/../include/c++/v1/__config:411:42: note: expanded from macro '_LIBCPP_OVERRIDABLE_FUNC_VIS'
  411 | #    define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default")
      |                                          ^
/Users/thakis/src/llvm-project/out/gn/bin/../include/c++/v1/__config:401:54: note: expanded from macro '_LIBCPP_VISIBILITY'
  401 | #      define _LIBCPP_VISIBILITY(vis) __attribute__((__visibility__(vis)))
      |                                                      ^
note: previous attribute is here
```

I.e. all it does is give you a "visibility doesn't match" error.

Am I holding it wrong? How is `-fvisibility-global-new-delete=force-hidden` to be used with this?

Also, libcxx/docs/DesignDocs/VisibilityMacros.rst still documents `_LIBCPP_OVERRIDABLE_FUNC_VIS`.

https://github.com/llvm/llvm-project/pull/113139


More information about the libcxx-commits mailing list