Skip to content
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

code-cov: generate dead functions with private/default linkage #91470

Merged
merged 1 commit into from
Dec 11, 2021

Commits on Dec 3, 2021

  1. code-cov: generate dead functions with private/default linkage

    As discovered in rust-lang#85461, the MSVC linker treats weak symbols slightly
    differently than unix-y linkers do. This causes link.exe to fail with
    LNK1227 "conflicting weak extern definition" where as other targets are
    able to link successfully.
    
    This changes the dead functions from being generated as weak/hidden to
    private/default which, as the LLVM reference says:
    
    > Global values with “private” linkage are only directly accessible by
    objects in the current module. In particular, linking code into a module
    with a private global value may cause the private to be renamed as
    necessary to avoid collisions. Because the symbol is private to the
    module, all references can be updated. This doesn’t show up in any
    symbol table in the object file.
    
    This fixes the conflicting weak symbols but doesn't address the reason
    *why* we have conflicting symbols for these dead functions. The test
    cases added in this commit contain a minimal repro of the fundamental
    issue which is that the logic used to decide what dead code functions
    should be codegen'd in the current CGU doesn't take into account that
    functions can be duplicated across multiple CGUs (for instance, in the
    case of `#[inline(always)]` functions).
    
    Fixing that is likely to be a more complex change (see
    rust-lang#85461 (comment)).
    
    Fixes rust-lang#85461
    wesleywiser committed Dec 3, 2021
    Configuration menu
    Copy the full SHA
    d5f6b9c View commit details
    Browse the repository at this point in the history