Skip to content

Commit 4075d70

Browse files
committed
stdlib: remove the dependency on the injected modules
Inject the necessary module maps and apinotes via the VFS. This cleans up the developer build in preparation for a secondary change to remove this need for deployed scenarios as well. Injecting the content via the VFS will enable us restore the ability to work with a pristine installation of Visual Studio, dropping the custom action for the Swift installer, and open the pathway to per-user installation of Swift. Thanks to @bnbarham for the help and discussion in resolving the test issues.
1 parent c94210c commit 4075d70

15 files changed

+111
-53
lines changed

stdlib/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ else()
2424
set(SWIFT_BUILD_TEST_SUPPORT_MODULES_default FALSE)
2525
endif()
2626

27+
# TODO(compnerd) use a target to avoid re-creating this file all the time
28+
function(generate_windows_vfs_overlay)
29+
file(TO_CMAKE_PATH ${VCToolsInstallDir} VCToolsInstallDir)
30+
file(TO_CMAKE_PATH ${UniversalCRTSdkDir} UniversalCRTSdkDir)
31+
configure_file("${PROJECT_SOURCE_DIR}/cmake/WindowsVFS.yaml.in"
32+
"${CMAKE_CURRENT_BINARY_DIR}/windows-vfs-overlay.yaml"
33+
@ONLY)
34+
endfunction()
35+
if(WINDOWS IN_LIST SWIFT_SDKS)
36+
generate_windows_vfs_overlay()
37+
file(TO_CMAKE_PATH "${CMAKE_CURRENT_BINARY_DIR}/windows-vfs-overlay.yaml"
38+
SWIFT_WINDOWS_VFS_OVERLAY)
39+
endif()
40+
2741
#
2842
# User-configurable options for the standard library.
2943
#

stdlib/cmake/WindowsVFS.yaml.in

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
version: 0
3+
case-sensitive: false
4+
use-external-names: false
5+
roots:
6+
- name: "@UniversalCRTSdkDir@\\Include\\@UCRTVersion@\\um"
7+
type: directory
8+
contents:
9+
- name: module.modulemap
10+
type: file
11+
external-contents: "@PROJECT_SOURCE_DIR@\\public\\Platform\\winsdk.modulemap"
12+
- name: "@UniversalCRTSdkDir@\\Include\\@UCRTVersion@\\ucrt"
13+
type: directory
14+
contents:
15+
- name: module.modulemap
16+
type: file
17+
external-contents: "@PROJECT_SOURCE_DIR@\\public\\Platform\\ucrt.modulemap"
18+
- name: "@VCToolsInstallDir@\\include"
19+
type: directory
20+
contents:
21+
- name: module.modulemap
22+
type: file
23+
external-contents: "@PROJECT_SOURCE_DIR@\\public\\Platform\\vcruntime.modulemap"
24+
- name: vcruntime.apinotes
25+
type: file
26+
external-contents: "@PROJECT_SOURCE_DIR@\\public\\Platform\\vcruntime.apinotes"
27+

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,8 @@ function(add_swift_target_library_single target name)
875875
list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS
876876
-Xcc;-Xclang;-Xcc;-ivfsoverlay;-Xcc;-Xclang;-Xcc;${SWIFTLIB_SINGLE_VFS_OVERLAY})
877877
endif()
878+
list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS
879+
-vfsoverlay;"${SWIFT_WINDOWS_VFS_OVERLAY}")
878880
swift_windows_include_for_arch(${SWIFTLIB_SINGLE_ARCHITECTURE} SWIFTLIB_INCLUDE)
879881
foreach(directory ${SWIFTLIB_INCLUDE})
880882
list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS -Xcc;-isystem;-Xcc;${directory})

test/Driver/batch_mode_dependencies_make_wrong_order.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
// RUN: echo 'public func main() {}' >%t/main.swift
77
//
88
// First prime the incremental state, but note that we're building in the d c b a (reverse-alphabetical) order.
9-
// RUN: cd %t && %target-swiftc_driver -enable-batch-mode -incremental -output-file-map %S/Inputs/abcd_filemap.yaml -module-name main -j 1 d.swift c.swift b.swift a.swift main.swift
9+
// RUN: cd %t && %swiftc_driver-stdlib-target -enable-batch-mode -incremental -output-file-map %S/Inputs/abcd_filemap.yaml -module-name main -j 1 d.swift c.swift b.swift a.swift main.swift
1010
//
1111
// Now perturb the interface of a.swift and delete its output
1212
// RUN: echo 'class a { var x : Int = 10 }' >%t/a.swift
1313
// RUN: rm %t/a.o
1414
//
1515
// Now rebuild, which will rebuild a.swift then do a cascading dep-graph invalidation
16-
// RUN: cd %t && %target-swiftc_driver -enable-batch-mode -incremental -output-file-map %S/Inputs/abcd_filemap.yaml -module-name main -j 1 d.swift c.swift b.swift a.swift main.swift -driver-show-incremental -driver-show-job-lifecycle >%t/out.txt 2>&1
16+
// RUN: cd %t && %swiftc_driver-stdlib-target -enable-batch-mode -incremental -output-file-map %S/Inputs/abcd_filemap.yaml -module-name main -j 1 d.swift c.swift b.swift a.swift main.swift -driver-show-incremental -driver-show-job-lifecycle >%t/out.txt 2>&1
1717
// RUN: %FileCheck %s <%t/out.txt
1818
//
1919
// Check that we saw invalidation happen in command-line argument order

test/Incremental/Fingerprints/class-fingerprint.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// Seeing weird failure on CI, so set the mod times
1111
// RUN: touch -t 200101010101 %t/*.swift
1212

13-
// RUN: cd %t && %target-swiftc_driver -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >&output3
13+
// RUN: cd %t && %swiftc_driver-stdlib-target -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >&output3
1414

1515
// only-run-for-debugging: cp %t/usesB.swiftdeps %t/usesB3.swiftdeps
1616

@@ -24,7 +24,7 @@
2424
// RUN: touch -t 200101010101 %t/*.swift
2525
// RUN: touch -t 200301010101 %t/definesAB.swift
2626

27-
// RUN: cd %t && %target-swiftc_driver -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >&output4
27+
// RUN: cd %t && %swiftc_driver-stdlib-target -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >&output4
2828

2929
// only-run-for-debugging: cp %t/usesB.swiftdeps %t/usesB4.swiftdeps
3030

test/Incremental/Fingerprints/enum-fingerprint.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// Seeing weird failure on CI, so set the mod times
1111
// RUN: touch -t 200101010101 %t/*.swift
1212

13-
// RUN: cd %t && %target-swiftc_driver -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >&output3
13+
// RUN: cd %t && %swiftc_driver-stdlib-target -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >&output3
1414

1515
// only-run-for-debugging: cp %t/usesB.swiftdeps %t/usesB3.swiftdeps
1616

@@ -24,7 +24,7 @@
2424
// RUN: touch -t 200101010101 %t/*.swift
2525
// RUN: touch -t 200301010101 %t/definesAB.swift
2626

27-
// RUN: cd %t && %target-swiftc_driver -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >&output4
27+
// RUN: cd %t && %swiftc_driver-stdlib-target -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >&output4
2828

2929
// only-run-for-debugging: cp %t/usesB.swiftdeps %t/usesB4.swiftdeps
3030

test/Incremental/Fingerprints/extension-adds-member.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// Seeing weird failure on CI, so set the mod times
1111
// RUN: touch -t 200101010101 %t/*.swift
1212

13-
// RUN: cd %t && %target-swiftc_driver -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >& %t/output3
13+
// RUN: cd %t && %swiftc_driver-stdlib-target -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >& %t/output3
1414

1515
// Change one type, only uses of that type get recompiled
1616

@@ -21,7 +21,7 @@
2121
// RUN: touch -t 200101010101 %t/*.swift
2222
// RUN: touch -t 200301010101 %t/definesAB.swift
2323

24-
// RUN: cd %t && %target-swiftc_driver -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >& %t/output4
24+
// RUN: cd %t && %swiftc_driver-stdlib-target -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >& %t/output4
2525

2626
// RUN: %FileCheck -check-prefix=CHECK-RECOMPILED-W %s < %t/output4
2727
// RUN: %FileCheck -check-prefix=CHECK-NOT-RECOMPILED-W %s < %t/output4

test/Incremental/Fingerprints/nested-enum-fingerprint.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// Seeing weird failure on CI, so set the mod times
1111
// RUN: touch -t 200101010101 %t/*.swift
1212

13-
// RUN: cd %t && %target-swiftc_driver -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >&output3
13+
// RUN: cd %t && %swiftc_driver-stdlib-target -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >&output3
1414

1515
// only-run-for-debugging: cp %t/usesB.swiftdeps %t/usesB3.swiftdeps
1616

@@ -24,7 +24,7 @@
2424
// RUN: touch -t 200101010101 %t/*.swift
2525
// RUN: touch -t 200301010101 %t/definesAB.swift
2626

27-
// RUN: cd %t && %target-swiftc_driver -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >&output4
27+
// RUN: cd %t && %swiftc_driver-stdlib-target -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >&output4
2828

2929
// only-run-for-debugging: cp %t/usesB.swiftdeps %t/usesB4.swiftdeps
3030

test/Incremental/Fingerprints/protocol-fingerprint.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// Seeing weird failure on CI, so set the mod times
1111
// RUN: touch -t 200101010101 %t/*.swift
1212

13-
// RUN: cd %t && %target-swiftc_driver -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >&output3
13+
// RUN: cd %t && %swiftc_driver-stdlib-target -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >&output3
1414

1515
// only-run-for-debugging: cp %t/usesB.swiftdeps %t/usesB3.swiftdeps
1616

@@ -24,7 +24,7 @@
2424
// RUN: touch -t 200101010101 %t/*.swift
2525
// RUN: touch -t 200301010101 %t/definesAB.swift
2626

27-
// RUN: cd %t && %target-swiftc_driver -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >&output4
27+
// RUN: cd %t && %swiftc_driver-stdlib-target -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >&output4
2828

2929
// only-run-for-debugging: cp %t/usesB.swiftdeps %t/usesB4.swiftdeps
3030

test/Incremental/Fingerprints/struct-fingerprint.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// Seeing weird failure on CI, so set the mod times
1111
// RUN: touch -t 200101010101 %t/*.swift
1212

13-
// RUN: cd %t && %target-swiftc_driver -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >&output3
13+
// RUN: cd %t && %swiftc_driver-stdlib-target -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >&output3
1414

1515
// only-run-for-debugging: cp %t/usesB.swiftdeps %t/usesB3.swiftdeps
1616

@@ -24,7 +24,7 @@
2424
// RUN: touch -t 200101010101 %t/*.swift
2525
// RUN: touch -t 200301010101 %t/definesAB.swift
2626

27-
// RUN: cd %t && %target-swiftc_driver -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >&output4
27+
// RUN: cd %t && %swiftc_driver-stdlib-target -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesAB.swift usesA.swift usesB.swift -module-name main -output-file-map ofm.json >&output4
2828

2929
// only-run-for-debugging: cp %t/usesB.swiftdeps %t/usesB4.swiftdeps
3030

test/Incremental/cross-file-failure.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// RUN: touch -t 200101010101 %t/*.swift
77
// RUN: cd %t
88

9-
// RUN: %target-swiftc_driver -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesA.swift usesA.swift -module-name main -output-file-map ofm.json >&output-baseline
9+
// RUN: %swiftc_driver-stdlib-target -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesA.swift usesA.swift -module-name main -output-file-map ofm.json >&output-baseline
1010

1111
// Change one type and cause a syntax error. This should cause _both_ files to
1212
// rebuild.
@@ -16,12 +16,12 @@
1616
// RUN: touch -t 200101010101 %t/*.swift
1717
// RUN: touch -t 200301010101 %t/definesA.swift
1818

19-
// RUN: not %target-swiftc_driver -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesA.swift usesA.swift -module-name main -output-file-map ofm.json
19+
// RUN: not %swiftc_driver-stdlib-target -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesA.swift usesA.swift -module-name main -output-file-map ofm.json
2020

2121
// RUN: cp %t/definesA{-three,}.swift
2222
// RUN: touch -t 200401010101 %t/definesA.swift
2323

24-
// RUN: not %target-swiftc_driver -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesA.swift usesA.swift -module-name main -output-file-map ofm.json >&output-incremental
24+
// RUN: not %swiftc_driver-stdlib-target -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesA.swift usesA.swift -module-name main -output-file-map ofm.json >&output-incremental
2525

2626
// RUN: %FileCheck -check-prefix=CHECK-RECOMPILED %s --dump-input=always < %t/output-incremental
2727

test/Incremental/superfluous-cascade.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// RUN: cp %t/definesPoint{-before,}.swift
66
// RUN: touch -t 200101010101 %t/*.swift
77

8-
// RUN: cd %t && %target-swiftc_driver -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesPoint.swift usesPoint.swift usesDisplay.swift -module-name main -output-file-map ofm.json >&output3
8+
// RUN: cd %t && %swiftc_driver-stdlib-target -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesPoint.swift usesPoint.swift usesDisplay.swift -module-name main -output-file-map ofm.json >&output3
99

1010
// Change one type - now only the user of that type rebuilds
1111

@@ -14,7 +14,7 @@
1414
// RUN: touch -t 200101010101 %t/*.swift
1515
// RUN: touch -t 200301010101 %t/definesPoint.swift
1616

17-
// RUN: cd %t && %target-swiftc_driver -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesPoint.swift usesPoint.swift usesDisplay.swift -module-name main -output-file-map ofm.json >&output4
17+
// RUN: cd %t && %swiftc_driver-stdlib-target -enable-batch-mode -j2 -incremental -driver-show-incremental main.swift definesPoint.swift usesPoint.swift usesDisplay.swift -module-name main -output-file-map ofm.json >&output4
1818

1919
// RUN: %FileCheck -check-prefix=CHECK-RECOMPILED %s --dump-input=always < %t/output4
2020

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import sys
22

33
for input_path in sys.argv[1:]:
4-
with open(input_path, 'r') as yaml_file:
4+
with open(input_path, 'rb') as yaml_file:
55
# Forwarding files are YAML files that start with '---'
6-
if yaml_file.read(3) != '---':
6+
if yaml_file.read(3) != b'---':
77
print("swiftmodule '%s' is not a forwarding module!" % input_path)
88
sys.exit(1)

0 commit comments

Comments
 (0)