Closed egorzhdan closed 1 week ago
cc @compnerd
@egorzhdan just to be clear, this is building Windows ARM64 on ARM64 right? I'm asking because I've been building the Windows ARM64 standard library on X64 and then using on ARM64. That is also what we are doing in CI currently, which does build the ARM64 standard library.
Yes, I'm building a Windows arm64 standard library on a Windows arm64 machine. I don't have an X64 machine to try cross-compiling this out unfortunately.
This particular build step was succeeding for me ~a month ago, but now it is failing consistently.
I do the native windows arm64 build locally. I'll see if I can reproduce it.
@egorzhdan no worries - just trying to figure out what exactly is different so we can hopefully isolate it more quickly. Fortunately @hjyamauchi has a ARM64 development environment to do the native side, I've been doing it mostly via cross-compilation.
@egorzhdan
The way I build the whole toolchain with swift\util\build.ps1
, I don't get a stdlib build failure at commit 2752414d7841b72149b34c201bf3ea302cadc6ad. But I use Visual Studio 17.7.6 with the Visual Studio C++ compiler version 14.37.32822. I think we've seen a case where the toolchain didn't build with version 17.8.x for some reason though it was for x64. It might be worth downgrading the Visual Studio version.
Before you run the ninja command, how do you run cmake? The build setup seems different from mine that I couldn't guess. If I run the command in S:\b\301
(where stdlib is built in our setup), I get the following error about StdlibUnicodeUnittest, which I don't know why, but is probably unrelated, and doesn't prevent our normal toolchain build flow. If you can share how the cmake command is run, I can try to reproduce that.
S:\SourceCache\swift>cd S:\b\301
S:\b\301>ninja swift-stdlib
[1/26] Performing build step for 'libdispatch-windows-aarch64'
ninja: no work to do.
[2/10] Performing install step for 'libdispatch-windows-aarch64'
-- Install configuration: "Release"
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/include/dispatch/base.h
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/include/dispatch/block.h
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/include/dispatch/data.h
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/include/dispatch/dispatch.h
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/include/dispatch/group.h
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/include/dispatch/introspection.h
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/include/dispatch/io.h
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/include/dispatch/object.h
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/include/dispatch/once.h
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/include/dispatch/queue.h
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/include/dispatch/semaphore.h
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/include/dispatch/source.h
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/include/dispatch/time.h
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/share/man/man3/dispatch.3
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/share/man/man3/dispatch_after.3
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/share/man/man3/dispatch_api.3
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/share/man/man3/dispatch_apply.3
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/share/man/man3/dispatch_async.3
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/share/man/man3/dispatch_data_create.3
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/share/man/man3/dispatch_group_create.3
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/share/man/man3/dispatch_io_create.3
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/share/man/man3/dispatch_io_read.3
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/share/man/man3/dispatch_object.3
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/share/man/man3/dispatch_once.3
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/share/man/man3/dispatch_queue_create.3
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/share/man/man3/dispatch_read.3
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/share/man/man3/dispatch_semaphore_create.3
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/share/man/man3/dispatch_source_create.3
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/share/man/man3/dispatch_time.3
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/include/os/generic_base.h
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/include/os/generic_unix_base.h
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/include/os/generic_win_base.h
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/include/os/object.h
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/include/Block.h
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/lib/BlocksRuntime.lib
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/bin/BlocksRuntime.dll
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/lib/dispatch.lib
-- Up-to-date: S:/b/301/libdispatch-windows-aarch64-prefix/bin/dispatch.dll
[0/1] Install the project...
[3/10] Compiling S:/b/301/stdlib/private/StdlibUnicodeUnittest//WINDOWS/aarch64/StdlibUnicodeUnittest.obj
FAILED: stdlib/private/StdlibUnicodeUnittest/WINDOWS/aarch64/StdlibUnicodeUnittest.obj S:/b/301/stdlib/private/StdlibUnicodeUnittest/WINDOWS/aarch64/StdlibUnicodeUnittest.obj
cmd.exe /C "cd /D S:\b\301\stdlib\private\StdlibUnicodeUnittest && "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E make_directory S:/b/301/stdlib/private/StdlibUnicodeUnittest/WINDOWS/aarch64 && "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E env PYTHONIOENCODING=UTF8 C:/Users/hiroshi/pythonarm64.3.9.10/tools/python3.exe S:/SourceCache/swift/utils/line-directive @S:/b/301/stdlib/private/StdlibUnicodeUnittest/8ba94feba727ed339b28cc5aad9eca60f5fad12a.txt -- S:/b/1/bin/swiftc.exe -c -target aarch64-unknown-windows-msvc -resource-dir S:/b/301/./lib/swift -O -D SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY -D SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED -D SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING -D SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING -D SWIFT_ENABLE_EXPERIMENTAL_OBSERVATION -D SWIFT_RUNTIME_OS_VERSIONING -D SWIFT_STDLIB_ENABLE_UNICODE_DATA -D SWIFT_STDLIB_ENABLE_VECTOR_TYPES -D SWIFT_STDLIB_HAS_COMMANDLINE -D SWIFT_STDLIB_HAS_STDIN -D SWIFT_STDLIB_HAS_ENVIRON -Xcc -DSWIFT_STDLIB_HAS_ENVIRON -D SWIFT_CONCURRENCY_USES_DISPATCH -D SWIFT_STDLIB_OVERRIDABLE_RETAIN_RELEASE -D SWIFT_THREADING_WIN32 -module-cache-path S:/b/301/./module-cache -no-link-objc-runtime -enable-library-evolution -library-level api -Xfrontend -require-explicit-availability=ignore -Xfrontend -enforce-exclusivity=unchecked -D SWIFT_ENABLE_REFLECTION -module-name StdlibUnicodeUnittest -swift-version 5 -runtime-compatibility-version none -disable-autolinking-runtime-compatibility-dynamic-replacements -Xfrontend -disable-autolinking-runtime-compatibility-concurrency -Xfrontend -disable-objc-interop -Xfrontend -enable-experimental-associated-type-inference -warn-implicit-overrides -Xfrontend -enable-ossa-modules -Xfrontend -enable-lexical-lifetimes=false -Xfrontend -disable-implicit-concurrency-module-import -Xfrontend -disable-implicit-string-processing-module-import -D_WINDLL -Xcc -Xclang -Xcc -ivfsoverlay -Xcc -Xclang -Xcc S:/b/301/stdlib/private/StdlibUnicodeUnittest/windows-sdk-vfs-overlay.yaml -vfsoverlay "S:/b/301/stdlib/windows-vfs-overlay.yaml" -strict-implicit-module-context -Xcc -Xclang -Xcc -fbuiltin-headers-in-system-modules -libc MultiThreadedDLL -Xfrontend -define-availability -Xfrontend "SwiftStdlib 9999:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999" -Xfrontend -define-availability -Xfrontend "SwiftStdlib 5.0:macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2" -Xfrontend -define-availability -Xfrontend "SwiftStdlib 5.1:macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0" -Xfrontend -define-availability -Xfrontend "SwiftStdlib 5.2:macOS 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4" -Xfrontend -define-availability -Xfrontend "SwiftStdlib 5.3:macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0" -Xfrontend -define-availability -Xfrontend "SwiftStdlib 5.4:macOS 11.3, iOS 14.5, watchOS 7.4, tvOS 14.5" -Xfrontend -define-availability -Xfrontend "SwiftStdlib 5.5:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0" -Xfrontend -define-availability -Xfrontend "SwiftStdlib 5.6:macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4" -Xfrontend -define-availability -Xfrontend "SwiftStdlib 5.7:macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0" -Xfrontend -define-availability -Xfrontend "SwiftStdlib 5.8:macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4" -Xfrontend -define-availability -Xfrontend "SwiftStdlib 5.9:macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0" -Xfrontend -define-availability -Xfrontend "SwiftStdlib 5.10:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999" -Xfrontend -define-availability -Xfrontend "SwiftStdlib 5.11:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999" -Xfrontend -target-min-inlining-version -Xfrontend min -module-link-name swiftStdlibUnicodeUnittest -whole-module-optimization -color-diagnostics -parse-as-library -I S:/b/301/./lib/swift/windows -o S:/b/301/stdlib/private/StdlibUnicodeUnittest//WINDOWS/aarch64/StdlibUnicodeUnittest.obj @S:/b/301/stdlib/private/StdlibUnicodeUnittest/8ba94feba727ed339b28cc5aad9eca60f5fad12a.txt"
[4/10] Compiling S:/b/301/stdlib/private/StdlibCollectionUnittest//WINDOWS/aarch64/StdlibCollectionUnittest.obj
FAILED: stdlib/private/StdlibCollectionUnittest/WINDOWS/aarch64/StdlibCollectionUnittest.obj S:/b/301/stdlib/private/StdlibCollectionUnittest/WINDOWS/aarch64/StdlibCollectionUnittest.obj
stdlib\private\StdlibCollectionUnittest\CMakeFiles\StdlibCollectionUnittest.obj-b9ed8f3.bat 81717827b7d0b1fb
Batch file failed at line 4 with errorcode -1
[5/10] Generating S:/b/301/./lib/swift/windows/StdlibUnicodeUnittest.swiftmodule/aarch64-unknown-windows-msvc.swiftmodule
FAILED: lib/swift/windows/StdlibUnicodeUnittest.swiftmodule/aarch64-unknown-windows-msvc.swiftmodule lib/swift/windows/StdlibUnicodeUnittest.swiftmodule/aarch64-unknown-windows-msvc.swiftdoc lib/swift/windows/StdlibUnicodeUnittest.swiftmodule/aarch64-unknown-windows-msvc.swiftinterface lib/swift/windows/StdlibUnicodeUnittest.swiftmodule/aarch64-unknown-windows-msvc.private.swiftinterface S:/b/301/lib/swift/windows/StdlibUnicodeUnittest.swiftmodule/aarch64-unknown-windows-msvc.swiftmodule S:/b/301/lib/swift/windows/StdlibUnicodeUnittest.swiftmodule/aarch64-unknown-windows-msvc.swiftdoc S:/b/301/lib/swift/windows/StdlibUnicodeUnittest.swiftmodule/aarch64-unknown-windows-msvc.swiftinterface S:/b/301/lib/swift/windows/StdlibUnicodeUnittest.swiftmodule/aarch64-unknown-windows-msvc.private.swiftinterface
stdlib\private\StdlibUnicodeUnittest\CMakeFiles\aarch64-unknown-windows-msvc.swiftmodule-b8aa386.bat f2be334567bf2012
Batch file failed at line 6 with errorcode -1
[6/10] Generating S:/b/301/./lib/swift/windows/StdlibCollectionUnittest.swiftmodule/aarch64-unknown-windows-msvc.swiftmodule
FAILED: lib/swift/windows/StdlibCollectionUnittest.swiftmodule/aarch64-unknown-windows-msvc.swiftmodule lib/swift/windows/StdlibCollectionUnittest.swiftmodule/aarch64-unknown-windows-msvc.swiftdoc lib/swift/windows/StdlibCollectionUnittest.swiftmodule/aarch64-unknown-windows-msvc.swiftinterface lib/swift/windows/StdlibCollectionUnittest.swiftmodule/aarch64-unknown-windows-msvc.private.swiftinterface S:/b/301/lib/swift/windows/StdlibCollectionUnittest.swiftmodule/aarch64-unknown-windows-msvc.swiftmodule S:/b/301/lib/swift/windows/StdlibCollectionUnittest.swiftmodule/aarch64-unknown-windows-msvc.swiftdoc S:/b/301/lib/swift/windows/StdlibCollectionUnittest.swiftmodule/aarch64-unknown-windows-msvc.swiftinterface S:/b/301/lib/swift/windows/StdlibCollectionUnittest.swiftmodule/aarch64-unknown-windows-msvc.private.swiftinterface
stdlib\private\StdlibCollectionUnittest\CMakeFiles\aarch64-unknown-windows-msvc.swiftmodule-5d93b26.bat f3b050f15a841a63
Batch file failed at line 6 with errorcode -1
ninja: build stopped: subcommand failed.
Thanks a lot @hjyamauchi!
I'll try using build.ps1
and will check if I still see the crash, also will try downgrading VS as you suggested.
So far I was building Swift with these CMake options:
-G Ninja
-D
Python3_EXECUTABLE="C:\Program Files\Python311-arm64\python.exe"
-D
SWIFT_PATH_TO_LIBDISPATCH_SOURCE="C:\Sources\swift\swift-corelibs-libdispatch"
-D
SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE="C:\Sources\swift\swift-syntax"
-D
LLVM_DIR="C:\Builds.noindex\swift\llvm-project\lib\cmake\llvm"
-D
LLVM_CMAKE_DIR="C:\Sources\swift\llvm-project\llvm\cmake\modules"
-D
LLVM_TOOLS_BINARY_DIR="C:\Builds.noindex\swift\llvm-project\bin"
-D
Clang_DIR="C:\Builds.noindex\swift\llvm-project\lib\cmake\clang"
-D
SWIFT_PATH_TO_CMARK_SOURCE="C:\Sources\swift\swift-cmark"
-D
SWIFT_PATH_TO_CMARK_BUILD="C:\Builds.noindex\swift\swift-cmark"
-D
SWIFT_INCLUDE_DOCS=OFF
-D
CMAKE_C_FLAGS="/GS- /Oy /Gw /Gy"
-D
CMAKE_CXX_FLAGS="/GS- /Oy /Gw /Gy"
-D
LLVM_PARALLEL_LINK_JOBS=6
-D
LLVM_ENABLE_PDB=YES
-D
SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP=YES
@egorzhdan just FYI, the paths that you are using are emphatically discouraged. They are too long. The reason that the builds expect everything in S:\b\1
is because the paths in the swift test suite are extremely long and go past the 261 character limit resulting in failures.
@compnerd alright, thanks for the heads up!
I worked around the crash by doing this:
diff --git a/lib/SILGen/SILGenApply.cpp b/lib/SILGen/SILGenApply.cpp
--- a/lib/SILGen/SILGenApply.cpp (revision 6bf39cccd69a8f468a562e44e21049563d899456)
+++ b/lib/SILGen/SILGenApply.cpp (date 1704997307862)
@@ -4792,6 +4792,7 @@
}
void emit(SILGenFunction &SGF, CleanupLocation l, ForUnwind_t forUnwind) override {
+ if (!BorrowedMoveOnlyValues.empty())
for (auto i = BorrowedMoveOnlyValues.rbegin(), e = BorrowedMoveOnlyValues.rend();
i != e; ++i) {
SGF.B.createEndBorrow(l, *i);
It seems really strange that it is crashing inside std::vector::rbegin
for an empty vector, I suspect there is some memory corruption happening elsewhere.
I wasn't seeing this crash before because this code was merged fairly recently (https://github.com/apple/swift/commit/96c87dbf817298a0cf603d36a86be2688cabee3b).
@egorzhdan I upgraded to Visual Studio 17.8.4, the current latest, and my build with build.ps1
works and doesn't get the crash.
I'm going to close the issue as the newer VS resolves the issue and the Apple CI is green.
Description
The compiler crashes while building the Swift stdlib on Windows. I only tested this on aarch64.
Reproduction
ninja swift-stdlib
Stack dump
Expected behavior
Should not crash
Environment
Windows 11 aarch64 Visual Studio Community 2022 17.8.3 C/C++ Compiler (C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.38.33130/bin/Hostarm64/arm64/cl.exe) Version: 19.38.33133.0 No Swift toolchain installed. UCRT 10.0.22621.0 CMake 3.27.8 Ninja 1.10.2
Additional information
No response