Windows Nightlies

windows
(Alexey Lysenko) #81

I have luck here building Foundation

However, I used to set -Xlinker -FORCE:MULTIPLE to workaround linker error that says that some things was already defined.

But now I have no clues how to use it. I mean, I'm not sure what args I need to pass to swiftc to build something with Foundation :confused:

UPDATE: I think, I figured out how to setup Foundation.
What I've done is runed cmake --build S:\b\foundation --target install and then copied all installed files from Program Files to toolchain. After that, swiftc was able to run without -I and -l{lib} flags, though I ran into another issue:

C:\SwiftDev\Dev>swiftc demo.swift -o demo.exe
e[1m<module-includes>:1:10: e[0me[0;1;30mnote: e[0me[1min file included from <module-includes>:1:
e[0m#include "CoreFoundation.h"
e[0;1;32m         ^
e[0me[1mC:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\lib\swift\CoreFoundation/CoreFoundation.h:101:10: e[0me[0;1;30mnote: e[0me[1min file included from C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\lib\swift\CoreFoundation/CoreFoundation.h:101:
e[0m#include <CoreFoundation/ForSwiftFoundationOnly.h>
e[0;1;32m         ^
e[0me[1mC:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\lib\swift\CoreFoundation/ForSwiftFoundationOnly.h:34:10: e[0me[0;1;31merror: e[0me[1m'fts.h' file not found
e[0m#include <fts.h>
e[0;1;32m         ^
e[0me[1m<unknown>:0: e[0me[0;1;31merror: e[0me[1mcould not build C module 'CoreFoundation'
e[0m
Current state of affairs with Foundation on Windows
(Saleem Abdulrasool) #82

Ah, yeah, __CFInitializeWinSock was a copy paste error on my part. This is why pre-commit CI would be useful for Windows.

The /FORCE:MULTIPLE is a compiler issue that I've not had a chance to look into. See SR-10192. Feels like we are not marking a symbol as COMDAT where we should be. You should be able to use that as a temporary workaround, but, I would rather not have that be checked in as it can hide other issues (and can cause more subtle runtime failures due to difference instances being used).

1 Like
(Pedro José Pereira Vieito) #83

Any update on pre-build toolchains with Foundation? :slight_smile:

I have successfully build it, but I was not able to use it. It seems I have to specify some flags to swiftc so that the Clang Importer can correctly read CoreFoundation headers.

Z:\Downloads>swiftc main.swift -o main.exe && main
<module-includes>:1:10: note: in file included from <module-includes>:1:
e#include "CoreFoundation.h"
         ^
C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\lib\swift\CoreFoundation/CoreFoundation.h:101:10: note: in file included from C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\lib\swift\CoreFoundation/CoreFoundation.h:101:
#include <CoreFoundation/ForSwiftFoundationOnly.h>
         ^
C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\lib\swift\CoreFoundation/ForSwiftFoundationOnly.h:33:10: error: 'fts.h' file not found
#include <fts.h>
         ^
<unknown>:0: error: could not build C module 'CoreFoundation'
1 Like
Current state of affairs with Foundation on Windows
(Saleem Abdulrasool) #84

Yeah, turns out that I need to change the build for supporting this as the wrong linker gets picked up. The overall benefit of the change is that it fixes dependency tracking in the build so that changes in CoreFoundation are detected properly and will trigger a rebuild. This also simplifies the link dependency tracking since the library is not an imported target but a proper library that is available to CMake. The problem is that the build is failing for some reason with that set of changes. I suppose that I may have to do a staged change where I change the search paths before I switch the build layout and then go through and clean things up.

The patches for this are already up on GitHub, but, I have been working on a different set of problems and haven't gotten back around to fixing the build for swift-corelibs-foundation (it ends up rippling through swift-corelibs-xctest, swift-package-manager, swift-llbuild).

Yeah, the CoreFoundation headers need to be in the search path for now, but since the intention is to remove CoreFoundation from the public interface, that shouldn't be needed long term. In the meantime, we should consider installing the CoreFoundation headers into the SDK image, so that -sdk can resolve the include path.

Perhaps we should have a separate thread for Foundation on Windows.

2 Likes