-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[android] add an Android NDK Swift overlay #72634
Conversation
89534bb
to
cb98c2b
Compare
@swift-ci please test |
This needs some changes to build Foundation that @compnerd has as well. |
a13f749
to
378f474
Compare
@swift-ci please test |
@swift-ci please test source compatibility |
I made some comments on your latest commit. |
4786393
to
b5531e7
Compare
@finagolfin addressed your review comments |
Fixed some executable tests that were failing natively on Android and rebased, hyp#1. |
@@ -241,7 +241,7 @@ public var S_IFIFO: Int32 { return Int32(0x1000) } | |||
public var S_IREAD: Int32 { return Int32(0x0100) } | |||
public var S_IWRITE: Int32 { return Int32(0x0080) } | |||
public var S_IEXEC: Int32 { return Int32(0x0040) } | |||
#else | |||
#elseif !os(Android) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to do this? I understand that you are avoiding this subsequent compilation error when trying to build against the resulting stdlib and it does fix that:
swift-corelibs-foundation/Sources/Foundation/FileHandle.swift:324:39: error: ambiguous use of 'S_IFMT'
322 |
323 | let readBlockSize: Int
324 | if Int(statbuf.st_mode) & Int(S_IFMT) == Int(S_IFREG) {
| `- error: ambiguous use of 'S_IFMT'
325 | // TODO: Should files over a certain size always be mmap()'d?
326 | if options.contains(.alwaysMapped) {
Android.S_IFMT:1:12: note: found this candidate in module 'Android'
1 | public var S_IFMT: mode_t { get }
| `- note: found this candidate in module 'Android'
posix_filesystem.S_IFMT:1:12: note: found this candidate in module 'posix_filesystem'
1 | public var S_IFMT: Int32 { get }
| `- note: found this candidate in module 'posix_filesystem'
However, it then causes problems downstream when building projects like NIO, as these constants are imported as Int32
from the C headers but mode_t
is UInt32
on Android AArch64:
swift-nio/Sources/NIOCore/FileHandle.swift:147:76: error: default argument value of type 'Int32' cannot be converted to type 'NIOPOSIXFileMode' (aka 'UInt32')
145 │ /// - parameters:
146 │ /// - posixMode: `file mode` applied when file is created. Default permissions are: read and write for fileowner, read for owners group and others.
147 │ public static func allowFileCreation(posixMode: NIOPOSIXFileMode = defaultPermissions) -> Flags {
│ ╰─ error: default argument value of type 'Int32' cannot be converted to type 'NIOPOSIXFileMode' (aka 'UInt32')
148 │ return Flags(posixMode: posixMode, posixFlags: O_CREAT)
149 │ }
It is convenient that these constants in this file are typed mode_t
on all non-Windows platforms: any way we can make this work? You would not need all the mode_t
conversions on swiftlang/swift-corelibs-foundation#4889 either if we got this working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I don't have a good idea for how to resolve this ambiguity, but perhaps we can special case these constants when they're imported on Android in the clang importer, and make them disfavored, so that Swift will always prefer the ones from the 'Android' module. what do you think of that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems extreme, must be a simpler way? I will try some things and let you know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I can do it by using fine grained export control on some of the modules here that use linux/stat.h, trying that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think that will work! @finagolfin I will update the PR and swift-corelibs-foundation too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm seeing native compilation errors in Termux after this change:
[220/223][ 98%][55.721s] Linking Swift shared library lib/libFoundation.so
FAILED: lib/libFoundation.so Sources/Foundation/CMakeFiles/Foundation.dir/AffineTransform.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Array.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/AttributedString/AttributedString.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/AttributedString/AttributedStringAttribute.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/AttributedString/AttributedStringCodable.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/AttributedString/AttributedStringRunCoalescing.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/AttributedString/AttributedString+Locking.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Boxing.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Bridging.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Bundle.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/ByteCountFormatter.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Calendar.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/CGFloat.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/CharacterSet.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Codable.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Collections+DataProtocol.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/ContiguousBytes.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/AttributedString/Conversion.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Data.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/DataProtocol.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Date.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/DateComponents.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/DateComponentsFormatter.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/DateFormatter.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/DateInterval.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/DateIntervalFormatter.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Decimal.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Dictionary.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/DispatchData+DataProtocol.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/EnergyFormatter.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/ExtraStringAPIs.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/FileHandle.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/FileManager.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/FileManager+POSIX.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/FileManager+Win32.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/FileManager+XDG.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Formatter.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/AttributedString/FoundationAttributes.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/FoundationErrors.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Host.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/IndexPath.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/IndexSet.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/ISO8601DateFormatter.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/JSONDecoder.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/JSONEncoder.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/JSONSerialization.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/JSONSerialization+Parser.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/LengthFormatter.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Locale.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/MassFormatter.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Measurement.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/MeasurementFormatter.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Morphology.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Notification.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NotificationQueue.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSArray.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSAttributedString.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSCache.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSCalendar.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSCFArray.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSCFBoolean.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSCFCharacterSet.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSCFDictionary.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSCFSet.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSCFString.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSCFTypeShims.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSCharacterSet.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSCoder.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSComparisonPredicate.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSCompoundPredicate.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSConcreteValue.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSData+DataProtocol.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSData.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSDate.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSDateComponents.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSDecimalNumber.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSDictionary.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSEnumerator.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSError.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSExpression.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSGeometry.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSIndexPath.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSIndexSet.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSKeyedArchiver.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSKeyedArchiverHelpers.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSKeyedCoderOldStyleArray.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSKeyedUnarchiver.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSLocale.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSLock.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSLog.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSMeasurement.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSNotification.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSNull.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSNumber.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSObjCRuntime.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSObject.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSOrderedSet.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSPathUtilities.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSPersonNameComponents.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSPlatform.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSPredicate.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSRange.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSRegularExpression.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSSet.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSSortDescriptor.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSSpecialValue.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSString.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSStringAPI.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSSwiftRuntime.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSTextCheckingResult.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSTimeZone.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSURL.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSURLComponents.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSURLQueryItem.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSURLError.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSUUID.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NSValue.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/NumberFormatter.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Operation.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/PersonNameComponents.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/PersonNameComponentsFormatter.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Pointers+DataProtocol.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Port.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/PortMessage.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Process.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/ProcessInfo.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Progress.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/ProgressFraction.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/PropertyListEncoder.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/PropertyListSerialization.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/ReferenceConvertible.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/RunLoop.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Scanner.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/ScannerAPI.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Set.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Stream.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/String.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/StringEncodings.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Thread.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Timer.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/TimeZone.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/Unit.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/URL.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/URLComponents.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/URLQueryItem.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/URLResourceKey.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/UserDefaults.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/UUID.swift.o Sources/Foundation/CMakeFiles/Foundation.dir/WinSDK+Extensions.swift.o swift/Foundation.swiftmodule
: && /data/data/com.termux/files/home/build/Ninja-Release/swift-android-aarch64/bin/swiftc -j 8 -num-threads 8 -emit-library -o lib/libFoundation.so -module-name Foundation -module-link-name Foundation -emit-module -emit-module-path swift/Foundation.swiftmodule -emit-dependencies -DDEPLOYMENT_RUNTIME_SWIFT -DFoundation_EXPORTS -DSWIFT_CORELIBS_FOUNDATION_HAS_THREADS -module-cache-path "/data/data/com.termux/files/home/build/Ninja-Release/foundation-android-aarch64/module-cache" -O -wmo -Xcc -DSWIFT_CORELIBS_FOUNDATION_HAS_THREADS -Xfrontend -disable-autolink-framework -Xfrontend CoreFoundation -Xcc -F/data/data/com.termux/files/home/build/Ninja-Release/foundation-android-aarch64 -vfsoverlay /data/data/com.termux/files/home/build/Ninja-Release/libdispatch-android-aarch64/dispatch-vfs-overlay.yaml -output-file-map Sources/Foundation/CMakeFiles/Foundation.dir/Release/output-file-map.json -I /data/data/com.termux/files/home/build/Ninja-Release/foundation-android-aarch64/CoreFoundation.framework/Headers -I /data/data/com.termux/files/home/build/Ninja-Release/libdispatch-android-aarch64/src/swift/swift -I /data/data/com.termux/files/home/build/Ninja-Release/libdispatch-android-aarch64 -I /data/data/com.termux/files/home/swift-corelibs-libdispatch -I /data/data/com.termux/files/home/swift-corelibs-libdispatch/src -I /data/data/com.termux/files/home/build/Ninja-Release/libdispatch-android-aarch64/src -I /data/data/com.termux/files/home/swift-corelibs-libdispatch/src/BlocksRuntime /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/AffineTransform.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Array.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/AttributedString/AttributedString.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/AttributedString/AttributedStringAttribute.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/AttributedString/AttributedStringCodable.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/AttributedString/AttributedStringRunCoalescing.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/AttributedString/AttributedString+Locking.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Boxing.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Bridging.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Bundle.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/ByteCountFormatter.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Calendar.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/CGFloat.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/CharacterSet.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Codable.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Collections+DataProtocol.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/ContiguousBytes.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/AttributedString/Conversion.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Data.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/DataProtocol.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Date.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/DateComponents.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/DateComponentsFormatter.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/DateFormatter.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/DateInterval.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/DateIntervalFormatter.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Decimal.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Dictionary.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/DispatchData+DataProtocol.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/EnergyFormatter.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/ExtraStringAPIs.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/FileHandle.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/FileManager.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/FileManager+POSIX.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/FileManager+Win32.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/FileManager+XDG.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Formatter.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/AttributedString/FoundationAttributes.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/FoundationErrors.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Host.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/IndexPath.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/IndexSet.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/ISO8601DateFormatter.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/JSONDecoder.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/JSONEncoder.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/JSONSerialization.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/JSONSerialization+Parser.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/LengthFormatter.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Locale.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/MassFormatter.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Measurement.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/MeasurementFormatter.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Morphology.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Notification.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NotificationQueue.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSArray.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSAttributedString.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSCache.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSCalendar.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSCFArray.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSCFBoolean.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSCFCharacterSet.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSCFDictionary.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSCFSet.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSCFString.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSCFTypeShims.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSCharacterSet.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSCoder.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSComparisonPredicate.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSCompoundPredicate.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSConcreteValue.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSData+DataProtocol.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSData.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSDate.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSDateComponents.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSDecimalNumber.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSDictionary.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSEnumerator.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSError.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSExpression.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSGeometry.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSIndexPath.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSIndexSet.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSKeyedArchiver.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSKeyedArchiverHelpers.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSKeyedCoderOldStyleArray.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSKeyedUnarchiver.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSLocale.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSLock.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSLog.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSMeasurement.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSNotification.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSNull.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSNumber.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSObjCRuntime.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSObject.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSOrderedSet.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSPathUtilities.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSPersonNameComponents.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSPlatform.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSPredicate.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSRange.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSRegularExpression.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSSet.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSSortDescriptor.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSSpecialValue.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSString.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSStringAPI.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSSwiftRuntime.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSTextCheckingResult.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSTimeZone.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSURL.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSURLComponents.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSURLQueryItem.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSURLError.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSUUID.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NSValue.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/NumberFormatter.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Operation.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/PersonNameComponents.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/PersonNameComponentsFormatter.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Pointers+DataProtocol.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Port.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/PortMessage.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Process.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/ProcessInfo.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Progress.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/ProgressFraction.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/PropertyListEncoder.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/PropertyListSerialization.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/ReferenceConvertible.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/RunLoop.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Scanner.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/ScannerAPI.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Set.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Stream.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/String.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/StringEncodings.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Thread.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Timer.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/TimeZone.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Unit.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/URL.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/URLComponents.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/URLQueryItem.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/URLResourceKey.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/UserDefaults.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/UUID.swift /data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/WinSDK+Extensions.swift -no-toolchain-stdlib-rpath -Xlinker -soname -Xlinker libFoundation.so -L /data/data/com.termux/files/home/build/Ninja-Release/foundation-android-aarch64/lib -L /data/data/com.termux/files/home/build/Ninja-Release/foundation-android-aarch64/lib -L /data/data/com.termux/files/home/build/Ninja-Release/libdispatch-android-aarch64 -L /data/data/com.termux/files/home/build/Ninja-Release/libdispatch-android-aarch64 -L /data/data/com.termux/files/home/build/Ninja-Release/libdispatch-android-aarch64 -L /data/data/com.termux/files/usr/lib -L /data/data/com.termux/files/usr/aarch64-linux-android/lib -L /system/lib64 -Xlinker -rpath -Xlinker /data/data/com.termux/files/home/build/Ninja-Release/libdispatch-android-aarch64:/data/data/com.termux/files/usr/lib: lib/libCoreFoundation.a lib/libuuid.a /data/data/com.termux/files/home/build/Ninja-Release/libdispatch-android-aarch64/libswiftDispatch.so -llog /data/data/com.termux/files/usr/lib/libicuuc.so -ldl /data/data/com.termux/files/usr/lib/libicui18n.so /data/data/com.termux/files/usr/lib/libicudata.so -lm /data/data/com.termux/files/home/build/Ninja-Release/libdispatch-android-aarch64/libdispatch.so /data/data/com.termux/files/home/build/Ninja-Release/libdispatch-android-aarch64/libBlocksRuntime.so -l:libunwind.a -ldl -lc -l:libunwind.a -ldl && :
<module-includes>:1:10: note: in file included from <module-includes>:1:
1 │ #include "Headers/CoreFoundation.h"
│ ╰─ note: in file included from <module-includes>:1:
2 │ #include "Headers/CFPlugInCOM.h"
3 │
/data/data/com.termux/files/home/build/Ninja-Release/foundation-android-aarch64/CoreFoundation.framework/Headers/CoreFoundation.h:103:10: note: in file included from /data/data/com.termux/files/home/build/Ninja-Release/foundation-android-aarch64/CoreFoundation.framework/Headers/CoreFoundation.h:103:
101 │ #include <CoreFoundation/CFNotificationCenter.h>
102 │
103 │ #include <CoreFoundation/ForSwiftFoundationOnly.h>
│ ╰─ note: in file included from /data/data/com.termux/files/home/build/Ninja-Release/foundation-android-aarch64/CoreFoundation.framework/Headers/CoreFoundation.h:103:
104 │
105 │ #endif /* ! __COREFOUNDATION_COREFOUNDATION__ */
/data/data/com.termux/files/home/build/Ninja-Release/foundation-android-aarch64/CoreFoundation.framework/Headers/ForSwiftFoundationOnly.h:607:18: error: definition of 'statx' must be imported from module 'posix_filesystem.linux_stat' before it is required
605 │ static inline int
606 │ _stat_with_btime(const char *filename, struct stat *buffer, struct timespec *btime) {
607 │ struct statx statx_buffer = {0};
│ ╰─ error: definition of 'statx' must be imported from module 'posix_filesystem.linux_stat' before it is required
608 │ *btime = (struct timespec) {0};
609 │
/data/data/com.termux/files/usr/include/linux/stat.h:59:8: note: definition here is not reachable
57 │ __s32 __reserved;
58 │ };
59 │ struct statx {
│ ╰─ note: definition here is not reachable
60 │ __u32 stx_mask;
61 │ __u32 stx_blksize;
<module-includes>:1:10: note: in file included from <module-includes>:1:
1 │ #include "Headers/CoreFoundation.h"
│ ╰─ note: in file included from <module-includes>:1:
2 │ #include "Headers/CFPlugInCOM.h"
3 │
/data/data/com.termux/files/home/build/Ninja-Release/foundation-android-aarch64/CoreFoundation.framework/Headers/CoreFoundation.h:103:10: note: in file included from /data/data/com.termux/files/home/build/Ninja-Release/foundation-android-aarch64/CoreFoundation.framework/Headers/CoreFoundation.h:103:
101 │ #include <CoreFoundation/CFNotificationCenter.h>
102 │
103 │ #include <CoreFoundation/ForSwiftFoundationOnly.h>
│ ╰─ note: in file included from /data/data/com.termux/files/home/build/Ninja-Release/foundation-android-aarch64/CoreFoundation.framework/Headers/CoreFoundation.h:103:
104 │
105 │ #endif /* ! __COREFOUNDATION_COREFOUNDATION__ */
/data/data/com.termux/files/home/build/Ninja-Release/foundation-android-aarch64/CoreFoundation.framework/Headers/ForSwiftFoundationOnly.h:610:87: error: use of undeclared identifier 'STATX_ALL'
608 │ *btime = (struct timespec) {0};
609 │
610 │ int ret = _statx(AT_FDCWD, filename, AT_SYMLINK_NOFOLLOW | AT_STATX_SYNC_AS_STAT, STATX_ALL, &statx_buffer);
│ ╰─ error: use of undeclared identifier 'STATX_ALL'
611 │ if (ret == 0) {
612 │ *buffer = (struct stat) {
<module-includes>:1:10: note: in file included from <module-includes>:1:
1 │ #include "Headers/CoreFoundation.h"
│ ╰─ note: in file included from <module-includes>:1:
2 │ #include "Headers/CFPlugInCOM.h"
3 │
/data/data/com.termux/files/home/build/Ninja-Release/foundation-android-aarch64/CoreFoundation.framework/Headers/CoreFoundation.h:103:10: note: in file included from /data/data/com.termux/files/home/build/Ninja-Release/foundation-android-aarch64/CoreFoundation.framework/Headers/CoreFoundation.h:103:
101 │ #include <CoreFoundation/CFNotificationCenter.h>
102 │
103 │ #include <CoreFoundation/ForSwiftFoundationOnly.h>
│ ╰─ note: in file included from /data/data/com.termux/files/home/build/Ninja-Release/foundation-android-aarch64/CoreFoundation.framework/Headers/CoreFoundation.h:103:
104 │
105 │ #endif /* ! __COREFOUNDATION_COREFOUNDATION__ */
/data/data/com.termux/files/home/build/Ninja-Release/foundation-android-aarch64/CoreFoundation.framework/Headers/ForSwiftFoundationOnly.h:628:37: error: use of undeclared identifier 'STATX_BTIME'
626 │ };
627 │ // Check that stx_btime was set in the response, not all filesystems support it.
628 │ if (statx_buffer.stx_mask & STATX_BTIME) {
│ ╰─ error: use of undeclared identifier 'STATX_BTIME'
629 │ *btime = (struct timespec) {
630 │ .tv_sec = statx_buffer.stx_btime.tv_sec,
/data/data/com.termux/files/home/swift-corelibs-foundation/Sources/Foundation/Bridging.swift:13:29: error: could not build C module 'CoreFoundation'
11 │ //===----------------------------------------------------------------------===//
12 │
13 │ @_implementationOnly import CoreFoundation
│ ╰─ error: could not build C module 'CoreFoundation'
14 │
15 │ #if canImport(ObjectiveC)
ninja: build stopped: subcommand failed.
You don't see this when cross-compiling foundation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@finagolfin No, it builds when cross-compliing. However, the linux/stat.h
include is only included whenever TARGET_ANDROID is set in the ForSwiftFoundationOnly.h
:
#if TARGET_OS_ANDROID
#include <errno.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <termios.h>
#include <linux/stat.h>
Is the TARGET_OS_ANDROID
define set whenever we're building for termux?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, the linux/stat.h include is only included whenever TARGET_ANDROID is set in the ForSwiftFoundationOnly.h
Where are you getting those includes from? I see nothing like that in that header, which only pulls in that linux/stat.h
header for Glibc, which is not used on Android:
#if TARGET_OS_ANDROID
#include <errno.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <termios.h>
#elif TARGET_OS_WASI
#include <fcntl.h>
#include <sys/stat.h>
// Define _WASI_EMULATED_MMAN here to use the emulated mman functions in
// Foundation-side without requiring transitive clients to define it.
#undef _WASI_EMULATED_MMAN
#define _WASI_EMULATED_MMAN
#include <sys/mman.h>
#elif TARGET_OS_LINUX
#include <errno.h>
#include <features.h>
#include <termios.h>
#ifdef __GLIBC_PREREQ
#if __GLIBC_PREREQ(2, 28) == 0
// required for statx() system call, glibc >=2.28 wraps the kernel function
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <linux/stat.h>
Is the TARGET_OS_ANDROID define set whenever we're building for termux?
Yes, it should be, otherwise it would not build at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see, you just modified your foundation pull to add it. I was building against the previous version of that pull first, to make sure everything still worked, so I missed that.
I will update my foundation patch and try again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's in the swift-corelibs-foundation PR, thanks for testing it!
b5531e7
to
c8caab4
Compare
@ian-twilightcoder I've added the '_math' module Swift overlay and the math constants are now properly deprecated from Swift . For float constants, it looks like using the '_Builtin_float' overlay works as well on Linux! Although at the moment on windows specifically I can't build it yet as the NDK headers doesn't ship an updated clang module map with '_Builtin_float', so it'll have to wait until an NDK update for the Windows-built Android SDK. Does it look good to you? |
@swift-ci please test |
@swift-ci please test |
@swift-ci please test source compatibility |
@swift-ci please test |
@swift-ci please test source compatibility |
@swift-ci please build toolchain |
Planning to merge later today, as Ian's feedback regarding the overlays with math and float constants has been addressed, and I would like to merge it this week. |
follow-up Synchronization fix that just got broken: #74160 |
Also, remove the libc imports for one file and one test where they weren't needed.
Also, remove most libc imports for one file and one test where they weren't needed and switch the others in that file to `internal import`.
Also, remove most libc imports for one file and one test where they weren't needed.
[android] add an Android NDK Swift overlay
This PR is based on the PR that adds the module map for the android NDK:
#72161