Skip to content

[DNM][WIP] Implement Windows toolchain #419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9fcd3f2
Implement WindowsToolchain
stevapple Sep 13, 2020
9076ab2
Fix swiftrtPath
stevapple Sep 13, 2020
2c9716b
Fix various problems
stevapple Sep 14, 2020
8b7b0df
Derive executable file name from Toolchain
stevapple Sep 14, 2020
3c0feb3
Fix addPlatformSpecificLinkerArgs for WindowsToolchain
stevapple Sep 14, 2020
633801d
Fix clangLibraryPath for Windows
stevapple Sep 14, 2020
59877f1
Disable profiling support on Windows
stevapple Sep 16, 2020
4b69ec6
Disable unsupported sanitizers on Windows
stevapple Sep 16, 2020
31d2556
Merge branch 'master' into windows-toolchain
stevapple Sep 17, 2020
d8c4f60
Fix cross-compilation problems
stevapple Sep 17, 2020
ed1b8c2
Fix CRT support for Windows
stevapple Sep 17, 2020
4bd5495
Keep update with the latest layout
stevapple Dec 19, 2020
7e82541
Fix subcommand discovery
stevapple Dec 19, 2020
46785ab
Merge branch 'main' into windows-toolchain
stevapple Dec 19, 2020
660a709
Fix build
stevapple Dec 19, 2020
b1e5ef9
Implement functions to depress warnings
stevapple Dec 19, 2020
e270919
Disable LTO support on Windows
stevapple Dec 19, 2020
aa908ad
Improve flags usage
stevapple Dec 20, 2020
a3ca4ab
Fix MSVC Runtime options
stevapple Dec 20, 2020
5d38461
Minor fixes
stevapple Feb 20, 2021
204f061
Merge changes from upstream
stevapple Feb 20, 2021
6909152
Fix PATH
stevapple Feb 20, 2021
aa427ed
Fix some tests on Windows
stevapple Feb 23, 2021
58c6f7a
Fix some tests on Windows
stevapple Feb 23, 2021
9d308f1
Merge 'upstream/main' into windows-toolchain
stevapple Feb 23, 2021
a666df9
Minor fixes
stevapple Feb 23, 2021
d48e3e1
Style fixes
stevapple Feb 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix some tests on Windows
  • Loading branch information
stevapple committed Feb 23, 2021
commit aa427ed7b5bf151b28ddf0faeb348586c0aa71a8
2 changes: 1 addition & 1 deletion Sources/SwiftDriver/Driver/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public struct Driver {

// Determine the compilation mode.
self.compilerMode = try Self.computeCompilerMode(&parsedOptions, driverKind: driverKind, diagnosticsEngine: diagnosticEngine)

self.shouldAttemptIncrementalCompilation = Self.shouldAttemptIncrementalCompilation(&parsedOptions,
diagnosticEngine: diagnosticsEngine,
compilerMode: compilerMode)
Expand Down
3 changes: 2 additions & 1 deletion Sources/SwiftDriver/Driver/OutputFileMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ fileprivate struct OutputFileMapJSON: Codable {

/// Converts into virtual path entries.
func toVirtualOutputFileMap() throws -> [VirtualPath : [FileType : VirtualPath]] {
Dictionary(try entries.map { input, entry in
// Add filter here due to a bug of TSC, see swift-tools-support-core#191
Dictionary(try entries.filter { $0.0 != "" }.map { input, entry in
(try VirtualPath(path: input), try entry.paths.mapValues(VirtualPath.init(path:)))
}, uniquingKeysWith: { $1 })
}
Expand Down
50 changes: 47 additions & 3 deletions Tests/SwiftDriverTests/IncrementalCompilationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ final class NonincrementalCompilationTests: XCTestCase {

try XCTAssertEqual(buildRecord.buildTime,
Date(legacyDriverSecsAndNanos: [1570318779, 32358000]))
#if os(Windows)
try XCTAssertEqual(buildRecord.inputInfos,
[
VirtualPath(path: "C:\\AS\\repos\\swift-driver\\sandbox\\sandbox\\sandbox\\file2.swift"):
InputInfo(status: .needsCascadingBuild,
previousModTime: Date(legacyDriverSecsAndNanos: [1570318778, 0])),
VirtualPath(path: "C:\\AS\\repos\\swift-driver\\sandbox\\sandbox\\sandbox\\main.swift"):
InputInfo(status: .upToDate,
previousModTime: Date(legacyDriverSecsAndNanos: [1570083660, 0])),
VirtualPath(path: "E:\\gazorp.swift"):
InputInfo(status: .needsNonCascadingBuild,
previousModTime: Date(legacyDriverSecsAndNanos: [0, 0]))
])
#else
try XCTAssertEqual(buildRecord.inputInfos,
[
VirtualPath(path: "/Volumes/AS/repos/swift-driver/sandbox/sandbox/sandbox/file2.swift"):
Expand All @@ -38,6 +52,7 @@ final class NonincrementalCompilationTests: XCTestCase {
InputInfo(status: .needsNonCascadingBuild,
previousModTime: Date(legacyDriverSecsAndNanos: [0, 0]))
])
#endif
}

func testBuildRecordWithoutOptionsReading() throws {
Expand All @@ -51,18 +66,33 @@ final class NonincrementalCompilationTests: XCTestCase {

try XCTAssertEqual(buildRecord.buildTime,
Date(legacyDriverSecsAndNanos: [1570318779, 32358000]))
#if os(Windows)
try XCTAssertEqual(buildRecord.inputInfos,
[
VirtualPath(path: "/Volumes/AS/repos/swift-driver/sandbox/sandbox/sandbox/file2.swift"):
VirtualPath(path: "C:\\repos\\swift-driver\\sandbox\\sandbox\\sandbox\\file2.swift"):
InputInfo(status: .needsCascadingBuild,
previousModTime: Date(legacyDriverSecsAndNanos: [1570318778, 0])),
VirtualPath(path: "C:\\repos\\swift-driver\\sandbox\\sandbox\\sandbox\\main.swift"):
InputInfo(status: .upToDate,
previousModTime: Date(legacyDriverSecsAndNanos: [1570083660, 0])),
VirtualPath(path: "E:\\gazorp.swift"):
InputInfo(status: .needsNonCascadingBuild,
previousModTime: Date(legacyDriverSecsAndNanos: [0, 0]))
])
#else
try XCTAssertEqual(buildRecord.inputInfos,
[
VirtualPath(path: "/Volumes/AS/repos/swift-driver/sandbox/sandbox/sandbox/file2.swift"):
InputInfo(status: .needsCascadingBuild,
previousModTime: Date(legacyDriverSecsAndNanos: [1570318778, 0])),
VirtualPath(path: "/Volumes/AS/repos/swift-driver/sandbox/sandbox/sandbox/main.swift"):
InputInfo(status: .upToDate,
previousModTime: Date(legacyDriverSecsAndNanos: [1570083660, 0])),
VirtualPath(path: "/Volumes/gazorp.swift"):
InputInfo(status: .needsNonCascadingBuild,
previousModTime: Date(legacyDriverSecsAndNanos: [0, 0]))
])
])
#endif
}

func testReadBinarySourceFileDependencyGraph() throws {
Expand Down Expand Up @@ -151,7 +181,11 @@ final class NonincrementalCompilationTests: XCTestCase {
XCTAssertFalse(foundEdge)
foundEdge = true

#if os(Windows)
XCTAssertEqual(defName, "C:\\Users\\owenvoorhees\\Desktop\\hello.swiftdeps")
#else
XCTAssertEqual(defName, "/Users/owenvoorhees/Desktop/hello.swiftdeps")
#endif
XCTAssertEqual(defNode.fingerprint, "38b457b424090ac2e595be0e5f7e3b5b")

XCTAssertEqual(useContext, "5hello1AC")
Expand Down Expand Up @@ -202,9 +236,15 @@ final class NonincrementalCompilationTests: XCTestCase {
func testReadAndWriteBuildRecord() throws {
let version = "Apple Swift version 5.1 (swiftlang-1100.0.270.13 clang-1100.0.33.7)"
let options = "abbbfbcaf36b93e58efaadd8271ff142"
#if os(Windows)
let file2 = "C:\\repos\\swift-driver\\sandbox\\sandbox\\sandbox\\file2.swift"
let main = "C:\\repos\\swift-driver\\sandbox\\sandbox\\sandbox\\main.swift"
let gazorp = "E:\\gazorp.swift"
#else
let file2 = "/Volumes/AS/repos/swift-driver/sandbox/sandbox/sandbox/file2.swift"
let main = "/Volumes/AS/repos/swift-driver/sandbox/sandbox/sandbox/main.swift"
let gazorp = "/Volumes/gazorp.swift"
#endif
let inputString =
"""
version: "\(version)"
Expand Down Expand Up @@ -712,7 +752,11 @@ final class IncrementalCompilationTests: XCTestCase {

private func replace(contentsOf name: String, with replacement: String ) {
print("*** replacing \(name) ***", to: &stderrStream); stderrStream.flush()
let path = try! XCTUnwrap(inputPathsAndContents.filter {$0.0.pathString.contains("/" + name + ".swift")}.first).0
#if os(Windows)
let path = try! XCTUnwrap(inputPathsAndContents.filter {$0.0.pathString.contains("\\\(name).swift")}.first).0
#else
let path = try! XCTUnwrap(inputPathsAndContents.filter {$0.0.pathString.contains("/\(name).swift")}.first).0
#endif
let previousContents = try! localFileSystem.readFileContents(path).cString
try! localFileSystem.writeFileContents(path) { $0 <<< replacement }
let newContents = try! localFileSystem.readFileContents(path).cString
Expand Down
Loading