Skip to content

Error when linking external C++ Bazel project on MacOS #23488

Description

@MarkShark99

Description of the bug:

I'm attempting to build the //main target of my example project (https://github.com/MarkShark99/bazel-test), which just compiles a simple cc_binary that depends on fruit. On Linux it compiles and runs correctly, but on MacOS (Apple Silicon) running bazel build -s //main results in the following error:

mark@marks-laptop bazel-test % bazel build -s //main             
INFO: Analyzed target //main:main (0 packages loaded, 0 targets configured).
SUBCOMMAND: # @@_main~_repo_rules~fruit//third_party/fruit/configuration/bazel:fruit-config-base [action 'Linking external/_main~_repo_rules~fruit/third_party/fruit/configuration/bazel/libfruit-config-base_link.a', configuration: 096dcc84165363e69a851ebe8131b032f5448c94ddc4951775429dc78e79f898, execution platform: @@platforms//host:host, mnemonic: CppArchive]
(cd /private/var/tmp/_bazel_mark/d43f12eb0790c1f57f9111b580b0b671/execroot/_main && \
  exec env - \
    PATH=/Users/mark/Library/Caches/bazelisk/downloads/sha256/981f82a470bad1349322b6f51c9c6ffa0aa291dab1014fac411543c12e661dff/bin:/Users/mark/.nvm/versions/node/v20.11.0/bin:/Users/mark/.docker/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/mark/.nvm/versions/node/v20.11.0/bin:/Users/mark/.docker/bin:/opt/homebrew/bin:/opt/homebrew/sbin \
    PWD=/proc/self/cwd \
    ZERO_AR_DATE=1 \
  /usr/bin/libtool @bazel-out/darwin_arm64-fastbuild/bin/external/_main~_repo_rules~fruit/third_party/fruit/configuration/bazel/libfruit-config-base_link.a-2.params)
# Configuration: 096dcc84165363e69a851ebe8131b032f5448c94ddc4951775429dc78e79f898
# Execution platform: @@platforms//host:host
SUBCOMMAND: # @@_main~_repo_rules~fruit//third_party/fruit:fruit [action 'Linking external/_main~_repo_rules~fruit/third_party/fruit/libfruit.a', configuration: 096dcc84165363e69a851ebe8131b032f5448c94ddc4951775429dc78e79f898, execution platform: @@platforms//host:host, mnemonic: CppArchive]
(cd /private/var/tmp/_bazel_mark/d43f12eb0790c1f57f9111b580b0b671/execroot/_main && \
  exec env - \
    PATH=/Users/mark/Library/Caches/bazelisk/downloads/sha256/981f82a470bad1349322b6f51c9c6ffa0aa291dab1014fac411543c12e661dff/bin:/Users/mark/.nvm/versions/node/v20.11.0/bin:/Users/mark/.docker/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/mark/.nvm/versions/node/v20.11.0/bin:/Users/mark/.docker/bin:/opt/homebrew/bin:/opt/homebrew/sbin \
    PWD=/proc/self/cwd \
    ZERO_AR_DATE=1 \
  /usr/bin/libtool @bazel-out/darwin_arm64-fastbuild/bin/external/_main~_repo_rules~fruit/third_party/fruit/libfruit.a-2.params)
# Configuration: 096dcc84165363e69a851ebe8131b032f5448c94ddc4951775429dc78e79f898
# Execution platform: @@platforms//host:host
SUBCOMMAND: # //main:main [action 'Compiling main/main.cpp', configuration: 096dcc84165363e69a851ebe8131b032f5448c94ddc4951775429dc78e79f898, execution platform: @@platforms//host:host, mnemonic: CppCompile]
(cd /private/var/tmp/_bazel_mark/d43f12eb0790c1f57f9111b580b0b671/execroot/_main && \
  exec env - \
    PATH=/Users/mark/Library/Caches/bazelisk/downloads/sha256/981f82a470bad1349322b6f51c9c6ffa0aa291dab1014fac411543c12e661dff/bin:/Users/mark/.nvm/versions/node/v20.11.0/bin:/Users/mark/.docker/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/mark/.nvm/versions/node/v20.11.0/bin:/Users/mark/.docker/bin:/opt/homebrew/bin:/opt/homebrew/sbin \
    PWD=/proc/self/cwd \
  external/bazel_tools~cc_configure_extension~local_config_cc/cc_wrapper.sh -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer '-std=c++14' -MD -MF bazel-out/darwin_arm64-fastbuild/bin/main/_objs/main/main.d '-frandom-seed=bazel-out/darwin_arm64-fastbuild/bin/main/_objs/main/main.o' -DBOOST_NO_CXX98_FUNCTION_BASE -iquote . -iquote bazel-out/darwin_arm64-fastbuild/bin -iquote external/_main~_repo_rules~fruit -iquote bazel-out/darwin_arm64-fastbuild/bin/external/_main~_repo_rules~fruit -iquote external/rules_boost~~non_module_dependencies~boost -iquote bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost -iquote external/rules_cc~ -iquote bazel-out/darwin_arm64-fastbuild/bin/external/rules_cc~ -iquote external/bazel_tools -iquote bazel-out/darwin_arm64-fastbuild/bin/external/bazel_tools -isystem external/_main~_repo_rules~fruit/third_party/fruit/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/_main~_repo_rules~fruit/third_party/fruit/include -isystem external/_main~_repo_rules~fruit/third_party/fruit/configuration/bazel -isystem bazel-out/darwin_arm64-fastbuild/bin/external/_main~_repo_rules~fruit/third_party/fruit/configuration/bazel -isystem external/rules_boost~~non_module_dependencies~boost/libs/unordered/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/unordered/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/assert/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/assert/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/current_function/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/current_function/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/config/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/config/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/container/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/container/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/core/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/core/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/intrusive/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/intrusive/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/cstdint/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/cstdint/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/limits/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/limits/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/move/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/move/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/detail/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/detail/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/winapi/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/winapi/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/static_assert/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/static_assert/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/noncopyable/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/noncopyable/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/functional/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/functional/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/container_hash/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/container_hash/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/describe/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/describe/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/mp11/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/mp11/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/integer/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/integer/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/type_traits/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/type_traits/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/mpl/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/mpl/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/preprocessor/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/preprocessor/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/iterator/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/iterator/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/utility/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/utility/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/io/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/io/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/swap/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/swap/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/throw_exception/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/throw_exception/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/smart_ptr/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/smart_ptr/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/align/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/align/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/predef/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/predef/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/scoped_array/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/scoped_array/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/checked_delete/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/checked_delete/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/scoped_ptr/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/scoped_ptr/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/shared_array/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/shared_array/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/shared_ptr/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/shared_ptr/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/tuple/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/tuple/include -isystem external/rules_boost~~non_module_dependencies~boost/libs/ref/include -isystem bazel-out/darwin_arm64-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/ref/include '-mmacosx-version-min=14.5' -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c main/main.cpp -o bazel-out/darwin_arm64-fastbuild/bin/main/_objs/main/main.o)
# Configuration: 096dcc84165363e69a851ebe8131b032f5448c94ddc4951775429dc78e79f898
# Execution platform: @@platforms//host:host
ERROR: /private/var/tmp/_bazel_mark/d43f12eb0790c1f57f9111b580b0b671/external/_main~_repo_rules~fruit/third_party/fruit/configuration/bazel/BUILD:5:22: Linking external/_main~_repo_rules~fruit/third_party/fruit/configuration/bazel/libfruit-config-base_link.a failed: (Exit 1): libtool failed: error executing CppArchive command (from target @@_main~_repo_rules~fruit//third_party/fruit/configuration/bazel:fruit-config-base) /usr/bin/libtool @bazel-out/darwin_arm64-fastbuild/bin/external/_main~_repo_rules~fruit/third_party/fruit/configuration/bazel/libfruit-config-base_link.a-2.params

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
error: /Library/Developer/CommandLineTools/usr/bin/libtool: no files specified
Usage: /Library/Developer/CommandLineTools/usr/bin/libtool -static [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-sacLT] [-no_warning_for_no_symbols]
Usage: /Library/Developer/CommandLineTools/usr/bin/libtool -dynamic [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-o output] [-install_name name] [-compatibility_version #] [-current_version #] [-seg1addr 0x#] [-segs_read_only_addr 0x#] [-segs_read_write_addr 0x#] [-seg_addr_table <filename>] [-seg_addr_table_filename <file_system_path>] [-all_load] [-noall_load]
Target //main:main failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.222s, Critical Path: 0.03s
INFO: 4 processes: 4 internal.
ERROR: Build did NOT complete successfully

Compiling @fruit//third_party/fruit works as intended.

Which category does this issue belong to?

C++ Rules, External Dependency

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Perform the following on MacOS (Apple Silicon):

  1. Clone https://github.com/MarkShark99/bazel-test
  2. Run bazel build //main

Which operating system are you running Bazel on?

MacOS Sonoma 14.6.1

What is the output of bazel info release?

release 7.3.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

N/A

What's the output of git remote get-url origin; git rev-parse HEAD ?

https://github.com/MarkShark99/bazel-test.git
9fe3fa06ce291b2cc0a3670c096e1e6f395b7574

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

N/A

Have you found anything relevant by searching the web?

Any other information, logs, or outputs that you want to share?

Xcode Command Line Tools version: 15.3.0.0.1.1708646388

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions