Skip to content

Commit eedeff0

Browse files
vam-googlecopybara-github
authored andcommitted
Fix windows-specific issues for pywrap rules
PiperOrigin-RevId: 694978320
1 parent ba68d05 commit eedeff0

File tree

8 files changed

+39
-9
lines changed

8 files changed

+39
-9
lines changed

.bazelrc

+7-1
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ build:windows --host_copt=-D_ENABLE_EXTENDED_ALIGNED_STORAGE
370370
# runfiles symlink tree to decide what to put into the Python wheel.
371371
startup --windows_enable_symlinks
372372
build:windows --enable_runfiles
373+
build:windows --nobuild_python_zip
374+
build:windows --dynamic_mode=off
373375

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

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

455458
# Same config as above but for XLA, which has different toolchain paths
456459
build:win_clang_xla --copt=/clang:-Weverything
460+
build:win_clang_xla --host_copt=/clang:-Weverything
457461
build:win_clang_xla --extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl
458462
build:win_clang_xla --extra_execution_platforms=//tools/toolchains/win:x64_windows-clang-cl
459463
build:win_clang_xla --host_platform=//tools/toolchains/win:x64_windows-clang-cl
@@ -811,10 +815,12 @@ build:macos_x86_pycpp_test --config=macos_x86_pycpp_test_filters -- //tensorflow
811815
build:cross_compile_macos_x86_pycpp_test --config=macos_x86_pycpp_test
812816
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
813817
# WINDOWS X86-64 CPU PYCPP
818+
build:windows_x86_cpu_pycpp_test_build_opts --copt=/d2ReducedOptimizeHugeFunctions --host_copt=/d2ReducedOptimizeHugeFunctions --dynamic_mode=off
819+
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
814820
test:windows_x86_cpu_pycpp_test_filters --test_tag_filters=-no_windows,-windows_excluded,-no_oss,-oss_excluded,-gpu,-tpu,-benchmark-test
815821
test:windows_x86_cpu_pycpp_test_filters --build_tag_filters=-no_windows,-windows_excluded,-no_oss,-oss_excluded,-benchmark-test
816822
test:windows_x86_cpu_pycpp_test_filters --test_lang_filters=cc,py --test_size_filters=small,medium --test_timeout="300,450,1200,3600"
817-
test:windows_x86_cpu_pycpp_test_opts --copt=/d2ReducedOptimizeHugeFunctions --host_copt=/d2ReducedOptimizeHugeFunctions --dynamic_mode=off --build_tests_only
823+
test:windows_x86_cpu_pycpp_test_opts --config=windows_x86_cpu_pycpp_test_build_opts --build_tests_only
818824
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/...
819825

820826
# END TF TEST SUITE OPTIONS

third_party/absl/build_dll.patch

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Index: absl/copts/GENERATED_copts.bzl
2+
<+>UTF-8
3+
===================================================================
4+
diff --git a/absl/copts/GENERATED_copts.bzl b/absl/copts/GENERATED_copts.bzl
5+
--- a/absl/copts/GENERATED_copts.bzl (revision fb3621f4f897824c0dbe0615fa94543df6192f30)
6+
+++ b/absl/copts/GENERATED_copts.bzl (date 1729733688013)
7+
@@ -11,6 +11,7 @@
8+
"/D_CRT_SECURE_NO_WARNINGS",
9+
"/D_SCL_SECURE_NO_WARNINGS",
10+
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE",
11+
+ "/DABSL_BUILD_DLL",
12+
]
13+
14+
ABSL_CLANG_CL_TEST_FLAGS = [

third_party/absl/workspace.bzl

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,8 @@ def repo():
4444
system_link_files = SYS_LINKS,
4545
strip_prefix = "abseil-cpp-{commit}".format(commit = ABSL_COMMIT),
4646
urls = tf_mirror_urls("https://github.com/abseil/abseil-cpp/archive/{commit}.tar.gz".format(commit = ABSL_COMMIT)),
47-
patch_file = ["//third_party/absl:nvidia_jetson.patch"],
47+
patch_file = [
48+
"//third_party/absl:nvidia_jetson.patch",
49+
"//third_party/absl:build_dll.patch",
50+
],
4851
)

third_party/llvm/toolchains.patch

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
12
diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
23
index 38970d9929b9..2690c97aa3e0 100644
34
--- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
45
+++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
56
@@ -34,6 +34,36 @@ exports_files([
6-
"utils/lit/lit.py",
7+
"utils/lldbDataFormatters.py",
78
])
89

910
+config_setting(

third_party/llvm/workspace.bzl

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def repo(name):
2323
"//third_party/llvm:toolchains.patch",
2424
"//third_party/llvm:zstd.patch",
2525
"//third_party/llvm:rocdl_shuffle_down.patch",
26-
"//third_party/llvm:intrinsic_memcpy.patch",
2726
],
2827
link_files = {"//third_party/llvm:run_lit.sh": "mlir/run_lit.sh"},
2928
)

third_party/py/rules_pywrap/pywrap.impl.bzl

+2-3
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def pywrap_library(
108108
testonly,
109109
compatible_with,
110110
py_cc_win_def_file,
111-
["PROTOBUF_USE_DLLS"],
111+
None,
112112
)
113113

114114
common_deps = extra_deps + [
@@ -158,7 +158,6 @@ def pywrap_library(
158158
win_def_file = ":%s" % win_def_name,
159159
testonly = testonly,
160160
compatible_with = compatible_with,
161-
local_defines = ["PROTOBUF_USE_DLLS"],
162161
)
163162
shared_objects.append(":%s" % shared_object_name)
164163

@@ -465,7 +464,7 @@ def pybind_extension(
465464
visibility = visibility,
466465
testonly = testonly,
467466
compatible_with = compatible_with,
468-
local_defines = ["PROTOBUF_USE_DLLS"],
467+
local_defines = ["PROTOBUF_USE_DLLS", "ABSL_CONSUME_DLL"],
469468
**kwargs
470469
)
471470

tsl/platform/default/build_config.bzl

+6-2
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,8 @@ def tf_proto_library_cc(
461461
create_service = False,
462462
create_java_proto = False,
463463
create_kotlin_proto = False,
464-
make_default_target_header_only = False):
464+
make_default_target_header_only = False,
465+
local_defines = None):
465466
js_codegen = js_codegen # unused argument
466467
native.filegroup(
467468
name = name + "_proto_srcs",
@@ -548,6 +549,7 @@ def tf_proto_library_cc(
548549
visibility = visibility,
549550
deps = cc_deps,
550551
protolib_deps = protolib_deps,
552+
local_defines = local_defines,
551553
)
552554

553555
def tf_proto_library_py(
@@ -612,7 +614,8 @@ def tf_proto_library(
612614
create_grpc_library = False,
613615
make_default_target_header_only = False,
614616
exports = [],
615-
tags = []):
617+
tags = [],
618+
local_defines = None):
616619
"""Make a proto library, possibly depending on other proto libraries."""
617620

618621
# TODO(b/145545130): Add docstring explaining what rules this creates and how
@@ -651,6 +654,7 @@ def tf_proto_library(
651654
make_default_target_header_only = make_default_target_header_only,
652655
protodeps = protodeps,
653656
visibility = visibility,
657+
local_defines = local_defines,
654658
)
655659

656660
if create_grpc_library:

tsl/profiler/protobuf/BUILD

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ package_group(
1515
tf_proto_library(
1616
name = "xplane_proto",
1717
srcs = ["xplane.proto"],
18+
local_defines = [
19+
"PROTOBUF_USE_DLLS",
20+
"LIBPROTOBUF_EXPORTS",
21+
],
1822
make_default_target_header_only = True,
1923
visibility = internal_visibility([":friends"]),
2024
)

0 commit comments

Comments
 (0)