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

generator/linux: Use swiftResourcesPath to find framework headers #139

Merged

Conversation

euanh
Copy link
Contributor

@euanh euanh commented Oct 31, 2024

Building with a Swift 6.0 SDK fails because the new _FoundationCShims framework headers can't be found:

<unknown>:0: error: missing required module '_FoundationCShims'

The necessary files are present in $PLATFORM.sdk/usr/lib/swift, but are not part of the list which is copied to
$PLATFORM.sdk/usr/include. The Static Linux SDK and WASM SDK generator don't copy these files into /usr/include; instead they set the swiftResourcesPath and swiftStaticResourcesPath fields in swift-sdk.json, which causes the build system to look in those paths for framework headers.

We can do the same for Linux SDKs, however we must stop copying the files to /usr/include, otherwise the build will fail because the framework header definitions are duplicated:

error: redefinition of module 'DispatchIntrospection'
 6 | }
 7 |
 8 | module DispatchIntrospection [system] [extern_c] {
   |        `- error: redefinition of module 'DispatchIntrospection'
 9 |    header "introspection.h"
10 |    export *

Partial fix for #138

Building with a Swift 6.0 SDK fails because the new `_FoundationCShims`
framework headers can't be found:

    <unknown>:0: error: missing required module '_FoundationCShims'

The necessary files are present in `$PLATFORM.sdk/usr/lib/swift`,
but are not part of the list which is copied to
`$PLATFORM.sdk/usr/include`.  The Static Linux SDK and WASM SDK
generator don't copy these files into /usr/include;  instead they
set the `swiftResourcesPath` and `swiftStaticResourcesPath` fields
in `swift-sdk.json`, which causes the build system to look in those
paths for framework headers.

We can do the same for Linux SDKs, however we must stop copying the
files to `/usr/include`, otherwise the build will fail because the
framework header definitions are duplicated:

    error: redefinition of module 'DispatchIntrospection'
     6 | }
     7 |
     8 | module DispatchIntrospection [system] [extern_c] {
       |        `- error: redefinition of module 'DispatchIntrospection'
     9 |    header "introspection.h"
    10 |    export *
@euanh euanh requested a review from MaxDesiatov as a code owner October 31, 2024 11:49
@euanh
Copy link
Contributor Author

euanh commented Oct 31, 2024

@swift-ci test

Copy link
Contributor

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

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

Great find, thanks!

How hard would it be to add a test for this to our test suite?

@euanh
Copy link
Contributor Author

euanh commented Oct 31, 2024

How hard would it be to add a test for this to our test suite?

The EndToEnd test would already catch it if it was run with Swift 6.0, but we currently only run tests in CI on macOS:

https://github.com/swiftlang/swift-sdk-generator/blob/ea3e8245233856cfc22901fa6f9c28101ace5e54/Utilities/test.sh#L16C1-L20C3

...but the EndToEnd tests are skipped on macOS 😞:

@MaxDesiatov
Copy link
Contributor

I see, I'll try look into running tests on Linux then at some point.

@MaxDesiatov MaxDesiatov merged commit 2ae9e21 into swiftlang:main Oct 31, 2024
3 checks passed
@MaxDesiatov MaxDesiatov added the bug Something isn't working label Oct 31, 2024
@euanh
Copy link
Contributor Author

euanh commented Oct 31, 2024

I see, I'll try look into running tests on Linux then at some point.

I have another PR in progress to fix an ld-linux.so problem; after that I might have some time to spend on the CI. We should think about adopting the GitHub actions CI (https://github.com/swiftlang/github-workflows). For example: https://github.com/apple/swift-container-plugin/blob/main/.github/workflows/pull_request.yml

@euanh euanh deleted the swiftResourcesPath-framework-headers branch October 31, 2024 12:18
@euanh
Copy link
Contributor Author

euanh commented Oct 31, 2024

The EndToEnd test would already catch it if it was run with Swift 6.0

I think this would need a matrix job to set --swift-version 6.0-RELEASE (and other options). I don't think just building on Swift 6.0 is enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants