Skip to content

utils: enable early swift driver on Windows #76574

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

compnerd
Copy link
Member

No description provided.

@compnerd
Copy link
Member Author

@swift-ci please test Windows platform

2 similar comments
@compnerd
Copy link
Member Author

@swift-ci please test Windows platform

@compnerd
Copy link
Member Author

@swift-ci please test Windows platform

@compnerd
Copy link
Member Author

@swift-ci please test Windows platform

@compnerd compnerd force-pushed the early-driver-win branch 3 times, most recently from 0083a3c to 808146f Compare October 3, 2024 01:13
@compnerd
Copy link
Member Author

compnerd commented Oct 3, 2024

@swift-ci please test Windows platform

@compnerd
Copy link
Member Author

compnerd commented Oct 3, 2024

@swift-ci please test Windows platform

@compnerd compnerd force-pushed the early-driver-win branch 3 times, most recently from 54f6c65 to f629b58 Compare November 14, 2024 01:25
@compnerd compnerd marked this pull request as ready for review November 14, 2024 01:25
@compnerd
Copy link
Member Author

@swift-ci please test Windows platform

1 similar comment
@compnerd
Copy link
Member Author

@swift-ci please test Windows platform

@compnerd
Copy link
Member Author

@swift-ci please test Windows platform

@compnerd
Copy link
Member Author

@swift-ci please test Windows platform

@compnerd
Copy link
Member Author

@swift-ci please test Windows platform

1 similar comment
@compnerd
Copy link
Member Author

@swift-ci please test Windows platform

@compnerd
Copy link
Member Author

@swift-ci please test Windows platform

1 similar comment
@compnerd
Copy link
Member Author

@swift-ci please test Windows platform

@compnerd
Copy link
Member Author

@swift-ci please test Windows platform

@compnerd
Copy link
Member Author

swiftlang/swift-foundation#1421
swiftlang/swift-foundation-icu#66

@swift-ci please build toolchain Windows platform

@compnerd
Copy link
Member Author

swiftlang/swift-foundation#1421
swiftlang/swift-foundation-icu#66

@swift-ci please build toolchain Windows platform

@compnerd
Copy link
Member Author

swiftlang/swift-foundation#1421
swiftlang/swift-foundation-icu#66

@swift-ci please build toolchain Windows platform

@compnerd
Copy link
Member Author

swiftlang/swift-foundation#1421
swiftlang/swift-foundation-icu#66

@swift-ci please build toolchain Windows platform

1 similar comment
@compnerd
Copy link
Member Author

swiftlang/swift-foundation#1421
swiftlang/swift-foundation-icu#66

@swift-ci please build toolchain Windows platform

@compnerd compnerd force-pushed the early-driver-win branch 2 times, most recently from b1608d6 to 2a8212e Compare July 23, 2025 04:45
@compnerd
Copy link
Member Author

swiftlang/swift-foundation#1421
swiftlang/swift-foundation-icu#66

@swift-ci please build toolchain Windows platform

-SwiftSDK (Get-PinnedToolchainSDK -OS $BuildPlatform.OS -Identifier "$($BuildPlatform.OS)Experimental") `
-BuildTargets default `
-Defines @{
BUILD_SHARED_LIBS = "NO";
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I understand (recalling from SwiftPM work I did last year) this is Windows specific because the swift-driver that is build with the "target" compiler is going to be placed close to the executable and that's the way how windows handles dynamic libraries (they have to be either close to the binary that uses them or on the PATH), so we have to link "host" built driver to things that are going to use it, do I understand this correctly?

I was helping Artem with new driver integration into swift-ide-test and the question is whether it's worth the trouble to maintain dynamic library for earlyswiftdriver on Linux/macOS as well (and put it in lib/swift/host/swift in the toolchain) or make it a static library as well, maybe you have thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

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

As far as I understand (recalling from SwiftPM work I did last year) this is Windows specific because the swift-driver that is build with the "target" compiler is going to be placed close to the executable and that's the way how windows handles dynamic libraries (they have to be either close to the binary that uses them or on the PATH), so we have to link "host" built driver to things that are going to use it, do I understand this correctly?

I don't follow this. The terminology makes this challenging to follow. There are only two builds involved:

  • build: the machine that the build is running on
  • host: the machine that the product will run on

Given that this is a build tool, we know that build == host.

You are correct that Windows (amongst others) do not support RPATH and so you need to copy the DLLs to specific locations (i.e. in Path or the executable directory).

I was helping Artem with new driver integration into swift-ide-test and the question is whether it's worth the trouble to maintain dynamic library for earlyswiftdriver on Linux/macOS as well (and put it in lib/swift/host/swift in the toolchain) or make it a static library as well, maybe you have thoughts?

Windows definitely cannot support dynamic linking for the early swift-driver. The placement and Path adjustment interferes with the testing of the swift driver. That was the motivation for finally addressing the shortcoming (and the remainder of the issues like the ClangImporter, Foundation, build, etc).

The CMake build can do the full dependency tree build and avoids any type of copying. I would like to see lib/swift/host/swift removed and would think that especially for developer tools and build tools, static linking is preferable. We do not need to consider binary sizes there due to these tools being used only on the build machine and not being shipped. The performance implications of these tools is a separate concern, but again, I think that the increased memory pressure is worth the simplicity.

@compnerd
Copy link
Member Author

swiftlang/swift-foundation#1421
swiftlang/swift-foundation-icu#66

@swift-ci please build toolchain Windows platform

@compnerd compnerd force-pushed the early-driver-win branch 2 times, most recently from 148768d to 9b75b00 Compare July 23, 2025 20:06
@compnerd
Copy link
Member Author

swiftlang/swift-foundation#1421
swiftlang/swift-foundation-icu#66

@swift-ci please build toolchain Windows platform

@compnerd
Copy link
Member Author

swiftlang/swift-foundation#1421
swiftlang/swift-foundation-icu#66

@swift-ci please build toolchain Windows platform

@compnerd compnerd force-pushed the early-driver-win branch 3 times, most recently from 215bad4 to 81d1a52 Compare July 24, 2025 04:12
@compnerd
Copy link
Member Author

swiftlang/swift-foundation#1421
swiftlang/swift-foundation-icu#66

@swift-ci please build toolchain Windows platform

1 similar comment
@compnerd
Copy link
Member Author

swiftlang/swift-foundation#1421
swiftlang/swift-foundation-icu#66

@swift-ci please build toolchain Windows platform

compnerd added 4 commits July 24, 2025 16:46
The early swift-driver on Windows requires statically linking to the
runtime. Update to a snapshot that is new enough to contain the static
runtime with the appropriate fixes to enable building the early
swift-driver.
This prepares the swift-driver building on Windows. By statically
linking the runtime and its dependencies, this will allow us to avoid
the runtime shuffling that is required to get the runtime required to
get the swift-driver working.
Enable the use of the early swift-driver to build the Swift toolchain.
This is the first step towards removing the accumulated debt and
workarounds when building the toolchain on Windows.
@compnerd
Copy link
Member Author

swiftlang/swift-foundation#1421
swiftlang/swift-foundation-icu#66

@swift-ci please build toolchain Windows platform

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.

2 participants