-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Cross-compiling packages which contain macros doesn't work #6950
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
Comments
That's correct, macros are not expected to work when cross-compiling today (that's not limited to any particular platform). |
Resolves #6950 Resolves rdar://105991372
Resolves #6950 Resolves rdar://105991372
### Motivation: Not supporting macros in cross-compilation is a major limitation, especially for libraries like https://github.com/apple/swift-mmio. ### Modifications: Added `enum BuildTriple { case buildTools, buildProducts }` and `var buildTriple: BuildTriple` on `ResolvedTarget` and `ResolvedProduct`. Corresponding value is assigned to this property depending on target and product type: `buildTools` for macros, plugins, and their dependencies, `buildProducts` for everything else (the default). Based on this property we can choose between `buildParameters.hostTriple` and `buildParameters.targetTriple` during build plan construction. ### Result: Resolves #6950 Resolves rdar://105991372
### Motivation: Not supporting macros in cross-compilation is a major limitation, especially for libraries like https://github.com/apple/swift-mmio. ### Modifications: Added `enum BuildTriple { case buildTools, buildProducts }` and `var buildTriple: BuildTriple` on `ResolvedTarget` and `ResolvedProduct`. Corresponding value is assigned to this property depending on target and product type: `buildTools` for macros, plugins, and their dependencies, `buildProducts` for everything else (the default). Based on this property we can choose between `buildParameters.hostTriple` and `buildParameters.targetTriple` during build plan construction. ### Result: Resolves #6950 Resolves rdar://105991372
### Motivation: Not supporting macros in cross-compilation is a major limitation, especially for libraries like https://github.com/apple/swift-mmio. ### Modifications: Added `enum BuildTriple { case tools, destination }` and `var buildTriple: BuildTriple` on `ResolvedTarget` and `ResolvedProduct`. We're not using "host" and "target" triple terminology in this enum, as that clashes with build system "targets" and can lead to confusion in this context. Corresponding value is assigned to this property depending on target and product type: `tools` for macros, plugins, and their dependencies, `destination` for everything else (the default). Based on this property we can choose between `buildParameters.hostTriple` and `buildParameters.targetTriple` during build plan construction. Additionally, the resolved products and resolved targets graph is now constructed in a way that allows certain targets and products to be built twice: once for host triple, once for target triple if needed. This required modifying build description and build manifest generation to distinguish these products and targets from each other that are built twice. Artifacts built for the host now have `-tools` suffix appended to their names. This cascaded into making changes throughout the code base for build tool plugins and package plugins handling, which constructed their paths in an ad-hoc manner without accounting for possible changes to these names. Also added `CrossCompilationPackageGraphTests` and `CrossCompilationBuildPlanTests` to verify the changes made are applied correctly. ### Result: Resolves #6950 Resolves rdar://105991372
Should be reopened as this is still being worked on, #7353. |
I'm still seeing issues with cross-compiling packages containing macros. I downloaded the April 25 trunk snapshot ubi9 toolchain, the latest LTS Android NDK 26d, and a trunk Android SDK that my daily Android CI generated, Using these commands, I consistently see build errors for packages that use macros:
I then modified the destination config
But it always fails with weird build errors when cross-compiling packages that have macros:
I just tried again with the April 27 trunk snapshot that was just tagged, same build error. @MaxDesiatov, let me know if you're able to reproduce with your cross-compilation SDK bundles for linux. |
### Motivation: Not supporting macros in cross-compilation is a major limitation, especially for libraries like https://github.com/apple/swift-mmio. ### Modifications: Added `enum BuildTriple { case tools, destination }` and `var buildTriple: BuildTriple` on `ResolvedTarget` and `ResolvedProduct`. We're not using "host" and "target" triple terminology in this enum, as that clashes with build system "targets" and can lead to confusion in this context. Corresponding value is assigned to this property depending on target and product type: `tools` for macros, plugins, and their dependencies, `destination` for everything else (the default). Based on this property we can choose between `buildParameters.hostTriple` and `buildParameters.targetTriple` during build plan construction. Additionally, the resolved products and resolved targets graph is now constructed in a way that allows certain targets and products to be built twice: once for host triple, once for target triple if needed. This required modifying build description and build manifest generation to distinguish these products and targets from each other that are built twice. Artifacts built for the host now have `-tools` suffix appended to their names. This cascaded into making changes throughout the code base for build tool plugins and package plugins handling, which constructed their paths in an ad-hoc manner without accounting for possible changes to these names. Also added `CrossCompilationPackageGraphTests` and `CrossCompilationBuildPlanTests` to verify the changes made are applied correctly. ### Result: Resolves swiftlang#6950 Resolves rdar://105991372
### Motivation: Not supporting macros in cross-compilation is a major limitation, especially for libraries like https://github.com/apple/swift-mmio. ### Modifications: Added `enum BuildTriple { case tools, destination }` and `var buildTriple: BuildTriple` on `ResolvedTarget` and `ResolvedProduct`. We're not using "host" and "target" triple terminology in this enum, as that clashes with build system "targets" and can lead to confusion in this context. Corresponding value is assigned to this property depending on target and product type: `tools` for macros, plugins, and their dependencies, `destination` for everything else (the default). Based on this property we can choose between `buildParameters.hostTriple` and `buildParameters.targetTriple` during build plan construction. Additionally, the resolved products and resolved targets graph is now constructed in a way that allows certain targets and products to be built twice: once for host triple, once for target triple if needed. This required modifying build description and build manifest generation to distinguish these products and targets from each other that are built twice. Artifacts built for the host now have `-tools` suffix appended to their names. This cascaded into making changes throughout the code base for build tool plugins and package plugins handling, which constructed their paths in an ad-hoc manner without accounting for possible changes to these names. Also added `CrossCompilationPackageGraphTests` and `CrossCompilationBuildPlanTests` to verify the changes made are applied correctly. ### Result: Resolves swiftlang#6950 Resolves rdar://105991372
Description
@woxiang04 reported in the forum that they couldn't cross-compile the macro examples, and @neonichu said that doesn't work yet. I am unsure what this entails, as presumably the official Swift 5.9 toolchain for macOS can cross-compile code with macros for iOS?
I have not tried this myself, just reporting that error from the forum.
Expected behavior
Macros to work when cross-compiling a package
Actual behavior
According to that forum thread:
Steps to reproduce
Swift Package Manager version/commit hash
5.9
Swift & OS version (output of
swift --version ; uname -a
)5.9 for Ubuntu 20.04 x86_64 cross-compiling to Android AArch64
The text was updated successfully, but these errors were encountered: