Hello.

As Windows Arm64 platform does not carry historical compatibility layers, the 
structure of Windows API DLLs is cleaner on Arm64 than on x64. For this reason, 
the x64 linking against `kernel32.dll` is not sufficient leading to undefined 
references to many Windows API symbols that are in different DLLs that would 
have to be added to the linking command explicitly.

To address that, there is a concept of umbrella DLLs 
(https://learn.microsoft.com/en-us/windows/win32/apiindex/windows-umbrella-libraries),
 that can be added instead. The recommended replacement for `kernel32.dll` is 
`onecore.dll` 
(https://learn.microsoft.com/en-us/windows-hardware/drivers/develop/building-for-onecore#building-for-onecore)
 that should be available since Windows 7.

In case of Cygwin linking, there is one exception, `pdh.dll` (Performance Data 
Helper, 
https://learn.microsoft.com/en-us/windows/win32/perfctrs/performance-counters-functions),
 that is not included in the `onecore.dll`.

Radek

---
>From 5a34927952b62bd273610ab85974922a7411375b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Radek=20Barto=C5=88?= <radek.bar...@microsoft.com>
Date: Mon, 9 Jun 2025 13:08:09 +0200
Subject: [PATCH] Cygwin: resolve AArch64 linking by linking to onecore instead
 of kernel32
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

As Windows Arm64 platform does not carry historical compatibility layers,
he structure of Windows API DLLs is cleaner on Arm64 than on x64. For this
reason, the x64 linking against kernel32.dll is not sufficient leading to
undefined references to many Windows API symbols that are in different DLLs
that would have to be added to the linking command explicitly.

To address that, there is a concept of umbrella DLLs
(https://learn.microsoft.com/en-us/windows/win32/apiindex/windows-umbrella-libraries),
that can be added instead. The recommended replacement for kernel32.dll is
onecore.dll 
(https://learn.microsoft.com/en-us/windows-hardware/drivers/develop/building-for-onecore#building-for-onecore)
that should be available since Windows 7.

In case of Cygwin linking, there is one exception, pdh.dll (Performance Data
Helper, 
https://learn.microsoft.com/en-us/windows/win32/perfctrs/performance-counters-functions),
that is not included in the onecore.dll.

Signed-off-by: Radek BartoĊˆ <radek.bar...@microsoft.com>
---
 winsup/cygwin/Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/winsup/cygwin/Makefile.am b/winsup/cygwin/Makefile.am
index 90a7332a8..96d1ab2f5 100644
--- a/winsup/cygwin/Makefile.am
+++ b/winsup/cygwin/Makefile.am
@@ -629,7 +629,7 @@ $(NEW_DLL_NAME): $(LDSCRIPT) libdll.a $(VERSION_OFILES) 
$(LIBSERVER)\
        $(LIBSERVER) \
        $(newlib_build)/libm.a \
        $(newlib_build)/libc.a \
-       -lgcc -lkernel32 -lntdll -Wl,-Map,cygwin.map
+       -lgcc -lpdh -lntdll -lonecore -Wl,-Map,cygwin.map
        @$(MKDIR_P) ${target_builddir}/winsup/testsuite/testinst/bin/
        $(AM_V_at)$(INSTALL_PROGRAM) $(NEW_DLL_NAME) 
${target_builddir}/winsup/testsuite/testinst/bin/$(DLL_NAME)
 
-- 
2.50.1.vfs.0.0

Attachment: 0001-Cygwin-resolve-AArch64-linking-by-linking-to-onecore-instead-of-kernel32.patch
Description: 0001-Cygwin-resolve-AArch64-linking-by-linking-to-onecore-instead-of-kernel32.patch

Reply via email to