Skip to content
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

[DNM][WIP] Implement Windows toolchain #419

Closed
wants to merge 27 commits into from

Conversation

stevapple
Copy link
Contributor

@stevapple stevapple commented Dec 19, 2020

Hello everyone, I'm back!

Sorry for absence for the past months. Now, WindowsToolchain has been:

  • Updated according to the latest layout;
  • Tested on real Windows machines.

The following commands are currently supported and tested:

  • swiftc
  • swift
  • SwiftPM (swift-build, swift-run, swift-test and any new ones to come)
  • REPL (swift-repl)
  • make-options

Some other things to do:

  • Prove compatibility with various linkers;
  • Prove support for statical linking;
  • Fix unit tests for the toolchain;
  • Fix compatibility with non-Unicode encoding (eg. GB2312);
  • Fit into swift-build pipeline;
  • Fix building swift-driver with SwiftPM on Windows (SR-14259);
  • Test cross-compilation with Android and Linux;
  • Try to implement commandLineFitsWithinSystemLimits and tokenizeResponseFile for Windows.

Hopefully landing by Swift 5.5 :)

@stevapple stevapple changed the title [Do Not Merge][WIP] Implement Windows toolchain [DNM][WIP] Implement Windows toolchain Dec 19, 2020
Copy link
Contributor

@owenv owenv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for continuing to work on this, it's really great to hear that everything is compiling and working on Windows! I added a few initial comments and questions, but feel free to ignore anything that doesn't make sense because I'm still not very familiar with the platform. I do think that in addition to these changes, we might need to add something equivalent to addRuntimeLibraryFlags in Toolchains.cpp from the old driver, possibly in an implementation of WindowsToolchain.addPlatformSpecificCommonFrontendOptions

Package.swift Outdated Show resolved Hide resolved
Comment on lines +53 to +55
if (triple.isWindows) {
result.append(sdkPath.appending(components: "usr", "lib", "swift", "windows"))
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used to find the correct path to the runtime, or something else maybe? I know in a few other places we append targetTriple.platformName() only when needed which might help remove the workaround here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I referred to the current layout of Windows toolchain and SDK, which is slightly different from other platforms. I think we need to unify SDK layout for the convenience of cross-compilation (and to eliminate differences across platforms), how do you think @compnerd ?

Sources/SwiftDriver/Toolchains/WindowsToolchain.swift Outdated Show resolved Hide resolved
// The default linker `LINK.exe` can use `/LTCG:INCREMENTAL` to enable LTO,
// and LLVM LTOs are available through `lld-link`. Both LTO methods still need
// additional work to be integrated, so disable this option for now.
if parsedOptions.hasArgument(.lto) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think lld LTO is supported on windows now on main, but that can be addressed in a future PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried but there’re some tricky problems... In fact I got the same output with the old driver on main when I passed -use-ld=lld-link, but just doesn’t function properly.
If that’s only a rare case, I think enabling it is a easy task👌

@stevapple
Copy link
Contributor Author

stevapple commented Feb 23, 2021

Opening swiftlang/swift-tools-support-core#191 to solve some TSC bugs on Windows. Some tests will function correctly after that patch.

@artemcm
Copy link
Contributor

artemcm commented Feb 23, 2021

@stevapple really awesome to see this coming along!

Could you please re-base this PR so that it is a bit easier to look at the specific changes?

@stevapple
Copy link
Contributor Author

CC @artemcm

@stevapple stevapple marked this pull request as draft February 27, 2021 19:56
@stevapple
Copy link
Contributor Author

For someone who may be watching the progress: This PR needs to wait for swiftlang/swift-tools-support-core#219 which brings lots of stability in path parsing and some useful helpers for unit testing.

@artemcm
Copy link
Contributor

artemcm commented Jan 19, 2022

@stevapple this is now quite stale with respect to a lot of recent work in this area by @compnerd.
If you'd like to further contribute with the Windows toolchain bringup, please take a look at the progress done since this PR.

@artemcm artemcm closed this Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants