Open
Description
Symbols annotated with __attribute__((availability))
always have default visibility, even if marked with __attribute__((__visibility__("hidden")))
and compiled with -fvisibility=hidden
. Self-contained repro (courtesy of @ldionne):
// Compile with: clang++ -xc++ - -shared -o a.out -fvisibility=hidden -fvisibility-inlines-hidden
// Check symbols with: nm -omg a.out | c++filt | grep value
template <class T>
struct foo {
__attribute__((__visibility__("hidden")))
__attribute__((availability(macos,strict,introduced=10.13)))
T value() const { return 0; }
};
int f(foo<int> x) {
return x.value();
}
Running nm
on the resulting binary shows it contains
a.out: 0000000000000408 (__TEXT,__text) weak external foo<int>::value() const
Annotating a symbol with availability should not affect its visibility.
Also tracked as rdar://33655115