mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 00:01:16 +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:
|
Notes:
|
||||||
zig build-obj just gives you back the first input file, doesn't combine them!
|
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?)
|
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
|
zig wasm-ld is a wrapper around wasm-ld and gives us maximum flexiblity
|
||||||
(but seems to be an unofficial API)
|
(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",
|
"--export-all",
|
||||||
"--no-entry",
|
"--no-entry",
|
||||||
"--import-undefined",
|
"--import-undefined",
|
||||||
// "--relocatable", // enable this when gen_wasm can handle Custom sections in any order
|
"--relocatable",
|
||||||
];
|
];
|
||||||
|
|
||||||
command.args(args);
|
command.args(args);
|
||||||
|
|
|
@ -45,7 +45,7 @@ fn build_wasm() {
|
||||||
&format!("{}/{}.o", out_dir, PLATFORM_FILENAME),
|
&format!("{}/{}.o", out_dir, PLATFORM_FILENAME),
|
||||||
"--export-all",
|
"--export-all",
|
||||||
"--no-entry",
|
"--no-entry",
|
||||||
// "--emit-relocs", // TODO: resize stack by relocating __heap_base (issue #2480) here and in repl_test build
|
"--relocatable",
|
||||||
];
|
];
|
||||||
|
|
||||||
let zig = zig_executable();
|
let zig = zig_executable();
|
||||||
|
@ -98,10 +98,18 @@ fn build_wasm_libc_compilerrt(out_dir: &str, source_path: &str) -> (String, Stri
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
(
|
let libc_path = run_command("find", &[&zig_cache_dir, "-name", "libc.a"])
|
||||||
run_command("find", &[&zig_cache_dir, "-name", "libc.a"]),
|
.split('\n')
|
||||||
run_command("find", &[&zig_cache_dir, "-name", "compiler_rt.o"]),
|
.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 {
|
fn feature_is_enabled(feature_name: &str) -> bool {
|
||||||
|
|
|
@ -40,6 +40,7 @@ fn main() {
|
||||||
PRE_LINKED_BINARY,
|
PRE_LINKED_BINARY,
|
||||||
"--export-all",
|
"--export-all",
|
||||||
"--no-entry",
|
"--no-entry",
|
||||||
|
"--relocatable",
|
||||||
];
|
];
|
||||||
|
|
||||||
let zig = zig_executable();
|
let zig = zig_executable();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue