Skip to content

Commit 7ac4f55

Browse files
committed
only emit link alias on windows
1 parent 0b71f93 commit 7ac4f55

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

pyo3-ffi/build.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ fn should_use_raw_dylib_linking(lib_name: &str) -> bool {
255255
}
256256

257257
fn emit_link_config(build_config: &BuildConfig) -> Result<()> {
258+
let target_os = cargo_env_var("CARGO_CFG_TARGET_OS").unwrap();
258259
let interpreter_config = &build_config.interpreter_config;
259260

260261
let lib_name = interpreter_config
@@ -275,12 +276,19 @@ fn emit_link_config(build_config: &BuildConfig) -> Result<()> {
275276
}
276277

277278
println!(
278-
"cargo:rustc-link-lib={link_model}pythonXY:{lib_name}",
279+
"cargo:rustc-link-lib={link_model}{alias}{lib_name}",
279280
link_model = if interpreter_config.shared() {
280281
""
281282
} else {
282283
"static="
283284
},
285+
// on windows we emit `#[link(name = "pythonXY")]` attributes
286+
// and need this alias here to get the right name for the final link
287+
alias = if target_os == "windows" {
288+
"pythonXY:"
289+
} else {
290+
""
291+
}
284292
);
285293

286294
if let Some(lib_dir) = interpreter_config.lib_dir() {

0 commit comments

Comments
 (0)