Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On Xcode 15, binaries depending on swift_proto_library fail to link with error: duplicate -rpath '/usr/lib/swift' #1135

Open
AttilaTheFun opened this issue Nov 12, 2023 · 6 comments

Comments

@AttilaTheFun
Copy link
Contributor

You can reproduce this for yourself in the master branch of rules_swift with an Xcode 15 toolchain on macOS Sonoma.

Just build the GRPC echo_server example:

logan@Logans-MacBook-Pro rules_swift % bazel build //examples/xplatform/grpc:echo_server
INFO: Analyzed target //examples/xplatform/grpc:echo_server (11 packages loaded, 1208 targets configured).
INFO: Found 1 target...
ERROR: /Users/logan/Developer/Bazel/rules_swift/examples/xplatform/grpc/BUILD:58:13: Linking examples/xplatform/grpc/echo_server failed: (Exit 1): cc_wrapper.sh failed: error executing command (from target //examples/xplatform/grpc:echo_server) external/local_config_apple_cc/cc_wrapper.sh @bazel-out/darwin_arm64-fastbuild/bin/examples/xplatform/grpc/echo_server-2.params

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
ld: warning: duplicate -rpath '/usr/lib/swift' ignored
ld: fatal warning(s) induced error (-fatal_warnings)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error in child process '/usr/bin/xcrun'. 1
Target //examples/xplatform/grpc:echo_server failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 2.201s, Critical Path: 2.01s
INFO: 5 processes: 3 internal, 1 darwin-sand
@brentleyjones
Copy link
Collaborator

Just wanted to call out that the example has -fatal_warnings. If you didn't have this it's just a warning, not a failure.

@keith
Copy link
Member

keith commented Nov 13, 2023

bazelbuild/apple_support#286

@acecilia
Copy link

acecilia commented May 3, 2024

To add some more context. The warning for me shows only when building test targets:

  • No warning: bazelisk build --config=public-ios //SharedModules/QRCodeKit:QRCodeKit
  • With warning: bazelisk build --config=public-ios //SharedModules/QRCodeKit:QRCodeKitUnitTests

The -no_warn_duplicate_libraries flag does not help here (probably you knew this already :D but online seems like the rpath and the library duplications are mixed, and so are their workarounds - so just clarifying)

The rpath shows twice despite the amount of dependencies. Attached below couple of examples.

Building test target with 2 dependencies:
Screenshot 2024-05-03 at 01 13 45

Building test target with more than 2 dependencies:
Screenshot 2024-05-03 at 01 30 50

@acecilia
Copy link

acecilia commented May 3, 2024

Looking at the flags pattern:

-L__BAZEL_XCODE_DEVELOPER_DIR__/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator
-L/usr/lib/swift
-Wl,-objc_abi_version,2
-Wl,-rpath,/usr/lib/swift

Maybe origin is here 🤔

@AttilaTheFun
Copy link
Contributor Author

@acecilia just curious, do you still see this issue with the new swift proto library implementation?

@acecilia
Copy link

acecilia commented May 3, 2024

Mmm my comment was more generic, just about building targets. I do not have knowledge about protos 😞

Maybe my comment is out of context in this protos-specific issue 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants