Crate link_args[][src]

Send arguments to the linker from within main.rs or lib.rs. Currently only supports Windows MSVC.

Usage

Add this to your Cargo.toml:

[dependencies]
link_args = "0.5"

Examples

msvc macros

// Reserve 8 MiB for the stack.
link_args::msvc::stack_size!(0x800000);
 
// Only set these in release mode.
#[cfg(not(debug_assertions))]
link_args::msvc! {
    // Link the ucrt dynamically and vcruntime statically.
    default_lib("ucrt", "libvcruntime", "libcmt");
    // Disable the other C runtime libraries.
    no_default_lib(
        "libvcruntimed.lib", "vcruntime.lib", "vcruntimed.lib",
        "libcmtd.lib", "msvcrt.lib", "msvcrtd.lib",
        "libucrt.lib", "libucrtd.lib", "ucrtd.lib",
    );
}

Raw arguments

link_args::msvc::raw!(unsafe "/STACK:0x800000 /ENTRY:mainCRTStartup");

This reserves 8 MiB (8,388,608 bytes) for the stack and sets the application’s entry point to mainCRTStartup.

Modules

msvc

Macros

msvc

Set a group of arguments for the msvc linker.

msvc_defaultlib

Add one or more default libraries.

msvc_nodefaultlib

Prevent one or more libraries being loaded unless explicitly added on the command line.

msvc_raw

Embeds raw linker arguments for msvc targets.

msvc_stack_size

Set how much virtual memory is avaliable for the stack.