Linker arguments not being passed to MSVC

I am trying to increase the stack size of my program using linker arguments and am finding that they're not being passed. I've tried both the RUSTFLAGS environment variable and the .cargo/config file. I am using MSVC.

config:

build.rustflags = [
    "-Clink-arg=/F 100000000"
]

I have also tried (invalid):

build.rustflags = [
    "-Clink-arg=/not_real"
]

While I don't have a conclusive way to check if stack size has increased, ~100MB is far higher than the 1MB default so I'd expect to be able to run code that uses 20% more stack memory. The last example is also invalid and should fail the build. I have also guaranteed that cargo is reading these rust flags by using an invalid flag '-not_real' instead of '-Clink-arg' and it did fail.

As I understand it, /F is a argument to the MSVC compiler, not the linker. Do you want to use /STACK:something?

If the configuration file doesn't work, I've used a build script to pass options to the linker. This would look something like:

fn main() {
    println!("cargo:rustc-link-arg-bins=/STACK:100000000");
    println!("cargo:rerun-if-changed=build.rs");
}

in a file called build.rs in the same directory as the Cargo.toml.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.