git: e19ad3bbab4d - main - science/py-tensorflow: fix build after it was broken by the snappy update
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 01 Oct 2026 20:14:36 UTC
The branch main has been updated by yuri:
URL: https://cgit.FreeBSD.org/ports/commit/?id=e19ad3bbab4d8026ecbda50afa3e528f48c1c277
commit e19ad3bbab4d8026ecbda50afa3e528f48c1c277
Author: Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2026-10-01 20:13:17 +0000
Commit: Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2026-10-01 20:14:34 +0000
science/py-tensorflow: fix build after it was broken by the snappy update
---
science/py-tensorflow/Makefile | 14 +++++++++++++-
.../files/bazel/riegeli-xopen-source.patch | 17 +++++++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/science/py-tensorflow/Makefile b/science/py-tensorflow/Makefile
index 75f50bb479a8..a138fcd939cb 100644
--- a/science/py-tensorflow/Makefile
+++ b/science/py-tensorflow/Makefile
@@ -1,7 +1,7 @@
PORTNAME= tensorflow
DISTVERSIONPREFIX= v
DISTVERSION= 2.21.0
-PORTREVISION= 3
+PORTREVISION= 4
CATEGORIES= science python # machine-learning
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
DIST_SUBDIR= ${PORTNAME}
@@ -140,6 +140,8 @@ post-patch:
${WRKSRC}/third_party/xla/third_party/py/
@${CP} ${PATCHDIR}/bazel/fix-environ.patch \
${WRKSRC}/third_party/xla/third_party/
+ @${CP} ${PATCHDIR}/bazel/riegeli-xopen-source.patch \
+ ${WRKSRC}/third_party/
@${CP} ${PATCHDIR}/llvm_freebsd.patch \
${WRKSRC}/third_party/xla/third_party/llvm/freebsd.patch
@${CP} ${PATCHDIR}/grpc.bazel.BUILD \
@@ -286,6 +288,16 @@ do-build:
else \
${ECHO_MSG} "WARNING: llvm config.bzl not found at $${LLVMCONF}; build may fail"; \
fi
+ # Fetch riegeli so we can patch snappy_writer.cc before the build.
+ @cd ${WRKSRC} && \
+ bazel --bazelrc="${WRKDIR}/bazelrc" ${BAZEL_BOOT} fetch @@riegeli//riegeli/snappy:snappy_writer
+ @RIEGELI_OB=$$(cd ${WRKSRC} && bazel --bazelrc="${WRKDIR}/bazelrc" ${BAZEL_BOOT} info output_base 2>/dev/null); \
+ RIEGELI_SW="$${RIEGELI_OB}/external/riegeli/riegeli/snappy/snappy_writer.cc"; \
+ if [ -f "$${RIEGELI_SW}" ]; then \
+ ${REINPLACE_CMD} -e 's|snappy::Compress(\&source, \&sink, {/\*level=\*/options.compression_level()});|snappy::Compress(\&source, \&sink, snappy::CompressionOptions{options.compression_level()});|' "$${RIEGELI_SW}"; \
+ else \
+ ${ECHO_MSG} "WARNING: riegeli snappy_writer.cc not found at $${RIEGELI_SW}; build may fail"; \
+ fi
@cd ${WRKSRC} && \
bazel --bazelrc="${WRKDIR}/bazelrc" ${BAZEL_BOOT} build --jobs ${TF_JOBS_NUMBER} ${BAZEL_COPT} ${BAZEL_ARCH_DEFINES} \
--host_copt="-I${LOCALBASE}/include" --host_copt="-I${LOCALBASE}/include/jsoncpp" \
diff --git a/science/py-tensorflow/files/bazel/riegeli-xopen-source.patch b/science/py-tensorflow/files/bazel/riegeli-xopen-source.patch
index 780c9df5dbf8..475a37de7269 100644
--- a/science/py-tensorflow/files/bazel/riegeli-xopen-source.patch
+++ b/science/py-tensorflow/files/bazel/riegeli-xopen-source.patch
@@ -1,3 +1,9 @@
+-- Fix snappy::Compress() call for snappy >= 1.2 which introduced a
+-- CompressionOptions struct with a constructor instead of an aggregate.
+-- Without this, the brace-initialiser is no longer valid and the build
+-- fails with "cannot convert initializer list argument to 'CompressionOptions'".
+-- See the snappy 1.2.0 API change: https://github.com/google/snappy/compare/1.1.10...1.2.0
+
--- a/riegeli/bytes/cfile_handle.cc
+++ b/riegeli/bytes/cfile_handle.cc
@@ -13,10 +13,12 @@
@@ -158,3 +164,14 @@
// Make `off_t` 64-bit even on 32-bit systems.
#undef _FILE_OFFSET_BITS
+--- a/riegeli/snappy/snappy_writer.cc
++++ b/riegeli/snappy/snappy_writer.cc
+@@ -267,7 +267,7 @@
+ }
+ ReaderSnappySource source(&src, *size);
+ WriterSnappySink sink(&dest);
+- snappy::Compress(&source, &sink, {/*level=*/options.compression_level()});
++ snappy::Compress(&source, &sink, snappy::CompressionOptions{options.compression_level()});
+ if (ABSL_PREDICT_FALSE(!dest.ok())) return dest.status();
+ if (ABSL_PREDICT_FALSE(!src.ok())) return src.status();
+ return absl::OkStatus();