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"]
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.
Code:
If the function is marked as
#[inline], it doesn't get compiled into the dll file:strings target/release/libfoo.so | grep fooThe 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.