mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
wasm: make host file relocatable
This commit is contained in:
parent
c436ac98e2
commit
dad1d14ef8
3 changed files with 16 additions and 7 deletions
|
@ -1155,7 +1155,7 @@ pub fn preprocess_host_wasm32(host_input_path: &Path, preprocessed_host_path: &P
|
|||
Notes:
|
||||
zig build-obj just gives you back the first input file, doesn't combine them!
|
||||
zig build-lib works but doesn't emit relocations, even with --emit-relocs (bug?)
|
||||
(gen_wasm needs relocs to adjust stack size by changing the __heap_base constant)
|
||||
(gen_wasm needs relocs for host-to-app calls and stack size adjustment)
|
||||
zig wasm-ld is a wrapper around wasm-ld and gives us maximum flexiblity
|
||||
(but seems to be an unofficial API)
|
||||
*/
|
||||
|
@ -1172,7 +1172,7 @@ pub fn preprocess_host_wasm32(host_input_path: &Path, preprocessed_host_path: &P
|
|||
"--export-all",
|
||||
"--no-entry",
|
||||
"--import-undefined",
|
||||
// "--relocatable", // enable this when gen_wasm can handle Custom sections in any order
|
||||
"--relocatable",
|
||||
];
|
||||
|
||||
command.args(args);
|
||||
|
|
|
@ -45,7 +45,7 @@ fn build_wasm() {
|
|||
&format!("{}/{}.o", out_dir, PLATFORM_FILENAME),
|
||||
"--export-all",
|
||||
"--no-entry",
|
||||
// "--emit-relocs", // TODO: resize stack by relocating __heap_base (issue #2480) here and in repl_test build
|
||||
"--relocatable",
|
||||
];
|
||||
|
||||
let zig = zig_executable();
|
||||
|
@ -98,10 +98,18 @@ fn build_wasm_libc_compilerrt(out_dir: &str, source_path: &str) -> (String, Stri
|
|||
],
|
||||
);
|
||||
|
||||
(
|
||||
run_command("find", &[&zig_cache_dir, "-name", "libc.a"]),
|
||||
run_command("find", &[&zig_cache_dir, "-name", "compiler_rt.o"]),
|
||||
)
|
||||
let libc_path = run_command("find", &[&zig_cache_dir, "-name", "libc.a"])
|
||||
.split('\n')
|
||||
.next()
|
||||
.unwrap()
|
||||
.into();
|
||||
let compiler_rt_path = run_command("find", &[&zig_cache_dir, "-name", "compiler_rt.o"])
|
||||
.split('\n')
|
||||
.next()
|
||||
.unwrap()
|
||||
.into();
|
||||
|
||||
(libc_path, compiler_rt_path)
|
||||
}
|
||||
|
||||
fn feature_is_enabled(feature_name: &str) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue