Repository: swiftlang/swift
Pull request #81601: Fix standalone stdlib build on Unix and make some Android CI tweaks
Author: login: finagolfin
Created: 2025-05-19T09:55:53Z | Merged: 2025-05-20T06:43:38Z

@weliveindetail, got [the list of now passing tests from the Windows toolchain CI](https://ci-external.swift.org/job/swift-main-windows-toolchain/1298/consoleText), please review that change.


Diff:
diff --git a/stdlib/cmake/modules/SwiftSource.cmake b/stdlib/cmake/modules/SwiftSource.cmake
index 1a09f905a1928..7975b3646a60d 100644
--- a/stdlib/cmake/modules/SwiftSource.cmake
+++ b/stdlib/cmake/modules/SwiftSource.cmake
@@ -928,9 +928,9 @@ function(_compile_swift_files
   endif()
 
   set(custom_env "PYTHONIOENCODING=UTF8")
-  if(SWIFTFILE_IS_STDLIB OR
+  if(SWIFT_INCLUDE_TOOLS AND (SWIFTFILE_IS_STDLIB OR
      # Linux "hosttools" build require builder's runtime before building the runtime.
-     (BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" AND SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD|FREEBSD")
+     (BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" AND SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|ANDROID|OPENBSD|FREEBSD"))
   )
     get_bootstrapping_swift_lib_dir(bs_lib_dir "${SWIFTFILE_BOOTSTRAPPING}")
     if(bs_lib_dir)
diff --git a/test/Frontend/default-search-paths.swift b/test/Frontend/default-search-paths.swift
index a80b2deba51ec..df3c4b50525fc 100644
--- a/test/Frontend/default-search-paths.swift
+++ b/test/Frontend/default-search-paths.swift
@@ -35,7 +35,7 @@
 // APPLE-NOSTDLIBIMPORT-NEXT: [0] BUILD_DIR/lib/swift/macosx
 // APPLE-NOSTDLIBIMPORT-NEXT: (End of search path lists.)
 
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource) -target x86_64-unknown-linux-android -nostdlibimport -parse %s -Rmodule-loading 2>&1 | %FileCheck -check-prefix=ANDROID-NOSTDLIBIMPORT %s
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource) -target x86_64-unknown-linux-android -nostdlibimport -parse -parse-stdlib %s -Rmodule-loading 2>&1 | %FileCheck -check-prefix=ANDROID-NOSTDLIBIMPORT %s
 // ANDROID-NOSTDLIBIMPORT: Implicit framework search paths:
 // ANDROID-NOSTDLIBIMPORT-NEXT: Runtime library import search paths:
 // ANDROID-NOSTDLIBIMPORT-NEXT: [0] BUILD_DIR/lib/swift/android
diff --git a/utils/windows-swift-android-lit-test-overrides.txt b/utils/windows-swift-android-lit-test-overrides.txt
index 61c4606af4327..e0ebecc6faaf7 100644
--- a/utils/windows-swift-android-lit-test-overrides.txt
+++ b/utils/windows-swift-android-lit-test-overrides.txt
@@ -46,100 +46,18 @@ xfail Swift(android-aarch64) :: IDE/complete_with_visible_members.swift
 xfail Swift(android-aarch64) :: IDE/print_opaque_result_type.swift
 xfail Swift(android-aarch64) :: IDE/rdar141440011.swift
 xfail Swift(android-aarch64) :: Index/Store/output-failure.swift
-xfail Swift(android-aarch64) :: Interop/Cxx/class/access/private-fileid-diagnostics.swift
-xfail Swift(android-aarch64) :: Interop/Cxx/class/closure-thunk-irgen.swift
 xfail Swift(android-aarch64) :: Interop/Cxx/class/constructors-copy-irgen-android.swift
 xfail Swift(android-aarch64) :: Interop/Cxx/class/constructors-irgen-android.swift
 xfail Swift(android-aarch64) :: Interop/Cxx/class/destructors-correct-abi-irgen.swift
-xfail Swift(android-aarch64) :: Interop/Cxx/class/function-call-irgen.swift
-xfail Swift(android-aarch64) :: Interop/Cxx/foreign-reference/inheritance-diagnostics.swift
 xfail Swift(android-aarch64) :: Interop/Cxx/stdlib/android-and-std-module.swift
 xfail Swift(android-aarch64) :: Interop/Cxx/union/anonymous-union-partly-invalid.swift
 xfail Swift(android-aarch64) :: Interop/CxxToSwiftToCxx/bridge-cxx-struct-back-to-cxx.swift
 xfail Swift(android-aarch64) :: Interop/CxxToSwiftToCxx/link-cxx-type-metadata-accessor.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToC/functions/swift-primitive-functions-c-bridging.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToC/structs/large-structs-pass-return-indirect-in-c.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToC/structs/small-structs-64-bit-pass-return-direct-in-c.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToC/structs/small-structs-pass-return-direct-in-c.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/class/nested-classes-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/class/swift-actor-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/class/swift-class-availability-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/class/swift-class-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/class/swift-class-inheritance-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/class/swift-class-ordering.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/class/swift-class-static-variables.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/class/swift-class-virtual-method-dispatch.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/class/swift-resilient-class-virtual-method-dispatch.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/class/swift-subclass-of-resilient-class-virtual-method-dispatch.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/core/swift-impl-defs-in-cxx-64-bit.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/core/swift-impl-defs-in-cxx.swift
 xfail Swift(android-aarch64) :: Interop/SwiftToCxx/core/validate-swift-impl-defs-in-cxx.cpp
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/cross-module-refs/do-not-expose-imported-api-by-default.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/cross-module-refs/imported-enum-refs-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/cross-module-refs/imported-struct-refs-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/cross-module-refs/not-referenced-cross-module-import.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/enums/enum-associated-value-class-type-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/enums/enum-member-param-no-shadow-case.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/enums/large-enums-pass-return-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/enums/resilient-enum-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/enums/small-enums-generated-stub-64bit.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/enums/small-enums-pass-return-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/enums/swift-enum-implementation.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/expose-attr/expose-rename-to-unavailable-decl.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/expose-attr/expose-swift-decls-to-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/extension/struct-extension-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/functions/cdecl.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/functions/function-availability.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/functions/swift-function-argument-keyword-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/functions/swift-function-overloads.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/functions/swift-function-unsupported-cxx-type.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/functions/swift-functions.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/functions/swift-no-expose-unsupported-alwaysEmitInClient-func.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/functions/swift-no-expose-unsupported-async-func.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/functions/swift-operators.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/functions/swift-primitive-functions-cxx-bridging.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/functions/swift-primitive-inout-functions-cxx-bridging.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/functions/swift-simd-vector-functions-cxx-bridging.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/functions/swift-transparent-functions-cxx-bridging.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/generics/generic-enum-in-cxx.swift
 xfail Swift(android-aarch64) :: Interop/SwiftToCxx/generics/generic-function-cxx-type-invalid.cpp
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/generics/generic-function-in-cxx.swift
 xfail Swift(android-aarch64) :: Interop/SwiftToCxx/generics/generic-struct-as-generic-func-arg-in-cpp.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/generics/generic-struct-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/generics/generic-struct-known-layout-direct-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/generics/generic-struct-known-layout-indirect-in-cxx.swift
 xfail Swift(android-aarch64) :: Interop/SwiftToCxx/generics/generic-type-cxx-type-invalid.cpp
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/generics/generic-type-traits-fwd.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/initializers/init-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/initializers/swift-init-availability-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/macros/macro-name-collision.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/methods/method-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/methods/mutating-method-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/methods/swift-method-availability-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/module/module-to-namespace.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/ownership/consuming-parameter-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/properties/bool-is-has-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/properties/getter-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/properties/setter-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/properties/swift-property-availability-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/stdlib/combination-of-stdlib-generics-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/stdlib/optional/optional-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/stdlib/stdlib-dep-inline-in-cxx.swift
 xfail Swift(android-aarch64) :: Interop/SwiftToCxx/stdlib/stdlib-in-cxx-no-diagnostics-generated-header.cpp
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/stdlib/swift-stdlib-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/structs/large-structs-pass-return-indirect-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/structs/nested-structs-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/structs/resilient-struct-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/structs/small-structs-pass-return-direct-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/structs/struct-with-opaque-layout-resilient-member-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/structs/struct-with-refcounted-member.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/structs/swift-struct-availability-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/structs/swift-struct-circular-dependent-defs.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/structs/swift-struct-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/unsupported/unsupported-enums-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/unsupported/unsupported-funcs-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/unsupported/unsupported-generics-in-cxx.swift
-xfail Swift(android-aarch64) :: Interop/SwiftToCxx/unsupported/unsupported-types-in-cxx.swift
 xfail Swift(android-aarch64) :: Interop/SwiftToCxxToSwift/hide-swift-module-namespace-in-swift.swift
 xfail Swift(android-aarch64) :: Interop/SwiftToCxxToSwift/import-swift-class-back-to-swift.swift
 xfail Swift(android-aarch64) :: ModuleInterface/BadStdlib.swiftinterface
@@ -149,7 +67,6 @@ xfail Swift(android-aarch64) :: ModuleInterface/swift_build_sdk_interfaces/check
 xfail Swift(android-aarch64) :: ModuleInterface/swift_build_sdk_interfaces/compiler-uses-prebuilt-envvar.swift
 xfail Swift(android-aarch64) :: ModuleInterface/swift_build_sdk_interfaces/compiler-uses-prebuilt.swift
 xfail Swift(android-aarch64) :: ModuleInterface/swift_build_sdk_interfaces/track-system-dependencies.swift
-xfail Swift(android-aarch64) :: SIL/clang-function-types-android.swift
 xfail Swift(android-aarch64) :: SILGen/magic_identifier_file_conflicting.swift.gyb
 xfail Swift(android-aarch64) :: ScanDependencies/can_import_with_map.swift
 xfail Swift(android-aarch64) :: ScanDependencies/cannot_import_with_map_duplicate_entries.swift
@@ -191,7 +108,6 @@ xfail Swift(android-aarch64) :: api-digester/macro-gen-json.swift
 xfail Swift(android-aarch64) :: api-digester/macro-gen.swift
 xfail Swift(android-aarch64) :: sil-func-extractor/basic.sil
 xfail Swift(android-aarch64) :: sil-func-extractor/basic.swift
-xfail Swift(android-aarch64) :: stdlib/FloatConstants.swift
 
 xfail Swift-validation(android-aarch64) :: BuildSystem/android_cross_compile.test
 xfail Swift-validation(android-aarch64) :: BuildSystem/build_lld.test
@@ -243,7 +159,3 @@ xfail Swift-validation(android-aarch64) :: Sema/type_checker_perf/slow/rdar91310
 xfail Swift-validation(android-aarch64) :: compiler_crashers_2_fixed/issue-56100.swift
 xfail Swift-validation(android-aarch64) :: compiler_scale/parse_array_nested.swift.gyb
 xfail Swift-validation(android-aarch64) :: execution/unavailable_decls.swift
-
-skip Swift(android-aarch64) :: Driver/parseable_output.swift
-skip Swift(android-aarch64) :: Driver/parseable_output_unicode.swift
-skip Swift-validation(android-aarch64) :: compiler_crashers_fixed/28795-inprotocol-isrequirementsignaturecomputed-missing-signature.swift


Reviews:
user: login: finagolfin
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-19T10:08:22Z
user: login: finagolfin
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-19T11:10:50Z
user: login: compnerd
state: APPROVED
author_association: MEMBER
submitted_at: 2025-05-19T15:22:54Z

Review comments:
diff_hunk: @@ -928,9 +928,9 @@ function(_compile_swift_files
   endif()
 
   set(custom_env "PYTHONIOENCODING=UTF8")
-  if(SWIFTFILE_IS_STDLIB OR
+  if(SWIFT_INCLUDE_TOOLS AND (SWIFTFILE_IS_STDLIB OR
path: stdlib/cmake/modules/SwiftSource.cmake
user: login: finagolfin
body: @rintaro, building a standalone stdlib on linux is currently broken without this change, please review.
created_at: 2025-05-19T10:08:22Z
author_association: MEMBER
diff_hunk: @@ -35,7 +35,7 @@
 // APPLE-NOSTDLIBIMPORT-NEXT: [0] BUILD_DIR/lib/swift/macosx
 // APPLE-NOSTDLIBIMPORT-NEXT: (End of search path lists.)
 
-// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource) -target x86_64-unknown-linux-android -nostdlibimport -parse %s -Rmodule-loading 2>&1 | %FileCheck -check-prefix=ANDROID-NOSTDLIBIMPORT %s
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource) -target x86_64-unknown-linux-android -nostdlibimport -parse -parse-stdlib %s -Rmodule-loading 2>&1 | %FileCheck -check-prefix=ANDROID-NOSTDLIBIMPORT %s
path: test/Frontend/default-search-paths.swift
user: login: finagolfin
body: This test breaks on precisely one CI without this change, [the community Android AArch64 CI](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-24.04-android-arm64/456/consoleText). That test output swallows up [the same error as the earlier line in this test that I fixed a couple days ago](https://github.com/swiftlang/swift/pull/81398#discussion_r2092385198), which I again found by running the `swift-frontend` command alone locally:
```
> /home/finagolfin/swift-DEVELOPMENT-SNAPSHOT-2025-05-14-a-ubi9/usr/bin/swift-frontend -target aarch64-unknown-linux-android -sdk /home/finagolfin/android-ndk-r27c/toolchains/llvm/prebuilt/linux-x86_64/sysroot -resource-dir /home/finagolfin/build/Ninja-Release/swift-linux-x86_64/./lib/swift -module-cache-path /home/finagolfin/build/Ninja-Release/swift-linux-x86_64/swift-test-results/aarch64-unknown-linux-android/clang-module-cache -swift-version 4 -typo-correction-limit 10 -sdk /home/finagolfin/swift/test/Inputs/clang-importer-sdk -target x86_64-unknown-linux-android -nostdlibimport -parse  /home/finagolfin/swift/test/Frontend/default-search-paths.swift -Rmodule-loading
<unknown>:0: warning: libc not found for 'x86_64-unknown-linux-android'; C stdlib may be unavailable
Module import search paths:
Framework search paths:
Implicit framework search paths:
Runtime library import search paths:
  [0] /home/finagolfin/build/Ninja-Release/swift-linux-x86_64/./lib/swift/android
  [1] /home/finagolfin/build/Ninja-Release/swift-linux-x86_64/./lib/swift/android/x86_64
(End of search path lists.)
<unknown>:0: error: could not find module '_Concurrency' for target 'x86_64-unknown-linux-android'; found: aarch64-unknown-linux-android, at: /home/finagolfin/build/Ninja-Release/swift-linux-x86_64/./lib/swift/android/_Concurrency.swiftmodule
```
Since this import search lookup is done independently of the `-parse-stdlib` flag for non-stdlib modules and the stdlib is not needed here, just adding `-parse-stdlib` avoids that unrelated error and gets this test to pass on the Android AArch64 CI too.
created_at: 2025-05-19T11:10:50Z
author_association: MEMBER

PR comments:
user: login: finagolfin
created_at: 2025-05-19T10:21:59Z
body: @swift-ci please smoke test
author_association: MEMBER
user: login: finagolfin
created_at: 2025-05-20T06:43:15Z
body: Merging to get Android CI green, still listening though if any feedback.
author_association: MEMBER