Skip to content

Building against API 28+ without libandroid-spawn has different nullability for posix_spawn* types #219

@marcprux

Description

@marcprux

When building against an Android SDK that targets API level 28 and higher, we no longer need to include the termux libandroid-spawn.so. But now the posix_spawn* types have a different nullability, leading to errors like this one:

/home/runner/work/swift-package-builds/swift-package-builds/swift-tools-support-core/Sources/TSCBasic/Process/Process.swift:736:50: error: value of optional type 'posix_spawn_file_actions_t?' (aka 'Optional<OpaquePointer>') must be unwrapped to a value of type 'posix_spawn_file_actions_t' (aka 'OpaquePointer')
 734 |                 // If no redirect was requested, open the pipe for stderr.
 735 |                 try open(pipe: &stderrPipe)
 736 |                 posix_spawn_file_actions_adddup2(&fileActions, stderrPipe[1], 2)
     |                                                  |- error: value of optional type 'posix_spawn_file_actions_t?' (aka 'Optional<OpaquePointer>') must be unwrapped to a value of type 'posix_spawn_file_actions_t' (aka 'OpaquePointer')
     |                                                  `- note: force-unwrap using '!' to abort execution if the optional value contains 'nil'
 737 | 
 738 |                 // Close the other ends of the pipe since they were dupped to 2.

The nullability difference is mentioned at 52cb792. We can just update swift-tools-support-core and other packages that use posix_spawn to special-case Android's optionality, but is there any way that the code can support both the older 6.1 SDK and future 6.2+ SDKs with the differing nullability?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions