-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.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.
Description
Code:
// src/lib.rs
#[inline] #[no_mangle] pub extern "C" fn foo() { }
# Cargo.toml
[package]
name = "foo"
version = "0.0.1"
edition = "2018"
[lib]
name = "foo"
crate-type = ["cdylib"]
cargo build --release
If the function is marked as #[inline]
, it doesn't get compiled into the dll file:
strings target/release/libfoo.so | grep foo
The reason a function may be marked as both #[inline]
and #[no_mangle]
is so that it gets inlined when compiling the crate as a rust library, but not inlined when compiling the crate as a cdylib.
There should be a warning to use something like #[cfg_attr(not(crate_type="cdylib"), inline]
instead.
This issue has been assigned to @doctorn via this comment.
Metadata
Metadata
Assignees
Labels
A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.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.