Context
Hi all, I am currently attempting to install Swift on a Windows laptop (with pretty close to a fresh installation of Windows).
I followed the installation instructions at Swift.org and they completed successfully (with one slight modification). Here are the exact commands that I ran (I had to change the python version from 3.7.8
to 3.7.8150.0
because otherwise the command failed stating that version 3.7.8
does not exist):
winget install Git.Git
winget install Python.Python.3 --version 3.7.8150.0
curl -sOL https://aka.ms/vs/16/release/vs_community.exe
start /w vs_community.exe --passive --wait --norestart --nocache ^
--installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community" ^
--add Microsoft.VisualStudio.Component.Windows10SDK.19041 ^
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64
del /q vs_community.exe
winget install Swift.Toolchain
Once installed, I ran the following commands to create a new executable package:
mkdir HelloWorld
cd HelloWorld
swift package init --type=executable
Issue
My issue is that when I attempt to build the package with swift build
, I get the following errors:
C:\Users\User\Documents\Swift\HelloWorld>swift build
warning: Failed creating default cache locations, Error Domain=NSCocoaErrorDomain Code=256 "(null)"
warning: Failed creating default cache locations, Error Domain=NSCocoaErrorDomain Code=256 "(null)"
C:\Users\User\Documents\Swift\HelloWorld: error: manifest parse error(s):
<module-includes>:1:10: note: in file included from <module-includes>:1:
#include "AssertionReporting.h"
^
C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\lib\swift\shims\AssertionReporting.h:16:10: note: in file included from C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\lib\swift\shims\AssertionReporting.h:16:
#include "SwiftStdint.h"
^
C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk\usr\lib\swift\shims\SwiftStdint.h:28:10: error: 'stdint.h' file not found
#include <stdint.h>
^
<unknown>:0: error: could not build C module 'SwiftShims'
The same error also occurs if I create a swift file containing print("Hello, world!")
and try compiling it with swiftc file.swift
.
Another error that might be important is the error that I get if I try to run anything in the swift repl:
C:\Users\User\Documents\Swift\HelloWorld>swift
Welcome to compnerd.org Swift version 5.5 (swift-5.5-RELEASE).
Type :help for assistance.
1> print("Hello, world!")
Assertion failed: false && "called into swift language runtime stub", file D:\a\1\s\llvm-project\lldb\source\Plugins\LanguageRuntime\Swift\SwiftLanguageRuntime.cpp, line 368
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
#0 0x00007ff6d010e5d5 (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\lldb.exe+0x1e5d5)
#1 0x00007ffb60d8caad (C:\WINDOWS\System32\ucrtbase.dll+0x6caad)
#2 0x00007ffb60d8dab1 (C:\WINDOWS\System32\ucrtbase.dll+0x6dab1)
#3 0x00007ffb60d8f4ee (C:\WINDOWS\System32\ucrtbase.dll+0x6f4ee)
#4 0x00007ffb60d8f3e5 (C:\WINDOWS\System32\ucrtbase.dll+0x6f3e5)
#5 0x00007ffb60d8f771 (C:\WINDOWS\System32\ucrtbase.dll+0x6f771)
#6 0x00007ffae3db556c PyInit__lldb (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll+0x82556c)
#7 0x00007ffae89a7774 PyInit__lldb (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll+0x5417774)
#8 0x00007ffae89acff3 PyInit__lldb (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll+0x541cff3)
#9 0x00007ffae89aa6e8 PyInit__lldb (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll+0x541a6e8)
#10 0x00007ffae89a4b36 PyInit__lldb (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll+0x5414b36)
#11 0x00007ffae3ade4a3 PyInit__lldb (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll+0x54e4a3)
#12 0x00007ffae3aeca9b PyInit__lldb (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll+0x55ca9b)
#13 0x00007ffae3abac46 PyInit__lldb (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll+0x52ac46)
#14 0x00007ffae3a6960a PyInit__lldb (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll+0x4d960a)
#15 0x00007ffae3a6832e PyInit__lldb (C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\liblldb.dll+0x4d832e)
#16 0x00007ffb60d410b2 (C:\WINDOWS\System32\ucrtbase.dll+0x210b2)
#17 0x00007ffb61f37c24 (C:\WINDOWS\System32\KERNEL32.DLL+0x17c24)
#18 0x00007ffb62e6d721 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x6d721)
Attempted solutions
In the past I have run into the same issue. From memory, I solved it by installing a certain version of Visual Studio and installing all of the c and cpp components available in that version (I just trial and errored a bunch of different versions, can't remember which one worked). iirc I also had to copy some headers from the Visual Studio SDK to the Swift toolchain to get it working correctly.
But that took me quite a while to get working (slow computer) and given that this is a fresh install of Swift on basically a fresh install of Windows (I've only installed a few essential apps so far) my thinking is that there might be something simple that I am missing which @compnerd and co might be able to help with.
Any help would be greatly appreciated