Use Default visibility for rustc-generated C symbol declarations by davidlattimore · Pull Request #131519 · rust-lang/rust (original) (raw)

Non-default visibilities should only be used for definitions, not declarations, otherwise linking can fail.

This is based on #123994.

Issue #123427

When I changed default-hidden-visibility to default-visibility in #130005, I updated all places in the code that used default-hidden-visibility, replicating the hidden-visibility bug to also happen for protected visibility.

Without this change, trying to build rustc with -Z default-visibility=protected fails with a link error.