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

Update SE-0387: Cross-Compilation Destination Bundles #1942

Merged
merged 22 commits into from
Apr 20, 2023
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
28ecd8f
Expand multiple sections, update naming of JSON props
MaxDesiatov Feb 6, 2023
e96b917
Mention package registries in the Future Directions section
MaxDesiatov Feb 6, 2023
9b56079
Specify `json5` for syntax highlighting everywhere
MaxDesiatov Feb 6, 2023
1f25bc0
Address PR feedback
MaxDesiatov Feb 7, 2023
0b52595
Address PR feedback
MaxDesiatov Feb 7, 2023
3d2a1c2
Address PR feedback
MaxDesiatov Feb 9, 2023
a9a77c1
Make `sdkRootPath` required
MaxDesiatov Feb 9, 2023
f1851cf
Address PR feedback
MaxDesiatov Feb 10, 2023
be0b74b
Disambiguate `swift build --destination` invocation example
MaxDesiatov Feb 10, 2023
cf2deb6
Add `swiftStaticResourcesPath` field to `destination.json`
MaxDesiatov Feb 10, 2023
5f39655
Clean up formatting
MaxDesiatov Feb 10, 2023
e8cd545
Fix typo
MaxDesiatov Feb 10, 2023
5d8bec2
Expand "Alternatives Considered"
MaxDesiatov Feb 21, 2023
d1f98e7
Refine wording
MaxDesiatov Feb 21, 2023
c7f5c7c
Add a link to implementation PR
MaxDesiatov Feb 28, 2023
58b2c5a
Fix toolset file reference in CLI invocation
MaxDesiatov Feb 28, 2023
515aac3
Add table of contents
MaxDesiatov Mar 2, 2023
6ce9bc1
Clean up table of contents
MaxDesiatov Mar 2, 2023
139e51f
Change `swift destination delete` to `swift destination remove` for c…
MaxDesiatov Mar 2, 2023
775b427
Update `swift destination configure` subcommand
MaxDesiatov Mar 3, 2023
db299df
Clarify command-line argument for `destination configure` subcommand
MaxDesiatov Mar 7, 2023
2d34fda
Fix `Authors` field formatting
MaxDesiatov Apr 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add swiftStaticResourcesPath field to destination.json
  • Loading branch information
MaxDesiatov committed Feb 10, 2023
commit cf2deb6e3d5ee5ba4e3ed8cccfbaf91177bd8226
27 changes: 16 additions & 11 deletions proposals/0387-cross-compilation-destinations.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,18 +294,22 @@ informally defined schema for these files:
"runTimeTriples": [
"<triple1>": {
"sdkRootPath": "<a required path relative to `destination.json` containing SDK root>",
"swiftResourcesPath": "<an optional path relative to `destination.json` containing Swift resources>",
"includeSearchPaths": ["<optional array of paths relative to `destination.json` containing headers>"],
"librarySearchPaths": ["<optional array of paths relative to `destination.json` containing libraries>"],
"toolsetPaths": ["<optional array of paths relative to `destination.json` containing toolset files>"]
// all of the properties listed below are optional:
"swiftResourcesPath": "<a path relative to `destination.json` containing Swift resources for dynamic linking>",
"swiftStaticResourcesPath": "<a path relative to `destination.json` containing Swift resources for static linking>",
"includeSearchPaths": ["<array of paths relative to `destination.json` containing headers>"],
"librarySearchPaths": ["<array of paths relative to `destination.json` containing libraries>"],
"toolsetPaths": ["<array of paths relative to `destination.json` containing toolset files>"]
},
// a destination can support more than one run-time triple:
"<triple2>": {
"sdkRootPath": "<a required path relative to `destination.json` containing SDK root>",
"swiftResourcesPath": "<an optional path relative to `destination.json` containing Swift resources>",
"includeSearchPaths": ["<optional array with relative paths containing headers in the destination tree>"],
"librarySearchPaths": ["<optional array with relative paths containing libraries in the destination tree>"],
"toolsetPaths": ["<optional array of paths relative to `destination.json` containing toolset files>"]
// all of the properties listed below are optional:
"swiftResourcesPath": "<a path relative to `destination.json` containing Swift resources for dynamic linking>",
"swiftStaticResourcesPath": "<a path relative to `destination.json` containing Swift resources for static linking>",
"includeSearchPaths": ["<array of paths relative to `destination.json` containing headers>"],
"librarySearchPaths": ["<array of paths relative to `destination.json` containing libraries>"],
"toolsetPaths": ["<array of paths relative to `destination.json` containing toolset files>"]
}
// more triples can be supported by a single destination if needed, primarily for sharing files between them.
]
Expand All @@ -318,9 +322,10 @@ bundles. That is, `../` components, if present in paths, will not be allowed to
directories outside of a corresponding destination bundle. Symlinks will also be validated to prevent them from escaping
out of the bundle.

If `sdkRootPath` is specified and `swiftResourcesPath` is not, the latter is inferred to be
`"\(sdkRootPath)/usr/lib/swift"`. Similarly `includeSearchPaths` is inferred as `["\(sdkRootPath)/usr/include"]`,
`librarySearchPaths` as `["\(sdkRootPath)/usr/lib"]`.
If `sdkRootPath` is specified and `swiftResourcesPath` is not, the latter is inferred to be
`"\(sdkRootPath)/usr/lib/swift"` when linking the Swift standard library dynamically, `"swiftStaticResourcesPath"` is
inferred to be `"\(sdkRootPath)/usr/lib/swift_static"` when linking it dynamically. Similarly, `includeSearchPaths` is

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second time: dynamically -> statically. Also, won't these be used just to build static libraries too, so maybe it should be made more general to when linking libraries dynamically in the first instance?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's addressed now.

won't these be used just to build static libraries too

I'm not aware of that. Can you point to specific place in the source code or documentation that supports this statement?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just built SwiftSyntax, which has several static libraries, on linux to check, and it appears to build the object files in a SPM target by looking in the dynamic resource directory for the stdlib interface files, then simply use ar to package them together. I don't know if that's a mistake, as the static resource directory has its own interface files, but what you wrote about the static stdlib initially is correct.

inferred as `["\(sdkRootPath)/usr/include"]`, `librarySearchPaths` as `["\(sdkRootPath)/usr/lib"]`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this changing the current behavior, ie these -I/-L flags are not added by default to the SDK path? Maybe these two include/lib paths should be kept empty by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We won't populate them in SwiftPM explicitly with -I/-L when these properties are absent or empty in destination.json, but that's my understanding of what the behavior is when only -sdk option is passed to swiftc.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's my understanding of what the behavior is when only -sdk option is passed to swiftc.

No, it doesn't on linux, see the output from swiftlang/swift#63416. The reason is that the SDK is the C sysroot and these are Swift include/lib flags, so the compiler only looks in the Swift resource directory, not the normal non-Swift SDK locations you list here.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you update this doc to mention that nothing is done by default, should be okay.


Here's `destination.json` file for the `ubuntu_jammy` artifact previously introduced as an example:

Expand Down