mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +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"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
"const_format",
|
|
||||||
"inkwell",
|
"inkwell",
|
||||||
"libloading",
|
"libloading",
|
||||||
"roc_builtins",
|
"roc_builtins",
|
||||||
|
|
|
@ -354,7 +354,7 @@ pub fn build_file<'a>(
|
||||||
problems
|
problems
|
||||||
} else {
|
} else {
|
||||||
todo!(
|
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()
|
exit_status.code()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ roc_utils = { path = "../../utils" }
|
||||||
|
|
||||||
wasi_libc_sys = { path = "../../wasi-libc-sys" }
|
wasi_libc_sys = { path = "../../wasi-libc-sys" }
|
||||||
|
|
||||||
const_format.workspace = true
|
|
||||||
bumpalo.workspace = true
|
bumpalo.workspace = true
|
||||||
libloading.workspace = true
|
libloading.workspace = true
|
||||||
tempfile.workspace = true
|
tempfile.workspace = true
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::target::{arch_str, target_zig_str};
|
use crate::target::{arch_str, target_zig_str};
|
||||||
use const_format::concatcp;
|
|
||||||
use libloading::{Error, Library};
|
use libloading::{Error, Library};
|
||||||
use roc_builtins::bitcode;
|
use roc_builtins::bitcode;
|
||||||
use roc_error_macros::internal_error;
|
use roc_error_macros::internal_error;
|
||||||
|
@ -61,71 +60,58 @@ pub fn link(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn host_filename(target: &Triple, opt_level: OptLevel) -> Option<&'static str> {
|
pub fn host_filename(target: &Triple, opt_level: OptLevel) -> Option<&'static str> {
|
||||||
match target {
|
match roc_target::OperatingSystem::from(target.operating_system) {
|
||||||
Triple {
|
roc_target::OperatingSystem::Wasi => {
|
||||||
architecture: Architecture::Wasm32,
|
// TODO wasm host extension should be something else ideally
|
||||||
..
|
// .bc does not seem to work because
|
||||||
} => {
|
//
|
||||||
use roc_target::OperatingSystem::*;
|
// > Non-Emscripten WebAssembly hasn't implemented __builtin_return_address
|
||||||
|
//
|
||||||
const WITHOUT_EXTENSION: &str = "wasm32";
|
// and zig does not currently emit `.a` webassembly static libraries
|
||||||
|
if matches!(opt_level, OptLevel::Development) {
|
||||||
let file_name = match roc_target::OperatingSystem::from(target.operating_system) {
|
Some("wasm32.wasm")
|
||||||
Wasi => {
|
} else {
|
||||||
// TODO wasm host extension should be something else ideally
|
Some("wasm32.zig")
|
||||||
// .bc does not seem to work because
|
}
|
||||||
//
|
|
||||||
// > Non-Emscripten WebAssembly hasn't implemented __builtin_return_address
|
|
||||||
//
|
|
||||||
// and zig does not currently emit `.a` webassembly static libraries
|
|
||||||
if matches!(opt_level, OptLevel::Development) {
|
|
||||||
concatcp!(WITHOUT_EXTENSION, ".wasm")
|
|
||||||
} else {
|
|
||||||
concatcp!(WITHOUT_EXTENSION, ".zig")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Unix => concatcp!(WITHOUT_EXTENSION, ".o"),
|
|
||||||
Windows => concatcp!(WITHOUT_EXTENSION, ".obj"),
|
|
||||||
};
|
|
||||||
|
|
||||||
Some(file_name)
|
|
||||||
}
|
}
|
||||||
Triple {
|
_ => match target {
|
||||||
operating_system: OperatingSystem::Linux,
|
Triple {
|
||||||
architecture: Architecture::X86_64,
|
operating_system: OperatingSystem::Linux,
|
||||||
..
|
architecture: Architecture::X86_64,
|
||||||
} => Some("linux-x64.o"),
|
..
|
||||||
Triple {
|
} => Some("linux-x64.o"),
|
||||||
operating_system: OperatingSystem::Linux,
|
Triple {
|
||||||
architecture: Architecture::Aarch64(_),
|
operating_system: OperatingSystem::Linux,
|
||||||
..
|
architecture: Architecture::Aarch64(_),
|
||||||
} => Some("linux-arm64.o"),
|
..
|
||||||
Triple {
|
} => Some("linux-arm64.o"),
|
||||||
operating_system: OperatingSystem::Darwin,
|
Triple {
|
||||||
architecture: Architecture::Aarch64(_),
|
operating_system: OperatingSystem::Darwin,
|
||||||
..
|
architecture: Architecture::Aarch64(_),
|
||||||
} => Some("macos-arm64.o"),
|
..
|
||||||
Triple {
|
} => Some("macos-arm64.o"),
|
||||||
operating_system: OperatingSystem::Darwin,
|
Triple {
|
||||||
architecture: Architecture::X86_64,
|
operating_system: OperatingSystem::Darwin,
|
||||||
..
|
architecture: Architecture::X86_64,
|
||||||
} => Some("macos-x64.o"),
|
..
|
||||||
Triple {
|
} => Some("macos-x64.o"),
|
||||||
operating_system: OperatingSystem::Windows,
|
Triple {
|
||||||
architecture: Architecture::X86_64,
|
operating_system: OperatingSystem::Windows,
|
||||||
..
|
architecture: Architecture::X86_64,
|
||||||
} => Some("windows-x64.obj"),
|
..
|
||||||
Triple {
|
} => Some("windows-x64.obj"),
|
||||||
operating_system: OperatingSystem::Windows,
|
Triple {
|
||||||
architecture: Architecture::X86_32(_),
|
operating_system: OperatingSystem::Windows,
|
||||||
..
|
architecture: Architecture::X86_32(_),
|
||||||
} => Some("windows-x86.obj"),
|
..
|
||||||
Triple {
|
} => Some("windows-x86.obj"),
|
||||||
operating_system: OperatingSystem::Windows,
|
Triple {
|
||||||
architecture: Architecture::Aarch64(_),
|
operating_system: OperatingSystem::Windows,
|
||||||
..
|
architecture: Architecture::Aarch64(_),
|
||||||
} => Some("windows-arm64.obj"),
|
..
|
||||||
_ => None,
|
} => Some("windows-arm64.obj"),
|
||||||
|
_ => None,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue