diff --git a/crates/cli/src/build.rs b/crates/cli/src/build.rs index d07986c68a..1654774836 100644 --- a/crates/cli/src/build.rs +++ b/crates/cli/src/build.rs @@ -379,18 +379,8 @@ pub fn build_file<'a>( inputs.push(host_input_path.as_path().to_str().unwrap()); } - let builtins_host_tempfile = { - #[cfg(unix)] - { - bitcode::host_unix_tempfile() - } - - #[cfg(windows)] - { - bitcode::host_windows_tempfile() - } - } - .expect("failed to write host builtins object to tempfile"); + let builtins_host_tempfile = + bitcode::host_tempfile().expect("failed to write host builtins object to tempfile"); if matches!(code_gen_options.backend, program::CodeGenBackend::Assembly) { inputs.push(builtins_host_tempfile.path().to_str().unwrap()); diff --git a/crates/compiler/build/src/link.rs b/crates/compiler/build/src/link.rs index 632302c250..b15dbacea0 100644 --- a/crates/compiler/build/src/link.rs +++ b/crates/compiler/build/src/link.rs @@ -705,18 +705,8 @@ pub fn rebuild_host( let env_home = env::var("HOME").unwrap_or_else(|_| "".to_string()); let env_cpath = env::var("CPATH").unwrap_or_else(|_| "".to_string()); - let builtins_host_tempfile = { - #[cfg(windows)] - { - bitcode::host_windows_tempfile() - } - - #[cfg(unix)] - { - bitcode::host_unix_tempfile() - } - } - .expect("failed to write host builtins object to tempfile"); + let builtins_host_tempfile = + bitcode::host_tempfile().expect("failed to write host builtins object to tempfile"); if zig_host_src.exists() { // Compile host.zig diff --git a/crates/compiler/builtins/src/bitcode.rs b/crates/compiler/builtins/src/bitcode.rs index 56d0bb339b..664f505972 100644 --- a/crates/compiler/builtins/src/bitcode.rs +++ b/crates/compiler/builtins/src/bitcode.rs @@ -27,7 +27,7 @@ pub fn host_wasm_tempfile() -> std::io::Result { } #[cfg(unix)] -pub fn host_unix_tempfile() -> std::io::Result { +fn host_unix_tempfile() -> std::io::Result { let tempfile = tempfile::Builder::new() .prefix("host_bitcode") .suffix(".o") @@ -40,7 +40,7 @@ pub fn host_unix_tempfile() -> std::io::Result { } #[cfg(windows)] -pub fn host_windows_tempfile() -> std::io::Result { +fn host_windows_tempfile() -> std::io::Result { let tempfile = tempfile::Builder::new() .prefix("host_bitcode") .suffix(".obj") @@ -52,6 +52,18 @@ pub fn host_windows_tempfile() -> std::io::Result { Ok(tempfile) } +pub fn host_tempfile() -> std::io::Result { + #[cfg(unix)] + { + host_unix_tempfile() + } + + #[cfg(windows)] + { + host_windows_tempfile() + } +} + #[derive(Debug, Default, Copy, Clone)] pub struct IntrinsicName { pub options: [&'static str; 14],