When attempting to run a program that builds a large clap::App (find the source here), I get a stackoverflow: thread \'
.<
There's no way to set the stack size of the main thread in Rust. In fact, an assumption about the size of the main thread's stack is made at the source code level in the Rust runtime library (https://github.com/rust-lang/rust/blob/master/src/libstd/rt/mod.rs#L85).
The environment variable RUST_MIN_STACK
influences the stack size of threads created within the program that's not the main thread, but you could just as easily specify that value within your source code at runtime.
The most straightforward way to solve your problem might be to run the clap in a separate thread you create, so that you can control its stack size.
Take this code for example:
extern crate clap;
use clap::App;
use std::thread;
fn main() {
let child = thread::Builder::new().stack_size(32 * 1024 * 1024).spawn(move || {
return App::new("example")
.version("v1.0-beta")
.args_from_usage("<INPUT> 'Sets the input file to use'")
.get_matches();
}).unwrap();
let matches = child.join().unwrap();
println!("INPUT is: {}", matches.value_of("INPUT").unwrap());
}
clap appears to be able to terminate the application correctly from within the child thread so your code should work with little modification.