Skip to content

[5.9] Build command plugin dependencies for the host, not the target #6799

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

Merged
merged 1 commit into from
Aug 14, 2023

Conversation

MaxDesiatov
Copy link
Contributor

@MaxDesiatov MaxDesiatov commented Aug 11, 2023

When cross-compiling, SwiftPM plugins and their dependencies run on the host and so must be compiled for the host OS and architecture, not the cross-compiled target OS and architecture. SwiftPM will compile a command plugin for the host but if the plugin depends on an executable it will cross-compile the executable for the target, so the plugin will not be able to run it:

error: Error Domain=NSPOSIXErrorDomain Code=8 "Exec format error"

Command plugin dependencies are already handled specially in PluginCommand.run; this commit makes that special build step use the host toolchain instead of the target toolchain.

#6060 handled the equivalent problem for build tool plugins.

(cherry picked from commit 1daaa1c)

# Conflicts:
#	Sources/CoreCommands/SwiftTool.swift

When cross-compiling, SwiftPM plugins and their dependencies run on the host and so must be compiled for the host OS and architecture, not the cross-compiled target OS and architecture. SwiftPM will compile a command plugin for the host but if the plugin depends on an executable it will cross-compile the executable for the target, so the plugin will not be able to run it:

    error: Error Domain=NSPOSIXErrorDomain Code=8 "Exec format error"

Command plugin dependencies are already handled specially in PluginCommand.run; this commit makes that special build step use the host toolchain instead of the target toolchain.

#6060 handled the equivalent problem for build tool plugins.

(cherry picked from commit 1daaa1c)

# Conflicts:
#	Sources/CoreCommands/SwiftTool.swift
@MaxDesiatov MaxDesiatov added the swift 5.9 This PR targets the 5.9 branch label Aug 11, 2023
@MaxDesiatov MaxDesiatov marked this pull request as draft August 11, 2023 08:50
@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

@MaxDesiatov MaxDesiatov marked this pull request as ready for review August 12, 2023 08:16
@MaxDesiatov MaxDesiatov self-assigned this Aug 12, 2023
@MaxDesiatov MaxDesiatov merged commit a432dc8 into release/5.9 Aug 14, 2023
@MaxDesiatov MaxDesiatov deleted the maxd/fix-command-plugins branch August 14, 2023 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cross-compilation swift 5.9 This PR targets the 5.9 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants