Skip to main content

rust_dynamic_env

Function rust_dynamic_env 

Source
pub fn rust_dynamic_env(target: Option<&str>) -> Vec<(String, String)>
Expand description

The environment a Rust app is compiled in so that it links the shared Lumen engine instead of compiling a copy of it into itself.

Two flags do it. -C prefer-dynamic tells the compiler to take the shared form of a crate wherever one exists, which is what makes the app pick the engine library over the static one beside it; it also applies to the Rust standard library, so the app and the engine end up sharing one copy of that too rather than each carrying its own. The second adds the app’s own directory to the list the loader searches, so the shared libraries sitting beside a packaged executable are found without a LD_LIBRARY_PATH in front of it.

Windows gets neither, and the returned environment is empty there. No linkable engine is built for it - a shared library exporting a graph this large is past what its import-library format can describe - so a Rust app on Windows carries the runtime inside its own binary, which is what the absence of these flags produces.

target is a Rust target triple to cross-compile for, or None for this machine. Anything already in RUSTFLAGS is kept and these are added after it, because setting the variable at all makes cargo ignore the rustflags an app’s own config may have set.