From d0fbf9c2ea7237ea09164f67b68e0faec7dfe4c8 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Thu, 6 Apr 2023 00:16:24 +0200 Subject: [PATCH] Strip .dll extension from raw-dylib link names --- crates/libs/bindgen/src/functions.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/libs/bindgen/src/functions.rs b/crates/libs/bindgen/src/functions.rs index 892223d41d..68c7e6f532 100644 --- a/crates/libs/bindgen/src/functions.rs +++ b/crates/libs/bindgen/src/functions.rs @@ -58,6 +58,10 @@ fn gen_link>( for param in params { tokens.push_str(&format!("{}, ", param.as_str())); } + + // Strip the dll suffix, including it will cause runtime failures as the + // dynamic loader will look for eg. "kernel32.dll.dll" + let link = link.strip_suffix(".dll").unwrap_or(link); let tokens = tokens.trim_end_matches(", "); format!( "::windows_targets::link!(\"{link}\" \"{abi}\"{doc} fn {name}({tokens}) {return_type});"