Skip to content

Commit

Permalink
Fix windows-specific issues for pywrap rules
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 694978320
  • Loading branch information
vam-google authored and copybara-github committed Nov 10, 2024
1 parent ba68d05 commit eedeff0
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 9 deletions.
8 changes: 7 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ build:windows --host_copt=-D_ENABLE_EXTENDED_ALIGNED_STORAGE
# runfiles symlink tree to decide what to put into the Python wheel.
startup --windows_enable_symlinks
build:windows --enable_runfiles
build:windows --nobuild_python_zip
build:windows --dynamic_mode=off

# Default paths for TF_SYSTEM_LIBS
build:linux --define=PREFIX=/usr
Expand Down Expand Up @@ -443,6 +445,7 @@ build:avx_win --copt=/arch:AVX

# Use Clang-cl compiler on Windows
build:win_clang --copt=/clang:-Weverything
build:win_clang --host_copt=/clang:-Weverything
build:win_clang --extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl
build:win_clang --extra_execution_platforms=//tensorflow/tools/toolchains/win:x64_windows-clang-cl
build:win_clang --host_platform=//tensorflow/tools/toolchains/win:x64_windows-clang-cl
Expand All @@ -454,6 +457,7 @@ test:win_clang --host_linkopt=/FORCE:MULTIPLE

# Same config as above but for XLA, which has different toolchain paths
build:win_clang_xla --copt=/clang:-Weverything
build:win_clang_xla --host_copt=/clang:-Weverything
build:win_clang_xla --extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl
build:win_clang_xla --extra_execution_platforms=//tools/toolchains/win:x64_windows-clang-cl
build:win_clang_xla --host_platform=//tools/toolchains/win:x64_windows-clang-cl
Expand Down Expand Up @@ -811,10 +815,12 @@ build:macos_x86_pycpp_test --config=macos_x86_pycpp_test_filters -- //tensorflow
build:cross_compile_macos_x86_pycpp_test --config=macos_x86_pycpp_test
build:cross_compile_macos_x86_pycpp_test -//tensorflow/core/kernels:quantized_conv_ops_test -//tensorflow/core/kernels:quantized_matmul_op_test -//tensorflow/python/ops:quantized_conv_ops_test -//tensorflow/tools/graph_transforms:transforms_test -//tensorflow/python/tools:aot_compiled_test
# WINDOWS X86-64 CPU PYCPP
build:windows_x86_cpu_pycpp_test_build_opts --copt=/d2ReducedOptimizeHugeFunctions --host_copt=/d2ReducedOptimizeHugeFunctions --dynamic_mode=off
build:windows_x86_cpu_pycpp_test_build_opts_debug --config=windows_x86_cpu_pycpp_test_build_opts --linkopt=/demangle:no --host_linkopt=/demangle:no --linkopt=/errorlimit:0 --host_linkopt=/errorlimit:0
test:windows_x86_cpu_pycpp_test_filters --test_tag_filters=-no_windows,-windows_excluded,-no_oss,-oss_excluded,-gpu,-tpu,-benchmark-test
test:windows_x86_cpu_pycpp_test_filters --build_tag_filters=-no_windows,-windows_excluded,-no_oss,-oss_excluded,-benchmark-test
test:windows_x86_cpu_pycpp_test_filters --test_lang_filters=cc,py --test_size_filters=small,medium --test_timeout="300,450,1200,3600"
test:windows_x86_cpu_pycpp_test_opts --copt=/d2ReducedOptimizeHugeFunctions --host_copt=/d2ReducedOptimizeHugeFunctions --dynamic_mode=off --build_tests_only
test:windows_x86_cpu_pycpp_test_opts --config=windows_x86_cpu_pycpp_test_build_opts --build_tests_only
test:windows_x86_cpu_pycpp_test --config=windows_x86_cpu_pycpp_test_opts --config=windows_x86_cpu_pycpp_test_filters -- //tensorflow/... -//tensorflow/java/... -//tensorflow/lite/... -//tensorflow/compiler/...

# END TF TEST SUITE OPTIONS
Expand Down
14 changes: 14 additions & 0 deletions third_party/absl/build_dll.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Index: absl/copts/GENERATED_copts.bzl
<+>UTF-8
===================================================================
diff --git a/absl/copts/GENERATED_copts.bzl b/absl/copts/GENERATED_copts.bzl
--- a/absl/copts/GENERATED_copts.bzl (revision fb3621f4f897824c0dbe0615fa94543df6192f30)
+++ b/absl/copts/GENERATED_copts.bzl (date 1729733688013)
@@ -11,6 +11,7 @@
"/D_CRT_SECURE_NO_WARNINGS",
"/D_SCL_SECURE_NO_WARNINGS",
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE",
+ "/DABSL_BUILD_DLL",
]

ABSL_CLANG_CL_TEST_FLAGS = [
5 changes: 4 additions & 1 deletion third_party/absl/workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,8 @@ def repo():
system_link_files = SYS_LINKS,
strip_prefix = "abseil-cpp-{commit}".format(commit = ABSL_COMMIT),
urls = tf_mirror_urls("https://github.com/abseil/abseil-cpp/archive/{commit}.tar.gz".format(commit = ABSL_COMMIT)),
patch_file = ["//third_party/absl:nvidia_jetson.patch"],
patch_file = [
"//third_party/absl:nvidia_jetson.patch",
"//third_party/absl:build_dll.patch",
],
)
3 changes: 2 additions & 1 deletion third_party/llvm/toolchains.patch
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
index 38970d9929b9..2690c97aa3e0 100644
--- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -34,6 +34,36 @@ exports_files([
"utils/lit/lit.py",
"utils/lldbDataFormatters.py",
])

+config_setting(
Expand Down
1 change: 0 additions & 1 deletion third_party/llvm/workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def repo(name):
"//third_party/llvm:toolchains.patch",
"//third_party/llvm:zstd.patch",
"//third_party/llvm:rocdl_shuffle_down.patch",
"//third_party/llvm:intrinsic_memcpy.patch",
],
link_files = {"//third_party/llvm:run_lit.sh": "mlir/run_lit.sh"},
)
5 changes: 2 additions & 3 deletions third_party/py/rules_pywrap/pywrap.impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def pywrap_library(
testonly,
compatible_with,
py_cc_win_def_file,
["PROTOBUF_USE_DLLS"],
None,
)

common_deps = extra_deps + [
Expand Down Expand Up @@ -158,7 +158,6 @@ def pywrap_library(
win_def_file = ":%s" % win_def_name,
testonly = testonly,
compatible_with = compatible_with,
local_defines = ["PROTOBUF_USE_DLLS"],
)
shared_objects.append(":%s" % shared_object_name)

Expand Down Expand Up @@ -465,7 +464,7 @@ def pybind_extension(
visibility = visibility,
testonly = testonly,
compatible_with = compatible_with,
local_defines = ["PROTOBUF_USE_DLLS"],
local_defines = ["PROTOBUF_USE_DLLS", "ABSL_CONSUME_DLL"],
**kwargs
)

Expand Down
8 changes: 6 additions & 2 deletions tsl/platform/default/build_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ def tf_proto_library_cc(
create_service = False,
create_java_proto = False,
create_kotlin_proto = False,
make_default_target_header_only = False):
make_default_target_header_only = False,
local_defines = None):
js_codegen = js_codegen # unused argument
native.filegroup(
name = name + "_proto_srcs",
Expand Down Expand Up @@ -548,6 +549,7 @@ def tf_proto_library_cc(
visibility = visibility,
deps = cc_deps,
protolib_deps = protolib_deps,
local_defines = local_defines,
)

def tf_proto_library_py(
Expand Down Expand Up @@ -612,7 +614,8 @@ def tf_proto_library(
create_grpc_library = False,
make_default_target_header_only = False,
exports = [],
tags = []):
tags = [],
local_defines = None):
"""Make a proto library, possibly depending on other proto libraries."""

# TODO(b/145545130): Add docstring explaining what rules this creates and how
Expand Down Expand Up @@ -651,6 +654,7 @@ def tf_proto_library(
make_default_target_header_only = make_default_target_header_only,
protodeps = protodeps,
visibility = visibility,
local_defines = local_defines,
)

if create_grpc_library:
Expand Down
4 changes: 4 additions & 0 deletions tsl/profiler/protobuf/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ package_group(
tf_proto_library(
name = "xplane_proto",
srcs = ["xplane.proto"],
local_defines = [
"PROTOBUF_USE_DLLS",
"LIBPROTOBUF_EXPORTS",
],
make_default_target_header_only = True,
visibility = internal_visibility([":friends"]),
)
Expand Down

0 comments on commit eedeff0

Please sign in to comment.