-
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
Reexported private functions cause linker errors #9790
Labels
A-codegen
Area: Code generation
Comments
As an example of where this can go wrong:
|
Is this the same issue affecting this code? pub use internal::S;
mod internal
{
pub struct S;
impl S
{
pub fn test(&self) {}
}
}
|
Checked to make sure, that test case fails on master and passes with this patch. |
bors
added a commit
that referenced
this issue
Oct 10, 2013
This fixes a bug in which the visibility rules were approximated by reachability, but forgot to cover the case where a 'pub use' reexports a private item. This fixes the commit by instead using the results of the privacy pass of the compiler to create the initial working set of the reachability pass. This may have the side effect of increasing the size of metadata, but it's difficult to avoid for correctness purposes sadly. Closes #9790
bors
added a commit
that referenced
this issue
Oct 10, 2013
This fixes a bug in which the visibility rules were approximated by reachability, but forgot to cover the case where a 'pub use' reexports a private item. This fixes the commit by instead using the results of the privacy pass of the compiler to create the initial working set of the reachability pass. This may have the side effect of increasing the size of metadata, but it's difficult to avoid for correctness purposes sadly. Closes #9790
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you have a library with this code:
No one can use the
bar
function at the top-level. The reason for this is that we mark the function with aninline
linkage, and LLVM then internalizes the symbol so no one else can use it.After some digging, it looks like this is because it is not flagged as "reachable" in the reachability pass of the compiler. After taking a look at the code, the reachability pass is doing a lot of approximations about privacy, and it's not taking public re-exports into account.
I believe that the best solution is to instead use the output of the privacy pass of the compiler to initially seed the work list of the reachability pass. Reachability should know nothing about privacy, it should only have to perform the iterations necessary to create a set of reachable items from public items.
The text was updated successfully, but these errors were encountered: