From nobody Sat Apr 4 18:40:44 2026 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4fp4Cx0Kjpz6WJFB for ; Sat, 04 Apr 2026 18:40:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fp4Cw5s9xz3SR6 for ; Sat, 04 Apr 2026 18:40:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1775328044; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9mEPG3CuVGWQntaitpdJ8DuS5hiZYONOexjtZl50+Ow=; b=wN7V+9Uxtye9VwWZX9uSQOVzkx3OavDnIwEmy0GrsTTQ8sxWsRyQaJhgzIPAEgPYfc4BbK pnTaZXxMGeADsasYZNlI/hTtpB/ECnSVWhGp3kHxiB6L6SI3zoeoyuzk5sUz2J9k9H3AgC zFGHmHbAwR8Z7WLPqveNqEpJshFSXY7HmbSf7QPBSvxrEOCaO7sydHsxElF0F8DYXTXJ3L Tq7o9cMyZsuzPQF03Eennw0Zgc84QfRt2G3KPP07Qmk7frUGn3AgcbYPnb76s3Mo4ZB9MX GPSSj80PvIXCg2Xbbko1wyu8+/yMWAlYfXolKoICy6WJC9k0kk00r7tyo7GBBw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1775328044; a=rsa-sha256; cv=none; b=R5lsEzLIzltyeHVgIZ91/L9V1lsxuruB4faWtEWzPXf9/7NeI0SwqtP3yWQsmJKWmSnG0P O26m6mcKY3HWfODwjJNblrM32F6T5uYRH1976xbrYiLxC0JyXGjGFyo/g7pnkUUStrtTrA k9NqHlc2sBtnl1mCVCf+ec+bN1PDDtEfXcg0K8gzAmrHxX6XZ7bps2gEM+M3graOmFHtAL y7oxxNt8wV6DgISQpzs8rSs323bOaKylwP2KYQPGTYJooEpBr45Z6+tkJIc9OvozS/tzB0 HN/dYx2rOmEDiln4GQ+R18DQgmhqsV8LJJcNZgnJUQznk7F6VyiIb0kjQif3Xg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1775328044; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9mEPG3CuVGWQntaitpdJ8DuS5hiZYONOexjtZl50+Ow=; b=pP9Ye3Uu6XMviNOvPRir5V0NLdjyn9dBPeDabUH/+rDFMU1oJP4qYmaRuPLSNqipjWZ1Jr kDWJje0xyX+NSntdtInXSrkI9PyYJxSkC7i6upRK60HrmX8AXDIU2Gdzi9ImEB3qiR3ny+ JDwBRPO9IeXLsn2QbqWvXAOfbDvVHD2iwu8WKByYQMDlFFTnH2TvUi/atO/EmwRVqUNwd6 Qzk6+Ve35Cj7FBAmRGpE9XOFH0ZyxfPOOoyqrooir8PfYL6bAF3UAbCRMEzmELTO4tCPnq Vu3C5BHvHF4Ien97B8MP7eUvdcOLbPkATjzxefj1fIuGbJSctzqhqq+eJi9jrg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fp4Cw591szWVb for ; Sat, 04 Apr 2026 18:40:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 259a9 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 04 Apr 2026 18:40:44 +0000 To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Yuri Victorovich Subject: git: ce9f734fcc8e - main - science/py-tensorflow: Fix unresolved symbol at run-time; Add test targets List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-ports-main@freebsd.org Sender: owner-dev-commits-ports-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: yuri X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ce9f734fcc8e698b8b4d2ce4c5f4840890e2de35 Auto-Submitted: auto-generated Date: Sat, 04 Apr 2026 18:40:44 +0000 Message-Id: <69d15b2c.259a9.1f5989c4@gitrepo.freebsd.org> The branch main has been updated by yuri: URL: https://cgit.FreeBSD.org/ports/commit/?id=ce9f734fcc8e698b8b4d2ce4c5f4840890e2de35 commit ce9f734fcc8e698b8b4d2ce4c5f4840890e2de35 Author: Yuri Victorovich AuthorDate: 2026-04-04 18:38:51 +0000 Commit: Yuri Victorovich CommitDate: 2026-04-04 18:40:39 +0000 science/py-tensorflow: Fix unresolved symbol at run-time; Add test targets --- science/py-tensorflow/Makefile | 48 ++++++-- science/py-tensorflow/Makefile.MASTER_SITES | 41 ++++++- science/py-tensorflow/distinfo | 39 +++++++ science/py-tensorflow/files/bazelrc | 36 +++++- .../files/cpuinfo-freebsd-alwayslink.patch | 11 ++ .../py-tensorflow/files/example-quick-training.py | 25 +++++ science/py-tensorflow/files/fix-llvm-config.py | 14 ++- science/py-tensorflow/files/freebsd/BUILD | 21 ++++ .../files/freebsd/compat_include/alloca.h | 4 + science/py-tensorflow/files/grpc-no-go-sdk.patch | 34 ++++++ science/py-tensorflow/files/patch-.bazelrc | 23 ---- science/py-tensorflow/files/patch-WORKSPACE | 125 --------------------- .../files/patch-tensorflow_python_BUILD | 48 ++++++++ .../files/patch-tensorflow_python__BUILD | 26 ----- .../files/patch-tensorflow_tf__version__script.lds | 20 ++++ .../patch-tensorflow_tools_pip__package_BUILD | 6 +- ...rflow_tools_pip__package_build__pip__package.py | 29 ++++- ...patch-tensorflow_tools_pip__package_utils_BUILD | 10 ++ ...ensorflow_tools_pip__package_utils____init__.py | 4 + .../files/patch-tensorflow_workspace0.bzl | 18 --- .../files/patch-tensorflow_workspace1.bzl | 17 --- .../files/patch-tensorflow_workspace2.bzl | 59 ++++------ .../files/patch-tensorflow_workspace3.bzl | 19 ---- .../patch-third__party_flatbuffers_BUILD.system | 14 --- .../patch-third__party_py_python__init__pip.bzl | 55 --------- .../patch-third__party_systemlibs_pybind11.BUILD | 8 +- ...ty_xla_third__party_absl_system.absl.base.BUILD | 18 --- ...y_xla_third__party_absl_system.absl.flags.BUILD | 10 -- ...xla_third__party_absl_system.absl.strings.BUILD | 15 --- ...d__party_absl_system.absl.synchronization.BUILD | 31 ----- ...hird__party_xla_third__party_llvm_workspace.bzl | 10 -- ...arty_xla_third__party_pthreadpool_workspace.bzl | 8 +- ...party_xla_third__party_py_python__init__pip.bzl | 55 --------- ...rty_xla_third__party_py_python__init__rules.bzl | 13 ++- ...ty_xla_third__party_python__runtime_BUILD.bazel | 4 +- ...remote__config_remote__platform__configure.bzl} | 6 +- ...d__party_xla_third__party_riegeli_workspace.bzl | 2 +- ...d__party_xla_third__party_xnnpack_workspace.bzl | 13 +++ .../py-tensorflow/files/protobuf-freebsd-upb.patch | 11 ++ .../files/pthreadpool-freebsd-alloca.patch | 16 +++ .../py-tensorflow/files/xnnpack-freebsd-mmap.patch | 68 +++++++++++ 41 files changed, 517 insertions(+), 517 deletions(-) diff --git a/science/py-tensorflow/Makefile b/science/py-tensorflow/Makefile index d465c21b1967..28fbe0623d0b 100644 --- a/science/py-tensorflow/Makefile +++ b/science/py-tensorflow/Makefile @@ -27,8 +27,7 @@ BUILD_DEPENDS= ${PYTHON_PKGNAMEPREFIX}grpcio-tools>=1.22.0:devel/py-grpcio-tools pybind11>=2.6.2:devel/pybind11 \ swig:devel/swig \ xxd:sysutils/xxd -LIB_DEPENDS= libgpr.so:devel/grpc \ - libpng.so:graphics/png \ +LIB_DEPENDS= libpng.so:graphics/png \ libsnappy.so:archivers/snappy \ libabsl_base.so:devel/abseil \ libsqlite3.so:databases/sqlite3 \ @@ -54,7 +53,9 @@ RUN_DEPENDS= pybind11>=2.6.2:devel/pybind11 \ ${PYTHON_PKGNAMEPREFIX}termcolor>=1.1.0:devel/py-termcolor@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}typing-extensions>=3.6.6:devel/py-typing-extensions@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}wrapt>=1.11.0:devel/py-wrapt@${PY_FLAVOR} \ - ${PYTHON_PKGNAMEPREFIX}grpcio>=1.24.3:devel/py-grpcio@${PY_FLAVOR} + ${PYTHON_PKGNAMEPREFIX}grpcio>=1.24.3:devel/py-grpcio@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}ml-dtypes>=0.3.1:math/py-ml-dtypes@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}opt-einsum>=3.3.0:math/py-opt-einsum@${PY_FLAVOR} USES= java jpeg perl5 python shebangfix ssl JAVA_VERSION= 21 @@ -72,7 +73,7 @@ OPTIONS_DEFINE= CPU_OPTS XLA OPTIONS_RADIO= PARALLEL_JOBS OPTIONS_RADIO_PARALLEL_JOBS= JOBS_1 JOBS_HALF JOBS_ALL PARALLEL_JOBS_DESC= How many jobs to run during build? -OPTIONS_DEFAULT= JOBS_HALF +OPTIONS_DEFAULT= JOBS_ALL JOBS_1_DESC= Run one job JOBS_1_VARS= TF_JOBS_NUMBER=1 @@ -135,6 +136,7 @@ post-patch: @${REINPLACE_CMD} "s#%%BAZEL_DIR%%#${WRKDIR}#" ${WRKDIR}/bazelrc @${REINPLACE_CMD} "s#%%BAZEL_DIST%%#${WRKDIR}#" ${WRKDIR}/bazelrc + @${REINPLACE_CMD} "s#%%WRKSRC%%#${WRKSRC}#" ${WRKDIR}/bazelrc @${REINPLACE_CMD} "s#%%JAVA_HOME%%#${JAVA_HOME}#" ${WRKDIR}/bazelrc # copy the toolchain over @@ -156,11 +158,23 @@ post-patch: ${WRKSRC}/WORKSPACE # Fix Python runtime headers: replace rules_python CC toolchain alias with - # a direct cc_library pointing to the system Python headers. + # a direct cc_library using a symlink to the system Python headers. @${REINPLACE_CMD} \ "s|%%PYTHON_INCLUDEDIR%%|${PYTHON_INCLUDEDIR}|g" \ - ${WRKDIR}/bazelrc \ - ${WRKSRC}/third_party/xla/third_party/python_runtime/BUILD.bazel + ${WRKDIR}/bazelrc + @${CP} ${PATCHDIR}/pthreadpool-freebsd-alloca.patch \ + ${WRKSRC}/third_party/xla/third_party/pthreadpool/freebsd_alloca.patch + @${CP} ${PATCHDIR}/xnnpack-freebsd-mmap.patch \ + ${WRKSRC}/third_party/xla/third_party/xnnpack/freebsd_mmap.patch + @${CP} ${PATCHDIR}/protobuf-freebsd-upb.patch \ + ${WRKSRC}/third_party/xla/third_party/protobuf/freebsd_upb.patch + @${CP} ${PATCHDIR}/cpuinfo-freebsd-alwayslink.patch \ + ${WRKSRC}/third_party/cpuinfo/cpuinfo_freebsd_alwayslink.patch + @${CP} ${PATCHDIR}/grpc-no-go-sdk.patch \ + ${WRKSRC}/third_party/xla/third_party/grpc/grpc_no_go.patch + + @${LN} -sf ${PYTHON_INCLUDEDIR} \ + ${WRKSRC}/third_party/xla/third_party/python_runtime/python_include # Create pypi hub stub (FreeBSD has no platform wheels in requirements_lock) @${MKDIR} ${WRKSRC}/bazel_pypi_hub @@ -169,12 +183,13 @@ post-patch: @${PRINTF} 'def install_deps(**kwargs):\n pass\n' \ > ${WRKSRC}/bazel_pypi_hub/requirements.bzl @${TOUCH} ${WRKSRC}/bazel_pypi_hub/WORKSPACE -.for _pypi_pkg in absl_py astor astunparse dill flatbuffers gast h5py jax \ +.for _pypi_pkg in absl_py astor astunparse auditwheel dill flatbuffers gast h5py jax \ keras lit ml_dtypes opt_einsum packaging portpicker protobuf requests \ scipy setuptools tblib termcolor typing_extensions wheel wrapt zstandard @${MKDIR} ${WRKSRC}/bazel_pypi_hub/${_pypi_pkg} @${PRINTF} 'package(default_visibility = ["//visibility:public"])\npy_library(name = "pkg", srcs = [])\npy_library(name = "lib", srcs = [])\npy_library(name = "whl", srcs = [])\nalias(name = "${_pypi_pkg}", actual = ":pkg")\n' \ > ${WRKSRC}/bazel_pypi_hub/${_pypi_pkg}/BUILD.bazel + @${TOUCH} ${WRKSRC}/bazel_pypi_hub/${_pypi_pkg}/WORKSPACE .endfor # numpy needs extra cc_library for numpy_headers used by C++ deps @${MKDIR} ${WRKSRC}/bazel_pypi_hub/numpy @@ -187,6 +202,7 @@ post-patch: ${WRKSRC}/bazel_pypi_hub/numpy/site-packages/numpy/core/include @${PRINTF} 'package(default_visibility = ["//visibility:public"])\npy_library(name = "pkg", srcs = [])\npy_library(name = "lib", srcs = [])\nalias(name = "numpy", actual = ":pkg")\ncc_library(\n name = "numpy_headers",\n hdrs = glob(["include/**/*.h"]),\n includes = ["include"],\n)\n' \ > ${WRKSRC}/bazel_pypi_hub/numpy/BUILD.bazel + @${TOUCH} ${WRKSRC}/bazel_pypi_hub/numpy/WORKSPACE do-configure: @cd ${WRKSRC} && ${SETENV} \ @@ -208,7 +224,7 @@ do-configure: TF_IGNORE_MAX_BAZEL_VERSION=1 \ CC_OPT_FLAGS="-march=${CPU_TARGET} -I${LOCALBASE}/include" \ PREFIX="${LOCALBASE}" \ - TF_SYSTEM_LIBS="astor_archive astunparse_archive boringssl com_github_googlecloudplatform_google_cloud_cpp com_github_grpc_grpc \ + TF_SYSTEM_LIBS="astor_archive astunparse_archive boringssl com_github_googlecloudplatform_google_cloud_cpp \ com_googlesource_code_re2 curl cython dill_archive functools32_archive gast_archive \ gif hwloc icu jsoncpp_git libjpeg_turbo nasm org_sqlite pasta png pybind11 six_archive snappy \ tblib_archive termcolor_archive typing_extensions_archive wrapt zlib" \ @@ -273,4 +289,18 @@ post-install: # autoplist: thousands of files, all under ${PYTHON_SITELIBDIR} @cd ${STAGEDIR}${PREFIX} && \ ${FIND} ${PYTHON_SITELIBDIR:C|^${LOCALBASE}/||} -type f -or -type l | ${GREP} -v "egg-info/" >> ${TMPPLIST} +do-test: + @cd ${WRKSRC} && \ + bazel --bazelrc="${WRKDIR}/bazelrc" ${BAZEL_BOOT} test \ + --jobs ${TF_JOBS_NUMBER} ${BAZEL_COPT} --host_copt="-I${LOCALBASE}/include" \ + --host_linkopt="-L${LOCALBASE}/lib -lexecinfo" ${BAZEL_LINKOPT} --copt="-I${LOCALBASE}/include" \ + --verbose_failures \ + --distdir=${WRKDIR}/bazel-dist \ + --test_output=errors \ + //tensorflow/python/... + +do-test-quick: build + @cd ${TEST_WRKSRC} && \ + ${SETENV} ${TEST_ENV} ${PYTHON_CMD} ${FILESDIR}/example-quick-training.py + .include diff --git a/science/py-tensorflow/Makefile.MASTER_SITES b/science/py-tensorflow/Makefile.MASTER_SITES index 0334204a5130..d9093e42d786 100644 --- a/science/py-tensorflow/Makefile.MASTER_SITES +++ b/science/py-tensorflow/Makefile.MASTER_SITES @@ -70,7 +70,26 @@ clang+llvm-18.1.8-x86_64-linux-gnu-ubuntu-18.04.tar.xz:clang18 \ x86_64_ubuntu18_gcc8.4-0.2.1.tar.xz:gcc_sysroot \ cpython-3.11.13+20250808-x86_64-unknown-linux-gnu-install_only.tar.gz:cpython311 \ libtinfo.so.5:libtinfo \ -copyright.txt:libtinfo_cp +copyright.txt:libtinfo_cp \ +v1.74.0.tar.gz:grpc_src \ +28e9d1f26771c6517c3b4be10254887673c940189.zip:googletest_src \ +4de3c74cf21a9958c1cf26d8993c55c6e0d28b49.tar.gz:envoy_api_src \ +v1.2.1.zip:protoc_gen_validate_src \ +bazel-gazelle-v0.37.0.tar.gz:bazel_gazelle_src \ +rules_java-8.7.0.tar.gz:rules_java_870 \ +7.0.2.tar.gz:rules_proto_702 \ +v2.35.0.tar.gz:google_cloud_cpp_src \ +d198303a4319092ab31895c4b98d64174ebe8872.tar.gz:bazel_compdb_src \ +6360e96b5cf8e5980c887ce58ef727e53d77243a.tar.gz:c_ares_src \ +3a472e524827f72d1ad621c4983dd5af54c46776.tar.gz:cncf_xds_src \ +12235e24652fc7f809373e7c11a5f73c5763fc4c.tar.gz:benchmark \ +1f95f8083066f5b38fd2db172e7e7f9aa7c49d2d.tar.gz:libprotobuf_mutator_src \ +5501a1a255805e0be83a41348bb5f2630d5ed6b3.tar.gz:opencensus_cpp_src \ +ced79860f8c8a091a2eabfee6d47783f828a9b59.tar.gz:opentelemetry_cpp_src \ +v0.3.0.tar.gz:opencensus_proto_src \ +rules_cc-0.0.17.tar.gz:rules_cc_017 \ +rules_shell-v0.3.0.tar.gz:rules_shell_030 \ +0.8.0.tar.gz:yaml_cpp_src MASTER_SITES+=https://github.com/bazelbuild/platforms/releases/download/0.0.11/:platforms \ https://github.com/bazelbuild/apple_support/releases/download/1.24.5/:apple \ @@ -144,4 +163,22 @@ https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.8/:clang18 \ https://storage.googleapis.com/ml-sysroot-testing/x86_64/:gcc_sysroot \ https://github.com/astral-sh/python-build-standalone/releases/download/20250808/:cpython311 \ https://storage.googleapis.com/ml-sysroot-testing/libtinfo/:libtinfo \ -https://storage.googleapis.com/ml-sysroot-testing/libtinfo/:libtinfo_cp +https://storage.googleapis.com/ml-sysroot-testing/libtinfo/:libtinfo_cp \ +https://github.com/grpc/grpc/archive/refs/tags/:grpc_src \ +https://github.com/google/googletest/archive/:googletest_src \ +https://github.com/envoyproxy/data-plane-api/archive/:envoy_api_src \ +https://github.com/bufbuild/protoc-gen-validate/archive/refs/tags/:protoc_gen_validate_src \ +https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.37.0/:bazel_gazelle_src \ +https://github.com/bazelbuild/rules_java/releases/download/8.7.0/:rules_java_870 \ +https://github.com/bazelbuild/rules_proto/archive/refs/tags/:rules_proto_702 \ +https://github.com/googleapis/google-cloud-cpp/archive/refs/tags/:google_cloud_cpp_src \ +https://github.com/grailbio/bazel-compilation-database/archive/:bazel_compdb_src \ +https://github.com/c-ares/c-ares/archive/:c_ares_src \ +https://github.com/cncf/xds/archive/:cncf_xds_src \ +https://github.com/google/libprotobuf-mutator/archive/:libprotobuf_mutator_src \ +https://github.com/census-instrumentation/opencensus-cpp/archive/:opencensus_cpp_src \ +https://github.com/open-telemetry/opentelemetry-cpp/archive/:opentelemetry_cpp_src \ +https://github.com/census-instrumentation/opencensus-proto/archive/refs/tags/:opencensus_proto_src \ +https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/:rules_cc_017 \ +https://github.com/bazelbuild/rules_shell/releases/download/v0.3.0/:rules_shell_030 \ +https://github.com/jbeder/yaml-cpp/archive/refs/tags/:yaml_cpp_src diff --git a/science/py-tensorflow/distinfo b/science/py-tensorflow/distinfo index 604e0177f7fa..7c068e226d83 100644 --- a/science/py-tensorflow/distinfo +++ b/science/py-tensorflow/distinfo @@ -147,3 +147,42 @@ SHA256 (tensorflow/libtinfo.so.5) = 12cffc7274190ca1693a52ccd8303e719407e707c855 SIZE (tensorflow/libtinfo.so.5) = 170784 SHA256 (tensorflow/copyright.txt) = 5e8ee902c8906ddb7779fd36dc9979cb08b51fbebf7c0b1a9aeb78af382af590 SIZE (tensorflow/copyright.txt) = 6366 + +SHA256 (tensorflow/v1.74.0.tar.gz) = dd6a2fa311ba8441bbefd2764c55b99136ff10f7ea42954be96006a2723d33fc +SIZE (tensorflow/v1.74.0.tar.gz) = 15014902 +SHA256 (tensorflow/28e9d1f26771c6517c3b4be10254887673c940189.zip) = f253ca1a07262f8efde8328e4b2c68979e40ddfcfc001f70d1d5f612c7de2974 +SIZE (tensorflow/28e9d1f26771c6517c3b4be10254887673c940189.zip) = 1136851 +SHA256 (tensorflow/4de3c74cf21a9958c1cf26d8993c55c6e0d28b49.tar.gz) = cd8b49614408b43bd45d90e3e98d69e24eea632ff42ac3bfb8bca68bc31e377f +SIZE (tensorflow/4de3c74cf21a9958c1cf26d8993c55c6e0d28b49.tar.gz) = 697162 +SHA256 (tensorflow/v1.2.1.zip) = ab51e978326b87e06be7a12fc6496f3ff6586339043557dbbd31f622332a5d45 +SIZE (tensorflow/v1.2.1.zip) = 306941 +SHA256 (tensorflow/bazel-gazelle-v0.37.0.tar.gz) = d76bf7a60fd8b050444090dfa2837a4eaf9829e1165618ee35dceca5cbdf58d5 +SIZE (tensorflow/bazel-gazelle-v0.37.0.tar.gz) = 1815577 +SHA256 (tensorflow/rules_java-8.7.0.tar.gz) = 5449ed36d61269579dd9f4b0e532cd131840f285b389b3795ae8b4d717387dd8 +SIZE (tensorflow/rules_java-8.7.0.tar.gz) = 112619 +SHA256 (tensorflow/7.0.2.tar.gz) = 0e5c64a2599a6e26c6a03d6162242d231ecc0de219534c38cb4402171def21e8 +SIZE (tensorflow/7.0.2.tar.gz) = 48590 +SHA256 (tensorflow/v2.35.0.tar.gz) = 81ea28cf9e5bb032d356b0187409f30b1035f8ea5b530675ea248c8a6c0070aa +SIZE (tensorflow/v2.35.0.tar.gz) = 15773128 +SHA256 (tensorflow/d198303a4319092ab31895c4b98d64174ebe8872.tar.gz) = 79502264d1a3a4b6309d4dae8c822e7349bcfe33e84f3c6d1affb2a40d11a31d +SIZE (tensorflow/d198303a4319092ab31895c4b98d64174ebe8872.tar.gz) = 16045 +SHA256 (tensorflow/6360e96b5cf8e5980c887ce58ef727e53d77243a.tar.gz) = bf26e5b25e259911914a85ae847b6d723488adb5af4f8bdeb9d0871a318476e3 +SIZE (tensorflow/6360e96b5cf8e5980c887ce58ef727e53d77243a.tar.gz) = 778663 +SHA256 (tensorflow/3a472e524827f72d1ad621c4983dd5af54c46776.tar.gz) = dc305e20c9fa80822322271b50aa2ffa917bf4fd3973bcec52bfc28dc32c5927 +SIZE (tensorflow/3a472e524827f72d1ad621c4983dd5af54c46776.tar.gz) = 104469 +SHA256 (tensorflow/12235e24652fc7f809373e7c11a5f73c5763fc4c.tar.gz) = 11f344710a80fd73db0fc686b4fe40867dc34d914d9cdfd7a4b416a65d1e692f +SIZE (tensorflow/12235e24652fc7f809373e7c11a5f73c5763fc4c.tar.gz) = 254083 +SHA256 (tensorflow/1f95f8083066f5b38fd2db172e7e7f9aa7c49d2d.tar.gz) = 9c8f800aed088cdf89adc3eaaa66b56b4da7da041f26338aa71a2ab43d860d46 +SIZE (tensorflow/1f95f8083066f5b38fd2db172e7e7f9aa7c49d2d.tar.gz) = 41620 +SHA256 (tensorflow/5501a1a255805e0be83a41348bb5f2630d5ed6b3.tar.gz) = 46b3b5812c150a21bacf860c2f76fc42b89773ed77ee954c32adeb8593aa2a8e +SIZE (tensorflow/5501a1a255805e0be83a41348bb5f2630d5ed6b3.tar.gz) = 191703 +SHA256 (tensorflow/ced79860f8c8a091a2eabfee6d47783f828a9b59.tar.gz) = a85a22521de7426c3e019d50e18d0af16e0391e0353923308eb168b3e624aea1 +SIZE (tensorflow/ced79860f8c8a091a2eabfee6d47783f828a9b59.tar.gz) = 1048635 +SHA256 (tensorflow/v0.3.0.tar.gz) = b7e13f0b4259e80c3070b583c2f39e53153085a6918718b1c710caf7037572b0 +SIZE (tensorflow/v0.3.0.tar.gz) = 163404 +SHA256 (tensorflow/rules_cc-0.0.17.tar.gz) = abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1 +SIZE (tensorflow/rules_cc-0.0.17.tar.gz) = 178823 +SHA256 (tensorflow/rules_shell-v0.3.0.tar.gz) = d8cd4a3a91fc1dc68d4c7d6b655f09def109f7186437e3f50a9b60ab436a0c53 +SIZE (tensorflow/rules_shell-v0.3.0.tar.gz) = 22046 +SHA256 (tensorflow/0.8.0.tar.gz) = fbe74bbdcee21d656715688706da3c8becfd946d92cd44705cc6098bb23b3a16 +SIZE (tensorflow/0.8.0.tar.gz) = 1017151 diff --git a/science/py-tensorflow/files/bazelrc b/science/py-tensorflow/files/bazelrc index f63c64a60da6..eead349e0876 100644 --- a/science/py-tensorflow/files/bazelrc +++ b/science/py-tensorflow/files/bazelrc @@ -15,6 +15,29 @@ build --noincompatible_disallow_unsound_directory_outputs fetch --repository_cache="%%BAZEL_DIR%%/bazel-cache/" --distdir="%%BAZEL_DIST%%/bazel-dist/" build --repository_cache="%%BAZEL_DIR%%/bazel-cache/" --distdir="%%BAZEL_DIST%%/bazel-dist/" +# Override @pypi hub and individual @pypi_* repos with offline stubs +# (FreeBSD has no platform wheels in requirements_lock; stubs point to system packages) +build --override_repository=pypi=%%WRKSRC%%/bazel_pypi_hub +fetch --override_repository=pypi=%%WRKSRC%%/bazel_pypi_hub +build --override_repository=pypi_absl_py=%%WRKSRC%%/bazel_pypi_hub/absl_py +build --override_repository=pypi_astunparse=%%WRKSRC%%/bazel_pypi_hub/astunparse +build --override_repository=pypi_auditwheel=%%WRKSRC%%/bazel_pypi_hub/auditwheel +build --override_repository=pypi_flatbuffers=%%WRKSRC%%/bazel_pypi_hub/flatbuffers +build --override_repository=pypi_gast=%%WRKSRC%%/bazel_pypi_hub/gast +build --override_repository=pypi_keras=%%WRKSRC%%/bazel_pypi_hub/keras +build --override_repository=pypi_lit=%%WRKSRC%%/bazel_pypi_hub/lit +build --override_repository=pypi_ml_dtypes=%%WRKSRC%%/bazel_pypi_hub/ml_dtypes +build --override_repository=pypi_numpy=%%WRKSRC%%/bazel_pypi_hub/numpy +build --override_repository=pypi_opt_einsum=%%WRKSRC%%/bazel_pypi_hub/opt_einsum +build --override_repository=pypi_packaging=%%WRKSRC%%/bazel_pypi_hub/packaging +build --override_repository=pypi_protobuf=%%WRKSRC%%/bazel_pypi_hub/protobuf +build --override_repository=pypi_requests=%%WRKSRC%%/bazel_pypi_hub/requests +build --override_repository=pypi_setuptools=%%WRKSRC%%/bazel_pypi_hub/setuptools +build --override_repository=pypi_termcolor=%%WRKSRC%%/bazel_pypi_hub/termcolor +build --override_repository=pypi_typing_extensions=%%WRKSRC%%/bazel_pypi_hub/typing_extensions +build --override_repository=pypi_wheel=%%WRKSRC%%/bazel_pypi_hub/wheel +build --override_repository=pypi_wrapt=%%WRKSRC%%/bazel_pypi_hub/wrapt + build --define=PREFIX=%%LOCALBASE%% build --define=LIBDIR=%%LOCALBASE%%/lib build --define=INCLUDEDIR=%%LOCALBASE%%/include @@ -26,6 +49,7 @@ build --define tensorflow_mkldnn_contraction_kernel=0 build --action_env=BAZEL_CXXOPTS="-std=c++17" build --extra_toolchains=//freebsd:cc-toolchain-freebsd +build --extra_toolchains=//freebsd:python_cc_toolchain build --linkopt="-lexecinfo" --toolchain_resolution_debug=//freebsd:freebsd_clang # backtrace() is in libexecinfo on FreeBSD; needed for both target and exec builds. build --host_linkopt=-L%%LOCALBASE%%/lib @@ -34,9 +58,19 @@ build --host_linkopt=-lhwloc # System and Python headers for both target and host (tool) builds. # copts in cc_library don't propagate to dependents so we set these globally. +# _XOPEN_SOURCE=700 enables XSI extensions (isascii, etc.) even when per-file +# code defines _POSIX_C_SOURCE. +# __BSD_VISIBLE=1 enables BSD extensions (syscall, MAP_ANON, etc.). FreeBSD's +# _visible.h never resets __BSD_VISIBLE to 0 in the _XOPEN_SOURCE or +# _POSIX_C_SOURCE paths (only in _ANSI_SOURCE/_C99_SOURCE paths), so the +# command-line definition persists. +build --host_copt=-D_XOPEN_SOURCE=700 +build --host_copt=-D__BSD_VISIBLE=1 build --host_copt=-isystem%%LOCALBASE%%/include build --host_copt=-isystem%%PYTHON_INCLUDEDIR%% build --host_copt=-isystem%%NUMPY_INCLUDEDIR%% +build --copt=-D_XOPEN_SOURCE=700 +build --copt=-D__BSD_VISIBLE=1 build --copt=-isystem%%LOCALBASE%%/include build --copt=-isystem%%PYTHON_INCLUDEDIR%% build --copt=-isystem%%NUMPY_INCLUDEDIR%% @@ -59,8 +93,6 @@ build --host_action_env=KERAS_HOME="%%BAZEL_DIST%%/.keras" build --repo_env=JAVA_HOME=%%JAVA_HOME%% build --action_env=JAVA_HOME=%%JAVA_HOME%% -build --config=freebsd - # Limit parallel actions to avoid OOM on large files like LLVMDialect.cpp build --local_ram_resources=HOST_RAM*.7 build --local_cpu_resources=HOST_CPUS-4 diff --git a/science/py-tensorflow/files/cpuinfo-freebsd-alwayslink.patch b/science/py-tensorflow/files/cpuinfo-freebsd-alwayslink.patch new file mode 100644 index 000000000000..7423f274a523 --- /dev/null +++ b/science/py-tensorflow/files/cpuinfo-freebsd-alwayslink.patch @@ -0,0 +1,11 @@ +diff --git a/BUILD.bazel b/BUILD.bazel +--- a/BUILD.bazel ++++ b/BUILD.bazel +@@ -182,6 +182,7 @@ + ":macos_x86_64_legacy": False, + "//conditions:default": True, + }), ++ alwayslink = True, + # Headers must be in textual_hdrs to allow us to set the standard to C99 + textual_hdrs = [ + "include/cpuinfo.h", diff --git a/science/py-tensorflow/files/example-quick-training.py b/science/py-tensorflow/files/example-quick-training.py new file mode 100644 index 000000000000..3d69ae98cf9d --- /dev/null +++ b/science/py-tensorflow/files/example-quick-training.py @@ -0,0 +1,25 @@ +import tensorflow as tf + +# 1. Load and prepare the MNIST dataset +mnist = tf.keras.datasets.mnist +(x_train, y_train), (x_test, y_test) = mnist.load_data() +x_train, x_test = x_train / 255.0, x_test / 255.0 # Normalize pixel values + +# 2. Build the Sequential model +model = tf.keras.models.Sequential([ + tf.keras.layers.Flatten(input_shape=(28, 28)), # Flatten 2D image to 1D array + tf.keras.layers.Dense(128, activation='relu'), # Hidden layer with ReLU activation + tf.keras.layers.Dropout(0.2), # Regularization to prevent overfitting + tf.keras.layers.Dense(10) # Output layer for 10 classes +]) + +# 3. Compile the model +model.compile(optimizer='adam', + loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True), + metrics=['accuracy']) + +# 4. Train the model +model.fit(x_train, y_train, epochs=5) + +# 5. Evaluate accuracy +model.evaluate(x_test, y_test, verbose=2) diff --git a/science/py-tensorflow/files/fix-llvm-config.py b/science/py-tensorflow/files/fix-llvm-config.py index 6b3757662c9d..d8e336d9b5b3 100644 --- a/science/py-tensorflow/files/fix-llvm-config.py +++ b/science/py-tensorflow/files/fix-llvm-config.py @@ -1,17 +1,21 @@ #!/usr/bin/env python3 -"""Patch LLVM config.bzl to use @platforms//os:freebsd condition.""" +"""Patch LLVM config.bzl to use @platforms//os:freebsd condition (idempotent).""" import os import sys f = sys.argv[1] r = os.path.realpath(f) c = open(r).read() +# Replace old-style condition (idempotent: only matches original) c = c.replace( '"@bazel_tools//src/conditions:freebsd": posix_defines,', '"@platforms//os:freebsd": posix_defines,') -c = c.replace( - '"//conditions:default": native_arch_defines("X86", "x86_64-unknown-linux-gnu"),', - '"@platforms//os:freebsd": native_arch_defines("X86", "x86_64-unknown-freebsd14-elf"),\n' - ' "//conditions:default": native_arch_defines("X86", "x86_64-unknown-linux-gnu"),') +# Add FreeBSD arch defines if not already present +freebsd_arch = ('"@platforms//os:freebsd": native_arch_defines("X86", "x86_64-unknown-freebsd14-elf"),\n' + ' "//conditions:default": native_arch_defines("X86", "x86_64-unknown-linux-gnu"),') +if '"@platforms//os:freebsd": native_arch_defines' not in c: + c = c.replace( + '"//conditions:default": native_arch_defines("X86", "x86_64-unknown-linux-gnu"),', + freebsd_arch) os.chmod(r, 0o644) open(r, 'w').write(c) diff --git a/science/py-tensorflow/files/freebsd/BUILD b/science/py-tensorflow/files/freebsd/BUILD index 116c8428aee9..04a5fda857fd 100644 --- a/science/py-tensorflow/files/freebsd/BUILD +++ b/science/py-tensorflow/files/freebsd/BUILD @@ -86,3 +86,24 @@ toolchain( toolchain_type = "@bazel_tools//tools/python:toolchain_type", ) +load("@rules_python//python/cc:py_cc_toolchain.bzl", "py_cc_toolchain") + +# Python C/C++ headers toolchain for FreeBSD (satisfies @rules_python//python/cc:toolchain_type) +py_cc_toolchain( + name = "python_cc_toolchain_impl", + headers = "@xla//third_party/python_runtime:headers", + python_version = "3.11", +) + +toolchain( + name = "python_cc_toolchain", + exec_compatible_with = [ + "@platforms//os:freebsd", + ], + target_compatible_with = [ + "@platforms//os:freebsd", + ], + toolchain = ":python_cc_toolchain_impl", + toolchain_type = "@rules_python//python/cc:toolchain_type", +) + diff --git a/science/py-tensorflow/files/freebsd/compat_include/alloca.h b/science/py-tensorflow/files/freebsd/compat_include/alloca.h new file mode 100644 index 000000000000..4b475cdea825 --- /dev/null +++ b/science/py-tensorflow/files/freebsd/compat_include/alloca.h @@ -0,0 +1,4 @@ +#ifndef _ALLOCA_H +#define _ALLOCA_H +#include +#endif diff --git a/science/py-tensorflow/files/grpc-no-go-sdk.patch b/science/py-tensorflow/files/grpc-no-go-sdk.patch new file mode 100644 index 000000000000..cef295cd5ed8 --- /dev/null +++ b/science/py-tensorflow/files/grpc-no-go-sdk.patch @@ -0,0 +1,34 @@ +diff --git a/bazel/grpc_extra_deps.bzl b/bazel/grpc_extra_deps.bzl +--- a/bazel/grpc_extra_deps.bzl ++++ b/bazel/grpc_extra_deps.bzl +@@ -14,16 +14,13 @@ + """Loads the dependencies necessary for the external repositories defined in grpc_deps.bzl.""" + + load("@bazel_features//:deps.bzl", "bazel_features_deps") +-load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") + load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies") + load("@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies") +-load("@com_envoyproxy_protoc_gen_validate//:dependencies.bzl", "go_third_party") + load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language") + load("@com_google_googletest//:googletest_deps.bzl", "googletest_deps") + load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") + load("@envoy_api//bazel:repositories.bzl", "api_dependencies") + load("@google_cloud_cpp//bazel:google_cloud_cpp_deps.bzl", "google_cloud_cpp_deps") +-load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") + load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies") + load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies") + load("@rules_python//python:repositories.bzl", "py_repositories") +@@ -64,13 +61,7 @@ + + api_dependencies() + +- go_rules_dependencies() +- go_register_toolchains(version = "1.22.5") +- gazelle_dependencies() + +- # Pull-in the go 3rd party dependencies for protoc_gen_validate, which is +- # needed for building C++ xDS protos +- go_third_party() + + apple_rules_dependencies(ignore_version_differences = ignore_version_differences) + diff --git a/science/py-tensorflow/files/patch-.bazelrc b/science/py-tensorflow/files/patch-.bazelrc deleted file mode 100644 index 591a60488da1..000000000000 --- a/science/py-tensorflow/files/patch-.bazelrc +++ /dev/null @@ -1,23 +0,0 @@ ---- .bazelrc.orig2025-01-01 00:00:00 UTC -+++ .bazelrc -@@ -178,6 +178,20 @@ common:clang_local --repo_env USE_HERMETIC_CC_TOOLCHAIN=0 - # Print a stacktrace when a test is killed - test --test_env="GTEST_INSTALL_FAILURE_SIGNAL_HANDLER=1" - -+# Use our custom-configured c++ toolchain. -+# Use --cpu as a differentiator. -+build:freebsd --cpu=freebsd -+ -+# Use the default Bazel C++ toolchain to build the tools used during the -+# build. -+build:freebsd --crosstool_top=//freebsd:freebsd_clang -+build:freebsd --linkopt=-L%%LOCALBASE%%/lib -+ -+build:freebsd --define build_with_onednn_v2=true -+build:freebsd --define force_libcpp=enabled -+build:freebsd --action_env=CXXFLAGS=-stdlib=libc++ -+build:freebsd --noincompatible_enable_cc_toolchain_resolution -+ - - # Default options should come above this line. - diff --git a/science/py-tensorflow/files/patch-WORKSPACE b/science/py-tensorflow/files/patch-WORKSPACE deleted file mode 100644 index b3990a3ca56b..000000000000 --- a/science/py-tensorflow/files/patch-WORKSPACE +++ /dev/null @@ -1,125 +0,0 @@ ---- WORKSPACE.orig -+++ WORKSPACE -@@ -95,6 +95,122 @@ - install_deps() - # End hermetic Python initialization - -+# FreeBSD: Register the rules_python runtime_env py_cc_toolchain so that -+# @@rules_python//python/cc:current_py_cc_headers can be built. -+# This toolchain uses empty headers/libs (system Python) and satisfies -+# the PY_CC_TOOLCHAIN_TYPE requirement without hermetic Python. -+register_toolchains("@rules_python//python/runtime_env_toolchains:runtime_env_py_cc_toolchain") -+ -+# FreeBSD: Register protobuf Python toolchain needed for py_proto_library. -+register_toolchains("@com_google_protobuf//bazel/private/toolchains:python_source_toolchain") -+ -+# FreeBSD: Register runtime_env_toolchain as fallback for @rules_python//python:toolchain_type. -+# On FreeBSD the exec platform is detected as "freebsd" (not "linux"), so none of the -+# hermetic python_3_11_toolchains match. This toolchain uses a shell script to locate -+# python3 at action-runtime via PATH, which resolves to /usr/local/bin/python3.11 in -+# both local and poudriere-jail builds. It is registered after python_init_toolchains() -+# so it only applies when no platform-specific toolchain matches. -+register_toolchains("@rules_python//python/runtime_env_toolchains:runtime_env_toolchain") -+ -+# FreeBSD: stub repositories for old-style @pypi_* deps -+# (these are not created by pip_parse on FreeBSD due to missing platform wheels) -+new_local_repository( -+ name = "pypi_keras", -+ path = "bazel_pypi_hub/keras", -+ build_file_content = """package(default_visibility=["//visibility:public"]) -+py_library(name="pkg",srcs=[]) -+""", -+) -+ -+new_local_repository( -+ name = "pypi_setuptools", -+ path = "bazel_pypi_hub/setuptools", -+ build_file_content = """package(default_visibility=["//visibility:public"]) -+py_library(name="pkg",srcs=[]) -+""", -+) -+ -+new_local_repository( -+ name = "pypi_wheel", -+ path = "bazel_pypi_hub/wheel", -+ build_file_content = """package(default_visibility=["//visibility:public"]) -+py_library(name="pkg",srcs=[]) -+""", -+) -+ -+new_local_repository( -+ name = "pypi_packaging", -+ path = "bazel_pypi_hub/packaging", -+ build_file_content = """package(default_visibility=["//visibility:public"]) -+py_library(name="pkg",srcs=[]) -+""", -+) -+ -+new_local_repository( -+ name = "pypi_absl_py", -+ path = "bazel_pypi_hub/absl_py", -+ build_file_content = """package(default_visibility=["//visibility:public"]) -+py_library(name="pkg",srcs=[]) -+""", -+) -+ -+new_local_repository( -+ name = "pypi_protobuf", -+ path = "bazel_pypi_hub/protobuf", -+ build_file_content = """package(default_visibility=["//visibility:public"]) -+py_library(name="pkg",srcs=[]) -+""", -+) -+ -+new_local_repository( -+ name = "pypi_numpy", -+ path = "bazel_pypi_hub/numpy", -+ build_file_content = """package(default_visibility=["//visibility:public"]) -+py_library(name="pkg",srcs=[]) -+""", -+) -+ -+# FreeBSD: Define @system_python for protobuf's proto_api target. -+# The bundled protobuf 6.31.1 uses @system_python//:python_headers in its -+# proto_api cc_library. We provide real Python 3.11 headers here. -+new_local_repository( -+ name = "system_python", -+ path = "%%LOCALBASE%%", -+ build_file_content = -+"""package(default_visibility = ["//visibility:public"]) -+ -+load("@bazel_skylib//rules:common_settings.bzl", "string_flag") -+ -+cc_library( -+ name = "python_headers", -+ includes = ["include/python%%PYTHON_VER%%"], -+ textual_hdrs = [], -+) -+ -+string_flag( -+ name = "internal_python_support", -+ build_setting_default = "Supported", -+ values = ["None", "Supported", "Unsupported"], -+) -+ -+config_setting( -+ name = "none", -+ flag_values = {":internal_python_support": "None"}, -+) -+ -+config_setting( -+ name = "supported", -+ flag_values = {":internal_python_support": "Supported"}, -+) -+ -+config_setting( -+ name = "unsupported", -+ flag_values = {":internal_python_support": "Unsupported"}, -+) -+""", -+) -+ -+ - load("@//tensorflow:workspace2.bzl", "tf_workspace2") - - tf_workspace2() diff --git a/science/py-tensorflow/files/patch-tensorflow_python_BUILD b/science/py-tensorflow/files/patch-tensorflow_python_BUILD new file mode 100644 index 000000000000..af45020d2295 --- /dev/null +++ b/science/py-tensorflow/files/patch-tensorflow_python_BUILD @@ -0,0 +1,48 @@ +--- tensorflow/python/BUILD.orig 2026-03-04 21:33:50 UTC ++++ tensorflow/python/BUILD +@@ -1479,6 +1479,21 @@ pybind_extension( + "//tensorflow/distribute/experimental/rpc/kernels:rpc_ops", + "//tensorflow/dtensor/cc:tensor_layout", + "@xla//xla/backends/profiler/cpu:python_tracer", ++ # Shardy dialect deps: ensure these archives are included in libtensorflow_cc.so.2 ++ # via the pywrap split-library mechanism (they would otherwise be filtered out as ++ # starlark_only, since pywrap_quantization is starlark_only=True). ++ "@shardy//shardy/common:file_utils", ++ "@shardy//shardy/common:logging", ++ "@shardy//shardy/dialect/sdy/ir:axis_list_ref", ++ "@shardy//shardy/dialect/sdy/ir:dialect", ++ "@shardy//shardy/dialect/sdy/transforms/common:op_properties", ++ "@shardy//shardy/dialect/sdy/transforms/common:sharding_walker", ++ "@shardy//shardy/dialect/sdy/transforms/import:passes", ++ "@shardy//shardy/dialect/sdy/transforms/propagation:op_sharding_rule_builder", ++ "@shardy//shardy/dialect/sdy/transforms/propagation:op_sharding_rule_registry", ++ "@shardy//shardy/dialect/sdy/transforms/propagation:sharding_projection", ++ "@shardy//shardy/dialect/sdy/transforms/propagation:utils", ++ "@shardy//shardy/dialect/sdy/transforms/propagation/debugging:source_sharding", + ], + ) + +@@ -1577,6 +1592,11 @@ pywrap_library( + "-ldl", + "-lm", + ], ++ "//tensorflow:freebsd": [ ++ "-lpthread", ++ "-ldl", ++ "-lm", ++ ], + "//conditions:default": [ + "-z defs", + "-lpthread", +@@ -1593,6 +1613,11 @@ pywrap_library( + "-DEFAULTLIB:ntdll.lib", + ], + "//tensorflow:macos": [ ++ "-lpthread", ++ "-ldl", ++ "-lm", ++ ], ++ "//tensorflow:freebsd": [ + "-lpthread", + "-ldl", + "-lm", diff --git a/science/py-tensorflow/files/patch-tensorflow_python__BUILD b/science/py-tensorflow/files/patch-tensorflow_python__BUILD deleted file mode 100644 index 00a1005c4971..000000000000 --- a/science/py-tensorflow/files/patch-tensorflow_python__BUILD +++ /dev/null @@ -1,26 +0,0 @@ ---- tensorflow/python/BUILD.orig 2025-01-01 00:00:00 UTC -+++ tensorflow/python/BUILD -@@ -1573,6 +1573,11 @@ - "tensorflow/tensorflow_framework": select({ - "//tensorflow:windows": [], - "//tensorflow:macos": [ -+ "-lpthread", -+ "-ldl", -+ "-lm", -+ ], -+ "//tensorflow:freebsd": [ - "-lpthread", - "-ldl", - "-lm", -@@ -1597,6 +1602,11 @@ - "-ldl", - "-lm", - ], -+ "//tensorflow:freebsd": [ -+ "-lpthread", -+ "-ldl", -+ "-lm", -+ ], - "//conditions:default": [ - "-z defs", - "-lpthread", diff --git a/science/py-tensorflow/files/patch-tensorflow_tf__version__script.lds b/science/py-tensorflow/files/patch-tensorflow_tf__version__script.lds new file mode 100644 index 000000000000..f4b62cd230fd --- /dev/null +++ b/science/py-tensorflow/files/patch-tensorflow_tf__version__script.lds @@ -0,0 +1,20 @@ +--- tensorflow/tf_version_script.lds.orig 2026-04-03 18:07:06 UTC ++++ tensorflow/tf_version_script.lds +@@ -18,12 +18,11 @@ tensorflow { + *TFL*; + *TfLite*; + *quantization*; +- *mlir*detail*; +- *mlir*func*; +- *mlir*TF*; +- *mlir*shape*; +- *mlir*scf*; +- *mlir*quant*; ++ *mlir*; ++ *llvm*; ++ *LLVM*; ++ *cpuinfo*; ++ *ducc0*; + local: + *; + }; diff --git a/science/py-tensorflow/files/patch-tensorflow_tools_pip__package_BUILD b/science/py-tensorflow/files/patch-tensorflow_tools_pip__package_BUILD index f9ffad3a0162..42cf2c1a234c 100644 --- a/science/py-tensorflow/files/patch-tensorflow_tools_pip__package_BUILD +++ b/science/py-tensorflow/files/patch-tensorflow_tools_pip__package_BUILD @@ -1,6 +1,6 @@ ---- tensorflow/tools/pip_package/BUILD.orig 2026-03-22 23:01:32.877130000 -0700 -+++ tensorflow/tools/pip_package/BUILD 2026-03-22 23:01:32.877162000 -0700 -@@ -323,12 +323,14 @@ +--- tensorflow/tools/pip_package/BUILD.orig 2026-03-04 21:33:50 UTC ++++ tensorflow/tools/pip_package/BUILD +@@ -323,12 +323,14 @@ tf_wheel( "@platforms//os:macos": "macosx", "@platforms//os:windows": "win", "@platforms//os:linux": "linux", diff --git a/science/py-tensorflow/files/patch-tensorflow_tools_pip__package_build__pip__package.py b/science/py-tensorflow/files/patch-tensorflow_tools_pip__package_build__pip__package.py index b2253989dfec..8d6ee8eb4201 100644 --- a/science/py-tensorflow/files/patch-tensorflow_tools_pip__package_build__pip__package.py +++ b/science/py-tensorflow/files/patch-tensorflow_tools_pip__package_build__pip__package.py @@ -1,6 +1,24 @@ ---- tensorflow/tools/pip_package/build_pip_package.py.orig 2025-01-01 00:00:00 UTC +--- tensorflow/tools/pip_package/build_pip_package.py.orig 2026-04-04 07:32:44 UTC +++ tensorflow/tools/pip_package/build_pip_package.py -@@ -397,6 +397,12 @@ +@@ -33,11 +33,12 @@ import tempfile + import sys + import tempfile + +-from tensorflow.tools.pip_package.utils.utils import copy_file +-from tensorflow.tools.pip_package.utils.utils import create_init_files +-from tensorflow.tools.pip_package.utils.utils import is_macos +-from tensorflow.tools.pip_package.utils.utils import is_windows +-from tensorflow.tools.pip_package.utils.utils import replace_inplace ++sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) ++from utils.utils import copy_file ++from utils.utils import create_init_files ++from utils.utils import is_macos ++from utils.utils import is_windows ++from utils.utils import replace_inplace + + + def parse_args() -> argparse.Namespace: +@@ -397,6 +398,12 @@ def create_local_config_python(dst_dir: str) -> None: numpy_include_dir = "external/pypi_numpy/site-packages/numpy/_core/include" if not os.path.exists(numpy_include_dir): numpy_include_dir = "external/pypi_numpy/site-packages/numpy/core/include" @@ -13,8 +31,7 @@ shutil.copytree( numpy_include_dir, os.path.join(dst_dir, "numpy_include"), -@@ -404,5 +410,10 @@ - if is_windows(): +@@ -405,7 +412,12 @@ def create_local_config_python(dst_dir: str) -> None: path = "external/python_*/include" else: path = "external/python_*/include/python*" @@ -25,4 +42,6 @@ + _inc = sysconfig.get_path('include') + if _inc and os.path.exists(_inc): + _python_includes = [_inc] -+ shutil.copytree(_python_includes[0], os.path.join(dst_dir, "python_include")) + + + def build_wheel( diff --git a/science/py-tensorflow/files/patch-tensorflow_tools_pip__package_utils_BUILD b/science/py-tensorflow/files/patch-tensorflow_tools_pip__package_utils_BUILD new file mode 100644 index 000000000000..dd0346b16b3c --- /dev/null +++ b/science/py-tensorflow/files/patch-tensorflow_tools_pip__package_utils_BUILD @@ -0,0 +1,10 @@ +--- tensorflow/tools/pip_package/utils/BUILD.orig 2026-04-04 09:56:19 UTC ++++ tensorflow/tools/pip_package/utils/BUILD +@@ -3,6 +3,7 @@ py_library( + py_library( + name = "py_utils", + srcs = [ ++ "__init__.py", + "utils.py", + ], + ) diff --git a/science/py-tensorflow/files/patch-tensorflow_tools_pip__package_utils____init__.py b/science/py-tensorflow/files/patch-tensorflow_tools_pip__package_utils____init__.py new file mode 100644 index 000000000000..07ebab795373 --- /dev/null +++ b/science/py-tensorflow/files/patch-tensorflow_tools_pip__package_utils____init__.py @@ -0,0 +1,4 @@ +--- tensorflow/tools/pip_package/utils/__init__.py.orig 1970-01-01 00:00:00 UTC ++++ tensorflow/tools/pip_package/utils/__init__.py +@@ -0,0 +1 @@ ++ diff --git a/science/py-tensorflow/files/patch-tensorflow_workspace0.bzl b/science/py-tensorflow/files/patch-tensorflow_workspace0.bzl deleted file mode 100644 index c9404737b914..000000000000 --- a/science/py-tensorflow/files/patch-tensorflow_workspace0.bzl +++ /dev/null @@ -1,18 +0,0 @@ ---- tensorflow/workspace0.bzl.orig -+++ tensorflow/workspace0.bzl -@@ -5,7 +5,6 @@ - load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies") - load("@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies") - load("@build_bazel_rules_swift//swift:repositories.bzl", "swift_rules_dependencies") --load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps") - load("@local_config_android//:android.bzl", "android_workspace") - load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies") - load("//third_party:repo.bzl", "tf_http_archive", "tf_mirror_urls") -@@ -100,7 +99,6 @@ - # at the end of the WORKSPACE file. - _tf_bind() - -- grpc_extra_deps() - rules_foreign_cc_dependencies() - config_googleapis() - diff --git a/science/py-tensorflow/files/patch-tensorflow_workspace1.bzl b/science/py-tensorflow/files/patch-tensorflow_workspace1.bzl deleted file mode 100644 index cae90a63d448..000000000000 --- a/science/py-tensorflow/files/patch-tensorflow_workspace1.bzl +++ /dev/null @@ -1,17 +0,0 @@ ---- tensorflow/workspace1.bzl.orig -+++ tensorflow/workspace1.bzl -@@ -1,6 +1,5 @@ - """TensorFlow workspace initialization. Consult the WORKSPACE on how to use it.""" - --load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") - load("@com_google_benchmark//:bazel/benchmark_deps.bzl", "benchmark_deps") - load("@io_bazel_rules_closure//closure:defs.bzl", "closure_repositories") - load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies") -@@ -33,7 +32,6 @@ def workspace(with_rules_cc = True): - - android_configure(name = "local_config_android") - -- grpc_deps() - benchmark_deps() - - # Alias so it can be loaded without assigning to a different symbol to prevent diff --git a/science/py-tensorflow/files/patch-tensorflow_workspace2.bzl b/science/py-tensorflow/files/patch-tensorflow_workspace2.bzl index c6b25a0370bf..a9ba0a253e9f 100644 --- a/science/py-tensorflow/files/patch-tensorflow_workspace2.bzl +++ b/science/py-tensorflow/files/patch-tensorflow_workspace2.bzl @@ -1,55 +1,34 @@ ---- tensorflow/workspace2.bzl.orig +--- tensorflow/workspace2.bzl.orig 2026-03-04 21:33:50 UTC +++ tensorflow/workspace2.bzl -@@ -178,6 +178,7 @@ - name = "XNNPACK", +@@ -179,6 +179,7 @@ def _tf_repositories(): sha256 = "44bf8a258cfd0d7b500b6058a2bb5c7387c8cebba295cfca985a68d16513f7c8", strip_prefix = "XNNPACK-25b42dfddb0ee22170d73ff0d4b333ea1e6edfeb", -+ patch_file = ["//third_party:fix-xnnpack.patch", "//third_party:xnnpack-posix-c-source.patch", "//third_party:xnnpack-freebsd-x86.patch"], urls = tf_mirror_urls("https://github.com/google/XNNPACK/archive/25b42dfddb0ee22170d73ff0d4b333ea1e6edfeb.zip"), ++ patch_file = ["@xla//third_party/xnnpack:freebsd_mmap.patch"], ) # LINT.ThenChange(//tensorflow/lite/tools/cmake/modules/xnnpack.cmake) -@@ -200,7 +201,8 @@ - # LINT.IfChange(pthreadpool) - tf_http_archive( + +@@ -202,6 +203,7 @@ def _tf_repositories(): name = "pthreadpool", sha256 = "f602ab141bdc5d5872a79d6551e9063b5bfa7ad6ad60cceaa641de5c45c86d70", strip_prefix = "pthreadpool-0e6ca13779b57d397a5ba6bfdcaa8a275bc8ea2e", -+ patch_file = ["//third_party:pthreadpool-alloca.patch"], ++ patch_file = ["@xla//third_party/pthreadpool:freebsd_alloca.patch"], urls = tf_mirror_urls("https://github.com/google/pthreadpool/archive/0e6ca13779b57d397a5ba6bfdcaa8a275bc8ea2e.zip"), ) -@@ -407,7 +409,10 @@ - maybe( - tf_http_archive, - name = "com_google_protobuf", -- patch_file = ["@xla//third_party/protobuf:protobuf.patch"], -+ patch_file = [ -+ "@xla//third_party/protobuf:protobuf.patch", -+ "//third_party:fix-protobuf-java.patch", -+ ], - sha256 = "6e09bbc950ba60c3a7b30280210cd285af8d7d8ed5e0a6ed101c72aff22e8d88", - strip_prefix = "protobuf-6.31.1", - urls = tf_mirror_urls("https://github.com/protocolbuffers/protobuf/archive/refs/tags/v6.31.1.zip"), -@@ -471,6 +476,15 @@ - sha256 = "dd6a2fa311ba8441bbefd2764c55b99136ff10f7ea42954be96006a2723d33fc", - strip_prefix = "grpc-1.74.0", - system_build_file = "//third_party/systemlibs:grpc.BUILD", -+ system_link_files = { -+ "//third_party/systemlibs:grpc.bazel.BUILD": "bazel/BUILD.bazel", -+ "//third_party/systemlibs:grpc.bazel.cc_grpc_library.bzl": "bazel/cc_grpc_library.bzl", -+ "//third_party/systemlibs:grpc.bazel.generate_cc.bzl": "bazel/generate_cc.bzl", -+ "//third_party/systemlibs:grpc.bazel.grpc_deps.bzl": "bazel/grpc_deps.bzl", -+ "//third_party/systemlibs:grpc.bazel.grpc_extra_deps.bzl": "bazel/grpc_extra_deps.bzl", -+ "//third_party/systemlibs:grpc.bazel.protobuf.bzl": "bazel/protobuf.bzl", -+ "//third_party/systemlibs:grpc.bazel.python_rules.bzl": "bazel/python_rules.bzl", -+ }, + # LINT.ThenChange(//tensorflow/lite/cmake/DownloadPThreadPool.cmake) +@@ -210,7 +212,7 @@ def _tf_repositories(): + name = "cpuinfo", + sha256 = "c0254ce97f7abc778dd2df0aaca1e0506dba1cd514fdb9fe88c07849393f8ef4", + strip_prefix = "cpuinfo-8a9210069b5a37dd89ed118a783945502a30a4ae", +- patch_file = ["//third_party/cpuinfo:cpuinfo_ppc64le_support.patch"], ++ patch_file = ["//third_party/cpuinfo:cpuinfo_ppc64le_support.patch", "//third_party/cpuinfo:cpuinfo_freebsd_alwayslink.patch"], + urls = tf_mirror_urls("https://github.com/pytorch/cpuinfo/archive/8a9210069b5a37dd89ed118a783945502a30a4ae.zip"), + ) + +@@ -474,6 +476,7 @@ def _tf_repositories(): patch_file = [ "@xla//third_party/grpc:grpc.patch", ++ "@xla//third_party/grpc:grpc_no_go.patch", ], -@@ -895,6 +909,7 @@ - name = "riegeli", *** 532 LINES SKIPPED ***