-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
#[inline]
prevents symbol from appearing in staticlib
output
#72463
Comments
Tried with |
I’ve noticed this for a while but I always assumed it was intended... It would be really nice if this was fixed |
This appears to have been done deliberately: #36280. Maybe it shouldn't apply to |
Expanding on @Aaron1011's note, I would also expect this not to apply to |
I think I'm going to take this on @rustbot claim |
…matthewjasper Export `#[inline]` fns with extern indicators In ancient history (rust-lang#36280) we stopped `#[inline]` fns being codegened if they weren't used. However, - rust-lang#72944 - rust-lang#72463 observe that when writing something like ```rust #![crate_type = "cdylib"] #[no_mangle] #[inline] pub extern "C" fn foo() { // ... } ``` we really _do_ want `foo` to be codegened. This change makes this the case. Resolves rust-lang#72944, resolves rust-lang#72463 (and maybe some more)
…matthewjasper Export `#[inline]` fns with extern indicators In ancient history (rust-lang#36280) we stopped `#[inline]` fns being codegened if they weren't used. However, - rust-lang#72944 - rust-lang#72463 observe that when writing something like ```rust #![crate_type = "cdylib"] #[no_mangle] #[inline] pub extern "C" fn foo() { // ... } ``` we really _do_ want `foo` to be codegened. This change makes this the case. Resolves rust-lang#72944, resolves rust-lang#72463 (and maybe some more)
…matthewjasper Export `#[inline]` fns with extern indicators In ancient history (rust-lang#36280) we stopped `#[inline]` fns being codegened if they weren't used. However, - rust-lang#72944 - rust-lang#72463 observe that when writing something like ```rust #![crate_type = "cdylib"] #[no_mangle] #[inline] pub extern "C" fn foo() { // ... } ``` we really _do_ want `foo` to be codegened. This change makes this the case. Resolves rust-lang#72944, resolves rust-lang#72463 (and maybe some more)
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_one
function makes it to the static library, but thesquare
function 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.1
stable, 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.toml
profile settings, they are not needed to reproduce.This issue has been assigned to @doctorn via this comment.
The text was updated successfully, but these errors were encountered: