Skip to content

Linking a static C library does not include all symbols #78827

Open
@Firstyear

Description

@Firstyear

This relates to #15460. On 1.47 stable and 1.48 nightly, when using cc/cbindgen, if a symbol in the C file is not used by the .rs file, then it is not in the resulting cdylib. It is possible to force the symbol to be included by "calling" it as show in #19321 .

The linked repository is able to reproduce this. Testing on OpenSUSE tumbleweed (fully patched with gcc10). After cargo build then the resulting libdemo.so does not contain the symbol wrapper_add.

This appears to be a regression since #15460 which was intended to resolve this behaviour. I appreciate your advice on this, thanks,

https://github.com/Firstyear/demo_r_link

EDIT: Worth noting in wrapper.c that it does not need to link to any R libs, and that SEXP is a typdef to typedef struct SEXPREC *SEXP;

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesP-lowLow priorityT-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions