bazelbuild / rules_swift

Bazel rules to build Swift on Apple and Linux platforms
Apache License 2.0
309 stars 133 forks source link

Swift Macro - cc_wrapper.sh failed: error executing CppLink command #1171

Closed SpectralDragon closed 6 months ago

SpectralDragon commented 6 months ago

Hi! I'm trying to move my SPM project to bazel, and encounter a problem with Swift Compiler Plugin. It's failed when I trying to build my project with the next message:

[AdaEngine] bazel build //:AdaEngine --verbose_failures                                                                                              feature/bazel 
INFO: Analyzed target //:AdaEngine (0 packages loaded, 276 targets configured).
ERROR: /Users/v.prusakov/Developer/AdaEngine/BUILD.bazel:176:22: Linking AdaEngineMacros [for tool] failed: (Exit 1): cc_wrapper.sh failed: error executing CppLink command (from target //:AdaEngineMacros) 
  (cd /private/var/tmp/_bazel_v.prusakov/e44332a643cc6911c41cf089411221c1/sandbox/darwin-sandbox/265/execroot/_main && \
  exec env - \
    APPLE_SDK_PLATFORM=MacOSX \
    APPLE_SDK_VERSION_OVERRIDE=14.0 \
    PATH='/Users/v.prusakov/Library/Caches/bazelisk/downloads/sha256/93772ce53afbe2282d0d727137a19c835eaa6f328964d02024bf3c234993bf7b/bin:/usr/local/opt/e2fsprogs/sbin:/usr/local/opt/e2fsprogs/bin:/Users/v.prusakov/.nvm/versions/node/v16.17.1/bin:/usr/local/bin/python3:/Users/v.prusakov/Developer/depot_tools:/usr/local/opt/openjdk@11/bin:/Library/Frameworks/Mono.framework/Home/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:/Applications/VMware Fusion.app/Contents/Public:/opt/devkitpro/tools/bin:/usr/local/share/dotnet:~/.dotnet/tools:/usr/local/go/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/opt/osquery:/opt/pfutil:/opt/puppetlabs/bin:/usr/local/bin:/Users/v.prusakov/webOS_TV_SDK/CLI/bin' \
    RELATIVE_AST_PATH=true \
    XCODE_VERSION_OVERRIDE=15.0.1.15A507 \
    ZERO_AR_DATE=1 \
  external/apple_support~1.11.1~apple_cc_configure_extension~local_config_apple_cc/cc_wrapper.sh @bazel-out/darwin_arm64-opt-exec-ST-13d3ddad9198/bin/AdaEngineMacros-2.params)
# Configuration: 70c3daebfcf68f5211379def6eb90b530ddf361c971cf35da9bd5c3abe7ccadd
# Execution platform: @@local_config_platform//:host

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
stderr (/private/var/tmp/_bazel_v.prusakov/e44332a643cc6911c41cf089411221c1/execroot/_main/bazel-out/_tmp/actions/stderr-4) 10543988 exceeds maximum size of --experimental_ui_max_stdouterr_bytes=1048576 bytes; skipping
Target //:AdaEngine failed to build
INFO: Elapsed time: 0.465s, Critical Path: 0.36s
INFO: 4 processes: 4 internal.
ERROR: Build did NOT complete successfully

You can check this project here: https://github.com/AdaEngine/AdaEngine/tree/feature/bazel

I'm not really sure where I should digging. Thanks!

keith commented 6 months ago

What's in this log?

stderr (/private/var/tmp/_bazel_v.prusakov/e44332a643cc6911c41cf089411221c1/execroot/_main/bazel-out/_tmp/actions/stderr-4) 10543988 exceeds maximum size of --experimental_ui_max_stdouterr_bytes=1048576 bytes; skipping

It's saying the log was too big to print it directly to stderr

SpectralDragon commented 6 months ago

@keith I'm so scared, 10mb of err logs stderr-4.zip

SpectralDragon commented 6 months ago

What's in this log?

stderr (/private/var/tmp/_bazel_v.prusakov/e44332a643cc6911c41cf089411221c1/execroot/_main/bazel-out/_tmp/actions/stderr-4) 10543988 exceeds maximum size of --experimental_ui_max_stdouterr_bytes=1048576 bytes; skipping

It's saying the log was too big to print it directly to stderr

Long story short, the problem in duplicate symbols, and I need a time to understand - why?

keith commented 6 months ago

Looks like it's related to your build configuration. Is it possible you have SwiftSyntax and SwiftSyntax_opt both in the same dependency tree?

SpectralDragon commented 6 months ago

@keith You definitely right! I removed @SwiftSyntax and it's just works! And I glad to see a new way to get stderr in Bazel :)

Thanks!

keith commented 6 months ago

awesome!