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

Linker failures when using plugin in "dependencies" of target #6676

Open
MahdiBM opened this issue Jul 5, 2023 · 0 comments
Open

Linker failures when using plugin in "dependencies" of target #6676

MahdiBM opened this issue Jul 5, 2023 · 0 comments
Labels

Comments

@MahdiBM
Copy link

MahdiBM commented Jul 5, 2023

Description

If you add a BuildTool plugin to the "dependencies" array of a target, you can get different weird inconsistent linker failures.

This is a programmer error as you're supposed to add plugins to the "plugins" array, and not the "dependencies" array.

These linker errors were also super confusing to me and i only managed to solve them after some help from @neonichu.

Expected behavior

SPM should optimally throw errors about it, than letting it get to the linker stage.

Actual behavior

Different weird linker errors on most platforms.
But still working on macOS Sonoma + Xcode 15 beta 2.

Places where it failed building:

  • Github CI (macOS 13, Xcode 14.x)
  • Github CI (Ubuntu jammy + Swift 5.8/5.9 nightly/main)
  • Local dev-container w/ SSWG VSCode extension (Swift 5.8 jammy image)

Error example (https://github.com/vapor/penny-bot/actions/runs/5448652483/jobs/9912081018):

<unknown>:0: error: error opening input file '/__w/penny-bot/penny-bot/.build/plugins/outputs/penny-bot/GHHooksLambda/OpenAPIGenerator/GeneratedSources/Server.swift' (No such file or directory)

Steps to reproduce

  • Create an executable package (not sure if the failures will happen without an executable target)
  • Add a BuildTool plugin like https://github.com/apple/swift-openapi-generator to the dependencies of package.
  • Add the BuildTool plugin in the "dependencies" array of the executable target. Don't add it to the "plugins" array.
  • Not sure, might need to actually get the BuildTool plugin minimally working ... probably not though.
  • Try to build on different platforms. For me, only macOS Sonoma + Xcode 15 beta 2 didn't fail with weird errors.

Swift Package Manager version/commit hash

% swift package --version
Swift Package Manager - Swift 5.9.0

Swift & OS version (output of swift --version ; uname -a)

Local machine were the build was consistently successful, unlike all other platforms:

swift-driver version: 1.82.2 Apple Swift version 5.9 (swiftlang-5.9.0.114.10 clang-1500.0.29.1)
Target: arm64-apple-macosx14.0
Darwin Macbook.local 23.0.0 Darwin Kernel Version 23.0.0: Tue Jun 13 21:16:44 PDT 2023; root:xnu-10002.0.116.505.3~3/RELEASE_ARM64_T6000 arm64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants