From 15637450a5f02f4e824061a5cb5453bc4f3d28f6 Mon Sep 17 00:00:00 2001 From: karenwuz Date: Thu, 22 Oct 2026 18:21:53 +0000 Subject: [PATCH] adding Windows linker flag to py_extenstion --- python/private/cc/py_extension_macro.bzl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/python/private/cc/py_extension_macro.bzl b/python/private/cc/py_extension_macro.bzl index b76685113a..bd1f46d0ca 100644 --- a/python/private/cc/py_extension_macro.bzl +++ b/python/private/cc/py_extension_macro.bzl @@ -101,6 +101,23 @@ def py_extension( "//conditions:default": ["-fPIC"], }) + linkopts = linkopts + select({ + # Windows MinGW linker flags are needed for Python upb windows x86 wheels test + "//python/dist:windows_x86_32": ["-static-libgcc"], + "//conditions:default": [], + }) + select({ + "//python/dist:windows_x86_64_mingw": [ + "-Wl,--dynamicbase", + "-Wl,--nxcompat", + "-Wl,--high-entropy-va", + ], + "//python/dist:windows_x86_32_mingw": [ + "-Wl,--dynamicbase", + "-Wl,--nxcompat", + ], + "//conditions:default": [], + }) + # Private alias targets are appended to avoid "duplicate dependency label" errors # if a user explicitly passes //python/cc:current_py_cc_headers or //python/cc:current_py_cc_libs # in their deps attribute (including when deps is a select() expression).