From 341fd64e5fb0e1623dd5e5d7314273c7190f8bdb Mon Sep 17 00:00:00 2001 From: Mark Ross Date: Wed, 16 Sep 2026 08:46:11 -0700 Subject: [PATCH] Don't build a shared library for embedded data xls_cc_embed_data produces both a static and a shared library. Linking the shared variant fails on macOS because the toolchain passes the ELF-only -soname flag to the Mach-O linker: ld64.lld: error: unknown argument '-soname=libxls_Sbuild_Urules_Stests_Slibarbitrary_Udata_Ufile.dylib' This blocks any test target depending on embedded data, since tests link their dependencies dynamically by default. On current main that includes the rule's own test: //xls/build_rules/tests:embed_data_test cannot be built on macOS at all. Embedded data is only ever linked statically into its consumers, so the shared library is an unused artifact -- no target in the tree depends on it. Passing disallow_dynamic_library skips producing it, which avoids the broken link on macOS and drops a dead artifact on every platform. Verified on macOS arm64 against 924b9fd07: //xls/build_rules/tests/... passes 31/31 with this change and embed_data_test fails to build without it; //xls/common/... passes 37/37; the four main tools still build; and //xls/common:subprocess_helper_embedded still builds under --dynamic_mode=fully. Co-authored with Claude Code (https://claude.com/claude-code). --- xls/build_rules/xls_cc_embed_data_rules.bzl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xls/build_rules/xls_cc_embed_data_rules.bzl b/xls/build_rules/xls_cc_embed_data_rules.bzl index 99aad81c2a..3972ed98b5 100644 --- a/xls/build_rules/xls_cc_embed_data_rules.bzl +++ b/xls/build_rules/xls_cc_embed_data_rules.bzl @@ -122,6 +122,11 @@ def get_embedded_data( ctx.attr._absl_span[CcInfo].linking_context, ctx.attr._libc_runtime[CcInfo].linking_context, ], + # Embedded data is only ever linked statically into its consumers, and + # building the shared variant breaks on macOS: the toolchain passes the + # ELF-only `-soname` to the Mach-O linker, which rejects it. Skipping + # the shared library avoids the dead artifact on every platform. + disallow_dynamic_library = True, ) return CcInfo(compilation_context = comp_ctx, linking_context = link_ctx)