Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Oct 2021 19:06:59 GMT
From:      Piotr Kubaj <pkubaj@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: b3ab9cf93726 - main - science/py-tensorflow: fix build on powerpc64
Message-ID:  <202110121906.19CJ6xUB020080@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by pkubaj:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b3ab9cf93726f7219c60161b8da3d091704093da

commit b3ab9cf93726f7219c60161b8da3d091704093da
Author:     Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2021-10-12 18:37:07 +0000
Commit:     Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2021-10-12 18:37:07 +0000

    science/py-tensorflow: fix build on powerpc64
    
    The bundled abseil needs the same patch that was already upstreamed.
    
    Approved by: portmgr (blanket: build fix)
    PR:     259082
---
 science/py-tensorflow/Makefile                     |  3 +-
 ...-patch-absl_base_internal_unscaledcycleclock.cc | 47 ++++++++++++++++++++++
 .../files/patch-tensorflow_workspace.bzl           | 12 +++++-
 3 files changed, 59 insertions(+), 3 deletions(-)

diff --git a/science/py-tensorflow/Makefile b/science/py-tensorflow/Makefile
index d8a810ed5057..75b162628505 100644
--- a/science/py-tensorflow/Makefile
+++ b/science/py-tensorflow/Makefile
@@ -13,7 +13,7 @@ COMMENT=	Computation using data flow graphs for scalable machine learning
 LICENSE=	APACHE20
 LICENSE_FILE=	${WRKSRC}/LICENSE
 
-ONLY_FOR_ARCHS=	amd64
+ONLY_FOR_ARCHS=	amd64 powerpc64
 
 BUILD_DEPENDS=	${RUN_DEPENDS} \
 		${PYTHON_PKGNAMEPREFIX}grpcio-tools>=1.22.0:devel/py-grpcio-tools@${PY_FLAVOR} \
@@ -75,6 +75,7 @@ post-patch:
 	# the bzl files.
 	@${MKDIR} ${WRKDIR}/bazel-cache
 	@${MKDIR} ${WRKDIR}/bazel-distdir
+	@${CP} ${FILESDIR}/extra-patch-absl_base_internal_unscaledcycleclock.cc ${WRKSRC}/third_party/
 
 .for file in ${DISTFILES:C/\:(.*)//}
 	@${ECHO} "Moving ${file} to ${WRKDIR}/bazel-cache"
diff --git a/science/py-tensorflow/files/extra-patch-absl_base_internal_unscaledcycleclock.cc b/science/py-tensorflow/files/extra-patch-absl_base_internal_unscaledcycleclock.cc
new file mode 100644
index 000000000000..43bbada5c4bb
--- /dev/null
+++ b/science/py-tensorflow/files/extra-patch-absl_base_internal_unscaledcycleclock.cc
@@ -0,0 +1,47 @@
+--- a/absl/base/internal/unscaledcycleclock.cc.orig	2021-10-11 21:53:31.946215000 +0200
++++ b/absl/base/internal/unscaledcycleclock.cc	2021-10-11 21:57:54.536557000 +0200
+@@ -21,8 +21,15 @@
+ #endif
+ 
+ #if defined(__powerpc__) || defined(__ppc__)
++#ifdef __linux__
+ #include <sys/platform/ppc.h>
++#else
++#include "absl/base/call_once.h"
++#include <sys/types.h>
++#include <sys/sysctl.h>
++#include <threads.h>
+ #endif
++#endif
+ 
+ #include "absl/base/internal/sysinfo.h"
+ 
+@@ -56,11 +63,28 @@
+ #elif defined(__powerpc__) || defined(__ppc__)
+ 
+ int64_t UnscaledCycleClock::Now() {
++#ifdef __linux__
+   return __ppc_get_timebase();
++#else
++  int64_t tbr;
++  asm volatile("mfspr %0, 268" : "=r"(tbr));
++  return tbr;
++#endif
+ }
+ 
+ double UnscaledCycleClock::Frequency() {
++#ifdef __linux__
+   return __ppc_get_timebase_freq();
++#else
++  static once_flag init_timebase_frequency_once;
++  static double timebase_frequency = 0.0;
++  base_internal::LowLevelCallOnce(&init_timebase_frequency_once, [&]() {
++    size_t length = sizeof(timebase_frequency);
++    sysctlbyname("kern.timecounter.tc.timebase.frequency", &timebase_frequency,
++                 &length, nullptr, 0);
++  });
++  return timebase_frequency;
++#endif
+ }
+ 
+ #elif defined(__aarch64__)
diff --git a/science/py-tensorflow/files/patch-tensorflow_workspace.bzl b/science/py-tensorflow/files/patch-tensorflow_workspace.bzl
index d25f9d632e8e..45a4a12c3d2b 100644
--- a/science/py-tensorflow/files/patch-tensorflow_workspace.bzl
+++ b/science/py-tensorflow/files/patch-tensorflow_workspace.bzl
@@ -1,6 +1,14 @@
---- tensorflow/workspace.bzl.orig	2021-07-08 11:05:27 UTC
+--- tensorflow/workspace.bzl.orig	2021-01-04 20:18:42 UTC
 +++ tensorflow/workspace.bzl
-@@ -324,6 +324,7 @@ def tf_repositories(path_prefix = "", tf_repo_name = "
+@@ -157,6 +157,7 @@ def tf_repositories(path_prefix = "", tf_repo_name = "
+     tf_http_archive(
+         name = "com_google_absl",
+         build_file = clean_dep("//third_party:com_google_absl.BUILD"),
++        patch_file = clean_dep("//third_party:extra-patch-absl_base_internal_unscaledcycleclock.cc"),
+         sha256 = "acd93f6baaedc4414ebd08b33bebca7c7a46888916101d8c0b8083573526d070",
+         strip_prefix = "abseil-cpp-43ef2148c0936ebf7cb4be6b19927a9d9d145b8f",
+         urls = [
+@@ -324,6 +325,7 @@ def tf_repositories(path_prefix = "", tf_repo_name = "
          build_file = clean_dep("//third_party:functools32.BUILD"),
          sha256 = "f6253dfbe0538ad2e387bd8fdfd9293c925d63553f5813c4e587745416501e6d",
          strip_prefix = "functools32-3.2.3-2",



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202110121906.19CJ6xUB020080>