apple / swift-foundation

The Foundation project
Apache License 2.0
2.28k stars 135 forks source link

FoundationEssentials: make build on Android #705

Closed compnerd closed 4 days ago

compnerd commented 1 week ago

This adjusts the API usage to account for differences on Android. The biggest source of difference is the nullability, particularly in the fts APIs. Unfortunately, MMAP_FAILED is not imported by the clang importer due to the casting involved so we manually inline the constant at the single site.

compnerd commented 1 week ago

@swift-ci please test

parkera commented 1 week ago

Looks like it introduces some issues for Linux?

/build/swift-foundation/Sources/FoundationEssentials/FileManager/FileOperations+Enumeration.swift:308:51: error: value of optional type 'UnsafeMutablePointer<CChar>?' (aka 'Optional<UnsafeMutablePointer<Int8>>') must be unwrapped to a value of type 'UnsafeMutablePointer<CChar>' (aka 'UnsafeMutablePointer<Int8>')
compnerd commented 1 week ago

@swift-ci please test

compnerd commented 1 week ago

@swift-ci please test

compnerd commented 1 week ago

@parkera yeah, I didn't have a Linux machine handy - turns out that the nullability differences are in the FTS parameter not the structure! Trying to clean up the behavioural differences :(

compnerd commented 1 week ago

@swift-ci please test

compnerd commented 1 week ago

@swift-ci please test

compnerd commented 1 week ago

@swift-ci please test

compnerd commented 1 week ago

@parkera @jmschonfeld - okay, I expect this to pass the CI now, but this will not build for Android. I've dug through the issue and it appears to be a bug in Bionic. The declaration that they have in the Bionic header is misattributed with incorrect nullability. I am going to see if I can adjust this via APINotes, failing that, we might have to do some shims for fts_open.

compnerd commented 4 days ago

@swift-ci please test

compnerd commented 4 days ago

@parkera @jmschonfeld - can we get this merged? The remaining failure requires an updated toolchain to build (I just merged the necessary changes into the compiler).