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

[SR-9995] Figure out how to properly handle /MT{,d} and /MD{,d} #52398

Closed
compnerd opened this issue Feb 25, 2019 · 11 comments
Closed

[SR-9995] Figure out how to properly handle /MT{,d} and /MD{,d} #52398

compnerd opened this issue Feb 25, 2019 · 11 comments
Assignees
Labels
compiler The Swift compiler in itself

Comments

@compnerd
Copy link
Collaborator

Previous ID SR-9995
Radar None
Original Reporter @compnerd
Type Sub-task
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Sub-task
Assignee @compnerd
Priority Medium

md5: 7beffdd6fe2309d512947c81cff65724

Parent-Task:

Issue Description:

Windows has 4 different modes of building:
/MTd - single threaded, statically linked, debug
/MT - single threaded, statically linked, release
/MDd - dynamic MSVCRT, debug
/MD - dynamic MSVCRT

You cannot mix and match the builds with these as they impact the ABI of the C types. We have a few places where we workaround this by manually recreating `/MD` builds.

@compnerd
Copy link
Collaborator Author

CC: @belkadan @gwynne

@gwynne
Copy link
Contributor

gwynne commented Feb 25, 2019

One of the fun side effects of this is that you can't do the equivalent of, for example, build-script --release-debuginfo --swift-build-type=Debug.

@belkadan
Copy link
Contributor

I think we should focus on /MD{,d} first, and worry about "everything statically-linked" later. Would we need to build and distribute two copies of the standard library, then? Do we want to treat these as different architectures or architecture-environments?

(i.e. lib/swift/windows/x86_64-debug)

@compnerd
Copy link
Collaborator Author

#24849

@compnerd
Copy link
Collaborator Author

@belkadan - yes, this will require distribution of multiple standard libraries. I say multiple, because we will need 4 runtime libraries (/MD, /MDd, /MT, /MTd). I think that we want to treat this more like Microsoft and have suffixes instead. `swiftCore.dll` and `swiftCored.dll` which reside in the same directory.

@belkadan
Copy link
Contributor

Is that better than different directories? Seems harder, especially with autolinking. swift_static wasn't really the best idea, but it's closer to that, right?

@compnerd
Copy link
Collaborator Author

We now can do `-libc MD` or `-libc MDd` (or for those that like verbose names: `-libc MultiThreadedDLL` or `-libc MultiThreadedDebugDLL` to match Visual Studio and CMake).

@compnerd
Copy link
Collaborator Author

I think that its definitely easier than the `swift_static`. It avoids the complexity of changing search directories and install behaviour based on the configuration. The way that `-libc` works is that it already configures the autolinking so it just becomes this very simple thing of specifying the flag properly.

@belkadan
Copy link
Contributor

Yes, but you need to do that for the WinSDK overlay too, no?

@compnerd
Copy link
Collaborator Author

Right, the SDK overlay would be built similarly, with the `d` suffixed variants - e.g. swiftMSVCRTd.dll. We could use the `-module-name` and `-module-link-name` options to get it behave the same - that is, the user still says `import MSVCRT` but gets the `swiftMSVCRTd.lib` import library at link time. The one complication to this would be the `swiftrt.obj` that needs the variants as well.

@gwynne
Copy link
Contributor

gwynne commented May 18, 2019

I'd go with the d-suffixed variants, yeah. Matching the existing Windows convention (and doing better than VS already does at it, to boot!) strikes me as the least error-prone and most "intuitive" for native Windows developers, and there isn't really a difference between the various options when it comes to developers coming from other platforms anyway (since only Windows has this particular weirdness about how runtime libraries get linked).

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

3 participants