Skip to content

Commit e9d6ba9

Browse files
committed
cmake: enable SwiftCompilerSources on Windows
1 parent 77f53a5 commit e9d6ba9

13 files changed

+55
-3
lines changed

CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,18 @@ option(SWIFT_ENABLE_BACKTRACING
736736
set(SWIFT_DARWIN_DEPLOYMENT_VERSION_MACCATALYST "14.5" CACHE STRING
737737
"Minimum deployment target version for macCatalyst")
738738

739+
# A tempoarary hack: force enabling HOSTTOOLS mode on Windows.
740+
# Right now, SwiftCompilerSources cannot be enabled for lldb because on Windows
741+
# swift and lldb are built in a unified build and there is a missing dependency
742+
# on swiftrt.
743+
# Swift and lldb are configured with the same cmake invocation and therefore
744+
# enabling bootstrapping for swift and disabling it for lldb only works by
745+
# hardcoding the bootstrapping mode in the cmake file.
746+
# https://github.com/apple/swift/issues/73322
747+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
748+
set(BOOTSTRAPPING_MODE "HOSTTOOLS")
749+
endif()
750+
739751
#
740752
# End of user-configurable options.
741753
#
@@ -904,6 +916,10 @@ if("${SWIFT_NATIVE_SWIFT_TOOLS_PATH}" STREQUAL "")
904916
# This is the normal case. We are not cross-compiling.
905917
set(SWIFT_NATIVE_SWIFT_TOOLS_PATH "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
906918
set(SWIFT_EXEC_FOR_SWIFT_MODULES "${CMAKE_Swift_COMPILER}")
919+
if(NOT SWIFT_EXEC_FOR_SWIFT_MODULES)
920+
message(WARNING "BOOSTRAPPING set to OFF because no Swift compiler is defined")
921+
set(BOOTSTRAPPING_MODE "OFF")
922+
endif()
907923
elseif(BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*")
908924
# If cross-compiling, we don't have to bootstrap. We can just use the previously
909925
# built native swiftc to build the swift compiler modules.

SwiftCompilerSources/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ function(add_swift_compiler_modules_library name)
106106
"-Xcc" "-std=c++17"
107107
"-Xcc" "-DCOMPILED_WITH_SWIFT" "-Xcc" "-DSWIFT_TARGET"
108108
"-Xcc" "-UIBOutlet" "-Xcc" "-UIBAction" "-Xcc" "-UIBInspectable")
109+
109110
# Prior to 5.9, we have to use the experimental flag for C++ interop.
110111
if (CMAKE_Swift_COMPILER_VERSION VERSION_LESS 5.9)
111112
list(APPEND swift_compile_options "-Xfrontend" "-enable-experimental-cxx-interop")
@@ -167,7 +168,13 @@ function(add_swift_compiler_modules_library name)
167168
# under `include/swift`. These are either located next to the compiler (in case of open source toolchains) or
168169
# in the SDK (in case a Swift compiler from Xcode)
169170
get_filename_component(swift_exec_bin_dir ${ALS_SWIFT_EXEC} DIRECTORY)
170-
list(APPEND sdk_option "-I" "${swift_exec_bin_dir}/../lib" "-I" "${sdk_path}/usr/lib")
171+
172+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
173+
list(APPEND swift_compile_options "-static")
174+
list(APPEND sdk_option "-sdk" "${SWIFT_PATH_TO_SWIFT_SDK}")
175+
else()
176+
list(APPEND sdk_option "-I" "${swift_exec_bin_dir}/../lib" "-I" "${sdk_path}/usr/lib")
177+
endif()
171178

172179
set(all_obj_files)
173180
set(all_module_targets)

test/AutoDiff/SILOptimizer/vjp_and_pullback_inlining.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
// REQUIRES: asserts
66
// REQUIRES: swift_in_compiler
7+
// UNSUPPORTED: OS=windows-msvc
78

89
import _Differentiation
910
#if canImport(Glibc)

test/IRGen/loadable_by_address_address_assignment.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// RUN: %target-swift-frontend %s -O -Xllvm -sil-print-after=loadable-address -c -o %t/t.o 2>&1 | %FileCheck %s
22

3-
// XFAIL: OS=windows-msvc
4-
53
public struct LargeThing {
64
var s0 : String = ""
75
var s1 : String = ""

test/embedded/optionset2.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// REQUIRES: optimized_stdlib
66
// REQUIRES: CODEGENERATOR=ARM
77

8+
// https://github.com/apple/swift/issues/73249
9+
// UNSUPPORTED: OS=windows-msvc
10+
811
protocol MyOptionSet: Equatable {
912
init(rawValue: Int)
1013
init()

test/embedded/ouroboros-bug.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
// REQUIRES: optimized_stdlib
1111
// REQUIRES: CODEGENERATOR=ARM
1212

13+
// https://github.com/apple/swift/issues/73249
14+
// UNSUPPORTED: OS=windows-msvc
15+
1316
public func test() {}
1417
test()
1518

test/embedded/stdlib-array.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// REQUIRES: optimized_stdlib
66
// REQUIRES: CODEGENERATOR=ARM
77

8+
// https://github.com/apple/swift/issues/73249
9+
// UNSUPPORTED: OS=windows-msvc
10+
811
public func test() {
912
var array: [Int] = [1, 2, 3]
1013
array.append(42)

test/embedded/stdlib-basic.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
// REQUIRES: swift_in_compiler
55
// REQUIRES: CODEGENERATOR=ARM
66

7+
// https://github.com/apple/swift/issues/73249
8+
// UNSUPPORTED: OS=windows-msvc
9+
710
public func bool() -> Bool {
811
return true
912
}

test/embedded/stdlib-dictionary.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
// REQUIRES: swift_in_compiler
55
// REQUIRES: optimized_stdlib
66

7+
// https://github.com/apple/swift/issues/73249
8+
// UNSUPPORTED: OS=windows-msvc
9+
710
public func test() {
811
var d: [Int:Int] = [1: 2, 3: 4, 5: 6]
912
d[8] = 9

test/embedded/stdlib-random.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
// REQUIRES: swift_in_compiler
55
// REQUIRES: optimized_stdlib
66

7+
// https://github.com/apple/swift/issues/73249
8+
// UNSUPPORTED: OS=windows-msvc
9+
710
public func test() {
811
Bool.random()
912
Int.random(in: 0 ..< 100)

0 commit comments

Comments
 (0)