Compile error trying to follow Swift for Windows MSVC instructions

I'm trying to build Swift for Windows with Visual Studio using the
directions found here:

I'm following the MSVC section for directions. I am stuck in step 6.
LLVM/Clang/Compiler-RT

I seem to be hitting a C++ error in the code in IndexDataStore.h. Any
ideas on how to get around this?

C:\PROGRA~2\MICROS~1\2017\COMMUN~1\VC\Tools\MSVC\1411~1.255\bin\Hostx64\x64\cl.exe
/nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE
-D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE
-D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0
-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-Itools\clang\lib\Index -IC:\Source\SWIFT\llvm\tools\clang\lib\Index
-IC:\Source\SWIFT\llvm\tools\clang\include -Itools\clang\include
-Iinclude -IC:\Source\SWIFT\llvm\include /DWIN32 /D_WINDOWS
/Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast /W4 -wd4141 -wd4146
-wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351 -wd4355
-wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4800
-wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245
-wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204
-wd4577 -wd4091 -wd4592 -wd4319 -wd4324 -w14062 -we4238 /MD /O1 /Ob1
-UNDEBUG /EHs-c- /GR- /showIncludes
/Fotools\clang\lib\Index\CMakeFiles\clangIndex.dir\IndexDataStore.cpp.obj
/Fdtools\clang\lib\Index\CMakeFiles\clangIndex.dir\clangIndex.pdb /FS
-c C:\Source\SWIFT\llvm\tools\clang\lib\Index\IndexDataStore.cpp
C:\Source\SWIFT\llvm\tools\clang\include\clang/Index/IndexDataStore.h(41):
error C3646: 'ModTime': unknown override specifier
C:\Source\SWIFT\llvm\tools\clang\include\clang/Index/IndexDataStore.h(41):
error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
C:\Source\SWIFT\llvm\tools\clang\include\clang/Index/IndexDataStore.h(74):
error C3646: 'ModTime': unknown override specifier
C:\Source\SWIFT\llvm\tools\clang\include\clang/Index/IndexDataStore.h(74):
error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
C:\Source\SWIFT\llvm\tools\clang\lib\Index\IndexDataStore.cpp(164):
error C2039: 'ModTime': is not a member of
'clang::index::AbstractDirectoryWatcher::Event'
C:\Source\SWIFT\llvm\tools\clang\include\clang/Index/IndexDataStore.h(38):
note: see declaration of
'clang::index::AbstractDirectoryWatcher::Event'
C:\Source\SWIFT\llvm\tools\clang\lib\Index\IndexDataStore.cpp(164):
error C2039: '__this': is not a member of
'clang::index::AbstractDirectoryWatcher::Event'
C:\Source\SWIFT\llvm\tools\clang\include\clang/Index/IndexDataStore.h(38):
note: see declaration of
'clang::index::AbstractDirectoryWatcher::Event'
[2723/3603] Building CXX object
tools\clang\lib\Index\CMakeFiles\clangIndex.dir\IndexingContext.cpp.obj
ninja: build stopped: subcommand failed.

Note: I'm using VS2017 instead of VS2015 because it's supposed to have
better C++ conformance.

I also want to note, building Debug hits a different fatal error where
MSVC aborts saying you must compile with /bigobj because the files are
too large. I changed my build and then hit the above compile error
with IndexDataStore.h. I then tried building a release version without
/bigobj, but I hit the same compile error with IndexDataStore.h.

Also, can somebody clarify what the differences are between the
different build approaches in the document (clang vs. MSVC vs.
clang-cl). Will these all produce binaries that are interoperable with
each other and allow me to link against regular MSVC built C
libraries? And do one of these clang options need MSVC's clang-C2?

And also, what is Compiler-RT and since it is optional, what do I lose
if I skip it?

And finally, why is the Win10 SDK needed? Doesn't that mean it won't
work on Win7 or Win8? What could Swift need that requires Win10 APIs?

Thanks,
Eric

+CC Compnerd

···

On Nov 9, 2017, at 10:36 AM, Eric Wing via swift-users <swift-users@swift.org> wrote:

I'm trying to build Swift for Windows with Visual Studio using the
directions found here:
https://github.com/apple/swift/blob/master/docs/Windows.md

I'm following the MSVC section for directions. I am stuck in step 6.
LLVM/Clang/Compiler-RT

I seem to be hitting a C++ error in the code in IndexDataStore.h. Any
ideas on how to get around this?

C:\PROGRA~2\MICROS~1\2017\COMMUN~1\VC\Tools\MSVC\1411~1.255\bin\Hostx64\x64\cl.exe
/nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE
-D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE
-D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0
-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-Itools\clang\lib\Index -IC:\Source\SWIFT\llvm\tools\clang\lib\Index
-IC:\Source\SWIFT\llvm\tools\clang\include -Itools\clang\include
-Iinclude -IC:\Source\SWIFT\llvm\include /DWIN32 /D_WINDOWS
/Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast /W4 -wd4141 -wd4146
-wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351 -wd4355
-wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4800
-wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245
-wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204
-wd4577 -wd4091 -wd4592 -wd4319 -wd4324 -w14062 -we4238 /MD /O1 /Ob1
-UNDEBUG /EHs-c- /GR- /showIncludes
/Fotools\clang\lib\Index\CMakeFiles\clangIndex.dir\IndexDataStore.cpp.obj
/Fdtools\clang\lib\Index\CMakeFiles\clangIndex.dir\clangIndex.pdb /FS
-c C:\Source\SWIFT\llvm\tools\clang\lib\Index\IndexDataStore.cpp
C:\Source\SWIFT\llvm\tools\clang\include\clang/Index/IndexDataStore.h(41):
error C3646: 'ModTime': unknown override specifier
C:\Source\SWIFT\llvm\tools\clang\include\clang/Index/IndexDataStore.h(41):
error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
C:\Source\SWIFT\llvm\tools\clang\include\clang/Index/IndexDataStore.h(74):
error C3646: 'ModTime': unknown override specifier
C:\Source\SWIFT\llvm\tools\clang\include\clang/Index/IndexDataStore.h(74):
error C4430: missing type specifier - int assumed. Note: C++ does not
support default-int
C:\Source\SWIFT\llvm\tools\clang\lib\Index\IndexDataStore.cpp(164):
error C2039: 'ModTime': is not a member of
'clang::index::AbstractDirectoryWatcher::Event'
C:\Source\SWIFT\llvm\tools\clang\include\clang/Index/IndexDataStore.h(38):
note: see declaration of
'clang::index::AbstractDirectoryWatcher::Event'
C:\Source\SWIFT\llvm\tools\clang\lib\Index\IndexDataStore.cpp(164):
error C2039: '__this': is not a member of
'clang::index::AbstractDirectoryWatcher::Event'
C:\Source\SWIFT\llvm\tools\clang\include\clang/Index/IndexDataStore.h(38):
note: see declaration of
'clang::index::AbstractDirectoryWatcher::Event'
[2723/3603] Building CXX object
tools\clang\lib\Index\CMakeFiles\clangIndex.dir\IndexingContext.cpp.obj
ninja: build stopped: subcommand failed.

Note: I'm using VS2017 instead of VS2015 because it's supposed to have
better C++ conformance.

I also want to note, building Debug hits a different fatal error where
MSVC aborts saying you must compile with /bigobj because the files are
too large. I changed my build and then hit the above compile error
with IndexDataStore.h. I then tried building a release version without
/bigobj, but I hit the same compile error with IndexDataStore.h.

Also, can somebody clarify what the differences are between the
different build approaches in the document (clang vs. MSVC vs.
clang-cl). Will these all produce binaries that are interoperable with
each other and allow me to link against regular MSVC built C
libraries? And do one of these clang options need MSVC's clang-C2?

And also, what is Compiler-RT and since it is optional, what do I lose
if I skip it?

And finally, why is the Win10 SDK needed? Doesn't that mean it won't
work on Win7 or Win8? What could Swift need that requires Win10 APIs?

Thanks,
Eric
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

I’ve not used the MSVC build mode very much. I suspect that this is a name
lookup failure and needs a namespace qualification. I’ll look into
tweaking that when I’m near a computer. In the mean time, I recommend
using the cross-compile or possibly trying with clang-cl.

···

On Tue, Nov 14, 2017 at 1:05 PM Michael Gottesman <mgottesman@apple.com> wrote:

+CC Compnerd

> On Nov 9, 2017, at 10:36 AM, Eric Wing via swift-users < > swift-users@swift.org> wrote:
>
> I'm trying to build Swift for Windows with Visual Studio using the
> directions found here:
> https://github.com/apple/swift/blob/master/docs/Windows.md
>
> I'm following the MSVC section for directions. I am stuck in step 6.
> LLVM/Clang/Compiler-RT
>
> I seem to be hitting a C++ error in the code in IndexDataStore.h. Any
> ideas on how to get around this?
>
>
>
C:\PROGRA~2\MICROS~1\2017\COMMUN~1\VC\Tools\MSVC\1411~1.255\bin\Hostx64\x64\cl.exe
> /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE
> -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE
> -D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0
> -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE
> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
> -Itools\clang\lib\Index -IC:\Source\SWIFT\llvm\tools\clang\lib\Index
> -IC:\Source\SWIFT\llvm\tools\clang\include -Itools\clang\include
> -Iinclude -IC:\Source\SWIFT\llvm\include /DWIN32 /D_WINDOWS
> /Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast /W4 -wd4141 -wd4146
> -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351 -wd4355
> -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4800
> -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245
> -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204
> -wd4577 -wd4091 -wd4592 -wd4319 -wd4324 -w14062 -we4238 /MD /O1 /Ob1
> -UNDEBUG /EHs-c- /GR- /showIncludes
> /Fotools\clang\lib\Index\CMakeFiles\clangIndex.dir\IndexDataStore.cpp.obj
> /Fdtools\clang\lib\Index\CMakeFiles\clangIndex.dir\clangIndex.pdb /FS
> -c C:\Source\SWIFT\llvm\tools\clang\lib\Index\IndexDataStore.cpp
>
C:\Source\SWIFT\llvm\tools\clang\include\clang/Index/IndexDataStore.h(41):
> error C3646: 'ModTime': unknown override specifier
>
C:\Source\SWIFT\llvm\tools\clang\include\clang/Index/IndexDataStore.h(41):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
>
C:\Source\SWIFT\llvm\tools\clang\include\clang/Index/IndexDataStore.h(74):
> error C3646: 'ModTime': unknown override specifier
>
C:\Source\SWIFT\llvm\tools\clang\include\clang/Index/IndexDataStore.h(74):
> error C4430: missing type specifier - int assumed. Note: C++ does not
> support default-int
> C:\Source\SWIFT\llvm\tools\clang\lib\Index\IndexDataStore.cpp(164):
> error C2039: 'ModTime': is not a member of
> 'clang::index::AbstractDirectoryWatcher::Event'
>
C:\Source\SWIFT\llvm\tools\clang\include\clang/Index/IndexDataStore.h(38):
> note: see declaration of
> 'clang::index::AbstractDirectoryWatcher::Event'
> C:\Source\SWIFT\llvm\tools\clang\lib\Index\IndexDataStore.cpp(164):
> error C2039: '__this': is not a member of
> 'clang::index::AbstractDirectoryWatcher::Event'
>
C:\Source\SWIFT\llvm\tools\clang\include\clang/Index/IndexDataStore.h(38):
> note: see declaration of
> 'clang::index::AbstractDirectoryWatcher::Event'
> [2723/3603] Building CXX object
> tools\clang\lib\Index\CMakeFiles\clangIndex.dir\IndexingContext.cpp.obj
> ninja: build stopped: subcommand failed.
>
>
> Note: I'm using VS2017 instead of VS2015 because it's supposed to have
> better C++ conformance.
>
> I also want to note, building Debug hits a different fatal error where
> MSVC aborts saying you must compile with /bigobj because the files are
> too large. I changed my build and then hit the above compile error
> with IndexDataStore.h. I then tried building a release version without
> /bigobj, but I hit the same compile error with IndexDataStore.h.
>
>
>
>
>
> Also, can somebody clarify what the differences are between the
> different build approaches in the document (clang vs. MSVC vs.
> clang-cl). Will these all produce binaries that are interoperable with
> each other and allow me to link against regular MSVC built C
> libraries? And do one of these clang options need MSVC's clang-C2?
>
> And also, what is Compiler-RT and since it is optional, what do I lose
> if I skip it?
>
> And finally, why is the Win10 SDK needed? Doesn't that mean it won't
> work on Win7 or Win8? What could Swift need that requires Win10 APIs?
>
> Thanks,
> Eric
> _______________________________________________
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

--

Saleem Abdulrasool
compnerd (at) compnerd (dot) org

Thank you for the response.
I installed the nightly build of LLVM for Windows (64-bit) and tried clang-cl.

The compile got stuck building LLVM/Clang in step 6 of the
instructions. The error is pasted below. Any idea how to fix this?

Also, are there any deeper instructions on the cross-compiling
instructions? This is all very foreign to me for Windows since the
usual workflow is around Visual Studio. Reading the fist step shows
the keyword "export", which is not a valid keyword in the Windows
cmd.exe. So I'm already missing a lot of needed context.

Thanks,
Eric

[252/2299] Building CXX object
tools\clang\lib\DirectoryWa...keFiles\clangDirectoryWatcher.dir\DirectoryWatcher.cpp.obj
FAILED: tools/clang/lib/DirectoryWatcher/CMakeFiles/clangDirectoryWatcher.dir/DirectoryWatcher.cpp.obj
C:\LLVM64\bin\clang-cl.exe /nologo -DGTEST_HAS_RTTI=0 -DUNICODE
-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
-D_DEBUG_POINTER_IMPL="" -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0
-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-Itools\clang\lib\DirectoryWatcher
-IC:\Source\SWIFT\llvm\tools\clang\lib\DirectoryWatcher
-IC:\Source\SWIFT\llvm\tools\clang\include -Itools\clang\include
-Iinclude -IC:\Source\SWIFT\llvm\include
-fms-compatibility-version=19.00 -Z7 /Zc:inline /Zc:strictStrings /Oi
/Zc:rvalueCast /Brepro -Wall -W -Wno-unused-parameter -Wwrite-strings
-Wcast-qual -Wmissing-field-initializers -Wcovered-switch-default
-Wdelete-non-virtual-dtor -Wstring-conversion /MD /O1 /Ob1 -UNDEBUG
/EHs-c- /GR- /showIncludes
/Fotools\clang\lib\DirectoryWatcher\CMakeFiles\clangDirectoryWatcher.dir\DirectoryWatcher.cpp.obj
/Fdtools\clang\lib\DirectoryWatcher\CMakeFiles\clangDirectoryWatcher.dir\clangDirectoryWatcher.pdb
-c C:\Source\SWIFT\llvm\tools\clang\lib\DirectoryWatcher\DirectoryWatcher.cpp
In file included from
C:\Source\SWIFT\llvm\tools\clang\lib\DirectoryWatcher\DirectoryWatcher.cpp:13:
In file included from
C:\Source\SWIFT\llvm\tools\clang\include\clang/DirectoryWatcher/DirectoryWatcher.h:17:
C:\Source\SWIFT\llvm\tools\clang\include\clang/Index/IndexDataStore.h(41,5):
error: unknown type name 'timespec'
    timespec ModTime;
    ^
C:\Source\SWIFT\llvm\tools\clang\include\clang/Index/IndexDataStore.h(74,5):
error: unknown type name 'timespec'
    timespec ModTime;
    ^
2 errors generated.
[254/2299] Building CXX object
tools\clang\lib\Tooling\Refactor\CMakeFiles\clangToolingRefactor.dir\TypeUtils.cpp.obj
ninja: build stopped: subcommand failed.

···

On 11/14/17, Saleem Abdulrasool <compnerd@compnerd.org> wrote:

I’ve not used the MSVC build mode very much. I suspect that this is a name
lookup failure and needs a namespace qualification. I’ll look into
tweaking that when I’m near a computer. In the mean time, I recommend
using the cross-compile or possibly trying with clang-cl.

This reply is about 4 months late and I also failed to built Swift with MSVC. However, I got a bit further.

Confirm that you have the correct version of Visual studio installed. As the instructions say "Make sure to include "Programming Languages|Visual C++" and "Windows and Web Development|Universal Windows App Development|Windows SDK" in your installation."

I think its fair to say that many (myself included) don't actually know all the building dependencies (of llvm and swift) and where they are included in the various Visual Studio components.

What I learned is that:
1 .With Visual studio (2017), you need the professional version to install dependencies like "ATL support".
2. Some components are named differently in the 2017 version compared to what the instruction says.
My naive advise is that one should install Visual studio with all components that are somewhat connected to Windows SDK" and "C/C++" development.