-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
-Zdefault-hidden-visibility
causes linking errors due to intrinsic-related calls
#123427
Comments
In my original test of this locally I only changed https://github.com/rust-lang/rust/pull/118417/files#diff-6e38fd176c5407241bf7308381c05b28fd0b2d7f768ea52721cd3eaa6145653fR87 and it appeared to work correctly in terms of the resulting symbol table. |
If that's the desired behavior, perhaps this flag should have a different name. I'd assume the original target config field's behavior was intentional, and it's confusing to have a compiler flag with the same name but subtly different behavior. |
That makes sense and I'm not sure this is the root of either issue, but just wanted to mention that not all of these are strictly needed for our purposes. It could also be that the behavior should be different on macOS for both cases and it just never came up because there was no way to disable symbols on Mac before this change. So if the problem exists here, then it would also exist if you built rust with a custom configuration to hide symbols by default on macOS so it seems then that the flag isn't necessarily broken, but instead the underlying functionality is broken on macOS? |
Two tests that should pass, but fail with the flag: chbaker0@eec2e8e |
@alexcrichton the target spec field Was it intended to apply hidden visibility to rustc-generated references to |
…petrochenkov Use Default visibility for rustc-generated C symbol declarations Previously, visibility for these symbols was determined by the `default-hidden-visibility` target option or the presence of `-Zdefault-hidden-visibility`. This leads to issue rust-lang#123427, where use of the flag leads to undefined hidden symbols (i.e., references that can never be resolved to an exported symbol from another shared library) for functions often provided by a platform shared library, such as `memcpy` and `memcmp` from `libc.so`. References to symbols provided by shared libraries must have default visibility. Hidden visibility is mostly useful for _defined_ symbols.
…vis, r=Urgau Use Default visibility for rustc-generated C symbol declarations Non-default visibilities should only be used for definitions, not declarations, otherwise linking can fail. This is based on rust-lang#123994. Issue rust-lang#123427 When I changed `default-hidden-visibility` to `default-visibility` in rust-lang#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.
Rollup merge of rust-lang#131519 - davidlattimore:intrinsics-default-vis, r=Urgau Use Default visibility for rustc-generated C symbol declarations Non-default visibilities should only be used for definitions, not declarations, otherwise linking can fail. This is based on rust-lang#123994. Issue rust-lang#123427 When I changed `default-hidden-visibility` to `default-visibility` in rust-lang#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.
-Zdefault-hidden-visibility
should affect symbols defined in a crate. References to externally-defined symbols should not have hidden visibility.Certain intrinsics such as
compare_bytes
may emit calls tolibc.so
functions (e.g.memcmp
). When-Zdefault-hidden-visibility
is used, these symbol references are hidden. This leads to linking errors since an undefined hidden symbol cannot be resolved to a symbol in a dynamic library.Repro:
error:
The flag was added in #118417; MCP rust-lang/compiler-team#656
While this flag isn't really intended for use on
bin
crates, I suspect crates downstream of anrlib
orstaticlib
would have the same errors.The text was updated successfully, but these errors were encountered: