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

[6.0] Add support for new Bionic module from Android overlay (import Bionic) (#7615) #7752

Merged
merged 2 commits into from
Jul 10, 2024

Conversation

finagolfin
Copy link
Member

@finagolfin finagolfin commented Jul 3, 2024

Explanation: Now that this new overlay was merged into the 6.0 compiler too in swiftlang/swift#74758, this adds the overlay to five of the seven files that currently import Glibc, with those last two showing no difference if this wasn't added, like PackageDescription.swift, so remove most of those imports.

Scope: Add imports on Android and remove a handful in two files that were unused

Issue: None

Original PRs: #7615 and #7755

Risk: Very low

Testing: Passed all CI on trunk, plus on my daily Android CI

Reviewer: @bnbarham

@finagolfin finagolfin requested a review from a team as a code owner July 3, 2024 19:33
@finagolfin
Copy link
Member Author

@kateinoigakukun, need a CI run here.

@kateinoigakukun
Copy link
Member

@swift-ci test

@finagolfin
Copy link
Member Author

@kateinoigakukun, passed CI, ready for merge. I need this so the upcoming Swift 6.0 compiler snapshots with this overlay have a SwiftPM that can generate the test file with this new overlay.

@finagolfin
Copy link
Member Author

Hold off, missed one more import which I just submitted in #7755, will add that here once it's in trunk.

@@ -4,6 +4,8 @@ import Darwin
import Glibc
#elseif canImport(Musl)
import Musl
#elseif canImport(Android)
import Android
Copy link
Member

Choose a reason for hiding this comment

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

Can this be Bionic? The other platforms seem to be importing the C library rather than the platform module.

Copy link
Member

Choose a reason for hiding this comment

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

Is this relevant to the swift argument parser support pr as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -2,6 +2,8 @@
import Glibc
#elseif canImport(Musl)
import Musl
#elseif canImport(Android)
import Android
Copy link
Member

Choose a reason for hiding this comment

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

Likewise.

Copy link
Member Author

Choose a reason for hiding this comment

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

Miscellaneous_EchoExecutable/Sources/secho/main.swift:11:11: error: cannot find 'getcwd' in scope
     9 | #endif
    10 |
    11 | let cwd = getcwd(nil, Int(PATH_MAX))
       |           `- error: cannot find 'getcwd' in scope
    12 | defer { free(cwd) }
    13 | let workingDirectory = String(validatingUTF8: cwd!)!

getcwd() is declared in unistd.h, which is in the Android overlay but not in the Bionic module that Swift uses.

The rest may work as import Bionic though, I will do more testing and let you know.

@@ -132,6 +132,8 @@ public func generateTestObservationCode(buildParameters: BuildParameters) -> Str
@_exported import WinSDK
#elseif os(WASI)
@_exported import WASILibc
#elseif canImport(Android)
@_exported import Android
Copy link
Member

Choose a reason for hiding this comment

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

This one potentially as well - the Windows case is probably for additional Win32 APIs that are needed, but I am unsure about the re-export there 🤔.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -39,6 +39,8 @@ import Darwin
import Glibc
#elseif canImport(Musl)
import Musl
#elseif canImport(Android)
import Android
Copy link
Member

Choose a reason for hiding this comment

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

Seems at all the sources?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll check.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

This adds the overlay to four of the six files that currently `import
Glibc`, with those last two showing no difference if this _wasn't_
added, like `PackageDescription.swift`.
Also, add the import in `Environment.swift` too
@finagolfin finagolfin changed the title [6.0] Add support for new Android overlay (import Android) (#7615) [6.0] Add support for new Bionic module from Android overlay (import Bionic) (#7615) Jul 9, 2024
@compnerd
Copy link
Member

compnerd commented Jul 9, 2024

@swift-ci please test

@finagolfin
Copy link
Member Author

@bnbarham
Copy link
Contributor

@swift-ci please test Windows platform

@finagolfin
Copy link
Member Author

@MaxDesiatov, passed CI, ready for merge.

@bnbarham bnbarham merged commit c04a8b0 into swiftlang:release/6.0 Jul 10, 2024
5 checks passed
@finagolfin finagolfin deleted the release/6.0 branch July 10, 2024 18:53
@finagolfin
Copy link
Member Author

Thanks for the quick review, @bnbarham and @compnerd, now I can stop patching the prebuilt swift-package executable instead on my Android CI. 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants