liveBook · Manning

No_mangle

no_mangle is a Rust attribute that prevents name mangling for an item, preserving its symbol name in compiled output.

How 2 Manning books explain it

Refactoring to Rust

The no_mangle attribute prevents the Rust compiler from applying symbol name mangling to an item.

How it is used
Makes Rust function names predictable when C code must find them through a linker.
How deep it goes
Explains why mangling obstructs named C linkage and distinguishes it from visibility and calling conventions, without detailing the mangling algorithm.
Examples
Contrasts a calculator’s unresolved `solve` symbol with its annotated Rust function and an NGINX handler with an address-only callback.
What you can do after
Operate/configure it on Rust functions C calls by name, while omitting it from callbacks C receives by address.

Read how Refactoring to Rust explains no_mangle →

Rust in Action: Systems programming concepts and techniques

no_mangle is a Rust attribute that suppresses compiler name mangling for an item’s externally visible symbol.

How it is used
Controls Rust symbol names when a bare-metal kernel or external component must locate an item predictably.
How deep it goes
Explains symbol strings, name-mangling collisions, and boot failure risk, but stops short of linker-level details.
Examples
Uses a kernel’s panic handler and _start entry point as concrete no_mangle examples.
What you can do after
Apply no_mangle to preserve predictable symbols in a Rust kernel or external-component interface.

Read how Rust in Action: Systems programming concepts and techniques explains no_mangle →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.