Skip to content

Commit bfd6f62

Browse files
Rollup merge of rust-lang#124019 - ChrisDenton:futex-raw-dylib, r=joboet
Use raw-dylib for Windows synchronization functions Fixes rust-lang#123999 by using the raw-dylib feature to specify the DLL to load the Windows futex functions from (e.g. [`WaitOnAddress`](https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitonaddress)). This avoids reliance on the import library causing that issue. With apologies to `@bjorn3,` as it's currently necessary to revert this for cranelift.
2 parents abdeb13 + 5b024d6 commit bfd6f62

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
From 0d741cf82c3c908616abd39dc84ebf7d8702e0c3 Mon Sep 17 00:00:00 2001
2+
From: Chris Denton <chris@chrisdenton.dev>
3+
Date: Tue, 16 Apr 2024 15:51:34 +0000
4+
Subject: [PATCH] Revert use raw-dylib for Windows futex APIs
5+
6+
---
7+
library/std/src/sys/pal/windows/c.rs | 14 +-------------
8+
1 file changed, 1 insertion(+), 13 deletions(-)
9+
10+
diff --git a/library/std/src/sys/pal/windows/c.rs b/library/std/src/sys/pal/windows/c.rs
11+
index 9d58ce05f01..1c828bac4b6 100644
12+
--- a/library/std/src/sys/pal/windows/c.rs
13+
+++ b/library/std/src/sys/pal/windows/c.rs
14+
@@ -357,19 +357,7 @@ pub fn GetTempPath2W(bufferlength: u32, buffer: PWSTR) -> u32 {
15+
}
16+
17+
#[cfg(not(target_vendor = "win7"))]
18+
-// Use raw-dylib to import synchronization functions to workaround issues with the older mingw import library.
19+
-#[cfg_attr(
20+
- target_arch = "x86",
21+
- link(
22+
- name = "api-ms-win-core-synch-l1-2-0",
23+
- kind = "raw-dylib",
24+
- import_name_type = "undecorated"
25+
- )
26+
-)]
27+
-#[cfg_attr(
28+
- not(target_arch = "x86"),
29+
- link(name = "api-ms-win-core-synch-l1-2-0", kind = "raw-dylib")
30+
-)]
31+
+#[link(name = "synchronization")]
32+
extern "system" {
33+
pub fn WaitOnAddress(
34+
address: *const c_void,
35+
--
36+
2.42.0.windows.2
37+

library/std/src/sys/pal/windows/c.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,19 @@ compat_fn_with_fallback! {
357357
}
358358

359359
#[cfg(not(target_vendor = "win7"))]
360-
#[link(name = "synchronization")]
360+
// Use raw-dylib to import synchronization functions to workaround issues with the older mingw import library.
361+
#[cfg_attr(
362+
target_arch = "x86",
363+
link(
364+
name = "api-ms-win-core-synch-l1-2-0",
365+
kind = "raw-dylib",
366+
import_name_type = "undecorated"
367+
)
368+
)]
369+
#[cfg_attr(
370+
not(target_arch = "x86"),
371+
link(name = "api-ms-win-core-synch-l1-2-0", kind = "raw-dylib")
372+
)]
361373
extern "system" {
362374
pub fn WaitOnAddress(
363375
address: *const c_void,

0 commit comments

Comments
 (0)