Skip to content

dylib shared libraries will not make public symbols that may be necessary to link inlined code #65610

Description

@nagisa

When a dylib crate has a public inline(always) functions in it that use, as an implementation, other, private functions, using these public functions from other crates will fail with linkage errors because we fail to "export" the private functions.

An example project can be seen here. In this example the driver dylib crate privately externs a symbol from a static C library and uses it to implement an inline(always) interface/wrapper. The user crate then attempts to use the inline(always) wrapper, but linking fails with an error such as this:

/tmp/user/driver/src/lib.rs:8: undefined reference to `private_extern_symbol'

When inspecting the libdriver.so we can see that the extern symbol does indeed exist but is "private":

0000000000001100 t private_extern_symbol

I think we might be un-exporting items too aggressively here. cc @michaelwoerister @oli-obk

Blocks #55617

Regression from 1.36.0 (example builds successfully) to 1.37 (example fails to build).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions