-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Description
Description
The test Interop/SwiftToCxx/stdlib/stdlib-in-cxx-no-diagnostics-generated-header.cpp, which generates a C++ header from the String stdlib APIs, started failing on the Android CI this weekend:
09:07:34 In file included from /home/build-user/build/swift-project/Ninja-Release/swift-linux-x86_64/test-android-aarch64/Interop/SwiftToCxx/stdlib/Output/stdlib-in-cxx-no-diagnostics-generated-header.cpp.tmp/test-stdlib.cpp:2:
09:07:34 /home/build-user/build/swift-project/Ninja-Release/swift-linux-x86_64/test-android-aarch64/Interop/SwiftToCxx/stdlib/Output/stdlib-in-cxx-no-diagnostics-generated-header.cpp.tmp/Stringer.h:754:241: error: unknown platform 'visionos' in availability macro [-Werror,-Wavailability]
09:07:34 754 | SWIFT_EXTERN bool $sSS20isTriviallyIdentical2toSbSS_tF(struct swift_interop_passStub_swift_uint64_t_0_8_void_ptr_8_16 other, struct swift_interop_passStub_swift_uint64_t_0_8_void_ptr_8_16 _self) SWIFT_NOEXCEPT SWIFT_CALL SWIFT_AVAILABILITY(visionos,introduced=9999) SWIFT_AVAILABILITY(tvos,introduced=9999) SWIFT_AVAILABILITY(watchos,introduced=9999) SWIFT_AVAILABILITY(ios,introduced=9999) SWIFT_AVAILABILITY(macos,introduced=9999); // isTriviallyIdentical(to:)
09:07:34 | ^
09:07:34 /home/build-user/build/swift-project/Ninja-Release/swift-linux-x86_64/test-android-aarch64/Interop/SwiftToCxx/stdlib/Output/stdlib-in-cxx-no-diagnostics-generated-header.cpp.tmp/Stringer.h:795:251: error: unknown platform 'visionos' in availability macro [-Werror,-Wavailability]
09:07:34 795 | SWIFT_EXTERN bool $sSS8UTF8ViewV20isTriviallyIdentical2toSbAB_tF(struct swift_interop_passStub_swift_uint64_t_0_8_void_ptr_8_16 other, struct swift_interop_passStub_swift_uint64_t_0_8_void_ptr_8_16 _self) SWIFT_NOEXCEPT SWIFT_CALL SWIFT_AVAILABILITY(visionos,introduced=9999) SWIFT_AVAILABILITY(tvos,introduced=9999) SWIFT_AVAILABILITY(watchos,introduced=9999) SWIFT_AVAILABILITY(ios,introduced=9999) SWIFT_AVAILABILITY(macos,introduced=9999); // isTriviallyIdentical(to:)
09:07:34 | ^
09:07:34 /home/build-user/build/swift-project/Ninja-Release/swift-linux-x86_64/test-android-aarch64/Interop/SwiftToCxx/stdlib/Output/stdlib-in-cxx-no-diagnostics-generated-header.cpp.tmp/Stringer.h:1943:149: error: unknown platform 'visionos' in availability macro [-Werror,-Wavailability]
09:07:34 1943 | SWIFT_INLINE_THUNK bool isTriviallyIdenticalTo(const String& other) const SWIFT_SYMBOL("s:SS20isTriviallyIdentical2toSbSS_tF") SWIFT_AVAILABILITY(visionos,introduced=9999) SWIFT_AVAILABILITY(tvos,introduced=9999) SWIFT_AVAILABILITY(watchos,introduced=9999) SWIFT_AVAILABILITY(ios,introduced=9999) SWIFT_AVAILABILITY(macos,introduced=9999);
09:07:34 | ^
09:07:34 /home/build-user/build/swift-project/Ninja-Release/swift-linux-x86_64/test-android-aarch64/Interop/SwiftToCxx/stdlib/Output/stdlib-in-cxx-no-diagnostics-generated-header.cpp.tmp/Stringer.h:2100:177: error: unknown platform 'visionos' in availability macro [-Werror,-Wavailability]
09:07:34 2100 | SWIFT_INLINE_THUNK bool isTriviallyIdenticalTo(const __StringNested::UTF8View& other) const SWIFT_SYMBOL("s:SS8UTF8ViewV20isTriviallyIdentical2toSbAB_tF") SWIFT_AVAILABILITY(visionos,introduced=9999) SWIFT_AVAILABILITY(tvos,introduced=9999) SWIFT_AVAILABILITY(watchos,introduced=9999) SWIFT_AVAILABILITY(ios,introduced=9999) SWIFT_AVAILABILITY(macos,introduced=9999);
09:07:34 | ^
09:07:34 /home/build-user/build/swift-project/Ninja-Release/swift-linux-x86_64/test-android-aarch64/Interop/SwiftToCxx/stdlib/Output/stdlib-in-cxx-no-diagnostics-generated-header.cpp.tmp/Stringer.h:2684:104: error: unknown platform 'visionos' in availability macro [-Werror,-Wavailability]
09:07:34 2684 | SWIFT_INLINE_THUNK bool String::isTriviallyIdenticalTo(const String& other) const SWIFT_AVAILABILITY(visionos,introduced=9999) SWIFT_AVAILABILITY(tvos,introduced=9999) SWIFT_AVAILABILITY(watchos,introduced=9999) SWIFT_AVAILABILITY(ios,introduced=9999) SWIFT_AVAILABILITY(macos,introduced=9999) {
09:07:34 | ^
09:07:34 /home/build-user/build/swift-project/Ninja-Release/swift-linux-x86_64/test-android-aarch64/Interop/SwiftToCxx/stdlib/Output/stdlib-in-cxx-no-diagnostics-generated-header.cpp.tmp/Stringer.h:2736:140: error: unknown platform 'visionos' in availability macro [-Werror,-Wavailability]
09:07:34 2736 | SWIFT_INLINE_THUNK bool __StringNested::UTF8View::isTriviallyIdenticalTo(const __StringNested::UTF8View& other) const SWIFT_AVAILABILITY(visionos,introduced=9999) SWIFT_AVAILABILITY(tvos,introduced=9999) SWIFT_AVAILABILITY(watchos,introduced=9999) SWIFT_AVAILABILITY(ios,introduced=9999) SWIFT_AVAILABILITY(macos,introduced=9999) {
09:07:34 | ^
09:07:34 6 errors generated.
I disabled it for Android in #86034 to get that CI passing again. Prior to #82055, there were no such SWIFT_AVAILABILITY macros used in the generated header, which might be a coincidence that these stdlib availability annotations weren't widely used so far, and might be tied to Android recently adding availability also, #84574.
I wrote up some more info on that pull, which I'm copy-pasting here:
It appears that your pull, which merely uses these availability annotations more, turned up a latent bug in how these C++ Interop tests are run for non-Darwin availability platforms, with this C++ Interop test that was working for more than a year now failing.
The tests use the file availability-macros.def to map these stdlib annotations to the concrete OS versions that the Swift compiler recognizes, but ever since Mads added availability support for Android more than a month ago, #84574, we simply haven't hit this because not many stdlib APIs use this StdlibDeploymentTarget annotation, almost all in Concurrency and Duration, with no public APIs in String:
> grep -r "StdlibDeploymentTarget \d" stdlib/public | cut -f1 -d:| uniq -c
8 stdlib/public/core/StringWordBreaking.swift
1 stdlib/public/core/StringUTF8View.swift
1 stdlib/public/core/Instant.swift
1 stdlib/public/core/StringUnicodeScalarView.swift
4 stdlib/public/core/Substring.swift
1 stdlib/public/core/StringUTF16View.swift
4 stdlib/public/core/DurationProtocol.swift
1 stdlib/public/core/String.swift
38 stdlib/public/core/Duration.swift
1 stdlib/public/Concurrency/PlatformExecutorCooperative.swift
55 stdlib/public/Concurrency/Executor.swift
14 stdlib/public/Concurrency/Clock.swift
1 stdlib/public/Concurrency/PlatformExecutorNone.swift
7 stdlib/public/Concurrency/ExecutorImpl.swift
1 stdlib/public/Concurrency/PlatformExecutorWindows.swift
8 stdlib/public/Concurrency/CooperativeExecutor.swift
5 stdlib/public/Concurrency/DispatchExecutor.swift
2 stdlib/public/Concurrency/CFExecutor.swift
2 stdlib/public/Concurrency/UnimplementedExecutor.swift
5 stdlib/public/Concurrency/TaskSleepDuration.swift
2 stdlib/public/Concurrency/TaskSleep.swift
1 stdlib/public/Concurrency/GlobalConcurrentExecutor.swift
1 stdlib/public/Concurrency/PlatformExecutorDarwin.swift
30 stdlib/public/Concurrency/PartialAsyncTask.swift
3 stdlib/public/Concurrency/Task.swift
13 stdlib/public/Concurrency/SuspendingClock.swift
10 stdlib/public/Concurrency/ContinuousClock.swift
21 stdlib/public/Concurrency/ExecutorBridge.swift
1 stdlib/public/Concurrency/PlatformExecutorLinux.swift
Once you added these new String APIs, this single test that checks for the public String APIs exported to a C++ header exposed this availability bug, which we'll now have to fix.
Reproduction
Run the Android tests, as detailed in the doc or CI instructions.
Expected behavior
Test to pass as always
Environment
Latest Swift trunk
Additional information
Two possible fixes strike me:
- These Darwin availability annotations are useless when targeting non-Darwin platforms, so perhaps we start excluding them based on the target availability platform? That would make these stdlib annotations useless on non-Darwin platforms though...
- The actual error is because the LTS Android NDK 27's
clang++doesn't recognize visionos, which was added to the Swift compiler early last year and to upstream LLVM a couple months before that, llvm/llvm-project@7d3466b5c, but the LTS NDK 27 clang predates that. We're going to have switch to stable NDK 28 or later in the next couple months anyway, as the next LTS NDK appears imminent, and that should have support for visionOS too.
@lorentey and @hnrklssn, I'm sure you guys understand the Swift availability and C++ Interop sides of this better, let me know what you think.