Skip to content

Remove extra indirection from statics with linkage? #156468

Description

@RalfJung

I just learned from @bjorn3 that the way we represent statics with linkage, such as #[linkage = "extern_weak"], is kind of strange:

unsafe extern "C" {
    #[linkage = "extern_weak"]
    static test_symbol_that_does_not_exist: Option<unsafe extern "C" fn()>;
}

Here, test_symbol_that_does_not_exist will actually be a global variable local to this module that points to the weak symbol.

Now that we have the &raw address-of operator, we could avoid this extra indirection. Whether we should, I do not know.
Cc @bjorn3 @nikic @chorman0773

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesF-linkage#![feature(linkage)]`needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions