From 512f11d3d3b371abcf13248abf4e808ff3459502 Mon Sep 17 00:00:00 2001 From: Ihor Indyk Date: Thu, 19 Mar 2026 17:40:02 -0700 Subject: [PATCH] Fix macos linking errors by forcing use of clang. PiperOrigin-RevId: 886465318 --- grain/oss/build_whl.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/grain/oss/build_whl.sh b/grain/oss/build_whl.sh index 750c9c5f6..abe9f18ca 100644 --- a/grain/oss/build_whl.sh +++ b/grain/oss/build_whl.sh @@ -21,12 +21,17 @@ main() { # Enable host OS specific configs. For instance, "build:linux" will be used # automatically when building on Linux. write_to_bazelrc "build --enable_platform_specific_config" + write_to_bazelrc "build --verbose_failures" # Bazel 7.0.0 no longer supports dynamic symbol lookup on macOS. To resolve # undefined symbol errors in macOS arm64 builds, explicitly add the necessary # linker flags until dependencies are well defined. See # https://github.com/bazelbuild/bazel/issues/19730. write_to_bazelrc "build:macos --linkopt=-Wl,-undefined,dynamic_lookup" write_to_bazelrc "build:macos --host_linkopt=-Wl,-undefined,dynamic_lookup" + # Force clang on macos. Otherwise we get linker errors described in + # https://github.com/bazelbuild/bazel/issues/20838. + write_to_bazelrc "build:macos --action_env=CC=clang" + write_to_bazelrc "build:macos --action_env=CXX=clang++" write_to_bazelrc "build --@rules_python//python/config_settings:python_version=${PYTHON_VERSION}" # Set platform-wise file extension for extension modules.