No_mangle
no_mangle is a Rust attribute that prevents name mangling for an item, preserving its symbol name in compiled output.
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.
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
- name manglingaddresses · Name mangling is the transformation of identifiers into altered names to encode distinguishing information or reduce naming collisions.
- foreign function interfaceuses · A foreign function interface is a mechanism that enables code in one programming language to call functions or access data provided by another language through compatible conventions.
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.

