From 1dc5772b08adc34cc5e830e243f8884cdc5bac72 Mon Sep 17 00:00:00 2001 From: Loo Rong Jie Date: Wed, 4 Jul 2018 08:07:59 +0800 Subject: [PATCH] [Bazel/MSVC] Cleanup -ldl/-lm flags for MSVC --- tensorflow/core/BUILD | 8 +++----- third_party/double_conversion.BUILD | 16 ++++++++++------ third_party/fft2d/fft2d.BUILD | 10 +++++++++- third_party/flatbuffers/flatbuffers.BUILD | 12 ++++++++---- third_party/snappy.BUILD | 13 +++---------- 5 files changed, 33 insertions(+), 26 deletions(-) diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD index dbe87a6dbbb..1cd2830efbb 100644 --- a/tensorflow/core/BUILD +++ b/tensorflow/core/BUILD @@ -2477,13 +2477,11 @@ tf_cuda_library( hdrs = FRAMEWORK_INTERNAL_PUBLIC_HEADERS, copts = tf_copts(), linkopts = select({ - "//tensorflow:freebsd": [], + "//tensorflow:freebsd": ["-lm"], "//tensorflow:windows": [], "//tensorflow:windows_msvc": [], - "//conditions:default": ["-ldl"], - }) + [ - "-lm", - ], + "//conditions:default": ["-ldl", "-lm"], + }), deps = [ ":lib", ":lib_internal", diff --git a/third_party/double_conversion.BUILD b/third_party/double_conversion.BUILD index 9f905216c03..d875a1a2b5c 100644 --- a/third_party/double_conversion.BUILD +++ b/third_party/double_conversion.BUILD @@ -4,6 +4,11 @@ licenses(["notice"]) exports_files(["LICENSE"]) +config_setting( + name = "windows", + values = {"cpu": "x64_windows"}, +) + cc_library( name = "double-conversion", srcs = [ @@ -28,11 +33,10 @@ cc_library( "double-conversion/ieee.h", "double-conversion/strtod.h", ], - includes = [ - ".", - ], - linkopts = [ - "-lm", - ], + includes = ["."], + linkopts = select({ + ":windows": [], + "//conditions:default": ["-lm"], + }), visibility = ["//visibility:public"], ) diff --git a/third_party/fft2d/fft2d.BUILD b/third_party/fft2d/fft2d.BUILD index 3dbd36aec04..74dd3112fce 100644 --- a/third_party/fft2d/fft2d.BUILD +++ b/third_party/fft2d/fft2d.BUILD @@ -14,6 +14,11 @@ FFT2D_SRCS = [ "fft/fftsg.c", ] +config_setting( + name = "windows", + values = {"cpu": "x64_windows"}, +) + # This is the main 2D FFT library. The 2D FFTs in this library call # 1D FFTs. In addition, fast DCTs are provided for the special case # of 8x8 and 16x16. This code in this library is referred to as @@ -21,7 +26,10 @@ FFT2D_SRCS = [ cc_library( name = "fft2d", srcs = FFT2D_SRCS, - linkopts = ["-lm"], + linkopts = select({ + ":windows": [], + "//conditions:default": ["-lm"], + }), ) objc_library( diff --git a/third_party/flatbuffers/flatbuffers.BUILD b/third_party/flatbuffers/flatbuffers.BUILD index 639dff2cd01..3a19d28667a 100644 --- a/third_party/flatbuffers/flatbuffers.BUILD +++ b/third_party/flatbuffers/flatbuffers.BUILD @@ -12,12 +12,15 @@ config_setting( visibility = ["//visibility:public"], ) -FLATBUFFERS_COPTS = [ - "-fexceptions", -] + select({ +config_setting( + name = "windows", + values = {"cpu": "x64_windows"}, +) + +FLATBUFFERS_COPTS = select({ "@bazel_tools//src:windows": [], "@bazel_tools//src:windows_msvc": [], - "//conditions:default": ["-Wno-implicit-fallthrough"], + "//conditions:default": ["-Wno-implicit-fallthrough", "-fexceptions"], }) # Public flatc library to compile flatbuffer files at runtime. @@ -121,6 +124,7 @@ cc_binary( ":freebsd": [ "-lm", ], + ":windows": [], "//conditions:default": [ "-lm", "-ldl", diff --git a/third_party/snappy.BUILD b/third_party/snappy.BUILD index cc11f52d0eb..58120ccdf2d 100644 --- a/third_party/snappy.BUILD +++ b/third_party/snappy.BUILD @@ -18,17 +18,10 @@ cc_library( "snappy-stubs-public.h", ], hdrs = ["snappy.h"], - copts = select({ - "@org_tensorflow//tensorflow:windows": [ - "/DHAVE_CONFIG_H", - "/EHsc", - ], - "@org_tensorflow//tensorflow:windows_msvc": [ - "/DHAVE_CONFIG_H", - "/EHsc", - ], + copts = ["-DHAVE_CONFIG_H"] + select({ + "@org_tensorflow//tensorflow:windows": [], + "@org_tensorflow//tensorflow:windows_msvc": [], "//conditions:default": [ - "-DHAVE_CONFIG_H", "-fno-exceptions", "-Wno-sign-compare", "-Wno-shift-negative-value",