diff --git a/src/main/cpp/blaze_util_windows.cc b/src/main/cpp/blaze_util_windows.cc index 21525d6b3e5b56..45090fbc8a2858 100644 --- a/src/main/cpp/blaze_util_windows.cc +++ b/src/main/cpp/blaze_util_windows.cc @@ -466,7 +466,8 @@ std::unique_ptr GetProcessCWD(int pid) { } bool IsSharedLibrary(const string& filename) { - return blaze_util::ends_with(filename, ".dll"); + return (blaze_util::ends_with(filename, ".dll") || + blaze_util::ends_with(filename, ".pyd")); } string GetSystemJavabase() { diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/ArtifactCategory.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/ArtifactCategory.java index 246f7be207c43c..59a250437178bd 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/ArtifactCategory.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/ArtifactCategory.java @@ -23,7 +23,7 @@ public enum ArtifactCategory { STATIC_LIBRARY("lib", ".a", ".lib"), ALWAYSLINK_STATIC_LIBRARY("lib", ".lo", ".lo.lib"), - DYNAMIC_LIBRARY("lib", ".so", ".dylib", ".dll", ".wasm"), + DYNAMIC_LIBRARY("lib", ".so", ".dylib", ".dll", ".pyd",".wasm"), EXECUTABLE("", "", ".exe", ".wasm"), INTERFACE_LIBRARY("lib", ".ifso", ".tbd", ".if.lib", ".lib"), PIC_FILE("", ".pic"), diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl index 14d100076bf319..dd4bfaedfdfe26 100644 --- a/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl @@ -315,7 +315,7 @@ def _create_transitive_linking_actions( # entries during linking process. for libs in precompiled_files[:]: for artifact in libs: - if _matches([".so", ".dylib", ".dll", ".ifso", ".tbd", ".lib", ".dll.a"], artifact.basename) or cc_helper.is_valid_shared_library_artifact(artifact): + if _matches([".so", ".dylib", ".dll", ".pyd", ".ifso", ".tbd", ".lib", ".dll.a"], artifact.basename) or cc_helper.is_valid_shared_library_artifact(artifact): library_to_link = cc_common.create_library_to_link( actions = ctx.actions, feature_configuration = feature_configuration, @@ -461,7 +461,7 @@ def cc_binary_impl(ctx, additional_linkopts, force_linkstatic = False): # the target name. # This is no longer necessary, the toolchain can figure out the correct file extensions. target_name = ctx.label.name - has_legacy_link_shared_name = _is_link_shared(ctx) and (_matches([".so", ".dylib", ".dll"], target_name) or cc_helper.is_valid_shared_library_name(target_name)) + has_legacy_link_shared_name = _is_link_shared(ctx) and (_matches([".so", ".dylib", ".dll", ".pyd"], target_name) or cc_helper.is_valid_shared_library_name(target_name)) binary = None is_dbg_build = (cc_toolchain._cpp_configuration.compilation_mode() == "dbg") if has_legacy_link_shared_name: diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl index f286b7f2d07da2..e99cafff891f69 100644 --- a/src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl @@ -128,8 +128,9 @@ def _libraries_from_linking_context(linking_context): # string.endswith() checks) def _is_valid_shared_library_name(shared_library_name): if (shared_library_name.endswith(".so") or - shared_library_name.endswith(".dll") or shared_library_name.endswith(".dylib") or + shared_library_name.endswith(".dll") or + shared_library_name.endswith(".pyd") or shared_library_name.endswith(".wasm")): return True @@ -549,7 +550,7 @@ def _get_toolchain_global_make_variables(cc_toolchain): result["CROSSTOOLTOP"] = cc_toolchain._crosstool_top_path return result -_SHARED_LIBRARY_EXTENSIONS = ["so", "dll", "dylib", "wasm"] +_SHARED_LIBRARY_EXTENSIONS = ["so", "dylib", "dll", "pyd", "wasm"] def _is_valid_shared_library_artifact(shared_library): if (shared_library.extension in _SHARED_LIBRARY_EXTENSIONS): diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_helper_internal.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_helper_internal.bzl index eb0baedeb08c42..550809940c0b1f 100644 --- a/src/main/starlark/builtins_bzl/common/cc/cc_helper_internal.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_helper_internal.bzl @@ -101,7 +101,7 @@ _ARCHIVE = [".a", ".lib"] _PIC_ARCHIVE = [".pic.a"] _ALWAYSLINK_LIBRARY = [".lo"] _ALWAYSLINK_PIC_LIBRARY = [".pic.lo"] -_SHARED_LIBRARY = [".so", ".dylib", ".dll", ".wasm"] +_SHARED_LIBRARY = [".so", ".dylib", ".dll", ".pyd", ".wasm"] _INTERFACE_SHARED_LIBRARY = [".ifso", ".tbd", ".lib", ".dll.a"] _OBJECT_FILE = [".o", ".obj"] _PIC_OBJECT_FILE = [".pic.o"] @@ -175,7 +175,7 @@ _ArtifactCategoryInfo, _unused_new_aci = provider( _artifact_categories = [ _ArtifactCategoryInfo("STATIC_LIBRARY", "lib", ".a", ".lib"), _ArtifactCategoryInfo("ALWAYSLINK_STATIC_LIBRARY", "lib", ".lo", ".lo.lib"), - _ArtifactCategoryInfo("DYNAMIC_LIBRARY", "lib", ".so", ".dylib", ".dll", ".wasm"), + _ArtifactCategoryInfo("DYNAMIC_LIBRARY", "lib", ".so", ".dylib", ".dll", ".pyd", ".wasm"), _ArtifactCategoryInfo("EXECUTABLE", "", "", ".exe", ".wasm"), _ArtifactCategoryInfo("INTERFACE_LIBRARY", "lib", ".ifso", ".tbd", ".if.lib", ".lib"), _ArtifactCategoryInfo("PIC_FILE", "", ".pic"), diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_import.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_import.bzl index 51d31ff9c45f82..ca35c41a43bdea 100644 --- a/src/main/starlark/builtins_bzl/common/cc/cc_import.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_import.bzl @@ -42,7 +42,7 @@ def _perform_error_checks( if (shared_library_artifact != None and not cc_helper.is_valid_shared_library_artifact(shared_library_artifact)): - fail("'shared_library' does not produce any cc_import shared_library files (expected .so, .dylib or .dll)") + fail("'shared_library' does not produce any cc_import shared_library files (expected .so, .dylib, .dll or .pyd)") def _create_archive_action( ctx, @@ -339,8 +339,9 @@ A single precompiled shared library. Bazel ensures it is available to the binary that depends on it during runtime.

Permitted file types: .so, + .dylib, .dll - or .dylib + or .pyd

"""), "interface_library": attr.label( allow_single_file = [".ifso", ".tbd", ".lib", ".so", ".dylib"], diff --git a/src/main/starlark/builtins_bzl/common/cc/link/create_libraries_to_link_values.bzl b/src/main/starlark/builtins_bzl/common/cc/link/create_libraries_to_link_values.bzl index 5e725f3ec38f46..cce55b5d8fa603 100644 --- a/src/main/starlark/builtins_bzl/common/cc/link/create_libraries_to_link_values.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/link/create_libraries_to_link_values.bzl @@ -286,11 +286,12 @@ def _add_dynamic_library_to_link( # -l:libfoo.so.1 -> libfoo.so.1 has_compatible_name = ( name.startswith("lib") or - (not name.endswith(".so") and not name.endswith(".dylib") and not name.endswith(".dll")) + (not name.endswith(".so") and not name.endswith(".dylib") and + not name.endswith(".dll") and not name.endswith(".pyd")) ) if shared_library and has_compatible_name: lib_name = name.removeprefix("lib").removesuffix(".so").removesuffix(".dylib") \ - .removesuffix(".dll") + .removesuffix(".dll").removesuffix(".pyd") libraries_to_link_values.append( _NamedLibraryInfo( type = _TYPE.DYNAMIC_LIBRARY, diff --git a/third_party/BUILD b/third_party/BUILD index e1c89e563aa47f..c962972a6bde40 100644 --- a/third_party/BUILD +++ b/third_party/BUILD @@ -512,15 +512,15 @@ alias( UNNECESSARY_DYNAMIC_LIBRARIES = select({ "//src/conditions:windows": "*.so *.jnilib", - "//src/conditions:darwin": "*.so *.dll", - "//src/conditions:linux_x86_64": "*.jnilib *.dll", - "//src/conditions:linux_s390x": "*.jnilib *.dll", + "//src/conditions:darwin": "*.so *.dll *.pyd", + "//src/conditions:linux_x86_64": "*.jnilib *.dll *.pyd", + "//src/conditions:linux_s390x": "*.jnilib *.dll *.pyd", # The .so file is an x86/s390x one, so we can just remove it if the CPU is not x86/s390x - "//src/conditions:arm": "*.so *.jnilib *.dll", - "//src/conditions:linux_aarch64": "*.so *.jnilib *.dll", - "//src/conditions:linux_ppc": "*.so *.jnilib *.dll", - "//src/conditions:freebsd": "*.so *.jnilib *.dll", - "//src/conditions:openbsd": "*.so *.jnilib *.dll", + "//src/conditions:arm": "*.so *.jnilib *.dll *.pyd", + "//src/conditions:linux_aarch64": "*.so *.jnilib *.dll *.pyd", + "//src/conditions:linux_ppc": "*.so *.jnilib *.dll *.pyd", + "//src/conditions:freebsd": "*.so *.jnilib *.dll *.pyd", + "//src/conditions:openbsd": "*.so *.jnilib *.dll *.pyd", # Default is to play it safe -- better have a big binary than a slow binary # The empty string means nothing is to be removed from the library; # the rule command tests for the empty string explictly to avoid