summaryrefslogtreecommitdiff
path: root/science/py-tensorflow/files
diff options
context:
space:
mode:
authorYuri Victorovich <yuri@FreeBSD.org>2019-08-06 15:28:01 +0000
committerYuri Victorovich <yuri@FreeBSD.org>2019-08-06 15:28:01 +0000
commit069ecdaf120f4924be812e6fef29d7dfe605ecee (patch)
tree926d5e1fe25bb955421476bee97c7064e22026fa /science/py-tensorflow/files
parentsysutils/doctl: Update to version 1.26.3 (diff)
Re-add science/py-tensorflow: Computation using data flow graphs for scalable machine learning
Many thanks to Anthony who was highly persistent and skillful in getting the Tensorflow build on FreeBSD! PR: 226400 Submitted by: Anthony <amzo1337@gmail.com>
Diffstat (limited to 'science/py-tensorflow/files')
-rw-r--r--science/py-tensorflow/files/bazelrc17
-rw-r--r--science/py-tensorflow/files/patch-bazelrc11
-rw-r--r--science/py-tensorflow/files/patch-tensorflow_contrib_boosted__trees_build24
-rw-r--r--science/py-tensorflow/files/patch-tensorflow_contrib_ignite_kernels_client_ignite__plain__client__unix.cc13
-rw-r--r--science/py-tensorflow/files/patch-tensorflow_contrib_makefile_makefile49
-rw-r--r--science/py-tensorflow/files/patch-tensorflow_core_BUILD47
-rw-r--r--science/py-tensorflow/files/patch-tensorflow_core_platform_cloud_gcs__dns__cache.cc14
-rw-r--r--science/py-tensorflow/files/patch-tensorflow_core_platform_default_build__config.bzl13
-rw-r--r--science/py-tensorflow/files/patch-tensorflow_core_platform_posix_env.cc31
-rw-r--r--science/py-tensorflow/files/patch-tensorflow_core_proto_autotuning.proto21
-rw-r--r--science/py-tensorflow/files/patch-tensorflow_lite_experimental_micro_tools_make_targets_freebsd__makefile.inc13
-rw-r--r--science/py-tensorflow/files/patch-tensorflow_lite_kernels_internal_build11
-rw-r--r--science/py-tensorflow/files/patch-tensorflow_lite_tools_make_makefile19
-rw-r--r--science/py-tensorflow/files/patch-tensorflow_lite_tools_make_targets_freebsd__makefile.inc19
-rw-r--r--science/py-tensorflow/files/patch-tensorflow_tensorflow.bzl65
-rw-r--r--science/py-tensorflow/files/patch-tensorflow_tools_lib__package_build18
-rw-r--r--science/py-tensorflow/files/patch-tensorflow_tools_pip__package_build10
-rw-r--r--science/py-tensorflow/files/patch-tensorflow_workspace.bzl10
-rw-r--r--science/py-tensorflow/files/patch-third__party_aws_build.bazel13
-rw-r--r--science/py-tensorflow/files/patch-third__party_systemlibs_enum34.build17
-rw-r--r--science/py-tensorflow/files/patch-third__party_systemlibs_grpc.build11
-rw-r--r--science/py-tensorflow/files/patch-third__party_systemlibs_protobuf.bzl11
-rw-r--r--science/py-tensorflow/files/patch-third__party_systemlibs_swig.build11
-rw-r--r--science/py-tensorflow/files/patch-third__party_systemlibs_syslibs__configure.bzl10
-rw-r--r--science/py-tensorflow/files/patch-third_party_gpus_rocm_configure.bzl11
25 files changed, 489 insertions, 0 deletions
diff --git a/science/py-tensorflow/files/bazelrc b/science/py-tensorflow/files/bazelrc
new file mode 100644
index 000000000000..829431f9eb25
--- /dev/null
+++ b/science/py-tensorflow/files/bazelrc
@@ -0,0 +1,17 @@
+startup --batch
+
+build --strip=never
+build --verbose_failures --noshow_loading_progress
+test --verbose_test_summary --verbose_failures --noshow_loading_progress
+
+build --spawn_strategy=local --genrule_strategy=local
+test --spawn_strategy=local --genrule_strategy=local
+
+# make bazel only fetch distfiles from the cache
+fetch --repository_cache="%%BAZEL_DIR%%/bazel-cache/" --distdir="%%BAZEL_DIST%%/bazel-distdir/"
+build --repository_cache="%%BAZEL_DIR%%/bazel-cache/" --distdir="%%BAZEL_DIST%%/bazel-distdir/"
+
+build --define=PREFIX=%%LOCALBASE%%
+build --define=LIBDIR=%%LOCALBASE%%/lib
+
+build --config=noaws --config=nohdfs --config=noignite --config=nokafka
diff --git a/science/py-tensorflow/files/patch-bazelrc b/science/py-tensorflow/files/patch-bazelrc
new file mode 100644
index 000000000000..94e8db0ecd1d
--- /dev/null
+++ b/science/py-tensorflow/files/patch-bazelrc
@@ -0,0 +1,11 @@
+--- .bazelrc.orig 2019-07-13 21:45:36.138413000 +0100
++++ .bazelrc 2019-07-13 21:46:25.898491000 +0100
+@@ -101,7 +101,7 @@
+ build:c++1z --cxxopt=-stdlib=libc++
+
+ # Default paths for TF_SYSTEM_LIBS
+-build --define=PREFIX=/usr
++build --define=PREFIX=%%LOCALBASE%%
+ build --define=LIBDIR=$(PREFIX)/lib
+ build --define=INCLUDEDIR=$(PREFIX)/include
+
diff --git a/science/py-tensorflow/files/patch-tensorflow_contrib_boosted__trees_build b/science/py-tensorflow/files/patch-tensorflow_contrib_boosted__trees_build
new file mode 100644
index 000000000000..3711842c1939
--- /dev/null
+++ b/science/py-tensorflow/files/patch-tensorflow_contrib_boosted__trees_build
@@ -0,0 +1,24 @@
+--- tensorflow/contrib/boosted_trees/BUILD.orig 2019-07-07 15:35:52.034885000 +0100
++++ tensorflow/contrib/boosted_trees/BUILD 2019-07-07 15:50:02.149725000 +0100
+@@ -27,6 +27,10 @@
+ ":stats_accumulator_ops_kernels",
+ ":training_ops_kernels",
+ ],
++ linkopts = select({
++ "//tensorflow:freebsd": ["-lm", "-lexecinfo",],
++ }),
++
+ alwayslink = 1,
+ )
+
+@@ -40,6 +44,10 @@
+ ":stats_accumulator_ops_op_lib",
+ ":training_ops_op_lib",
+ ],
++ linkopts = select({
++ "//tensorflow:freebsd": ["-lm", "-lexecinfo",],
++ }),
++
+ )
+
+ py_library(
diff --git a/science/py-tensorflow/files/patch-tensorflow_contrib_ignite_kernels_client_ignite__plain__client__unix.cc b/science/py-tensorflow/files/patch-tensorflow_contrib_ignite_kernels_client_ignite__plain__client__unix.cc
new file mode 100644
index 000000000000..12d7a8e0d5af
--- /dev/null
+++ b/science/py-tensorflow/files/patch-tensorflow_contrib_ignite_kernels_client_ignite__plain__client__unix.cc
@@ -0,0 +1,13 @@
+--- tensorflow/contrib/ignite/kernels/client/ignite_plain_client_unix.cc.orig 2019-07-07 13:40:21.593527000 +0100
++++ tensorflow/contrib/ignite/kernels/client/ignite_plain_client_unix.cc 2019-07-07 13:40:59.586340000 +0100
+@@ -20,6 +20,10 @@
+ #include <sys/socket.h>
+ #include <unistd.h>
+
++#ifdef __FreeBSD__
++#include <netinet/in.h>
++#endif
++
+ #include <iostream>
+ #include <map>
+
diff --git a/science/py-tensorflow/files/patch-tensorflow_contrib_makefile_makefile b/science/py-tensorflow/files/patch-tensorflow_contrib_makefile_makefile
new file mode 100644
index 000000000000..d4ca3e053e57
--- /dev/null
+++ b/science/py-tensorflow/files/patch-tensorflow_contrib_makefile_makefile
@@ -0,0 +1,49 @@
+--- ./tensorflow/contrib/makefile/Makefile.orig 2019-07-08 16:51:36.748365000 +0100
++++ ./tensorflow/contrib/makefile/Makefile 2019-07-08 16:51:21.774903000 +0100
+@@ -60,12 +60,15 @@
+ ifeq ($(UNAME_S),Linux)
+ HOST_OS := LINUX
+ endif
++ ifeq ($(UNAME_S),FreeBSD)
++ HOST_OS := FREEBSD
++ endif
+ ifeq ($(UNAME_S),Darwin)
+ HOST_OS := OSX
+ endif
+ endif
+
+-HOST_ARCH := $(shell if [[ $(shell uname -m) =~ i[345678]86 ]]; then echo x86_32; else echo $(shell uname -m); fi)
++HOST_ARCH := $(shell if uname -m | grep -q i[345678]86; then echo x86_32; elif uname -m | grep -q amd64; then echo x86_64; else uname -m; fi)
+
+ # Where compiled objects are stored.
+ HOST_OBJDIR := $(MAKEFILE_DIR)/gen/host_obj/
+@@ -111,6 +114,9 @@
+ ifeq ($(HOST_OS),LINUX)
+ HOST_LIBS += -ldl -lpthread
+ endif
++ifeq ($(HOST_OS),FREEBSD)
++ HOST_LIBS += -lexecinfo -lpthread
++endif
+
+ # If we're on a Pi, link in pthreads and dl
+ ifeq ($(HOST_OS),PI)
+@@ -248,7 +254,7 @@
+ LDFLAGS += -all_load
+ endif
+ # Make sure that we don't strip global constructors on Linux.
+-ifeq ($(TARGET),LINUX)
++ifeq ($(TARGET),LINUX,FREEBSD)
+ ifeq ($(HAS_GEN_HOST_PROTOC),true)
+ LIBFLAGS += -L$(MAKEFILE_DIR)/gen/protobuf-host/lib
+ export LD_LIBRARY_PATH=$(MAKEFILE_DIR)/gen/protobuf-host/lib
+@@ -261,6 +267,10 @@
+ ifeq ($(TARGET),LINUX)
+ LIBS += -ldl -lpthread
+ endif
++ifeq ($(TARGET),FREEBSD)
++ LIBS += -lexecinfo -lpthread
++endif
++
+ # If we're cross-compiling for the Raspberry Pi, use the right gcc.
+ ifeq ($(TARGET),PI)
+ CXXFLAGS += $(ANDROID_TYPES) -DRASPBERRY_PI
diff --git a/science/py-tensorflow/files/patch-tensorflow_core_BUILD b/science/py-tensorflow/files/patch-tensorflow_core_BUILD
new file mode 100644
index 000000000000..c699215b4922
--- /dev/null
+++ b/science/py-tensorflow/files/patch-tensorflow_core_BUILD
@@ -0,0 +1,47 @@
+--- tensorflow/core/BUILD.orig 2019-06-18 23:48:23.000000000 +0100
++++ tensorflow/core/BUILD 2019-07-14 09:27:38.471527000 +0100
+@@ -2412,7 +2412,7 @@
+ copts = tf_copts(),
+ defines = LIB_INTERNAL_DEFINES,
+ linkopts = select({
+- "//tensorflow:freebsd": [],
++ "//tensorflow:freebsd": ["-lexecinfo",],
+ "//tensorflow:windows": [],
+ "//tensorflow:android": [],
+ "//conditions:default": [
+@@ -2512,7 +2512,7 @@
+ hdrs = ["lib/gif/gif_io.h"],
+ copts = tf_copts(),
+ linkopts = select({
+- "//tensorflow:freebsd": [],
++ "//tensorflow:freebsd": ["-lexecinfo",],
+ "//tensorflow:windows": [],
+ "//conditions:default": ["-ldl"],
+ }),
+@@ -2536,7 +2536,7 @@
+ ],
+ copts = tf_copts(),
+ linkopts = select({
+- "//tensorflow:freebsd": [],
++ "//tensorflow:freebsd": ["-lexecinfo",],
+ "//tensorflow:windows": [],
+ "//conditions:default": ["-ldl"],
+ }),
+@@ -2566,7 +2566,7 @@
+ ],
+ copts = tf_copts(),
+ linkopts = select({
+- "//tensorflow:freebsd": [],
++ "//tensorflow:freebsd": ["-lexecinfo",],
+ "//tensorflow:windows": [],
+ "//conditions:default": ["-ldl"],
+ }),
+@@ -2897,7 +2897,7 @@
+ hdrs = FRAMEWORK_INTERNAL_PUBLIC_HEADERS,
+ copts = tf_copts(),
+ linkopts = select({
+- "//tensorflow:freebsd": ["-lm"],
++ "//tensorflow:freebsd": ["-lm", "-lexecinfo",],
+ "//tensorflow:windows": [],
+ "//conditions:default": [
+ "-ldl",
diff --git a/science/py-tensorflow/files/patch-tensorflow_core_platform_cloud_gcs__dns__cache.cc b/science/py-tensorflow/files/patch-tensorflow_core_platform_cloud_gcs__dns__cache.cc
new file mode 100644
index 000000000000..5d3ee387c329
--- /dev/null
+++ b/science/py-tensorflow/files/patch-tensorflow_core_platform_cloud_gcs__dns__cache.cc
@@ -0,0 +1,14 @@
+--- tensorflow/core/platform/cloud/gcs_dns_cache.cc.orig 2019-06-18 23:48:23.000000000 +0100
++++ tensorflow/core/platform/cloud/gcs_dns_cache.cc 2019-07-06 18:15:09.827112000 +0100
+@@ -24,6 +24,11 @@
+ #endif
+ #include <sys/types.h>
+
++#ifdef __FreeBSD__
++#include <sys/socket.h>
++#include <netinet/in.h>
++#endif
++
+ namespace tensorflow {
+
+ namespace {
diff --git a/science/py-tensorflow/files/patch-tensorflow_core_platform_default_build__config.bzl b/science/py-tensorflow/files/patch-tensorflow_core_platform_default_build__config.bzl
new file mode 100644
index 000000000000..3ca7e7a22203
--- /dev/null
+++ b/science/py-tensorflow/files/patch-tensorflow_core_platform_default_build__config.bzl
@@ -0,0 +1,13 @@
+--- tensorflow/core/platform/default/build_config.bzl.orig 2019-07-06 21:55:11.899673000 +0100
++++ tensorflow/core/platform/default/build_config.bzl 2019-07-06 21:56:04.571430000 +0100
+@@ -796,9 +796,7 @@
+ "//tensorflow:ios": [],
+ "//tensorflow:windows": [],
+ "//tensorflow:macos": [],
+- "//conditions:default": [
+- "@hwloc",
+- ],
++ "//tensorflow:freebsd": [],
+ })
+
+ def tf_additional_numa_copts():
diff --git a/science/py-tensorflow/files/patch-tensorflow_core_platform_posix_env.cc b/science/py-tensorflow/files/patch-tensorflow_core_platform_posix_env.cc
new file mode 100644
index 000000000000..b50356e83924
--- /dev/null
+++ b/science/py-tensorflow/files/patch-tensorflow_core_platform_posix_env.cc
@@ -0,0 +1,31 @@
+--- tensorflow/core/platform/posix/env.cc.orig 2019-06-18 23:48:23.000000000 +0100
++++ tensorflow/core/platform/posix/env.cc 2019-07-06 21:03:28.090735000 +0100
+@@ -28,6 +28,10 @@
+ #include <thread>
+ #include <vector>
+
++#ifdef __FREEBSD__
++#include <pthread.h>
++#endif
++
+ #include "tensorflow/core/lib/core/error_codes.pb.h"
+ #include "tensorflow/core/platform/env.h"
+ #include "tensorflow/core/platform/load_library.h"
+@@ -113,7 +117,7 @@
+ // Has to be casted to long first, else this error appears:
+ // static_cast from 'pthread_t' (aka 'pthread *') to 'int32' (aka 'int')
+ // is not allowed
+- return static_cast<int32>(static_cast<int64>(pthread_self()));
++ return static_cast<int32>((int64)(pthread_self()));
+ #else
+ return static_cast<int32>(pthread_self());
+ #endif
+@@ -129,7 +133,7 @@
+ return true;
+ }
+ }
+-#if defined(__ANDROID__) || defined(__EMSCRIPTEN__)
++#if defined(__ANDROID__) || defined(__EMSCRIPTEN__) || defined(__FreeBSD__)
+ return false;
+ #else
+ char buf[100];
diff --git a/science/py-tensorflow/files/patch-tensorflow_core_proto_autotuning.proto b/science/py-tensorflow/files/patch-tensorflow_core_proto_autotuning.proto
new file mode 100644
index 000000000000..197b0575861b
--- /dev/null
+++ b/science/py-tensorflow/files/patch-tensorflow_core_proto_autotuning.proto
@@ -0,0 +1,21 @@
+--- tensorflow/core/protobuf/autotuning.proto.orig 2019-06-18 23:48:23.000000000 +0100
++++ tensorflow/core/protobuf/autotuning.proto 2019-07-30 11:45:04.342068000 +0100
+@@ -11,14 +11,14 @@
+ import "google/protobuf/duration.proto";
+
+ message CudnnVersion {
+- int32 major = 1;
+- int32 minor = 2;
++ int32 major_val = 1;
++ int32 minor_val = 2;
+ int32 patch = 3;
+ }
+
+ message ComputeCapability {
+- int32 major = 1;
+- int32 minor = 2;
++ int32 major_val = 1;
++ int32 minor_val = 2;
+ }
+
+ message AutotuneResult {
diff --git a/science/py-tensorflow/files/patch-tensorflow_lite_experimental_micro_tools_make_targets_freebsd__makefile.inc b/science/py-tensorflow/files/patch-tensorflow_lite_experimental_micro_tools_make_targets_freebsd__makefile.inc
new file mode 100644
index 000000000000..9558cdfd6513
--- /dev/null
+++ b/science/py-tensorflow/files/patch-tensorflow_lite_experimental_micro_tools_make_targets_freebsd__makefile.inc
@@ -0,0 +1,13 @@
+--- /dev/null 2019-07-08 14:38:21.999045000 +0100
++++ tensorflow/lite/experimental/micro/tools/make/targets/freebsd_makefile.inc 2019-07-08 14:37:33.196932000 +0100
+@@ -0,0 +1,10 @@
++# Settings for x86 on FreeBSD
++ifeq ($(TARGET), freebsd)
++ ifeq ($(TARGET_ARCH), x86_64)
++ PLATFORM_FLAGS = \
++ -DTF_LITE_DISABLE_X86_NEON
++ CXXFLAGS += $(PLATFORM_FLAGS)
++ CCFLAGS += $(PLATFORM_FLAGS)
++ endif
++endif
++
diff --git a/science/py-tensorflow/files/patch-tensorflow_lite_kernels_internal_build b/science/py-tensorflow/files/patch-tensorflow_lite_kernels_internal_build
new file mode 100644
index 000000000000..e47c7f0da602
--- /dev/null
+++ b/science/py-tensorflow/files/patch-tensorflow_lite_kernels_internal_build
@@ -0,0 +1,11 @@
+--- tensorflow/lite/kernels/internal/BUILD.orig 2019-07-09 13:22:19.397153000 +0100
++++ tensorflow/lite/kernels/internal/BUILD 2019-07-09 13:22:38.288994000 +0100
+@@ -607,7 +607,7 @@
+ ":neon_tensor_utils",
+ ],
+ "//conditions:default": [
+- ":portable_tensor_utils",
++ ":neon_tensor_utils",
+ ],
+ }),
+ )
diff --git a/science/py-tensorflow/files/patch-tensorflow_lite_tools_make_makefile b/science/py-tensorflow/files/patch-tensorflow_lite_tools_make_makefile
new file mode 100644
index 000000000000..e59b928023d7
--- /dev/null
+++ b/science/py-tensorflow/files/patch-tensorflow_lite_tools_make_makefile
@@ -0,0 +1,19 @@
+--- tensorflow/lite/tools/make/Makefile.orig 2019-07-08 14:04:30.373727000 +0100
++++ tensorflow/lite/tools/make/Makefile 2019-07-08 16:44:36.249811000 +0100
+@@ -16,12 +16,15 @@
+ ifeq ($(UNAME_S),Linux)
+ HOST_OS := linux
+ endif
++ ifeq ($(UNAME_S),FreeBSD)
++ HOST_OS := freebsd
++ endif
+ ifeq ($(UNAME_S),Darwin)
+ HOST_OS := osx
+ endif
+ endif
+
+-HOST_ARCH := $(shell if uname -m | grep -q i[345678]86; then echo x86_32; else uname -m; fi)
++HOST_ARCH := $(shell if uname -m | grep -q i[345678]86; then echo x86_32; elif uname -m | grep -q amd64; then echo x86_64; else uname -m; fi)
+
+ # Override these on the make command line to target a specific architecture. For example:
+ # make -f tensorflow/lite/tools/make/Makefile TARGET=rpi TARGET_ARCH=armv7l
diff --git a/science/py-tensorflow/files/patch-tensorflow_lite_tools_make_targets_freebsd__makefile.inc b/science/py-tensorflow/files/patch-tensorflow_lite_tools_make_targets_freebsd__makefile.inc
new file mode 100644
index 000000000000..1c66895e0274
--- /dev/null
+++ b/science/py-tensorflow/files/patch-tensorflow_lite_tools_make_targets_freebsd__makefile.inc
@@ -0,0 +1,19 @@
+--- /dev/null 2019-07-08 14:12:50.536743000 +0100
++++ tensorflow/lite/tools/make/targets/freebsd_makefile.inc 2019-07-08 14:11:35.495868000 +0100
+@@ -0,0 +1,16 @@
++# Settings for FreeBSD.
++ifeq ($(TARGET), freebsd)
++ CXXFLAGS += \
++ -fPIC \
++ -DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK \
++ -pthread
++ CFLAGS += \
++ -fPIC \
++ -DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK \
++ -pthread
++ # TODO(petewarden): In the future we may want to add architecture-specific
++ # flags like -msse4.2
++ LIBS += -lexecinfo
++endif
++
++
diff --git a/science/py-tensorflow/files/patch-tensorflow_tensorflow.bzl b/science/py-tensorflow/files/patch-tensorflow_tensorflow.bzl
new file mode 100644
index 000000000000..9eb43a60af6b
--- /dev/null
+++ b/science/py-tensorflow/files/patch-tensorflow_tensorflow.bzl
@@ -0,0 +1,65 @@
+--- tensorflow/tensorflow.bzl.orig 2019-06-18 23:48:23.000000000 +0100
++++ tensorflow/tensorflow.bzl 2019-07-13 13:57:17.579194000 +0100
+@@ -287,6 +287,7 @@
+ "-Wno-sign-compare",
+ "-fno-exceptions",
+ "-ftemplate-depth=900",
++ "-I%%LOCALBASE%%/include",
+ ]) +
+ if_cuda(["-DGOOGLE_CUDA=1"]) +
+ if_tensorrt(["-DGOOGLE_TENSORRT=1"]) +
+@@ -603,7 +604,7 @@
+ ],
+ ),
+ data = depset(data + added_data_deps),
+- linkopts = linkopts + _rpath_linkopts(name_os),
++ linkopts = linkopts + ["-lexecinfo", "-lgpr"] + _rpath_linkopts(name),
+ visibility = visibility,
+ **kwargs
+ )
+@@ -657,7 +658,7 @@
+ tf_cc_binary(
+ name = tool,
+ copts = tf_copts(),
+- linkopts = if_not_windows(["-lm", "-Wl,-ldl"]),
++ linkopts = if_not_windows(["-lm", "-Wl, -lexecinfo"]),
+ linkstatic = 1, # Faster to link this one-time-use binary dynamically
+ deps = [op_gen] + deps,
+ )
+@@ -839,7 +840,7 @@
+ tf_cc_binary(
+ name = tool_name,
+ copts = tf_copts(),
+- linkopts = if_not_windows(["-lm", "-Wl,-ldl"]) + cc_linkopts,
++ linkopts = if_not_windows(["-L%%LOCALBASE%%/lib", "-lm", "-Wl, -lexecinfo"]) + cc_linkopts,
+ linkstatic = 1, # Faster to link this one-time-use binary dynamically
+ visibility = [clean_dep("//tensorflow:internal")],
+ deps = ([
+@@ -954,8 +955,9 @@
+ "//conditions:default": [
+ "-lpthread",
+ "-lm",
++ "-lexecinfo",
+ ],
+- }) + linkopts + _rpath_linkopts(name),
++ }) + linkopts + ["-lexecinfo"] + _rpath_linkopts(name),
+ deps = deps + tf_binary_dynamic_kernel_deps(kernels) + if_mkl_ml(
+ [
+ clean_dep("//third_party/mkl:intel_binary_blob"),
+@@ -1103,7 +1105,7 @@
+ ]) + if_rocm_is_configured([
+ clean_dep("//tensorflow/core:gpu_lib"),
+ ]),
+- linkopts = if_not_windows(["-lpthread", "-lm"]) + linkopts + _rpath_linkopts(name),
++ linkopts = if_not_windows(["-lpthread", "-lm", "-lexecinfo",]) + linkopts + _rpath_linkopts(name),
+ linkstatic = linkstatic or select({
+ # cc_tests with ".so"s in srcs incorrectly link on Darwin
+ # unless linkstatic=1.
+@@ -1784,6 +1786,7 @@
+ linkopts = linkopts + select({
+ "//conditions:default": [
+ "-lm",
++ "-lexecinfo",
+ ],
+ clean_dep("//tensorflow:windows"): [],
+ clean_dep("//tensorflow:macos"): [],
diff --git a/science/py-tensorflow/files/patch-tensorflow_tools_lib__package_build b/science/py-tensorflow/files/patch-tensorflow_tools_lib__package_build
new file mode 100644
index 000000000000..09686fc90c31
--- /dev/null
+++ b/science/py-tensorflow/files/patch-tensorflow_tools_lib__package_build
@@ -0,0 +1,18 @@
+--- tensorflow/tools/lib_package/BUILD.orig 2019-07-06 21:58:28.528046000 +0100
++++ tensorflow/tools/lib_package/BUILD 2019-07-06 21:58:46.410184000 +0100
+@@ -152,7 +152,6 @@
+ "@gemmlowp//:LICENSE",
+ "@gif_archive//:COPYING",
+ "@highwayhash//:LICENSE",
+- "@hwloc//:COPYING",
+ "@icu//:icu4c/LICENSE",
+ "@jpeg//:LICENSE.md",
+ "@lmdb//:LICENSE",
+@@ -223,7 +222,6 @@
+ "@gemmlowp//:LICENSE",
+ "@gif_archive//:COPYING",
+ "@highwayhash//:LICENSE",
+- "@hwloc//:COPYING",
+ "@icu//:icu4j/main/shared/licenses/LICENSE",
+ "@jpeg//:LICENSE.md",
+ "@lmdb//:LICENSE",
diff --git a/science/py-tensorflow/files/patch-tensorflow_tools_pip__package_build b/science/py-tensorflow/files/patch-tensorflow_tools_pip__package_build
new file mode 100644
index 000000000000..0a235bd7e57e
--- /dev/null
+++ b/science/py-tensorflow/files/patch-tensorflow_tools_pip__package_build
@@ -0,0 +1,10 @@
+--- tensorflow/tools/pip_package/BUILD.orig 2019-07-06 22:03:09.438361000 +0100
++++ tensorflow/tools/pip_package/BUILD 2019-07-06 22:03:18.385021000 +0100
+@@ -175,7 +175,6 @@
+ "@gemmlowp//:LICENSE",
+ "@gif_archive//:COPYING",
+ "@highwayhash//:LICENSE",
+- "@hwloc//:COPYING",
+ "@icu//:icu4c/LICENSE",
+ "@jpeg//:LICENSE.md",
+ "@keras_applications_archive//:LICENSE",
diff --git a/science/py-tensorflow/files/patch-tensorflow_workspace.bzl b/science/py-tensorflow/files/patch-tensorflow_workspace.bzl
new file mode 100644
index 000000000000..29955c8d64d4
--- /dev/null
+++ b/science/py-tensorflow/files/patch-tensorflow_workspace.bzl
@@ -0,0 +1,10 @@
+--- tensorflow/workspace.bzl.orig 2019-07-11 15:46:44.460265000 +0100
++++ tensorflow/workspace.bzl 2019-07-11 15:47:14.104299000 +0100
+@@ -346,6 +346,7 @@
+ ],
+ sha256 = "8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1",
+ build_file = clean_dep("//third_party:enum34.BUILD"),
++ system_build_file = clean_dep("//third_party/systemlibs:enum34.BUILD"),
+ strip_prefix = "enum34-1.1.6/enum",
+ )
+
diff --git a/science/py-tensorflow/files/patch-third__party_aws_build.bazel b/science/py-tensorflow/files/patch-third__party_aws_build.bazel
new file mode 100644
index 000000000000..4b08a5e711ec
--- /dev/null
+++ b/science/py-tensorflow/files/patch-third__party_aws_build.bazel
@@ -0,0 +1,13 @@
+--- third_party/aws/BUILD.bazel.orig 2019-07-07 15:57:49.887118000 +0100
++++ third_party/aws/BUILD.bazel 2019-07-07 15:58:39.817675000 +0100
+@@ -27,7 +27,9 @@
+ "@org_tensorflow//tensorflow:raspberry_pi_armeabi": glob([
+ "aws-cpp-sdk-core/source/platform/linux-shared/*.cpp",
+ ]),
+- "//conditions:default": [],
++ "//conditions:default":glob([
++ "aws-cpp-sdk-core/source/platform/linux-shared/*.cpp",
++ ]),
+ }) + glob([
+ "aws-cpp-sdk-core/include/**/*.h",
+ "aws-cpp-sdk-core/source/*.cpp",
diff --git a/science/py-tensorflow/files/patch-third__party_systemlibs_enum34.build b/science/py-tensorflow/files/patch-third__party_systemlibs_enum34.build
new file mode 100644
index 000000000000..9a3e406dfc7c
--- /dev/null
+++ b/science/py-tensorflow/files/patch-third__party_systemlibs_enum34.build
@@ -0,0 +1,17 @@
+--- /dev/null 2019-07-11 15:43:12.610969000 +0100
++++ third_party/systemlibs/enum34.BUILD 2019-07-11 15:42:45.040593000 +0100
+@@ -0,0 +1,14 @@
++# Description:
++# enum34 provides a backport of the enum module for Python 2.
++
++licenses(["notice"]) # MIT
++
++filegroup(
++ name = "LICENSE",
++ visibility = ["//visibility:public"],
++)
++
++py_library(
++ name = "enum",
++ visibility = ["//visibility:public"],
++)
diff --git a/science/py-tensorflow/files/patch-third__party_systemlibs_grpc.build b/science/py-tensorflow/files/patch-third__party_systemlibs_grpc.build
new file mode 100644
index 000000000000..3b1d8133af05
--- /dev/null
+++ b/science/py-tensorflow/files/patch-third__party_systemlibs_grpc.build
@@ -0,0 +1,11 @@
+--- third_party/systemlibs/grpc.BUILD.orig 2019-06-18 23:48:23.000000000 +0100
++++ third_party/systemlibs/grpc.BUILD 2019-07-13 14:03:35.671155000 +0100
+@@ -7,7 +7,7 @@
+
+ cc_library(
+ name = "grpc",
+- linkopts = ["-lgrpc"],
++ linkopts = ["-lgrpc", "-lgpr"],
+ visibility = ["//visibility:public"],
+ )
+
diff --git a/science/py-tensorflow/files/patch-third__party_systemlibs_protobuf.bzl b/science/py-tensorflow/files/patch-third__party_systemlibs_protobuf.bzl
new file mode 100644
index 000000000000..db3f441180aa
--- /dev/null
+++ b/science/py-tensorflow/files/patch-third__party_systemlibs_protobuf.bzl
@@ -0,0 +1,11 @@
+--- third_party/systemlibs/protobuf.bzl.orig 2019-07-26 12:28:57.790848000 +0100
++++ third_party/systemlibs/protobuf.bzl 2019-07-26 12:29:42.978059000 +0100
+@@ -76,7 +76,7 @@
+ source_dir = _SourceDir(ctx)
+ gen_dir = _GenDir(ctx)
+ if source_dir:
+- import_flags = ["-I" + source_dir, "-I" + gen_dir]
++ import_flags = ["-I%%LOCALBASE%%/include", "-I" + source_dir, "-I" + gen_dir]
+ else:
+ import_flags = ["-I."]
+
diff --git a/science/py-tensorflow/files/patch-third__party_systemlibs_swig.build b/science/py-tensorflow/files/patch-third__party_systemlibs_swig.build
new file mode 100644
index 000000000000..b3b8f80f1fef
--- /dev/null
+++ b/science/py-tensorflow/files/patch-third__party_systemlibs_swig.build
@@ -0,0 +1,11 @@
+--- third_party/systemlibs/swig.BUILD.orig 2019-07-13 11:28:32.539254000 +0100
++++ third_party/systemlibs/swig.BUILD 2019-07-13 11:28:47.485432000 +0100
+@@ -13,7 +13,7 @@
+ genrule(
+ name = "lnswiglink",
+ outs = ["swiglink"],
+- cmd = "ln -s $$(which swig) $@",
++ cmd = "ln -s $$(which swig3.0) $@",
+ )
+
+ sh_binary(
diff --git a/science/py-tensorflow/files/patch-third__party_systemlibs_syslibs__configure.bzl b/science/py-tensorflow/files/patch-third__party_systemlibs_syslibs__configure.bzl
new file mode 100644
index 000000000000..09307db161e2
--- /dev/null
+++ b/science/py-tensorflow/files/patch-third__party_systemlibs_syslibs__configure.bzl
@@ -0,0 +1,10 @@
+--- third_party/systemlibs/syslibs_configure.bzl.orig 2019-07-11 15:43:32.713320000 +0100
++++ third_party/systemlibs/syslibs_configure.bzl 2019-07-11 15:43:54.448882000 +0100
+@@ -21,6 +21,7 @@
+ "curl",
+ "cython",
+ "double_conversion",
++ "enum34_archive",
+ "flatbuffers",
+ "gast_archive",
+ "gif_archive",
diff --git a/science/py-tensorflow/files/patch-third_party_gpus_rocm_configure.bzl b/science/py-tensorflow/files/patch-third_party_gpus_rocm_configure.bzl
new file mode 100644
index 000000000000..a6f2604c87ed
--- /dev/null
+++ b/science/py-tensorflow/files/patch-third_party_gpus_rocm_configure.bzl
@@ -0,0 +1,11 @@
+--- third_party/gpus/rocm_configure.bzl.orig 2019-06-18 23:48:23.000000000 +0100
++++ third_party/gpus/rocm_configure.bzl 2019-07-06 21:35:41.445803000 +0100
+@@ -308,7 +308,7 @@
+ Returns:
+ The platform-specific name of the library.
+ """
+- if cpu_value in ("Linux"):
++ if cpu_value in ("Linux", "FreeBSD"):
+ if static:
+ return "lib%s.a" % lib
+ else: