Bazel: Failed Linking Static Library(Libtool + Darwin)

Created on 17 Sep 2020  路  4Comments  路  Source: bazelbuild/bazel

Description of the problem / feature request:

I'm try to build a library using swift_library and I'm getting a linking issue with libtool.

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

load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")

swift_library(
    name = "Valet",
    srcs = glob(["Pods/Valet/*.swift"]),
)

What operating system are you running Bazel on?

MAC OS Catalina 10.5.6

What's the output of bazel info release?

bazel 3.5.0

Have you found anything relevant by searching the web?

No

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

ERROR: /Users/me/workspace/project/iOS/BUILD:4:14: Linking libValet.a failed (Exit 1): libtool failed: error executing command
  (cd /private/var/tmp/_bazel_me/48adbf0c831f3ae216f4c0cd02649425/sandbox/darwin-sandbox/1/execroot/__main__ && \
  exec env - \
    APPLE_SDK_PLATFORM=MacOSX \
    APPLE_SDK_VERSION_OVERRIDE=10.15 \
    XCODE_VERSION_OVERRIDE=11.5.0.11E608c \
  external/local_config_cc/libtool -no_warning_for_no_symbols -static -o bazel-out/darwin-fastbuild/bin/libValet.a -filelist bazel-out/darwin-fastbuild/bin/libValet.a-0.params)
Execution platform: @local_config_platform//:host

Use --sandbox_debug to see verbose messages from the sandbox libtool failed: error executing command
  (cd /private/var/tmp/_bazel_me/48adbf0c831f3ae216f4c0cd02649425/sandbox/darwin-sandbox/1/execroot/__main__ && \
  exec env - \
    APPLE_SDK_PLATFORM=MacOSX \
    APPLE_SDK_VERSION_OVERRIDE=10.15 \
    XCODE_VERSION_OVERRIDE=11.5.0.11E608c \
  external/local_config_cc/libtool -no_warning_for_no_symbols -static -o bazel-out/darwin-fastbuild/bin/libValet.a -filelist bazel-out/darwin-fastbuild/bin/libValet.a-0.params)
Execution platform: @local_config_platform//:host

Use --sandbox_debug to see verbose messages from the sandbox
fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file list file: bazel-out/darwin-fastbuild/bin/libValet.a-0.params_hashes.objlist is empty
Target //:Valet failed to build
bug untriaged z-team-Apple

All 4 comments

I believe this happens when your glob doesn't match anything, can you verify some sources are actually being compiled here? You can probably change your glob to glob(["Pods/Valet/*.swift"], allow_empty=False) to error sooner

Thank you very much @keith , I just changed the rule to navigate sub-levels. The source code was actually in a source subfolder.

swift_library(
    name = "Valet",
    srcs = glob(["Pods/Valet/**/*.swift"]),
)

No problem! Sounds like should close this then?

Closing-- thanks @keith!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iirina picture iirina  路  3Comments

mdzoba picture mdzoba  路  3Comments

GaofengCheng picture GaofengCheng  路  3Comments

buchgr picture buchgr  路  3Comments

davidzchen picture davidzchen  路  3Comments