mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 16:21:11 +00:00
Fix wasm32 host filename generation
This commit is contained in:
parent
e4e629c4e4
commit
fa2e0648ca
4 changed files with 52 additions and 68 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -3315,7 +3315,6 @@ name = "roc_build"
|
|||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"const_format",
|
||||
"inkwell",
|
||||
"libloading",
|
||||
"roc_builtins",
|
||||
|
|
|
@ -354,7 +354,7 @@ pub fn build_file<'a>(
|
|||
problems
|
||||
} else {
|
||||
todo!(
|
||||
"gracefully handle `ld` returning exit code {:?}",
|
||||
"gracefully handle `ld` (or `zig` in the case of wasm with --optimize) returning exit code {:?}",
|
||||
exit_status.code()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ roc_utils = { path = "../../utils" }
|
|||
|
||||
wasi_libc_sys = { path = "../../wasi-libc-sys" }
|
||||
|
||||
const_format.workspace = true
|
||||
bumpalo.workspace = true
|
||||
libloading.workspace = true
|
||||
tempfile.workspace = true
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use crate::target::{arch_str, target_zig_str};
|
||||
use const_format::concatcp;
|
||||
use libloading::{Error, Library};
|
||||
use roc_builtins::bitcode;
|
||||
use roc_error_macros::internal_error;
|
||||
|
@ -61,17 +60,8 @@ pub fn link(
|
|||
}
|
||||
|
||||
pub fn host_filename(target: &Triple, opt_level: OptLevel) -> Option<&'static str> {
|
||||
match target {
|
||||
Triple {
|
||||
architecture: Architecture::Wasm32,
|
||||
..
|
||||
} => {
|
||||
use roc_target::OperatingSystem::*;
|
||||
|
||||
const WITHOUT_EXTENSION: &str = "wasm32";
|
||||
|
||||
let file_name = match roc_target::OperatingSystem::from(target.operating_system) {
|
||||
Wasi => {
|
||||
match roc_target::OperatingSystem::from(target.operating_system) {
|
||||
roc_target::OperatingSystem::Wasi => {
|
||||
// TODO wasm host extension should be something else ideally
|
||||
// .bc does not seem to work because
|
||||
//
|
||||
|
@ -79,17 +69,12 @@ pub fn host_filename(target: &Triple, opt_level: OptLevel) -> Option<&'static st
|
|||
//
|
||||
// and zig does not currently emit `.a` webassembly static libraries
|
||||
if matches!(opt_level, OptLevel::Development) {
|
||||
concatcp!(WITHOUT_EXTENSION, ".wasm")
|
||||
Some("wasm32.wasm")
|
||||
} else {
|
||||
concatcp!(WITHOUT_EXTENSION, ".zig")
|
||||
Some("wasm32.zig")
|
||||
}
|
||||
}
|
||||
Unix => concatcp!(WITHOUT_EXTENSION, ".o"),
|
||||
Windows => concatcp!(WITHOUT_EXTENSION, ".obj"),
|
||||
};
|
||||
|
||||
Some(file_name)
|
||||
}
|
||||
_ => match target {
|
||||
Triple {
|
||||
operating_system: OperatingSystem::Linux,
|
||||
architecture: Architecture::X86_64,
|
||||
|
@ -126,6 +111,7 @@ pub fn host_filename(target: &Triple, opt_level: OptLevel) -> Option<&'static st
|
|||
..
|
||||
} => Some("windows-arm64.obj"),
|
||||
_ => None,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue