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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import Darwin
import Glibc
#elseif canImport(Musl)
import Musl
#elseif canImport(Bionic)
import Bionic
#endif

public extension Collection {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

#else
import Darwin.C
#endif
Expand Down
2 changes: 2 additions & 0 deletions Sources/Basics/Environment/Environment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import Musl
#elseif os(Windows)
import CRT
import WinSDK
#elseif canImport(Bionic)
import Bionic
#else
import Darwin.C
#endif
Expand Down
2 changes: 2 additions & 0 deletions Sources/Build/TestObservation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ public func generateTestObservationCode(buildParameters: BuildParameters) -> Str
@_exported import WinSDK
#elseif os(WASI)
@_exported import WASILibc
#elseif canImport(Bionic)
@_exported import Bionic
#else
@_exported import Darwin.C
#endif
Expand Down
2 changes: 2 additions & 0 deletions Sources/CoreCommands/SwiftCommandState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import Darwin
import Glibc
#elseif canImport(Musl)
import Musl
#elseif canImport(Bionic)
import Bionic
#endif

import func TSCBasic.exec
Expand Down
8 changes: 1 addition & 7 deletions Sources/PackageDescription/PackageDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@
//
//===----------------------------------------------------------------------===//

#if canImport(Glibc)
@_implementationOnly import Glibc
#elseif canImport(Musl)
@_implementationOnly import Musl
#elseif canImport(Darwin)
@_implementationOnly import Darwin.C
#elseif canImport(ucrt) && canImport(WinSDK)
#if canImport(ucrt) && canImport(WinSDK)
@_implementationOnly import ucrt
@_implementationOnly import struct WinSDK.HANDLE
#endif
Expand Down
11 changes: 0 additions & 11 deletions Tests/PackageLoadingTests/PD_5_3_LoadingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -505,17 +505,6 @@ final class PackageDescription5_3LoadingTests: PackageDescriptionLoadingTests {

func testNonZeroExitStatusDoesNotAssert() async throws {
let content = """
#if canImport(Glibc)
import Glibc
#elseif canImport(Musl)
import Musl
#elseif os(Windows)
import MSVCRT
import WinSDK
#else
import Darwin.C
#endif

print("crash")
exit(1)
"""
Expand Down