From 129879c16ff30c79244413988a26be7e83382dc8 Mon Sep 17 00:00:00 2001 From: Samuel Andersen Date: Tue, 16 Jun 2026 19:12:21 -0700 Subject: [PATCH 1/2] Fix macOS symbol export conflicts with TensorFlow --- MODULE.bazel | 12 +++--------- cpp/sequenced_chunk_writer.cc | 1 - oss/build_whl.sh | 5 +++++ python/BUILD | 9 +++++++++ 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index f91bc78..a7d18ed 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -25,16 +25,10 @@ bazel_dep(name = "rules_proto", version = "7.1.0") bazel_dep(name = "rules_python", version = "1.6.0") bazel_dep(name = "platforms", version = "0.0.11") -# We force the protobuf version to be 28.3 because 29.x (that is required by rules_python) causes -# segfault when importing TensorFlow due to a conflict with TF's protobuf version. -bazel_dep(name = "protobuf", version = "29.0-rc3") -single_version_override( - module_name = "protobuf", - version = "28.3", -) +bazel_dep(name = "protobuf", version = "33.1") -bazel_dep(name = "googletest", version = "1.15.2") -bazel_dep(name = "abseil-cpp", version = "20250127.1") +bazel_dep(name = "googletest", version = "1.17.0") +bazel_dep(name = "abseil-cpp", version = "20250512.1") bazel_dep(name = "abseil-py", version = "2.1.0") bazel_dep(name = "eigen", version = "3.4.0.bcr.3") bazel_dep(name = "riegeli", version = "0.0.0-20250717-5b2e77e") diff --git a/cpp/sequenced_chunk_writer.cc b/cpp/sequenced_chunk_writer.cc index 5b22dc4..23b15f1 100644 --- a/cpp/sequenced_chunk_writer.cc +++ b/cpp/sequenced_chunk_writer.cc @@ -119,7 +119,6 @@ void SequencedChunkWriterBase::TrySubmitFirstFutureChunk( } if (pad_to_block_boundary_) { if (!chunk_writer->PadToBlockBoundary()) { - { Fail(riegeli::Annotate( chunk_writer->status(), absl::StrFormat("Could not pad boundary for chunk: %d", diff --git a/oss/build_whl.sh b/oss/build_whl.sh index 3819881..49e4fb3 100755 --- a/oss/build_whl.sh +++ b/oss/build_whl.sh @@ -32,6 +32,11 @@ function main() { write_to_bazelrc "build --cxxopt=-Wno-deprecated-declarations --host_cxxopt=-Wno-deprecated-declarations" write_to_bazelrc "build --cxxopt=-Wno-parentheses --host_cxxopt=-Wno-parentheses" write_to_bazelrc "build --cxxopt=-Wno-sign-compare --host_cxxopt=-Wno-sign-compare" + # Set -fvisbility=hidden to prevent symbol collision with TensorFlow on macOS + if [ "$(uname)" = "Darwin" ]; then + write_to_bazelrc "build --copt=-fvisibility=hidden" + write_to_bazelrc "build --copt=-fvisibility-inlines-hidden" + fi PLATFORM="$(uname)" diff --git a/python/BUILD b/python/BUILD index d247e61..7192229 100644 --- a/python/BUILD +++ b/python/BUILD @@ -2,6 +2,7 @@ load("@pybind11_bazel//:build_defs.bzl", "pybind_extension") load("@pypi//:requirements.bzl", "requirement") +load("@rules_python//python:defs.bzl", "py_library", "py_test") package(default_visibility = ["//visibility:public"]) @@ -10,6 +11,14 @@ licenses(["notice"]) pybind_extension( name = "array_record_module", srcs = ["array_record_module.cc"], + linkopts = select({ + "@platforms//os:macos": ["-Wl,-exported_symbols_list,$(location :exported_symbols_mac.lds)"], + "//conditions:default": [], + }), + additional_linker_inputs = select({ + "@platforms//os:macos": [":exported_symbols_mac.lds"], + "//conditions:default": [], + }), deps = [ "@abseil-cpp//absl/status", "@abseil-cpp//absl/strings", From db612ddb4cc20ad6fff5ae5db6e987f4e090cb01 Mon Sep 17 00:00:00 2001 From: Samuel Andersen Date: Wed, 17 Jun 2026 09:40:59 -0700 Subject: [PATCH 2/2] Restore missing linker script --- python/exported_symbols_mac.lds | 1 + 1 file changed, 1 insertion(+) create mode 100644 python/exported_symbols_mac.lds diff --git a/python/exported_symbols_mac.lds b/python/exported_symbols_mac.lds new file mode 100644 index 0000000..22b297c --- /dev/null +++ b/python/exported_symbols_mac.lds @@ -0,0 +1 @@ +_PyInit_array_record_module