-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Use Default visibility for rustc-generated C symbol declarations #123994
Conversation
tagging @alexcrichton because their wasm additions introduced the original |
At the time the wasm target was added I vaguely recall that this was basically required to get the target working. For example it was just a quirk that was wasm-specific and wasn't intended to affect any other target. I don't recall the exact reason why it was necessary, but I vaguely recall it being required as otherwise all symbols were always exported from all wasm binaries. I just tried a local compilation with |
We do actually want the command line flag for another use case: controlling symbol export when the final link step is not performed by rustc. Related: rust-lang/compiler-team#656 and #73295 If you build a |
Ah ok makes sense! I can clarify then that at least for wasm-related stuff it's ok to disgregard this, I'll send a parallel PR to disable this option for wasm instead of enable it by default. |
r? compiler |
5452bdd
to
ddeca1b
Compare
This looks like a reasonable default for foreign functions. The change have very little impact on unsuspecting users now because none of the built-in targets use r=me after considering #123994 (comment). |
ddeca1b
to
a1c27e3
Compare
Sorry I sat on this so long. Not sure if I should go ahead and submit, so I'll wait |
@rustbot ready |
@bors r+ |
…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.
Rollup of 5 pull requests Successful merges: - rust-lang#123994 (Use Default visibility for rustc-generated C symbol declarations) - rust-lang#126818 (Better handle suggestions for the already present code and fix some suggestions) - rust-lang#127624 (Migrate and rename `issue-47551`, `issue-35164` and `issue-69368` `run-make` tests to rmake) - rust-lang#128361 (Migrate `link-cfg` and `rustdoc-default-output` `run-make` tests to rmake) - rust-lang#128436 (Update sysinfo version to 0.31.2) r? `@ghost` `@rustbot` modify labels: rollup
@bors r- Looks like this failed in #128519 (comment) |
a1c27e3
to
7d33fa6
Compare
The failure happens when targeting The test should only run on platforms where dylibs are supported. I'm not sure how to accomplish that with compiletest. I added an What do other tests do? I can't find examples. @rustbot ready |
The |
7d33fa6
to
0a814c6
Compare
@rustbot ready
|
Ah, ok, the target supports dynamic linking, but only cdylibs, not dylib crates.
@rustbot author |
☔ The latest upstream changes (presumably #131111) made this pull request unmergeable. Please resolve the merge conflicts. |
…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.
@chbaker0 any updates on this? thanks |
@davidlattimore I think it's okay for you to pick this up, thanks for offering. |
Oh, looks like it's done already in #131519 |
This PR can be closed, right? |
From my perspective, it's fine to close |
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 #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 asmemcpy
andmemcmp
fromlibc.so
.References to symbols provided by shared libraries must have default visibility. Hidden visibility is mostly useful for defined symbols.