diff --git a/Cargo.lock b/Cargo.lock index fbc511a319..27b447b6f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3315,7 +3315,6 @@ name = "roc_build" version = "0.0.1" dependencies = [ "bumpalo", - "const_format", "inkwell", "libloading", "roc_builtins", diff --git a/crates/cli/src/build.rs b/crates/cli/src/build.rs index 2a7ed50b73..67ce632d1c 100644 --- a/crates/cli/src/build.rs +++ b/crates/cli/src/build.rs @@ -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() ); } diff --git a/crates/compiler/build/Cargo.toml b/crates/compiler/build/Cargo.toml index de8e82e4d7..808263a70f 100644 --- a/crates/compiler/build/Cargo.toml +++ b/crates/compiler/build/Cargo.toml @@ -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 diff --git a/crates/compiler/build/src/link.rs b/crates/compiler/build/src/link.rs index cd69a54c17..8bced1b805 100644 --- a/crates/compiler/build/src/link.rs +++ b/crates/compiler/build/src/link.rs @@ -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,71 +60,58 @@ 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 => { - // TODO wasm host extension should be something else ideally - // .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) + 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 + // + // > 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) { + Some("wasm32.wasm") + } else { + Some("wasm32.zig") + } } - Triple { - operating_system: OperatingSystem::Linux, - architecture: Architecture::X86_64, - .. - } => Some("linux-x64.o"), - Triple { - operating_system: OperatingSystem::Linux, - architecture: Architecture::Aarch64(_), - .. - } => Some("linux-arm64.o"), - Triple { - operating_system: OperatingSystem::Darwin, - architecture: Architecture::Aarch64(_), - .. - } => Some("macos-arm64.o"), - Triple { - operating_system: OperatingSystem::Darwin, - architecture: Architecture::X86_64, - .. - } => Some("macos-x64.o"), - Triple { - operating_system: OperatingSystem::Windows, - architecture: Architecture::X86_64, - .. - } => Some("windows-x64.obj"), - Triple { - operating_system: OperatingSystem::Windows, - architecture: Architecture::X86_32(_), - .. - } => Some("windows-x86.obj"), - Triple { - operating_system: OperatingSystem::Windows, - architecture: Architecture::Aarch64(_), - .. - } => Some("windows-arm64.obj"), - _ => None, + _ => match target { + Triple { + operating_system: OperatingSystem::Linux, + architecture: Architecture::X86_64, + .. + } => Some("linux-x64.o"), + Triple { + operating_system: OperatingSystem::Linux, + architecture: Architecture::Aarch64(_), + .. + } => Some("linux-arm64.o"), + Triple { + operating_system: OperatingSystem::Darwin, + architecture: Architecture::Aarch64(_), + .. + } => Some("macos-arm64.o"), + Triple { + operating_system: OperatingSystem::Darwin, + architecture: Architecture::X86_64, + .. + } => Some("macos-x64.o"), + Triple { + operating_system: OperatingSystem::Windows, + architecture: Architecture::X86_64, + .. + } => Some("windows-x64.obj"), + Triple { + operating_system: OperatingSystem::Windows, + architecture: Architecture::X86_32(_), + .. + } => Some("windows-x86.obj"), + Triple { + operating_system: OperatingSystem::Windows, + architecture: Architecture::Aarch64(_), + .. + } => Some("windows-arm64.obj"), + _ => None, + }, } }