Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/cpp/blaze_util_windows.cc
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,8 @@ std::unique_ptr<blaze_util::Path> 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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
4 changes: 2 additions & 2 deletions src/main/starlark/builtins_bzl/common/cc/cc_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions src/main/starlark/builtins_bzl/common/cc/cc_helper.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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"),
Expand Down
5 changes: 3 additions & 2 deletions src/main/starlark/builtins_bzl/common/cc/cc_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -339,8 +339,9 @@ A single precompiled shared library. Bazel ensures it is available to the
binary that depends on it during runtime.
<p> Permitted file types:
<code>.so</code>,
<code>.dylib</code>,
<code>.dll</code>
or <code>.dylib</code>
or <code>.pyd</code>
</p>"""),
"interface_library": attr.label(
allow_single_file = [".ifso", ".tbd", ".lib", ".so", ".dylib"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions third_party/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading