mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
cli: create an option for wasm dev backend stack size
This commit is contained in:
parent
dd040d5f73
commit
91489ce6bd
3 changed files with 37 additions and 7 deletions
|
@ -48,6 +48,7 @@ pub fn build_file<'a>(
|
||||||
precompiled: bool,
|
precompiled: bool,
|
||||||
target_valgrind: bool,
|
target_valgrind: bool,
|
||||||
threading: Threading,
|
threading: Threading,
|
||||||
|
wasm_dev_stack_bytes: Option<u32>,
|
||||||
) -> Result<BuiltFile, LoadingProblem<'a>> {
|
) -> Result<BuiltFile, LoadingProblem<'a>> {
|
||||||
let compilation_start = Instant::now();
|
let compilation_start = Instant::now();
|
||||||
let target_info = TargetInfo::from(target);
|
let target_info = TargetInfo::from(target);
|
||||||
|
@ -246,6 +247,7 @@ pub fn build_file<'a>(
|
||||||
opt_level,
|
opt_level,
|
||||||
emit_debug_info,
|
emit_debug_info,
|
||||||
&preprocessed_host_path,
|
&preprocessed_host_path,
|
||||||
|
wasm_dev_stack_bytes,
|
||||||
);
|
);
|
||||||
|
|
||||||
buf.push('\n');
|
buf.push('\n');
|
||||||
|
|
|
@ -59,6 +59,7 @@ pub const FLAG_LINKER: &str = "linker";
|
||||||
pub const FLAG_PRECOMPILED: &str = "precompiled-host";
|
pub const FLAG_PRECOMPILED: &str = "precompiled-host";
|
||||||
pub const FLAG_VALGRIND: &str = "valgrind";
|
pub const FLAG_VALGRIND: &str = "valgrind";
|
||||||
pub const FLAG_CHECK: &str = "check";
|
pub const FLAG_CHECK: &str = "check";
|
||||||
|
pub const FLAG_WASM_STACK_SIZE_KB: &str = "wasm-stack-size-kb";
|
||||||
pub const ROC_FILE: &str = "ROC_FILE";
|
pub const ROC_FILE: &str = "ROC_FILE";
|
||||||
pub const ROC_DIR: &str = "ROC_DIR";
|
pub const ROC_DIR: &str = "ROC_DIR";
|
||||||
pub const GLUE_FILE: &str = "GLUE_FILE";
|
pub const GLUE_FILE: &str = "GLUE_FILE";
|
||||||
|
@ -117,6 +118,13 @@ pub fn build_app<'a>() -> Command<'a> {
|
||||||
.possible_values(["true", "false"])
|
.possible_values(["true", "false"])
|
||||||
.required(false);
|
.required(false);
|
||||||
|
|
||||||
|
let flag_wasm_stack_size_kb = Arg::new(FLAG_WASM_STACK_SIZE_KB)
|
||||||
|
.long(FLAG_WASM_STACK_SIZE_KB)
|
||||||
|
.help("Stack size in kilobytes for wasm32 target. Only applies when --dev also provided.")
|
||||||
|
.takes_value(true)
|
||||||
|
.validator(|s| s.parse::<u32>())
|
||||||
|
.required(false);
|
||||||
|
|
||||||
let roc_file_to_run = Arg::new(ROC_FILE)
|
let roc_file_to_run = Arg::new(ROC_FILE)
|
||||||
.help("The .roc file of an app to run")
|
.help("The .roc file of an app to run")
|
||||||
.allow_invalid_utf8(true)
|
.allow_invalid_utf8(true)
|
||||||
|
@ -145,6 +153,7 @@ pub fn build_app<'a>() -> Command<'a> {
|
||||||
.arg(flag_linker.clone())
|
.arg(flag_linker.clone())
|
||||||
.arg(flag_precompiled.clone())
|
.arg(flag_precompiled.clone())
|
||||||
.arg(flag_valgrind.clone())
|
.arg(flag_valgrind.clone())
|
||||||
|
.arg(flag_wasm_stack_size_kb.clone())
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(FLAG_TARGET)
|
Arg::new(FLAG_TARGET)
|
||||||
.long(FLAG_TARGET)
|
.long(FLAG_TARGET)
|
||||||
|
@ -515,6 +524,11 @@ pub fn build(
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let wasm_dev_stack_bytes: Option<u32> = matches
|
||||||
|
.value_of(FLAG_WASM_STACK_SIZE_KB)
|
||||||
|
.and_then(|s| s.parse::<u32>().ok())
|
||||||
|
.map(|x| x * 1024);
|
||||||
|
|
||||||
let target_valgrind = matches.is_present(FLAG_VALGRIND);
|
let target_valgrind = matches.is_present(FLAG_VALGRIND);
|
||||||
let res_binary_path = build_file(
|
let res_binary_path = build_file(
|
||||||
&arena,
|
&arena,
|
||||||
|
@ -528,6 +542,7 @@ pub fn build(
|
||||||
precompiled,
|
precompiled,
|
||||||
target_valgrind,
|
target_valgrind,
|
||||||
threading,
|
threading,
|
||||||
|
wasm_dev_stack_bytes,
|
||||||
);
|
);
|
||||||
|
|
||||||
match res_binary_path {
|
match res_binary_path {
|
||||||
|
|
|
@ -166,6 +166,7 @@ pub fn gen_from_mono_module(
|
||||||
opt_level: OptLevel,
|
opt_level: OptLevel,
|
||||||
emit_debug_info: bool,
|
emit_debug_info: bool,
|
||||||
preprocessed_host_path: &Path,
|
preprocessed_host_path: &Path,
|
||||||
|
wasm_dev_stack_bytes: Option<u32>,
|
||||||
) -> CodeGenTiming {
|
) -> CodeGenTiming {
|
||||||
match opt_level {
|
match opt_level {
|
||||||
OptLevel::Normal | OptLevel::Size | OptLevel::Optimize => gen_from_mono_module_llvm(
|
OptLevel::Normal | OptLevel::Size | OptLevel::Optimize => gen_from_mono_module_llvm(
|
||||||
|
@ -177,9 +178,14 @@ pub fn gen_from_mono_module(
|
||||||
opt_level,
|
opt_level,
|
||||||
emit_debug_info,
|
emit_debug_info,
|
||||||
),
|
),
|
||||||
OptLevel::Development => {
|
OptLevel::Development => gen_from_mono_module_dev(
|
||||||
gen_from_mono_module_dev(arena, loaded, target, app_o_file, preprocessed_host_path)
|
arena,
|
||||||
}
|
loaded,
|
||||||
|
target,
|
||||||
|
app_o_file,
|
||||||
|
preprocessed_host_path,
|
||||||
|
wasm_dev_stack_bytes,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,13 +422,18 @@ pub fn gen_from_mono_module_dev(
|
||||||
target: &target_lexicon::Triple,
|
target: &target_lexicon::Triple,
|
||||||
app_o_file: &Path,
|
app_o_file: &Path,
|
||||||
preprocessed_host_path: &Path,
|
preprocessed_host_path: &Path,
|
||||||
|
wasm_dev_stack_bytes: Option<u32>,
|
||||||
) -> CodeGenTiming {
|
) -> CodeGenTiming {
|
||||||
use target_lexicon::Architecture;
|
use target_lexicon::Architecture;
|
||||||
|
|
||||||
match target.architecture {
|
match target.architecture {
|
||||||
Architecture::Wasm32 => {
|
Architecture::Wasm32 => gen_from_mono_module_dev_wasm32(
|
||||||
gen_from_mono_module_dev_wasm32(arena, loaded, app_o_file, preprocessed_host_path)
|
arena,
|
||||||
}
|
loaded,
|
||||||
|
app_o_file,
|
||||||
|
preprocessed_host_path,
|
||||||
|
wasm_dev_stack_bytes,
|
||||||
|
),
|
||||||
Architecture::X86_64 | Architecture::Aarch64(_) => {
|
Architecture::X86_64 | Architecture::Aarch64(_) => {
|
||||||
gen_from_mono_module_dev_assembly(arena, loaded, target, app_o_file)
|
gen_from_mono_module_dev_assembly(arena, loaded, target, app_o_file)
|
||||||
}
|
}
|
||||||
|
@ -437,6 +448,7 @@ pub fn gen_from_mono_module_dev(
|
||||||
target: &target_lexicon::Triple,
|
target: &target_lexicon::Triple,
|
||||||
app_o_file: &Path,
|
app_o_file: &Path,
|
||||||
_host_input_path: &Path,
|
_host_input_path: &Path,
|
||||||
|
_wasm_dev_stack_bytes: Option<u32>,
|
||||||
) -> CodeGenTiming {
|
) -> CodeGenTiming {
|
||||||
use target_lexicon::Architecture;
|
use target_lexicon::Architecture;
|
||||||
|
|
||||||
|
@ -454,6 +466,7 @@ fn gen_from_mono_module_dev_wasm32(
|
||||||
loaded: MonomorphizedModule,
|
loaded: MonomorphizedModule,
|
||||||
app_o_file: &Path,
|
app_o_file: &Path,
|
||||||
preprocessed_host_path: &Path,
|
preprocessed_host_path: &Path,
|
||||||
|
wasm_dev_stack_bytes: Option<u32>,
|
||||||
) -> CodeGenTiming {
|
) -> CodeGenTiming {
|
||||||
let code_gen_start = Instant::now();
|
let code_gen_start = Instant::now();
|
||||||
let MonomorphizedModule {
|
let MonomorphizedModule {
|
||||||
|
@ -474,7 +487,7 @@ fn gen_from_mono_module_dev_wasm32(
|
||||||
arena,
|
arena,
|
||||||
module_id,
|
module_id,
|
||||||
exposed_to_host,
|
exposed_to_host,
|
||||||
stack_bytes: roc_gen_wasm::Env::DEFAULT_STACK_BYTES,
|
stack_bytes: wasm_dev_stack_bytes.unwrap_or(roc_gen_wasm::Env::DEFAULT_STACK_BYTES),
|
||||||
};
|
};
|
||||||
|
|
||||||
let host_bytes = std::fs::read(preprocessed_host_path).unwrap_or_else(|_| {
|
let host_bytes = std::fs::read(preprocessed_host_path).unwrap_or_else(|_| {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue