Skip to content

Reexported private functions cause linker errors #9790

Closed
@alexcrichton

Description

@alexcrichton

If you have a library with this code:

pub use foo::bar;

mod foo {
  pub fn bar() {}
}

No one can use the bar function at the top-level. The reason for this is that we mark the function with an inline 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions