Skip to content

Adding availability attribute overrides visibility of symbols #134151

Open
@var-const

Description

@var-const

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:codegenIR generation bugs: mangling, exceptions, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions