From e72495d380853fa2c7432bc4b04d861294091eb2 Mon Sep 17 00:00:00 2001 From: Gunhan Gulsoy Date: Sun, 12 Jan 2020 11:43:00 -0800 Subject: [PATCH] Move all linking information to BUILD files. do not use windows specific "pragma comment". Just be consistent. PiperOrigin-RevId: 289338931 Change-Id: Ib5a3d479a7fd0863eeff6bb60933aeb83c26dc01 --- tensorflow/core/debug/BUILD | 2 ++ tensorflow/core/debug/debug_io_utils.cc | 2 -- tensorflow/core/platform/windows/BUILD | 2 ++ tensorflow/core/platform/windows/net.cc | 2 -- tensorflow/stream_executor/lib/BUILD | 3 ++- tensorflow/stream_executor/lib/process_state.cc | 1 - 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tensorflow/core/debug/BUILD b/tensorflow/core/debug/BUILD index 8c7e8c73f61..4cf8bc3588e 100644 --- a/tensorflow/core/debug/BUILD +++ b/tensorflow/core/debug/BUILD @@ -15,6 +15,7 @@ load( "//tensorflow:tensorflow.bzl", "check_deps", + "if_windows", "tf_cc_binary", "tf_cc_test", "tf_copts", @@ -115,6 +116,7 @@ tf_cuda_library( srcs = ["debug_io_utils.cc"], hdrs = ["debug_io_utils.h"], copts = tf_copts(), + linkopts = if_windows(["-DEFAULTLIB:ws2_32.lib"]), linkstatic = 1, deps = [ ":debug_callback_registry", diff --git a/tensorflow/core/debug/debug_io_utils.cc b/tensorflow/core/debug/debug_io_utils.cc index 8e6042116b5..643dde7ad8c 100644 --- a/tensorflow/core/debug/debug_io_utils.cc +++ b/tensorflow/core/debug/debug_io_utils.cc @@ -27,8 +27,6 @@ limitations under the License. #ifndef PLATFORM_WINDOWS #include "grpcpp/create_channel.h" #else -// winsock2.h is used in grpc, so Ws2_32.lib is needed -#pragma comment(lib, "Ws2_32.lib") #endif // #ifndef PLATFORM_WINDOWS #include "absl/strings/ascii.h" diff --git a/tensorflow/core/platform/windows/BUILD b/tensorflow/core/platform/windows/BUILD index 397217ca365..f3a995bcff6 100644 --- a/tensorflow/core/platform/windows/BUILD +++ b/tensorflow/core/platform/windows/BUILD @@ -1,6 +1,7 @@ # Tensorflow windows-specific implementations of tensorflow/core/platform libraries. load( "//tensorflow:tensorflow.bzl", + "if_windows", "tf_copts", ) @@ -111,6 +112,7 @@ cc_library( name = "net", srcs = ["net.cc"], hdrs = ["//tensorflow/core/platform:net.h"], + linkopts = if_windows(["-DEFAULTLIB:ws2_32.lib"]), tags = [ "manual", "no_oss", diff --git a/tensorflow/core/platform/windows/net.cc b/tensorflow/core/platform/windows/net.cc index 787085086db..3a407bedd0c 100644 --- a/tensorflow/core/platform/windows/net.cc +++ b/tensorflow/core/platform/windows/net.cc @@ -26,8 +26,6 @@ limitations under the License. #undef ERROR -#pragma comment(lib, "Ws2_32.lib") - namespace tensorflow { namespace internal { diff --git a/tensorflow/stream_executor/lib/BUILD b/tensorflow/stream_executor/lib/BUILD index e1c2a72577b..76fe0ed94e3 100644 --- a/tensorflow/stream_executor/lib/BUILD +++ b/tensorflow/stream_executor/lib/BUILD @@ -1,4 +1,4 @@ -load("//tensorflow:tensorflow.bzl", "tf_cc_test") +load("//tensorflow:tensorflow.bzl", "if_windows", "tf_cc_test") load("//tensorflow/stream_executor:build_defs.bzl", "stream_executor_friends") package( @@ -30,6 +30,7 @@ cc_library( ], ), hdrs = glob(["**/*.h"]), + linkopts = if_windows(["-DEFAULTLIB:ws2_32.lib"]), deps = [ "//tensorflow/core:lib", "//tensorflow/core:protos_all_cc", diff --git a/tensorflow/stream_executor/lib/process_state.cc b/tensorflow/stream_executor/lib/process_state.cc index 1b85a7628ea..5a351e7a8d5 100644 --- a/tensorflow/stream_executor/lib/process_state.cc +++ b/tensorflow/stream_executor/lib/process_state.cc @@ -19,7 +19,6 @@ limitations under the License. #include #include #include -#pragma comment(lib, "Ws2_32.lib") #else #include #include