diff options
author | Yun Peng <pcloudy@google.com> | 2017-06-08 08:43:21 +0200 |
---|---|---|
committer | gunan <gunan@google.com> | 2017-06-07 23:43:21 -0700 |
commit | 08ed32dbb9e8f67eec9efce3807b5bdb3933eb2f (patch) | |
tree | 05546977d3132976761935abe3e435d5ed3f88a0 /third_party | |
parent | 02dbe153afe2c7f418fcf9044e2e3a8795a21d3a (diff) |
Windows: Make TensorFlow build without --cpu=x64_windows_msvc (#10466)
* Windows: Make TensorFlow build without --cpu=x64_windows_msvc
Since from Bazel 0.5.0, MSVC toolchain became the default toolchain on
Windows. So --cpu=x64_windows_msvc is not required as long as we adjust
the BUILD files in TensorFlow.
--cpu=x64_windows_msvc is also supported for now, but is depracated.
The configuration for cpu value x64_windows_msvc is a duplicate of
x64_windows, which should be removed in the future.
* Fix breakage on macOS
Diffstat (limited to 'third_party')
-rw-r--r-- | third_party/curl.BUILD | 65 | ||||
-rw-r--r-- | third_party/farmhash.BUILD | 10 | ||||
-rw-r--r-- | third_party/gif.BUILD | 12 | ||||
-rw-r--r-- | third_party/jpeg/jpeg.BUILD | 20 | ||||
-rw-r--r-- | third_party/nasm.BUILD | 13 | ||||
-rw-r--r-- | third_party/snappy.BUILD | 1 | ||||
-rw-r--r-- | third_party/swig.BUILD | 10 |
7 files changed, 97 insertions, 34 deletions
diff --git a/third_party/curl.BUILD b/third_party/curl.BUILD index 43f6599acc..882967df1c 100644 --- a/third_party/curl.BUILD +++ b/third_party/curl.BUILD @@ -5,6 +5,26 @@ licenses(["notice"]) # MIT/X derivative license exports_files(["COPYING"]) +CURL_WIN_COPTS = [ + "/I%prefix%/curl/lib", + "/DHAVE_CONFIG_H", + "/DCURL_DISABLE_FTP", + "/DCURL_DISABLE_NTLM", + "/DHAVE_LIBZ", + "/DHAVE_ZLIB_H", + # Defining _USING_V110_SDK71_ is hackery to defeat curl's incorrect + # detection of what OS releases we can build on with VC 2012. This + # may not be needed (or may have to change) if the WINVER setting + # changes in //third_party/msvc/vc_12_0/CROSSTOOL. + "/D_USING_V110_SDK71_", +] + +CURL_WIN_SRCS = [ + "lib/asyn-thread.c", + "lib/inet_ntop.c", + "lib/system_win32.c", +] + cc_library( name = "curl", srcs = [ @@ -210,11 +230,8 @@ cc_library( "@%ws%//tensorflow:ios": [ "lib/vtls/darwinssl.c", ], - "@%ws%//tensorflow:windows": [ - "lib/asyn-thread.c", - "lib/inet_ntop.c", - "lib/system_win32.c", - ], + "@%ws%//tensorflow:windows": CURL_WIN_SRCS, + "@%ws%//tensorflow:windows_msvc": CURL_WIN_SRCS, "//conditions:default": [ "lib/vtls/openssl.c", ], @@ -231,19 +248,8 @@ cc_library( "include/curl/typecheck-gcc.h", ], copts = select({ - "@%ws%//tensorflow:windows": [ - "/I%prefix%/curl/lib", - "/DHAVE_CONFIG_H", - "/DCURL_DISABLE_FTP", - "/DCURL_DISABLE_NTLM", - "/DHAVE_LIBZ", - "/DHAVE_ZLIB_H", - # Defining _USING_V110_SDK71_ is hackery to defeat curl's incorrect - # detection of what OS releases we can build on with VC 2012. This - # may not be needed (or may have to change) if the WINVER setting - # changes in //third_party/msvc/vc_12_0/CROSSTOOL. - "/D_USING_V110_SDK71_", - ], + "@%ws%//tensorflow:windows": CURL_WIN_COPTS, + "@%ws%//tensorflow:windows_msvc": CURL_WIN_COPTS, "//conditions:default": [ "-I%prefix%/curl/lib", "-D_GNU_SOURCE", @@ -262,6 +268,10 @@ cc_library( # See curl.h for discussion of write size and Windows "/DCURL_MAX_WRITE_SIZE=16384", ], + "@%ws%//tensorflow:windows_msvc": [ + # See curl.h for discussion of write size and Windows + "/DCURL_MAX_WRITE_SIZE=16384", + ], "//conditions:default": [ "-DCURL_MAX_WRITE_SIZE=65536", ], @@ -279,7 +289,10 @@ cc_library( ], "@%ws%//tensorflow:ios": [], "@%ws%//tensorflow:windows": [ - "ws2_32.lib", + "-Wl,ws2_32.lib", + ], + "@%ws%//tensorflow:windows_msvc": [ + "-Wl,ws2_32.lib", ], "//conditions:default": [ "-lrt", @@ -291,12 +304,19 @@ cc_library( ] + select({ "@%ws%//tensorflow:ios": [], "@%ws%//tensorflow:windows": [], + "@%ws%//tensorflow:windows_msvc": [], "//conditions:default": [ "@boringssl//:ssl", ], }), ) +CURL_BIN_WIN_COPTS = [ + "/I%prefix%/curl/lib", + "/DHAVE_CONFIG_H", + "/DCURL_DISABLE_LIBCURL_OPTION", +] + cc_binary( name = "curl_bin", srcs = [ @@ -386,11 +406,8 @@ cc_binary( "src/tool_xattr.h", ], copts = select({ - "@%ws%//tensorflow:windows": [ - "/I%prefix%/curl/lib", - "/DHAVE_CONFIG_H", - "/DCURL_DISABLE_LIBCURL_OPTION", - ], + "@%ws%//tensorflow:windows": CURL_BIN_WIN_COPTS, + "@%ws%//tensorflow:windows_msvc": CURL_BIN_WIN_COPTS, "//conditions:default": [ "-I%prefix%/curl/lib", "-D_GNU_SOURCE", diff --git a/third_party/farmhash.BUILD b/third_party/farmhash.BUILD index 6a1d4da6e5..a51e1511c1 100644 --- a/third_party/farmhash.BUILD +++ b/third_party/farmhash.BUILD @@ -3,12 +3,19 @@ licenses(["notice"]) # MIT exports_files(["COPYING"]) config_setting( - name = "windows", + name = "windows_msvc", values = { "cpu": "x64_windows_msvc", }, ) +config_setting( + name = "windows", + values = { + "cpu": "x64_windows", + }, +) + cc_library( name = "farmhash", srcs = ["src/farmhash.cc"], @@ -16,6 +23,7 @@ cc_library( # Disable __builtin_expect support on Windows copts = select({ ":windows": ["/DFARMHASH_OPTIONAL_BUILTIN_EXPECT"], + ":windows_msvc": ["/DFARMHASH_OPTIONAL_BUILTIN_EXPECT"], "//conditions:default": [], }), includes = ["src/."], diff --git a/third_party/gif.BUILD b/third_party/gif.BUILD index fec7449130..ad6821af3c 100644 --- a/third_party/gif.BUILD +++ b/third_party/gif.BUILD @@ -24,6 +24,7 @@ cc_library( visibility = ["//visibility:public"], deps = select({ ":windows": [":windows_polyfill"], + ":windows_msvc": [":windows_polyfill"], "//conditions:default": [], }), ) @@ -41,6 +42,15 @@ genrule( ) config_setting( + name = "windows_msvc", + values = { + "cpu": "x64_windows_msvc", + }, +) + +config_setting( name = "windows", - values = {"cpu": "x64_windows_msvc"}, + values = { + "cpu": "x64_windows", + }, ) diff --git a/third_party/jpeg/jpeg.BUILD b/third_party/jpeg/jpeg.BUILD index 78e03eadcf..f6078052ec 100644 --- a/third_party/jpeg/jpeg.BUILD +++ b/third_party/jpeg/jpeg.BUILD @@ -9,17 +9,20 @@ load("@%ws%//third_party:common.bzl", "template_rule") libjpegturbo_nocopts = "-[W]error" +WIN_COPTS = [ + "/Ox", + "/w14711", # function 'function' selected for inline expansion + "/w14710", # 'function' : function not inlined +] + libjpegturbo_copts = select({ ":android": [ "-O2", "-fPIE", "-w", ], - ":windows": [ - "/Ox", - "/w14711", # function 'function' selected for inline expansion - "/w14710", # 'function' : function not inlined - ], + ":windows": WIN_COPTS, + ":windows_msvc": WIN_COPTS, "//conditions:default": [ "-O3", "-w", @@ -370,6 +373,7 @@ genrule( outs = ["jconfig.h"], cmd = select({ ":windows": "cp $(location jconfig_win.h) $@", + ":windows_msvc": "cp $(location jconfig_win.h) $@", ":k8": "cp $(location jconfig_nowin_simd.h) $@", ":armeabi-v7a": "cp $(location jconfig_nowin_simd.h) $@", ":arm64-v8a": "cp $(location jconfig_nowin_simd.h) $@", @@ -386,6 +390,7 @@ genrule( outs = ["jconfigint.h"], cmd = select({ ":windows": "cp $(location jconfigint_win.h) $@", + ":windows_msvc": "cp $(location jconfigint_win.h) $@", "//conditions:default": "cp $(location jconfigint_nowin.h) $@", }), ) @@ -482,5 +487,10 @@ config_setting( config_setting( name = "windows", + values = {"cpu": "x64_windows"}, +) + +config_setting( + name = "windows_msvc", values = {"cpu": "x64_windows_msvc"}, ) diff --git a/third_party/nasm.BUILD b/third_party/nasm.BUILD index b3cf17a97e..341d58068b 100644 --- a/third_party/nasm.BUILD +++ b/third_party/nasm.BUILD @@ -101,6 +101,7 @@ cc_binary( ], copts = select({ ":windows": [], + ":windows_msvc": [], "//conditions:default": [ "-w", "-std=c99", @@ -108,12 +109,22 @@ cc_binary( }), defines = select({ ":windows": [], + ":windows_msvc": [], "//conditions:default": ["HAVE_SNPRINTF"], }), visibility = ["@jpeg//:__pkg__"], ) config_setting( + name = "windows_msvc", + values = { + "cpu": "x64_windows_msvc", + }, +) + +config_setting( name = "windows", - values = {"cpu": "x64_windows_msvc"}, + values = { + "cpu": "x64_windows", + }, ) diff --git a/third_party/snappy.BUILD b/third_party/snappy.BUILD index 37eebe291e..120028dc52 100644 --- a/third_party/snappy.BUILD +++ b/third_party/snappy.BUILD @@ -35,6 +35,7 @@ genrule( "-e 's/@ac_cv_have_stdint_h@/1/g' " + select({ "@%ws%//tensorflow:windows": "-e 's/@ac_cv_have_sys_uio_h@/0/g' ", + "@%ws%//tensorflow:windows_msvc": "-e 's/@ac_cv_have_sys_uio_h@/0/g' ", "//conditions:default": "-e 's/@ac_cv_have_sys_uio_h@/1/g' ", }) + "-e 's/@SNAPPY_MAJOR@/1/g' " + diff --git a/third_party/swig.BUILD b/third_party/swig.BUILD index bea5d6b531..d698fa934b 100644 --- a/third_party/swig.BUILD +++ b/third_party/swig.BUILD @@ -70,7 +70,8 @@ cc_binary( "Source/Swig/wrapfunc.c", ], copts = ["$(STACK_FRAME_UNLIMITED)"] + select({ - ":x64_windows_msvc": [], + ":windows": [], + ":windows_msvc": [], "//conditions:default": [ "-Wno-parentheses", "-Wno-unused-variable", @@ -331,6 +332,11 @@ genrule( ) config_setting( - name = "x64_windows_msvc", + name = "windows_msvc", values = {"cpu": "x64_windows_msvc"}, ) + +config_setting( + name = "windows", + values = {"cpu": "x64_windows"}, +) |