Why are pub functions marked as `# [inline]` missing in the compiled object file?

I created a new box with cargo new aand typed this in src/lib.rs:

pub fn xor(a: i32, b: i32) -> i32 {
    a ^ b
}

#[inline]
pub fn xor_inline(a: i32, b: i32) -> i32 {
    a ^ b
}

When I compile with cargo build --release, the generated one .rlibcontains only xor, not xor_inline:

$ gnm -D -C target/release/deps/liba-6a3c2798185fafee.rlib
gnm: __.SYMDEF: File format not recognized

a-6a3c2798185fafee.0.o:
0000000000000000 T a::xor::hf0d97103d53d3286
gnm: rust.metadata.bin: File format not recognized
gnm: a-6a3c2798185fafee.0.bytecode.deflate: File format not recognized

( gnmis GNU nminstalled on MacOS via Homebrew.)

I have two questions:

  • Why is xor_inlinenot inside the object file? I believe that its source must be present in rust.metadata.binorder to work with a cross-box, but why is a simple function not exported from an object file?

  • - rustc, cargo rustc --release -- ..., , #[inline] ? (, --crate-type -C?)

( , , .)

+4
1

Rust 1.13.0 #[inline]. Rust 1.13.0: #[inline] , . , , , , , aren 't .

, .

( , , .)

, , . , , , , . ( Rust , !), , ! , , , ; , , .

+5

Source: https://habr.com/ru/post/1670320/


All Articles