Skip to content

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

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
Nov 28, 2024

Conversation

euanh
Copy link
Contributor

@euanh euanh commented Nov 26, 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 *

This change fixes issue #152. Compared to #153, the end-to-end
tests now pass for all supported Swift versions, distributions and
architectures.

SDK Hello World Foundation
ubuntu_aarch64_5.9.2-RELEASE ok ok
ubuntu_aarch64_5.9.2-RELEASE_with-docker ok ok
ubuntu_aarch64_5.10.1-RELEASE ok ok
ubuntu_aarch64_5.10.1-RELEASE_with-docker ok ok
ubuntu_aarch64_6.0.2-RELEASE ok ok
ubuntu_aarch64_6.0.2-RELEASE_with-docker ok ok
ubuntu_x86_64_5.9.2-RELEASE ok ok
ubuntu_x86_64_5.9.2-RELEASE_with-docker ok ok
ubuntu_x86_64_5.10.1-RELEASE ok ok
ubuntu_x86_64_5.10.1-RELEASE_with-docker ok ok
ubuntu_x86_64_6.0.2-RELEASE ok ok
ubuntu_x86_64_6.0.2-RELEASE_with-docker ok ok
rhel_aarch64_5.9.2-RELEASE_with-docker ok ok
rhel_aarch64_5.10.1-RELEASE_with-docker ok ok
rhel_aarch64_6.0.2-RELEASE_with-docker ok ok
rhel_x86_64_5.9.2-RELEASE_with-docker ok ok
rhel_x86_64_5.10.1-RELEASE_with-docker ok ok
rhel_x86_64_6.0.2-RELEASE_with-docker ok ok

FAIL1: cannot find /lib/ld-linux-aarch64.so.1 (#147)
FAIL2: missing required module '_FoundationCShims' (#152)

Fixes: #152
Depends on: #153, #154

@euanh
Copy link
Contributor Author

euanh commented Nov 26, 2024

@swift-ci test

@euanh euanh added the bug Something isn't working label Nov 26, 2024
@euanh euanh force-pushed the issue152-foundation-cshims branch from a6aa907 to 77671c9 Compare November 27, 2024 11:24
@euanh
Copy link
Contributor Author

euanh commented Nov 27, 2024

@swift-ci test

@euanh euanh marked this pull request as ready for review November 27, 2024 11:26
@euanh euanh requested a review from MaxDesiatov as a code owner November 27, 2024 11:26
@euanh euanh force-pushed the issue152-foundation-cshims branch from 77671c9 to 7841011 Compare November 27, 2024 15:47
@euanh
Copy link
Contributor Author

euanh commented Nov 27, 2024

@swift-ci test

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 *

This change fixes issue swiftlang#152. Compared to swiftlang#153, the end-to-end
tests now pass for all supported Swift versions, distributions and
architectures.

| SDK                                       | Hello World | Foundation |
| ----------------------------------------- | ----------- | ---------- |
| ubuntu_aarch64_5.9.2-RELEASE              | ok          | ok         |
| ubuntu_aarch64_5.9.2-RELEASE_with-docker  | ok          | ok         |
| ubuntu_aarch64_5.10.1-RELEASE             | ok          | ok         |
| ubuntu_aarch64_5.10.1-RELEASE_with-docker | ok          | ok         |
| ubuntu_aarch64_6.0.2-RELEASE              | ok          | ok         |
| ubuntu_aarch64_6.0.2-RELEASE_with-docker  | ok          | ok         |
|                                           |             |            |
| ubuntu_x86_64_5.9.2-RELEASE               | ok          | ok         |
| ubuntu_x86_64_5.9.2-RELEASE_with-docker   | ok          | ok         |
| ubuntu_x86_64_5.10.1-RELEASE              | ok          | ok         |
| ubuntu_x86_64_5.10.1-RELEASE_with-docker  | ok          | ok         |
| ubuntu_x86_64_6.0.2-RELEASE               | ok          | ok         |
| ubuntu_x86_64_6.0.2-RELEASE_with-docker   | ok          | ok         |
|                                           |             |            |
| rhel_aarch64_5.9.2-RELEASE_with-docker    | ok          | ok         |
| rhel_aarch64_5.10.1-RELEASE_with-docker   | ok          | ok         |
| rhel_aarch64_6.0.2-RELEASE_with-docker    | ok          | ok         |
|                                           |             |            |
| rhel_x86_64_5.9.2-RELEASE_with-docker     | ok          | ok         |
| rhel_x86_64_5.10.1-RELEASE_with-docker    | ok          | ok         |
| rhel_x86_64_6.0.2-RELEASE_with-docker     | ok          | ok         |

FAIL1: cannot find /lib/ld-linux-aarch64.so.1  (swiftlang#147)
FAIL2: missing required module '_FoundationCShims'   (swiftlang#152)

Fixes: swiftlang#152
Depends on: swiftlang#153, swiftlang#154
@euanh euanh force-pushed the issue152-foundation-cshims branch from 7841011 to 8e3f228 Compare November 28, 2024 09:04
@euanh
Copy link
Contributor Author

euanh commented Nov 28, 2024

@swift-ci test

@euanh euanh enabled auto-merge (squash) November 28, 2024 09:05
@euanh euanh disabled auto-merge November 28, 2024 09:05
@euanh euanh enabled auto-merge (squash) November 28, 2024 09:05
@euanh euanh merged commit 4339b89 into swiftlang:main Nov 28, 2024
1 of 3 checks passed
@euanh euanh deleted the issue152-foundation-cshims branch November 28, 2024 09:07
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.

missing required module '_FoundationCShims' error when building with Swift 6.0 SDKs
2 participants