-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
#[inline] prevents symbol from appearing in staticlib output #72463
Copy link
Copy link
Closed
Labels
A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
I currently use Rust to generate a static library for FFI consumption. In some public interfaces, I call other FFI public interfaces as primarily a wrapper with a few tweaks. I'd like to mark these "inner" functions as inline, however, this seems to cause them to not show up in the final staticlib.
Given this drastically simplified example:
The
square_plus_onefunction makes it to the static library, but thesquarefunction does not:If I remove the
#[inline]attribute, we see both functions in the static lib:The relevant docs don't seem to hint that
#[inline]can prevent#[no_mangle]/pub extern "C"items from surviving all the way to the final library, or that they shouldn't be used together.I would expect any function marked
pub extern "C"and/or#[no_mangle]should be present in the final artifact, regardless of#[inline]attributes.I see this behavior on
1.43.1stable, as well as a recent nightly. I don't know if this is a regression, as this is the first time I've run into this.Thanks!
Edit: Simplified
Cargo.tomlprofile settings, they are not needed to reproduce.This issue has been assigned to @DoctorN via this comment.